idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
1,500
def retrieve_cash_drawer_shift ( location_id , shift_id , opts = { } ) data , _status_code , _headers = retrieve_cash_drawer_shift_with_http_info ( location_id , shift_id , opts ) return data end
RetrieveCashDrawerShift Provides the details for a single cash drawer shift including all events that occurred during the shift .
1,501
def retrieve_employee ( employee_id , opts = { } ) data , _status_code , _headers = retrieve_employee_with_http_info ( employee_id , opts ) return data end
RetrieveEmployee Provides the details for a single employee .
1,502
def retrieve_employee_role ( role_id , opts = { } ) data , _status_code , _headers = retrieve_employee_role_with_http_info ( role_id , opts ) return data end
RetrieveEmployeeRole Provides the details for a single employee role .
1,503
def update_employee_role ( role_id , body , opts = { } ) data , _status_code , _headers = update_employee_role_with_http_info ( role_id , body , opts ) return data end
UpdateEmployeeRole Modifies the details of an employee role .
1,504
def update_timecard ( timecard_id , body , opts = { } ) data , _status_code , _headers = update_timecard_with_http_info ( timecard_id , body , opts ) return data end
UpdateTimecard Modifies the details of a timecard with an API_EDIT event for the timecard . Updating an active timecard with a clockout_time clocks the employee out .
1,505
def create_customer_card ( customer_id , body , opts = { } ) data , _status_code , _headers = create_customer_card_with_http_info ( customer_id , body , opts ) return data end
CreateCustomerCard Adds a card on file to an existing customer . As with charges calls to CreateCustomerCard are idempotent . Multiple calls with the same card nonce return the same card record that was created with the provided nonce during the _first_ call . Cards on file are automatically updated on a monthly basis to confirm they are still valid and can be charged .
1,506
def delete_customer ( customer_id , opts = { } ) data , _status_code , _headers = delete_customer_with_http_info ( customer_id , opts ) return data end
DeleteCustomer Deletes a customer from a business along with any linked cards on file . When two profiles are merged into a single profile that profile is assigned a new customer_id . You must use the new customer_id to delete merged profiles .
1,507
def delete_customer_card ( customer_id , card_id , opts = { } ) data , _status_code , _headers = delete_customer_card_with_http_info ( customer_id , card_id , opts ) return data end
DeleteCustomerCard Removes a card on file from a customer .
1,508
def retrieve_customer ( customer_id , opts = { } ) data , _status_code , _headers = retrieve_customer_with_http_info ( customer_id , opts ) return data end
RetrieveCustomer Returns details for a single customer .
1,509
def search_customers ( body , opts = { } ) data , _status_code , _headers = search_customers_with_http_info ( body , opts ) return data end
SearchCustomers Searches the customer profiles associated with a Square account . Calling SearchCustomers without an explicit query parameter returns all customer profiles ordered alphabetically based on given_name and family_name .
1,510
def adjust_inventory ( location_id , variation_id , body , opts = { } ) data , _status_code , _headers = adjust_inventory_with_http_info ( location_id , variation_id , body , opts ) return data end
AdjustInventory Adjusts an item variation s current available inventory .
1,511
def apply_fee ( location_id , item_id , fee_id , opts = { } ) data , _status_code , _headers = apply_fee_with_http_info ( location_id , item_id , fee_id , opts ) return data end
ApplyFee Associates a fee with an item meaning the fee is automatically applied to the item in Square Register .
1,512
def apply_modifier_list ( location_id , modifier_list_id , item_id , opts = { } ) data , _status_code , _headers = apply_modifier_list_with_http_info ( location_id , modifier_list_id , item_id , opts ) return data end
ApplyModifierList Associates a modifier list with an item meaning modifier options from the list can be applied to the item .
1,513
def create_category ( location_id , body , opts = { } ) data , _status_code , _headers = create_category_with_http_info ( location_id , body , opts ) return data end
CreateCategory Creates an item category .
1,514
def create_discount ( location_id , body , opts = { } ) data , _status_code , _headers = create_discount_with_http_info ( location_id , body , opts ) return data end
CreateDiscount Creates a discount .
1,515
def create_item ( location_id , body , opts = { } ) data , _status_code , _headers = create_item_with_http_info ( location_id , body , opts ) return data end
CreateItem Creates an item and at least one variation for it . Item - related entities include fields you can use to associate them with entities in a non - Square system . When you create an item - related entity you can optionally specify its id . This value must be unique among all IDs ever specified for the account including those specified by other applications . You can never reuse an entity ID . If you do not specify an ID Square generates one for the entity . Item variations have a user_data string that lets you associate arbitrary metadata with the variation . The string cannot exceed 255 characters .
1,516
def create_modifier_list ( location_id , body , opts = { } ) data , _status_code , _headers = create_modifier_list_with_http_info ( location_id , body , opts ) return data end
CreateModifierList Creates an item modifier list and at least one modifier option for it .
1,517
def create_modifier_option ( location_id , modifier_list_id , body , opts = { } ) data , _status_code , _headers = create_modifier_option_with_http_info ( location_id , modifier_list_id , body , opts ) return data end
CreateModifierOption Creates an item modifier option and adds it to a modifier list .
1,518
def create_page ( location_id , body , opts = { } ) data , _status_code , _headers = create_page_with_http_info ( location_id , body , opts ) return data end
CreatePage Creates a Favorites page in Square Register .
1,519
def create_variation ( location_id , item_id , body , opts = { } ) data , _status_code , _headers = create_variation_with_http_info ( location_id , item_id , body , opts ) return data end
CreateVariation Creates an item variation for an existing item .
1,520
def list_categories ( location_id , opts = { } ) data , _status_code , _headers = list_categories_with_http_info ( location_id , opts ) return data end
ListCategories Lists all of a location s item categories .
1,521
def list_discounts ( location_id , opts = { } ) data , _status_code , _headers = list_discounts_with_http_info ( location_id , opts ) return data end
ListDiscounts Lists all of a location s discounts .
1,522
def list_inventory ( location_id , opts = { } ) data , _status_code , _headers = list_inventory_with_http_info ( location_id , opts ) return data end
ListInventory Provides inventory information for all of a merchant s inventory - enabled item variations .
1,523
def list_items ( location_id , opts = { } ) data , _status_code , _headers = list_items_with_http_info ( location_id , opts ) return data end
ListItems Provides summary information for all of a location s items .
1,524
def list_modifier_lists ( location_id , opts = { } ) data , _status_code , _headers = list_modifier_lists_with_http_info ( location_id , opts ) return data end
ListModifierLists Lists all of a location s modifier lists .
1,525
def list_pages ( location_id , opts = { } ) data , _status_code , _headers = list_pages_with_http_info ( location_id , opts ) return data end
ListPages Lists all of a location s Favorites pages in Square Register .
1,526
def remove_fee ( location_id , item_id , fee_id , opts = { } ) data , _status_code , _headers = remove_fee_with_http_info ( location_id , item_id , fee_id , opts ) return data end
RemoveFee Removes a fee assocation from an item meaning the fee is no longer automatically applied to the item in Square Register .
1,527
def remove_modifier_list ( location_id , modifier_list_id , item_id , opts = { } ) data , _status_code , _headers = remove_modifier_list_with_http_info ( location_id , modifier_list_id , item_id , opts ) return data end
RemoveModifierList Removes a modifier list association from an item meaning modifier options from the list can no longer be applied to the item .
1,528
def retrieve_item ( location_id , item_id , opts = { } ) data , _status_code , _headers = retrieve_item_with_http_info ( location_id , item_id , opts ) return data end
RetrieveItem Provides the details for a single item including associated modifier lists and fees .
1,529
def retrieve_modifier_list ( location_id , modifier_list_id , opts = { } ) data , _status_code , _headers = retrieve_modifier_list_with_http_info ( location_id , modifier_list_id , opts ) return data end
RetrieveModifierList Provides the details for a single modifier list .
1,530
def update_category ( location_id , category_id , body , opts = { } ) data , _status_code , _headers = update_category_with_http_info ( location_id , category_id , body , opts ) return data end
UpdateCategory Modifies the details of an existing item category .
1,531
def update_discount ( location_id , discount_id , body , opts = { } ) data , _status_code , _headers = update_discount_with_http_info ( location_id , discount_id , body , opts ) return data end
UpdateDiscount Modifies the details of an existing discount .
1,532
def update_item ( location_id , item_id , body , opts = { } ) data , _status_code , _headers = update_item_with_http_info ( location_id , item_id , body , opts ) return data end
UpdateItem Modifies the core details of an existing item .
1,533
def update_modifier_list ( location_id , modifier_list_id , body , opts = { } ) data , _status_code , _headers = update_modifier_list_with_http_info ( location_id , modifier_list_id , body , opts ) return data end
UpdateModifierList Modifies the details of an existing item modifier list .
1,534
def update_modifier_option ( location_id , modifier_list_id , modifier_option_id , body , opts = { } ) data , _status_code , _headers = update_modifier_option_with_http_info ( location_id , modifier_list_id , modifier_option_id , body , opts ) return data end
UpdateModifierOption Modifies the details of an existing item modifier option .
1,535
def update_page ( location_id , page_id , body , opts = { } ) data , _status_code , _headers = update_page_with_http_info ( location_id , page_id , body , opts ) return data end
UpdatePage Modifies the details of a Favorites page in Square Register .
1,536
def update_page_cell ( location_id , page_id , body , opts = { } ) data , _status_code , _headers = update_page_cell_with_http_info ( location_id , page_id , body , opts ) return data end
UpdatePageCell Modifies a cell of a Favorites page in Square Register .
1,537
def update_variation ( location_id , item_id , variation_id , body , opts = { } ) data , _status_code , _headers = update_variation_with_http_info ( location_id , item_id , variation_id , body , opts ) return data end
UpdateVariation Modifies the details of an existing item variation .
1,538
def delete_break_type ( id , opts = { } ) data , _status_code , _headers = delete_break_type_with_http_info ( id , opts ) return data end
DeleteBreakType Deletes an existing BreakType . A BreakType can be deleted even if it is referenced from a Shift .
1,539
def delete_shift ( id , opts = { } ) data , _status_code , _headers = delete_shift_with_http_info ( id , opts ) return data end
DeleteShift Deletes a Shift .
1,540
def get_break_type ( id , opts = { } ) data , _status_code , _headers = get_break_type_with_http_info ( id , opts ) return data end
GetBreakType Returns a single BreakType specified by id .
1,541
def get_employee_wage ( id , opts = { } ) data , _status_code , _headers = get_employee_wage_with_http_info ( id , opts ) return data end
GetEmployeeWage Returns a single EmployeeWage specified by id .
1,542
def get_shift ( id , opts = { } ) data , _status_code , _headers = get_shift_with_http_info ( id , opts ) return data end
GetShift Returns a single Shift specified by id .
1,543
def update_break_type ( id , body , opts = { } ) data , _status_code , _headers = update_break_type_with_http_info ( id , body , opts ) return data end
UpdateBreakType Updates an existing BreakType .
1,544
def update_shift ( id , body , opts = { } ) data , _status_code , _headers = update_shift_with_http_info ( id , body , opts ) return data end
UpdateShift Updates an existing Shift . When adding a Break to a Shift any earlier Breaks in the Shift have the end_at property set to a valid RFC - 3339 datetime string . When closing a Shift all Break instances in the shift must be complete with end_at set on each Break .
1,545
def update_workweek_config ( id , body , opts = { } ) data , _status_code , _headers = update_workweek_config_with_http_info ( id , body , opts ) return data end
UpdateWorkweekConfig Updates a WorkweekConfig .
1,546
def retrieve_transaction ( location_id , transaction_id , opts = { } ) data , _status_code , _headers = retrieve_transaction_with_http_info ( location_id , transaction_id , opts ) return data end
RetrieveTransaction Retrieves details for a single transaction .
1,547
def list_bank_accounts ( location_id , opts = { } ) data , _status_code , _headers = list_bank_accounts_with_http_info ( location_id , opts ) return data end
ListBankAccounts Provides non - confidential details for all of a location s associated bank accounts . This endpoint does not provide full bank account numbers and there is no way to obtain a full bank account number with the Connect API .
1,548
def list_orders ( location_id , opts = { } ) data , _status_code , _headers = list_orders_with_http_info ( location_id , opts ) return data end
ListOrders Provides summary information for a merchant s online store orders .
1,549
def retrieve_bank_account ( location_id , bank_account_id , opts = { } ) data , _status_code , _headers = retrieve_bank_account_with_http_info ( location_id , bank_account_id , opts ) return data end
RetrieveBankAccount Provides non - confidential details for a merchant s associated bank account . This endpoint does not provide full bank account numbers and there is no way to obtain a full bank account number with the Connect API .
1,550
def retrieve_order ( location_id , order_id , opts = { } ) data , _status_code , _headers = retrieve_order_with_http_info ( location_id , order_id , opts ) return data end
RetrieveOrder Provides comprehensive information for a single online store order including the order s history .
1,551
def retrieve_payment ( location_id , payment_id , opts = { } ) data , _status_code , _headers = retrieve_payment_with_http_info ( location_id , payment_id , opts ) return data end
RetrievePayment Provides comprehensive information for a single payment .
1,552
def render_activities ( activities , options = { } ) activities . map { | activity | Renderable . render ( activity , self , options . dup ) } . join . html_safe end
View helper for rendering many activities
1,553
def param ( name , type = nil , ** opts , & block ) add_definition ( false , name , type , block , opts ) end
Adds or redefines a parameter
1,554
def inch line = Builders :: Signature [ self ] line = line . gsub ( "__dry_initializer_options__" , "options" ) lines = [ "@!method initialize(#{line})" ] lines += [ "Initializes an instance of #{extended_class}" ] lines += definitions . values . map ( & :inch ) lines += [ "@return [#{extended_class}]" ] lines . join ( "\n" ) end
Human - readable representation of configured params and options
1,555
def [] ( undefined : true , ** ) null = ( undefined == false ) ? nil : UNDEFINED Module . new . tap do | mod | mod . extend DSL mod . include self mod . send ( :instance_variable_set , :@null , null ) end end
Returns a version of the module with custom settings
1,556
def define ( procedure = nil , & block ) config = Config . new ( null : null ) config . instance_exec ( & ( procedure || block ) ) config . mixin . include Mixin :: Root config . mixin end
Returns mixin module to be included to target class by hand
1,557
def get_android_inspect ( class_name = false ) source = get_source doctype_string = '<!doctyp' source_header = source [ 0 .. doctype_string . length ] . downcase source_is_html = source_header . start_with? ( doctype_string , '<html' ) parser = if source_is_html @android_html_parser ||= Nokogiri :: HTML :: SAX :: Parser . new ( Appium :: Common :: HTMLElements . new ) else @android_native_parser ||= Nokogiri :: XML :: SAX :: Parser . new ( AndroidElements . new ) end parser . document . reset parser . document . filter = class_name parser . parse source result = parser . document . result parser . document . reset result end
class AndroidElements Android only . Returns a string containing interesting elements . The text content description and id are returned .
1,558
def page ( opts = { } ) class_name = opts . is_a? ( Hash ) ? opts . fetch ( :class , nil ) : opts puts get_android_inspect class_name nil end
Intended for use with console . Inspects and prints the current page . Will return XHTML for Web contexts because of a quirk with Nokogiri .
1,559
def ele_index ( class_name , index ) results = tags ( class_name ) if index == 'last()' index = results . length index -= 1 if index >= 0 else raise 'Index must be >= 1' unless index >= 1 index -= 1 if index >= 1 end results [ index ] end
Find the element of type class_name at matching index .
1,560
def driver_attributes { caps : @core . caps , automation_name : @core . automation_name , custom_url : @core . custom_url , export_session : @core . export_session , export_session_path : @core . export_session_path , default_wait : @core . default_wait , sauce_username : @sauce . username , sauce_access_key : @sauce . access_key , sauce_endpoint : @sauce . endpoint , port : @core . port , device : @core . device , debug : @appium_debug , listener : @listener , wait_timeout : @core . wait_timeout , wait_interval : @core . wait_interval } end
Returns a hash of the driver attributes
1,561
def appium_server_version @core . appium_server_version rescue Selenium :: WebDriver :: Error :: WebDriverError => ex raise :: Appium :: Core :: Error :: ServerError unless ex . message . include? ( 'content-type=""' ) { } end
Returns the server s version info
1,562
def start_driver ( http_client_ops = { http_client : :: Appium :: Http :: Default . new , open_timeout : 999_999 , read_timeout : 999_999 } ) @core . quit_driver automation_name = @core . automation_name @driver = @core . start_driver ( server_url : server_url , http_client_ops : http_client_ops ) @http_client = @core . http_client extend_for ( device : @core . device , automation_name : @core . automation_name ) if automation_name . nil? @appium_server_status = appium_server_version @driver end
Creates a new global driver and quits the old one if it exists . You can customise http_client as the following
1,563
def set_implicit_wait ( wait ) @driver . manage . timeouts . implicit_wait = wait rescue Selenium :: WebDriver :: Error :: UnknownError => e unless e . message . include? ( 'The operation requested is not yet implemented by Espresso driver' ) raise :: Appium :: Core :: Error :: ServerError end { } end
To ignore error for Espresso Driver
1,564
def exists ( pre_check = 0 , post_check = @core . default_wait ) @driver . manage . timeouts . implicit_wait = pre_check exists = true begin yield rescue StandardError exists = false end @driver . manage . timeouts . implicit_wait = post_check if post_check != pre_check exists end
Returns existence of element .
1,565
def last_textfield result = eles_by_json ( _textfield_visible ) . last raise _no_such_element if result . nil? result end
Find the last TextField .
1,566
def px_to_window_rel ( opts = { } , driver = $driver ) w = driver . window_size x = opts . fetch :x , 0 y = opts . fetch :y , 0 OpenStruct . new ( x : "#{x.to_f} / #{w.width.to_f}" , y : "#{y.to_f} / #{w.height.to_f}" ) end
Converts pixel values to window relative values
1,567
def xml_keys ( target ) lazy_load_strings @lazy_load_strings . select { | key , _value | key . downcase . include? target . downcase } end
Search strings . xml s values for target .
1,568
def xml_values ( target ) lazy_load_strings @lazy_load_strings . select { | _key , value | value . downcase . include? target . downcase } end
Search strings . xml s keys for target .
1,569
def button ( value ) if value . is_a? Numeric index = value raise "#{index} is not a valid index. Must be >= 1" if index <= 0 return find_element :uiautomator , _button_visible_selectors ( index : index ) end find_element :uiautomator , _button_contains_string ( value ) end
backward compatibility Find the first button that contains value or by index .
1,570
def last_button button_index = tags ( BUTTON ) . length button_index -= 1 if button_index > 0 image_button_index = tags ( IMAGE_BUTTON ) . length image_button_index -= 1 if image_button_index > 0 find_element :uiautomator , _button_visible_selectors ( button_index : button_index , image_button_index : image_button_index ) end
Find the last button .
1,571
def text ( value ) return ele_index static_text_class , value if value . is_a? Numeric ele_by_json_visible_contains static_text_class , value end
Find the first UIAStaticText|XCUIElementTypeStaticText that contains value or by index .
1,572
def scroll_to ( text , scrollable_index = 0 ) text = %("#{text}") rid = resource_id ( text , "new UiSelector().resourceId(#{text})" ) args = rid . empty? ? [ "new UiSelector().textContains(#{text})" , "new UiSelector().descriptionContains(#{text})" ] : [ rid ] args . each_with_index do | arg , index | begin elem = find_element :uiautomator , scroll_uiselector ( arg , scrollable_index ) return elem rescue StandardError => e raise e if index == args . size - 1 end end end
Scroll to the first element containing target text or description .
1,573
def page ( opts = { } ) class_name = opts . is_a? ( Hash ) ? opts . fetch ( :class , nil ) : opts source = get_source if current_context && current_context . start_with? ( 'WEBVIEW' ) parser = @android_html_parser ||= Nokogiri :: HTML :: SAX :: Parser . new ( Appium :: Common :: HTMLElements . new ) parser . document . reset parser . document . filter = class_name parser . parse source result = parser . document . result puts result result else parser = Nokogiri :: XML :: SAX :: Parser . new ( UITestElementsPrinter . new ) if class_name parser . document . filter = class_name . is_a? ( Symbol ) ? class_name . to_s : class_name end parser . parse source nil end end
Prints a string of interesting elements to the console .
1,574
def ele_index ( class_name , index ) raise 'Index must be >= 1' unless index == 'last()' || ( index . is_a? ( Integer ) && index >= 1 ) elements = tags ( class_name ) if index == 'last()' result = elements . last else index -= 1 result = elements [ index ] end raise _no_such_element if result . nil? result end
Get the element of type class_name at matching index .
1,575
def _all_pred ( opts ) predicate = opts [ :predicate ] raise 'predicate must be provided' unless predicate visible = opts . fetch :visible , true %($.mainApp().getAllWithPredicate("#{predicate}", #{visible});) end
predicate - the predicate to evaluate on the main app
1,576
def wait_true ( opts = { } ) opts = opts . is_a? ( Numeric ) ? { timeout : opts } : opts if opts . is_a? Hash opts . empty? ? @core . wait_true { yield } : @core . wait_true ( opts ) { yield } else :: Appium :: Logger . warn ( 'Arguments should be Hash like {timeout: 100}' ) end end
Check every interval seconds to see if yield returns a truthy value . Note this isn t a strict boolean true any truthy value is accepted . false and nil are considered failures . Give up after timeout seconds .
1,577
def textfield ( value ) return ele_index EDIT_TEXT , value if value . is_a? Numeric complex_find_contains EDIT_TEXT , value end
Find the first EditText that contains value or by index .
1,578
def text ( value ) return ele_index TEXT_VIEW , value if value . is_a? Numeric complex_find_contains TEXT_VIEW , value end
Find the first TextView that contains value or by index .
1,579
def button ( value ) return ele_index button_class , value if value . is_a? Numeric ele_by_json_visible_contains button_class , value end
Find the first UIAButton|XCUIElementTypeButton that contains value or by index .
1,580
def setup_derived_entry_elements ( id_generator ) @hqmf_id = attr_val ( './*/cda:id/@root' ) || attr_val ( './*/cda:typeId/@extension' ) @title = attr_val ( './*/cda:code/cda:displayName/@value' ) . try ( :titleize ) @type = attr_val ( './*/cda:code/@code' ) @comments = @entry . xpath ( './*/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()' , HQMF2 :: Document :: NAMESPACES ) . map ( & :content ) handle_preconditions ( id_generator ) obs_test = attr_val ( './cda:measureObservationDefinition/@classCode' ) return unless ! @title && obs_test . to_s == 'OBS' @title = attr_val ( '../cda:code/cda:displayName/@value' ) @aggregator = attr_val ( './cda:measureObservationDefinition/cda:methodCode/cda:item/@code' ) end
Handles extracting elements from the entry
1,581
def handle_preconditions ( id_generator ) @preconditions = @entry . xpath ( './*/cda:precondition[not(@nullFlavor)]' , HQMF2 :: Document :: NAMESPACES ) . collect do | pre | precondition = Precondition . parse ( pre , @doc , id_generator ) precondition . reference . nil? && precondition . preconditions . empty? ? nil : precondition end @preconditions . compact! end
specifically handles extracting the preconditions for the population criteria
1,582
def handle_observation_criteria exp = @entry . at_xpath ( './cda:measureObservationDefinition/cda:value/cda:expression/@value' , HQMF2 :: Document :: NAMESPACES ) fail 'Measure Observations criteria is missing computed expression(s) ' if exp . nil? parts = exp . to_s . split ( '-' ) dc = parse_parts_to_dc ( parts ) @doc . add_data_criteria ( dc ) dc . children_criteria . each { | cc | @doc . add_reference_id ( cc ) } unless dc . children_criteria . nil? dc end
extracts out any measure observation definitons creating from them the proper criteria to generate a precondition
1,583
def parse_parts_to_dc ( parts ) case parts . length when 1 @doc . find_criteria_by_lvn ( parts . first . strip . split ( '.' ) [ 0 ] ) when 2 children = parts . collect { | p | @doc . find_criteria_by_lvn ( p . strip . split ( '.' ) [ 0 ] ) . id } id = "GROUP_TIMEDIFF_#{@id_generator.next_id}" HQMF2 :: DataCriteriaWrapper . new ( id : id , title : id , subset_operators : [ HQMF :: SubsetOperator . new ( 'DATETIMEDIFF' , nil ) ] , children_criteria : children , derivation_operator : HQMF :: DataCriteria :: XPRODUCT , type : 'derived' , definition : 'derived' , negation : false , source_data_criteria : id ) else fail "No defined extraction method to handle #{parts.length} parts" end end
generates the value given in an expression based on the number of criteria it references .
1,584
def conjunction_code case @type when HQMF :: PopulationCriteria :: IPP , HQMF :: PopulationCriteria :: DENOM , HQMF :: PopulationCriteria :: NUMER , HQMF :: PopulationCriteria :: MSRPOPL , HQMF :: PopulationCriteria :: STRAT HQMF :: Precondition :: ALL_TRUE when HQMF :: PopulationCriteria :: DENEXCEP , HQMF :: PopulationCriteria :: DENEX , HQMF :: PopulationCriteria :: MSRPOPLEX , HQMF :: PopulationCriteria :: NUMEX HQMF :: Precondition :: AT_LEAST_ONE_TRUE else fail "Unknown population type [#{@type}]" end end
Get the conjunction code ALL_TRUE or AT_LEAST_ONE_TRUE
1,585
def inclusive_temporal_ref? less_than_equal_tr = attr_val ( '../@highClosed' ) == 'true' && ( attr_val ( '../cda:low/@value' ) == '0' || attr_val ( '../cda:low/@nullFlavor' ) == 'NINF' ) greater_than_equal_tr = attr_val ( '../cda:high/@nullFlavor' ) == 'PINF' && attr_val ( '../cda:low/@value' ) ( less_than_equal_tr || greater_than_equal_tr ) && attr_val ( '../@lowClosed' ) == 'true' end
Check whether the temporal reference should be marked as inclusive
1,586
def inclusive_length_of_stay? less_than_equal_los = attr_val ( '../cda:low/@nullFlavor' ) == 'NINF' && attr_val ( '../@highClosed' ) != 'false' greater_than_equal_los = attr_val ( '../cda:high/@nullFlavor' ) == 'PINF' && attr_val ( '../@lowClosed' ) != 'false' ( less_than_equal_los || greater_than_equal_los ) && attr_val ( '@xsi:type' ) == 'PQ' end
Check whether the length of stay should be inclusive .
1,587
def generate_any_value? ( lm , hm ) ( lm . nil? || lm . is_a? ( HQMF :: AnyValue ) ) && ( hm . nil? || hm . is_a? ( HQMF :: AnyValue ) ) end
Check if are only AnyValue elements for low and high
1,588
def remove_population_preconditions ( doc ) pop_ids = doc . xpath ( "//cda:populationCriteriaSection/cda:component[@typeCode='COMP']/*/cda:id" , HQMF2 :: Document :: NAMESPACES ) pop_ids . each do | p_id | doc . xpath ( "//cda:precondition[./cda:criteriaReference/cda:id[@extension='#{p_id['extension']}' and @root='#{p_id['root']}']]" , HQMF2 :: Document :: NAMESPACES ) . remove end end
If a precondition references a population remove it
1,589
def extract_observations has_observation = false observation_section = @doc . xpath ( '/cda:QualityMeasureDocument/cda:component/cda:measureObservationSection' , HQMF2 :: Document :: NAMESPACES ) unless observation_section . empty? observation_section . xpath ( 'cda:definition' , HQMF2 :: Document :: NAMESPACES ) . each do | criteria_def | criteria_id = 'OBSERV' criteria = PopulationCriteria . new ( criteria_def , @document , @id_generator ) criteria . type = 'OBSERV' if @ids_by_hqmf_id [ "#{criteria.hqmf_id}" ] criteria . create_human_readable_id ( @ids_by_hqmf_id [ criteria . hqmf_id ] ) else criteria . create_human_readable_id ( population_id_with_counter ( criteria_id ) ) @ids_by_hqmf_id [ "#{criteria.hqmf_id}" ] = criteria . id end @population_criteria << criteria has_observation = true end end has_observation end
Extracts the measure observations will return true if one exists
1,590
def handle_base_populations ( population_def , population ) { HQMF :: PopulationCriteria :: IPP => 'initialPopulationCriteria' , HQMF :: PopulationCriteria :: DENOM => 'denominatorCriteria' , HQMF :: PopulationCriteria :: NUMER => 'numeratorCriteria' , HQMF :: PopulationCriteria :: NUMEX => 'numeratorExclusionCriteria' , HQMF :: PopulationCriteria :: DENEXCEP => 'denominatorExceptionCriteria' , HQMF :: PopulationCriteria :: DENEX => 'denominatorExclusionCriteria' , HQMF :: PopulationCriteria :: MSRPOPL => 'measurePopulationCriteria' , HQMF :: PopulationCriteria :: MSRPOPLEX => 'measurePopulationExclusionCriteria' } . each_pair do | criteria_id , criteria_element_name | criteria_def = population_def . at_xpath ( "cda:component[cda:#{criteria_element_name}]" , HQMF2 :: Document :: NAMESPACES ) if criteria_def build_population_criteria ( criteria_def , criteria_id , population ) end end end
Builds populations based an a predfined set of expected populations
1,591
def handle_stratifications ( population_def , number_of_populations , population , id_def , population_index ) stratifier_criteria_xpath = "cda:component/cda:stratifierCriteria[not(cda:component/cda:measureAttribute/cda:code[@code = 'SDE'])]/.." population_def . xpath ( stratifier_criteria_xpath , HQMF2 :: Document :: NAMESPACES ) . each_with_index do | criteria_def , criteria_def_index | next unless PopulationCriteria . new ( criteria_def , @document , @id_generator ) . preconditions . all? { | prcn | prcn . preconditions . length > 0 } index = number_of_populations + ( ( population_index - 1 ) * criteria_def . xpath ( './*/cda:precondition' ) . length ) + criteria_def_index criteria_id = HQMF :: PopulationCriteria :: STRAT stratified_population = population . dup stratified_population [ 'stratification' ] = criteria_def . at_xpath ( './*/cda:id/@root' ) . try ( :value ) || "#{criteria_id}-#{criteria_def_index}" build_population_criteria ( criteria_def , criteria_id , stratified_population ) stratified_population [ 'id' ] = id_def ? "#{id_def.value} - Stratification #{criteria_def_index + 1}" : "Population#{index}" title_def = population_def . at_xpath ( 'cda:title/@value' , HQMF2 :: Document :: NAMESPACES ) stratified_population [ 'title' ] = title_def ? "#{title_def.value} - Stratification #{criteria_def_index + 1}" : "Population #{index}" @stratifications << stratified_population end end
Generate the stratifications of populations if any exist
1,592
def build_population_criteria ( criteria_def , criteria_id , population ) criteria = PopulationCriteria . new ( criteria_def , @document , @id_generator ) identical = @population_criteria . select { | pc | pc . to_model . hqmf_id == criteria . to_model . hqmf_id } @reference_ids . concat ( criteria . to_model . referenced_data_criteria ) if identical . empty? if @ids_by_hqmf_id [ "#{criteria.hqmf_id}-#{population['stratification']}" ] criteria . create_human_readable_id ( @ids_by_hqmf_id [ "#{criteria.hqmf_id}-#{population['stratification']}" ] ) else criteria . create_human_readable_id ( population_id_with_counter ( criteria_id ) ) @ids_by_hqmf_id [ "#{criteria.hqmf_id}-#{population['stratification']}" ] = criteria . id end @population_criteria << criteria population [ criteria_id ] = criteria . id else population [ criteria_id ] = identical . first . id end end
Method to generate the criteria defining a population
1,593
def backfill_derived_code_lists data_criteria_by_id = { } @data_criteria . each { | criteria | data_criteria_by_id [ criteria . id ] = criteria } @data_criteria . each do | criteria | if ( criteria . derived_from ) derived_from = data_criteria_by_id [ criteria . derived_from ] criteria . definition = derived_from . definition criteria . status = derived_from . status criteria . code_list_id = derived_from . code_list_id end end end
if the data criteria is derived from another criteria then we want to grab the properties from the derived criteria this is typically the case with Occurrence A Occurrence B type data criteria
1,594
def get_unmatched_population_keys ( target , source ) return [ ] if target . length == source . length all_target_keys = target . values . map ( & :id ) with_ref_keys = source . values . map ( & :id ) . map { | key | @population_criteria_by_id [ @population_reference [ key ] ] . id if @population_criteria_by_id [ @population_reference [ key ] ] } return [ ] if with_ref_keys . include? nil all_target_keys - with_ref_keys end
source are things like exceptions or exclusions target are IPP or denom we want to find any denoms or IPPs that do not have exceptions or exclusions
1,595
def apply_to_submeasures ( subs , type , values , unpaired_type = nil , unpaired_keys = [ ] ) new_subs = [ ] subs . each do | sub | unless unpaired_keys . include? sub [ unpaired_type ] values . each do | value | if ( sub [ type ] and sub [ type ] != value . id ) tmp = { } HQMF :: PopulationCriteria :: ALL_POPULATION_CODES . each do | key | tmp [ key ] = sub [ key ] if sub [ key ] end sub = tmp new_subs << sub end sub [ type ] = value . id end end end subs . concat ( new_subs ) end
create a copy of each submeasre adding on the new values of the given type skip the unpaired values . Unpaired values are denominators without exclusions or populations without exceptions
1,596
def setup_default_values ( hqmf_contents , use_default_measure_period ) @id_generator = IdGenerator . new @doc = @entry = Document . parse ( hqmf_contents ) @id = attr_val ( 'cda:QualityMeasureDocument/cda:id/@extension' ) || attr_val ( 'cda:QualityMeasureDocument/cda:id/@root' ) . upcase @hqmf_set_id = attr_val ( 'cda:QualityMeasureDocument/cda:setId/@extension' ) || attr_val ( 'cda:QualityMeasureDocument/cda:setId/@root' ) . upcase @hqmf_version_number = attr_val ( 'cda:QualityMeasureDocument/cda:versionNumber/@value' ) @measure_period = extract_measure_period_or_default ( use_default_measure_period ) @attributes = @doc . xpath ( '/cda:QualityMeasureDocument/cda:subjectOf/cda:measureAttribute' , NAMESPACES ) . collect do | attribute | read_attribute ( attribute ) end @data_criteria = [ ] @source_data_criteria = [ ] @data_criteria_references = { } @occurrences_map = { } @reference_ids = [ ] end
Handles setup of the base values of the document defined here as ones that are either obtained from the xml directly or with limited parsing
1,597
def handle_attribute_code ( attribute , code , name ) null_flavor = attribute . at_xpath ( './cda:code/@nullFlavor' , NAMESPACES ) . try ( :value ) o_text = attribute . at_xpath ( './cda:code/cda:originalText/@value' , NAMESPACES ) . try ( :value ) code_obj = HQMF :: Coded . new ( attribute . at_xpath ( './cda:code/@xsi:type' , NAMESPACES ) . try ( :value ) || 'CD' , attribute . at_xpath ( './cda:code/@codeSystem' , NAMESPACES ) . try ( :value ) , code , attribute . at_xpath ( './cda:code/@valueSet' , NAMESPACES ) . try ( :value ) , name , null_flavor , o_text ) [ code_obj , null_flavor , o_text ] end
Extracts the code used by a particular attribute
1,598
def handle_attribute_value ( attribute , value ) type = attribute . at_xpath ( './cda:value/@xsi:type' , NAMESPACES ) . try ( :value ) case type when 'II' if value . nil? value = attribute . at_xpath ( './cda:value/@extension' , NAMESPACES ) . try ( :value ) end HQMF :: Identifier . new ( type , attribute . at_xpath ( './cda:value/@root' , NAMESPACES ) . try ( :value ) , attribute . at_xpath ( './cda:value/@extension' , NAMESPACES ) . try ( :value ) ) when 'ED' HQMF :: ED . new ( type , value , attribute . at_xpath ( './cda:value/@mediaType' , NAMESPACES ) . try ( :value ) ) when 'CD' HQMF :: Coded . new ( 'CD' , attribute . at_xpath ( './cda:value/@codeSystem' , NAMESPACES ) . try ( :value ) , attribute . at_xpath ( './cda:value/@code' , NAMESPACES ) . try ( :value ) , attribute . at_xpath ( './cda:value/@valueSet' , NAMESPACES ) . try ( :value ) , attribute . at_xpath ( './cda:value/cda:displayName/@value' , NAMESPACES ) . try ( :value ) ) else value . present? ? HQMF :: GenericValueContainer . new ( type , value ) : HQMF :: AnyValue . new ( type ) end end
Extracts the value used by a particular attribute
1,599
def handle_specific_source_data_criteria_reference ( criteria ) original_sdc = find ( @source_data_criteria , :id , criteria . source_data_criteria ) updated_sdc = find ( @source_data_criteria , :id , criteria . id ) if ! updated_sdc . nil? && ! criteria . specific_occurrence . nil? && ( original_sdc . nil? || original_sdc . specific_occurrence . nil? ) criteria . instance_variable_set ( :@source_data_criteria , criteria . id ) end return if original_sdc . nil? if ( criteria . specific_occurrence && ! original_sdc . specific_occurrence ) original_sdc . instance_variable_set ( :@specific_occurrence , criteria . specific_occurrence ) original_sdc . instance_variable_set ( :@specific_occurrence_const , criteria . specific_occurrence_const ) original_sdc . instance_variable_set ( :@code_list_id , criteria . code_list_id ) end end
For specific occurrence data criteria make sure the source data criteria reference points to the correct source data criteria .