id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
11,800
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.remove_fee
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
ruby
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
[ "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. @param location_id The ID of the fee's associated location. @param item_id The ID of the item to add the fee to. @param fee_id The ID of the fee to apply. @param [Hash] opts the optional parameters @return [V1Item]
[ "RemoveFee", "Removes", "a", "fee", "assocation", "from", "an", "item", "meaning", "the", "fee", "is", "no", "longer", "automatically", "applied", "to", "the", "item", "in", "Square", "Register", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1635-L1638
11,801
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.remove_modifier_list
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
ruby
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
[ "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. @param location_id The ID of the item's associated location. @param modifier_list_id The ID of the modifier list to remove. @param item_id The ID of the item to remove the modifier list from. @param [Hash] opts the optional parameters @return [V1Item]
[ "RemoveModifierList", "Removes", "a", "modifier", "list", "association", "from", "an", "item", "meaning", "modifier", "options", "from", "the", "list", "can", "no", "longer", "be", "applied", "to", "the", "item", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1698-L1701
11,802
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.retrieve_item
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
ruby
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
[ "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. @param location_id The ID of the item's associated location. @param item_id The item's ID. @param [Hash] opts the optional parameters @return [V1Item]
[ "RetrieveItem", "Provides", "the", "details", "for", "a", "single", "item", "including", "associated", "modifier", "lists", "and", "fees", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1760-L1763
11,803
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.retrieve_modifier_list
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
ruby
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
[ "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. @param location_id The ID of the item's associated location. @param modifier_list_id The modifier list's ID. @param [Hash] opts the optional parameters @return [V1ModifierList]
[ "RetrieveModifierList", "Provides", "the", "details", "for", "a", "single", "modifier", "list", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1819-L1822
11,804
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_category
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
ruby
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
[ "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. @param location_id The ID of the category's associated location. @param category_id The ID of the category to edit. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1Category]
[ "UpdateCategory", "Modifies", "the", "details", "of", "an", "existing", "item", "category", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1879-L1882
11,805
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_discount
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
ruby
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
[ "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. @param location_id The ID of the category's associated location. @param discount_id The ID of the discount to edit. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1Discount]
[ "UpdateDiscount", "Modifies", "the", "details", "of", "an", "existing", "discount", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1942-L1945
11,806
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_item
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
ruby
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
[ "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. @param location_id The ID of the item's associated location. @param item_id The ID of the item to modify. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1Item]
[ "UpdateItem", "Modifies", "the", "core", "details", "of", "an", "existing", "item", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L2068-L2071
11,807
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_modifier_list
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
ruby
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
[ "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. @param location_id The ID of the item's associated location. @param modifier_list_id The ID of the modifier list to edit. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1ModifierList]
[ "UpdateModifierList", "Modifies", "the", "details", "of", "an", "existing", "item", "modifier", "list", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L2131-L2134
11,808
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_modifier_option
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
ruby
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
[ "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. @param location_id The ID of the item's associated location. @param modifier_list_id The ID of the modifier list to edit. @param modifier_option_id The ID of the modifier list to edit. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1ModifierOption]
[ "UpdateModifierOption", "Modifies", "the", "details", "of", "an", "existing", "item", "modifier", "option", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L2195-L2198
11,809
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_page
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
ruby
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
[ "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. @param location_id The ID of the Favorites page's associated location @param page_id The ID of the page to modify. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1Page]
[ "UpdatePage", "Modifies", "the", "details", "of", "a", "Favorites", "page", "in", "Square", "Register", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L2261-L2264
11,810
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_page_cell
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
ruby
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
[ "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. @param location_id The ID of the Favorites page's associated location. @param page_id The ID of the page the cell belongs to. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1Page]
[ "UpdatePageCell", "Modifies", "a", "cell", "of", "a", "Favorites", "page", "in", "Square", "Register", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L2324-L2327
11,811
square/connect-ruby-sdk
lib/square_connect/api/v1_items_api.rb
SquareConnect.V1ItemsApi.update_variation
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
ruby
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
[ "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. @param location_id The ID of the item's associated location. @param item_id The ID of the item to modify. @param variation_id The ID of the variation to modify. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [V1Variation]
[ "UpdateVariation", "Modifies", "the", "details", "of", "an", "existing", "item", "variation", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L2388-L2391
11,812
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.delete_break_type
def delete_break_type(id, opts = {}) data, _status_code, _headers = delete_break_type_with_http_info(id, opts) return data end
ruby
def delete_break_type(id, opts = {}) data, _status_code, _headers = delete_break_type_with_http_info(id, opts) return data end
[ "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`. @param id UUID for the `BreakType` being deleted. @param [Hash] opts the optional parameters @return [DeleteBreakTypeResponse]
[ "DeleteBreakType", "Deletes", "an", "existing", "BreakType", ".", "A", "BreakType", "can", "be", "deleted", "even", "if", "it", "is", "referenced", "from", "a", "Shift", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L135-L138
11,813
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.delete_shift
def delete_shift(id, opts = {}) data, _status_code, _headers = delete_shift_with_http_info(id, opts) return data end
ruby
def delete_shift(id, opts = {}) data, _status_code, _headers = delete_shift_with_http_info(id, opts) return data end
[ "def", "delete_shift", "(", "id", ",", "opts", "=", "{", "}", ")", "data", ",", "_status_code", ",", "_headers", "=", "delete_shift_with_http_info", "(", "id", ",", "opts", ")", "return", "data", "end" ]
DeleteShift Deletes a `Shift`. @param id UUID for the `Shift` being deleted. @param [Hash] opts the optional parameters @return [DeleteShiftResponse]
[ "DeleteShift", "Deletes", "a", "Shift", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L190-L193
11,814
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.get_break_type
def get_break_type(id, opts = {}) data, _status_code, _headers = get_break_type_with_http_info(id, opts) return data end
ruby
def get_break_type(id, opts = {}) data, _status_code, _headers = get_break_type_with_http_info(id, opts) return data end
[ "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. @param id UUID for the `BreakType` being retrieved. @param [Hash] opts the optional parameters @return [GetBreakTypeResponse]
[ "GetBreakType", "Returns", "a", "single", "BreakType", "specified", "by", "id", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L245-L248
11,815
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.get_employee_wage
def get_employee_wage(id, opts = {}) data, _status_code, _headers = get_employee_wage_with_http_info(id, opts) return data end
ruby
def get_employee_wage(id, opts = {}) data, _status_code, _headers = get_employee_wage_with_http_info(id, opts) return data end
[ "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. @param id UUID for the `EmployeeWage` being retrieved. @param [Hash] opts the optional parameters @return [GetEmployeeWageResponse]
[ "GetEmployeeWage", "Returns", "a", "single", "EmployeeWage", "specified", "by", "id", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L300-L303
11,816
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.get_shift
def get_shift(id, opts = {}) data, _status_code, _headers = get_shift_with_http_info(id, opts) return data end
ruby
def get_shift(id, opts = {}) data, _status_code, _headers = get_shift_with_http_info(id, opts) return data end
[ "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. @param id UUID for the `Shift` being retrieved. @param [Hash] opts the optional parameters @return [GetShiftResponse]
[ "GetShift", "Returns", "a", "single", "Shift", "specified", "by", "id", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L355-L358
11,817
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.update_break_type
def update_break_type(id, body, opts = {}) data, _status_code, _headers = update_break_type_with_http_info(id, body, opts) return data end
ruby
def update_break_type(id, body, opts = {}) data, _status_code, _headers = update_break_type_with_http_info(id, body, opts) return data end
[ "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`. @param id UUID for the `BreakType` being updated. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [UpdateBreakTypeResponse]
[ "UpdateBreakType", "Updates", "an", "existing", "BreakType", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L643-L646
11,818
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.update_shift
def update_shift(id, body, opts = {}) data, _status_code, _headers = update_shift_with_http_info(id, body, opts) return data end
ruby
def update_shift(id, body, opts = {}) data, _status_code, _headers = update_shift_with_http_info(id, body, opts) return data end
[ "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`. @param id ID of the object being updated. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [UpdateShiftResponse]
[ "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", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L702-L705
11,819
square/connect-ruby-sdk
lib/square_connect/api/labor_api.rb
SquareConnect.LaborApi.update_workweek_config
def update_workweek_config(id, body, opts = {}) data, _status_code, _headers = update_workweek_config_with_http_info(id, body, opts) return data end
ruby
def update_workweek_config(id, body, opts = {}) data, _status_code, _headers = update_workweek_config_with_http_info(id, body, opts) return data end
[ "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`. @param id UUID for the `WorkweekConfig` object being updated. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [UpdateWorkweekConfigResponse]
[ "UpdateWorkweekConfig", "Updates", "a", "WorkweekConfig", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/labor_api.rb#L761-L764
11,820
square/connect-ruby-sdk
lib/square_connect/api/transactions_api.rb
SquareConnect.TransactionsApi.retrieve_transaction
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
ruby
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
[ "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. @param location_id The ID of the transaction's associated location. @param transaction_id The ID of the transaction to retrieve. @param [Hash] opts the optional parameters @return [RetrieveTransactionResponse]
[ "RetrieveTransaction", "Retrieves", "details", "for", "a", "single", "transaction", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/transactions_api.rb#L347-L350
11,821
square/connect-ruby-sdk
lib/square_connect/api/v1_transactions_api.rb
SquareConnect.V1TransactionsApi.list_bank_accounts
def list_bank_accounts(location_id, opts = {}) data, _status_code, _headers = list_bank_accounts_with_http_info(location_id, opts) return data end
ruby
def list_bank_accounts(location_id, opts = {}) data, _status_code, _headers = list_bank_accounts_with_http_info(location_id, opts) return data end
[ "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. @param location_id The ID of the location to list bank accounts for. @param [Hash] opts the optional parameters @return [Array<V1BankAccount>]
[ "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", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_transactions_api.rb#L84-L87
11,822
square/connect-ruby-sdk
lib/square_connect/api/v1_transactions_api.rb
SquareConnect.V1TransactionsApi.list_orders
def list_orders(location_id, opts = {}) data, _status_code, _headers = list_orders_with_http_info(location_id, opts) return data end
ruby
def list_orders(location_id, opts = {}) data, _status_code, _headers = list_orders_with_http_info(location_id, opts) return data end
[ "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. @param location_id The ID of the location to list online store orders for. @param [Hash] opts the optional parameters @option opts [String] :order TThe order in which payments are listed in the response. @option opts [Integer] :limit The maximum number of payments to return in a single response. This value cannot exceed 200. @option opts [String] :batch_token A pagination cursor to retrieve the next set of results for your original query to the endpoint. @return [Array<V1Order>]
[ "ListOrders", "Provides", "summary", "information", "for", "a", "merchant", "s", "online", "store", "orders", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_transactions_api.rb#L142-L145
11,823
square/connect-ruby-sdk
lib/square_connect/api/v1_transactions_api.rb
SquareConnect.V1TransactionsApi.retrieve_bank_account
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
ruby
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
[ "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. @param location_id The ID of the bank account&#39;s associated location. @param bank_account_id The bank account&#39;s Square-issued ID. You obtain this value from Settlement objects returned. @param [Hash] opts the optional parameters @return [V1BankAccount]
[ "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", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_transactions_api.rb#L435-L438
11,824
square/connect-ruby-sdk
lib/square_connect/api/v1_transactions_api.rb
SquareConnect.V1TransactionsApi.retrieve_order
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
ruby
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
[ "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. @param location_id The ID of the order&#39;s associated location. @param order_id The order&#39;s Square-issued ID. You obtain this value from Order objects returned by the List Orders endpoint @param [Hash] opts the optional parameters @return [V1Order]
[ "RetrieveOrder", "Provides", "comprehensive", "information", "for", "a", "single", "online", "store", "order", "including", "the", "order", "s", "history", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_transactions_api.rb#L494-L497
11,825
square/connect-ruby-sdk
lib/square_connect/api/v1_transactions_api.rb
SquareConnect.V1TransactionsApi.retrieve_payment
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
ruby
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
[ "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. @param location_id The ID of the payment&#39;s associated location. @param payment_id The Square-issued payment ID. payment_id comes from Payment objects returned by the List Payments endpoint, Settlement objects returned by the List Settlements endpoint, or Refund objects returned by the List Refunds endpoint. @param [Hash] opts the optional parameters @return [V1Payment]
[ "RetrievePayment", "Provides", "comprehensive", "information", "for", "a", "single", "payment", "." ]
798eb9ded716f23b9f1518386f1c311a34bca8bf
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_transactions_api.rb#L553-L556
11,826
GetStream/stream-rails
lib/stream_rails/utils/view_helpers.rb
StreamRails.ViewHelpers.render_activities
def render_activities(activities, options = {}) activities.map { |activity| Renderable.render(activity, self, options.dup) }.join.html_safe end
ruby
def render_activities(activities, options = {}) activities.map { |activity| Renderable.render(activity, self, options.dup) }.join.html_safe end
[ "def", "render_activities", "(", "activities", ",", "options", "=", "{", "}", ")", "activities", ".", "map", "{", "|", "activity", "|", "Renderable", ".", "render", "(", "activity", ",", "self", ",", "options", ".", "dup", ")", "}", ".", "join", ".", "html_safe", "end" ]
View helper for rendering many activities
[ "View", "helper", "for", "rendering", "many", "activities" ]
8ffa4f144169f1f31465c83f0401bad473630994
https://github.com/GetStream/stream-rails/blob/8ffa4f144169f1f31465c83f0401bad473630994/lib/stream_rails/utils/view_helpers.rb#L11-L13
11,827
dry-rb/dry-initializer
lib/dry/initializer/config.rb
Dry::Initializer.Config.param
def param(name, type = nil, **opts, &block) add_definition(false, name, type, block, opts) end
ruby
def param(name, type = nil, **opts, &block) add_definition(false, name, type, block, opts) end
[ "def", "param", "(", "name", ",", "type", "=", "nil", ",", "**", "opts", ",", "&", "block", ")", "add_definition", "(", "false", ",", "name", ",", "type", ",", "block", ",", "opts", ")", "end" ]
Adds or redefines a parameter @param [Symbol] name @param [#call, nil] type (nil) @option opts [Proc] :default @option opts [Boolean] :optional @option opts [Symbol] :as @option opts [true, false, :protected, :public, :private] :reader @return [self] itself
[ "Adds", "or", "redefines", "a", "parameter" ]
422d331468602ff0d3543fbb336b784343e5cc31
https://github.com/dry-rb/dry-initializer/blob/422d331468602ff0d3543fbb336b784343e5cc31/lib/dry/initializer/config.rb#L60-L62
11,828
dry-rb/dry-initializer
lib/dry/initializer/config.rb
Dry::Initializer.Config.inch
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
ruby
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
[ "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 @return [String]
[ "Human", "-", "readable", "representation", "of", "configured", "params", "and", "options" ]
422d331468602ff0d3543fbb336b784343e5cc31
https://github.com/dry-rb/dry-initializer/blob/422d331468602ff0d3543fbb336b784343e5cc31/lib/dry/initializer/config.rb#L115-L123
11,829
dry-rb/dry-initializer
lib/dry/initializer/dsl.rb
Dry::Initializer.DSL.[]
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
ruby
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
[ "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 @option settings [Boolean] :undefined If unassigned params and options should be treated different from nil @return [Dry::Initializer]
[ "Returns", "a", "version", "of", "the", "module", "with", "custom", "settings" ]
422d331468602ff0d3543fbb336b784343e5cc31
https://github.com/dry-rb/dry-initializer/blob/422d331468602ff0d3543fbb336b784343e5cc31/lib/dry/initializer/dsl.rb#L12-L19
11,830
dry-rb/dry-initializer
lib/dry/initializer/dsl.rb
Dry::Initializer.DSL.define
def define(procedure = nil, &block) config = Config.new(null: null) config.instance_exec(&(procedure || block)) config.mixin.include Mixin::Root config.mixin end
ruby
def define(procedure = nil, &block) config = Config.new(null: null) config.instance_exec(&(procedure || block)) config.mixin.include Mixin::Root config.mixin end
[ "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 @return [Module] @yield proc defining params and options
[ "Returns", "mixin", "module", "to", "be", "included", "to", "target", "class", "by", "hand" ]
422d331468602ff0d3543fbb336b784343e5cc31
https://github.com/dry-rb/dry-initializer/blob/422d331468602ff0d3543fbb336b784343e5cc31/lib/dry/initializer/dsl.rb#L24-L29
11,831
appium/ruby_lib
lib/appium_lib/android/common/helper.rb
Appium.Android.get_android_inspect
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 # parse html from webview @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 # ensure document is reset before parsing parser.document.filter = class_name parser.parse source result = parser.document.result parser.document.reset # clean up any created objects after parsing result end
ruby
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 # parse html from webview @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 # ensure document is reset before parsing parser.document.filter = class_name parser.parse source result = parser.document.result parser.document.reset # clean up any created objects after parsing result end
[ "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", "# parse html from webview", "@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", "# ensure document is reset before parsing", "parser", ".", "document", ".", "filter", "=", "class_name", "parser", ".", "parse", "source", "result", "=", "parser", ".", "document", ".", "result", "parser", ".", "document", ".", "reset", "# clean up any created objects after parsing", "result", "end" ]
class AndroidElements Android only. Returns a string containing interesting elements. The text, content description, and id are returned. @param class_name [String] the class name to filter on. if false (default) then all classes will be inspected @return [String]
[ "class", "AndroidElements", "Android", "only", ".", "Returns", "a", "string", "containing", "interesting", "elements", ".", "The", "text", "content", "description", "and", "id", "are", "returned", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/common/helper.rb#L95-L113
11,832
appium/ruby_lib
lib/appium_lib/android/common/helper.rb
Appium.Android.page
def page(opts = {}) class_name = opts.is_a?(Hash) ? opts.fetch(:class, nil) : opts puts get_android_inspect class_name nil end
ruby
def page(opts = {}) class_name = opts.is_a?(Hash) ? opts.fetch(:class, nil) : opts puts get_android_inspect class_name nil end
[ "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. @option class [Symbol] the class name to filter on. case insensitive include match. if nil (default) then all classes will be inspected @return [void]
[ "Intended", "for", "use", "with", "console", ".", "Inspects", "and", "prints", "the", "current", "page", ".", "Will", "return", "XHTML", "for", "Web", "contexts", "because", "of", "a", "quirk", "with", "Nokogiri", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/common/helper.rb#L121-L125
11,833
appium/ruby_lib
lib/appium_lib/android/common/helper.rb
Appium.Android.ele_index
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 # uiautomator has issues with index/instance so calculate the index # client side. results[index] end
ruby
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 # uiautomator has issues with index/instance so calculate the index # client side. results[index] end
[ "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", "# uiautomator has issues with index/instance so calculate the index", "# client side.", "results", "[", "index", "]", "end" ]
Find the element of type class_name at matching index. @param class_name [String] the class name to find @param index [Integer] the index @return [Element] the found element of type class_name
[ "Find", "the", "element", "of", "type", "class_name", "at", "matching", "index", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/common/helper.rb#L147-L161
11,834
appium/ruby_lib
lib/appium_lib/driver.rb
Appium.Driver.driver_attributes
def driver_attributes # rubocop:disable Layout/AlignHash { 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 } # rubocop:enable Layout/AlignHash end
ruby
def driver_attributes # rubocop:disable Layout/AlignHash { 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 } # rubocop:enable Layout/AlignHash end
[ "def", "driver_attributes", "# rubocop:disable Layout/AlignHash", "{", "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", "}", "# rubocop:enable Layout/AlignHash", "end" ]
Returns a hash of the driver attributes
[ "Returns", "a", "hash", "of", "the", "driver", "attributes" ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/driver.rb#L273-L293
11,835
appium/ruby_lib
lib/appium_lib/driver.rb
Appium.Driver.appium_server_version
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=""') # server (TestObject for instance) does not respond to status call {} end
ruby
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=""') # server (TestObject for instance) does not respond to status call {} end
[ "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=\"\"'", ")", "# server (TestObject for instance) does not respond to status call", "{", "}", "end" ]
Returns the server's version info @example { "build" => { "version" => "0.18.1", "revision" => "d242ebcfd92046a974347ccc3a28f0e898595198" } } @return [Hash]
[ "Returns", "the", "server", "s", "version", "info" ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/driver.rb#L375-L382
11,836
appium/ruby_lib
lib/appium_lib/driver.rb
Appium.Driver.start_driver
def start_driver(http_client_ops = { http_client: ::Appium::Http::Default.new, open_timeout: 999_999, read_timeout: 999_999 }) @core.quit_driver # If automationName is set only in server side, then the following automation_name should be nil before # starting 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 # if automation_name was nil before start_driver, then re-extend driver specific methods # to be able to extend correctly. extend_for(device: @core.device, automation_name: @core.automation_name) if automation_name.nil? @appium_server_status = appium_server_version @driver end
ruby
def start_driver(http_client_ops = { http_client: ::Appium::Http::Default.new, open_timeout: 999_999, read_timeout: 999_999 }) @core.quit_driver # If automationName is set only in server side, then the following automation_name should be nil before # starting 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 # if automation_name was nil before start_driver, then re-extend driver specific methods # to be able to extend correctly. extend_for(device: @core.device, automation_name: @core.automation_name) if automation_name.nil? @appium_server_status = appium_server_version @driver end
[ "def", "start_driver", "(", "http_client_ops", "=", "{", "http_client", ":", "::", "Appium", "::", "Http", "::", "Default", ".", "new", ",", "open_timeout", ":", "999_999", ",", "read_timeout", ":", "999_999", "}", ")", "@core", ".", "quit_driver", "# If automationName is set only in server side, then the following automation_name should be nil before", "# starting 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", "# if automation_name was nil before start_driver, then re-extend driver specific methods", "# to be able to extend correctly.", "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 Read http://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Device to understand more what the driver can call instance methods. @example require 'rubygems' require 'appium_lib' # platformName takes a string or a symbol. # Start iOS driver opts = { caps: { platformName: :ios, app: '/path/to/MyiOS.app' }, appium_lib: { wait_timeout: 30 } } appium_driver = Appium::Driver.new(opts) #=> return an Appium::Driver instance appium_driver.start_driver #=> return an Appium::Core::Base::Driver @option http_client_ops [Hash] :http_client Custom HTTP Client @option http_client_ops [Hash] :open_timeout Custom open timeout for http client. @option http_client_ops [Hash] :read_timeout Custom read timeout for http client. @return [Selenium::WebDriver] the new global driver
[ "Creates", "a", "new", "global", "driver", "and", "quits", "the", "old", "one", "if", "it", "exists", ".", "You", "can", "customise", "http_client", "as", "the", "following" ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/driver.rb#L540-L558
11,837
appium/ruby_lib
lib/appium_lib/driver.rb
Appium.Driver.set_implicit_wait
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
ruby
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
[ "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
[ "To", "ignore", "error", "for", "Espresso", "Driver" ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/driver.rb#L561-L569
11,838
appium/ruby_lib
lib/appium_lib/driver.rb
Appium.Driver.exists
def exists(pre_check = 0, post_check = @core.default_wait) # do not uset set_wait here. # it will cause problems with other methods reading the default_wait of 0 # which then gets converted to a 1 second wait. @driver.manage.timeouts.implicit_wait = pre_check # the element exists unless an error is raised. exists = true begin yield # search for element rescue StandardError exists = false # error means it's not there end # restore wait @driver.manage.timeouts.implicit_wait = post_check if post_check != pre_check exists end
ruby
def exists(pre_check = 0, post_check = @core.default_wait) # do not uset set_wait here. # it will cause problems with other methods reading the default_wait of 0 # which then gets converted to a 1 second wait. @driver.manage.timeouts.implicit_wait = pre_check # the element exists unless an error is raised. exists = true begin yield # search for element rescue StandardError exists = false # error means it's not there end # restore wait @driver.manage.timeouts.implicit_wait = post_check if post_check != pre_check exists end
[ "def", "exists", "(", "pre_check", "=", "0", ",", "post_check", "=", "@core", ".", "default_wait", ")", "# do not uset set_wait here.", "# it will cause problems with other methods reading the default_wait of 0", "# which then gets converted to a 1 second wait.", "@driver", ".", "manage", ".", "timeouts", ".", "implicit_wait", "=", "pre_check", "# the element exists unless an error is raised.", "exists", "=", "true", "begin", "yield", "# search for element", "rescue", "StandardError", "exists", "=", "false", "# error means it's not there", "end", "# restore wait", "@driver", ".", "manage", ".", "timeouts", ".", "implicit_wait", "=", "post_check", "if", "post_check", "!=", "pre_check", "exists", "end" ]
Returns existence of element. Example: exists { button('sign in') } ? puts('true') : puts('false') @param [Integer] pre_check The amount in seconds to set the wait to before checking existence @param [Integer] post_check The amount in seconds to set the wait to after checking existence @yield The block to call @return [Boolean]
[ "Returns", "existence", "of", "element", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/driver.rb#L603-L621
11,839
appium/ruby_lib
lib/appium_lib/ios/element/textfield.rb
Appium.Ios.last_textfield
def last_textfield result = eles_by_json(_textfield_visible).last raise _no_such_element if result.nil? result end
ruby
def last_textfield result = eles_by_json(_textfield_visible).last raise _no_such_element if result.nil? result end
[ "def", "last_textfield", "result", "=", "eles_by_json", "(", "_textfield_visible", ")", ".", "last", "raise", "_no_such_element", "if", "result", ".", "nil?", "result", "end" ]
Find the last TextField. @return [TextField]
[ "Find", "the", "last", "TextField", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/ios/element/textfield.rb#L75-L80
11,840
appium/ruby_lib
lib/appium_lib/common/helper.rb
Appium.Common.px_to_window_rel
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
ruby
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
[ "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 @example px_to_window_rel x: 50, y: 150 #=> #<OpenStruct x="50.0 / 375.0", y="150.0 / 667.0">
[ "Converts", "pixel", "values", "to", "window", "relative", "values" ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/common/helper.rb#L164-L171
11,841
appium/ruby_lib
lib/appium_lib/common/helper.rb
Appium.Common.xml_keys
def xml_keys(target) lazy_load_strings @lazy_load_strings.select { |key, _value| key.downcase.include? target.downcase } end
ruby
def xml_keys(target) lazy_load_strings @lazy_load_strings.select { |key, _value| key.downcase.include? target.downcase } end
[ "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. @param target [String] the target to search for in strings.xml values @return [Array]
[ "Search", "strings", ".", "xml", "s", "values", "for", "target", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/common/helper.rb#L183-L186
11,842
appium/ruby_lib
lib/appium_lib/common/helper.rb
Appium.Common.xml_values
def xml_values(target) lazy_load_strings @lazy_load_strings.select { |_key, value| value.downcase.include? target.downcase } end
ruby
def xml_values(target) lazy_load_strings @lazy_load_strings.select { |_key, value| value.downcase.include? target.downcase } end
[ "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. @param target [String] the target to search for in strings.xml keys @return [Array]
[ "Search", "strings", ".", "xml", "s", "keys", "for", "target", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/common/helper.rb#L191-L194
11,843
appium/ruby_lib
lib/appium_lib/android/element/button.rb
Appium.Android.button
def button(value) # Don't use ele_index because that only works on one element type. # Android needs to combine button and image button to match iOS. if value.is_a? Numeric index = value raise "#{index} is not a valid index. Must be >= 1" if index <= 0 # 1 indexed return find_element :uiautomator, _button_visible_selectors(index: index) end find_element :uiautomator, _button_contains_string(value) end
ruby
def button(value) # Don't use ele_index because that only works on one element type. # Android needs to combine button and image button to match iOS. if value.is_a? Numeric index = value raise "#{index} is not a valid index. Must be >= 1" if index <= 0 # 1 indexed return find_element :uiautomator, _button_visible_selectors(index: index) end find_element :uiautomator, _button_contains_string(value) end
[ "def", "button", "(", "value", ")", "# Don't use ele_index because that only works on one element type.", "# Android needs to combine button and image button to match iOS.", "if", "value", ".", "is_a?", "Numeric", "index", "=", "value", "raise", "\"#{index} is not a valid index. Must be >= 1\"", "if", "index", "<=", "0", "# 1 indexed", "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. @param value [String, Integer] the value to exactly match. If int then the button at that index is returned. @return [BUTTON]
[ "backward", "compatibility", "Find", "the", "first", "button", "that", "contains", "value", "or", "by", "index", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/element/button.rb#L27-L39
11,844
appium/ruby_lib
lib/appium_lib/android/element/button.rb
Appium.Android.last_button
def last_button # uiautomator index doesn't support last # and it's 0 indexed 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
ruby
def last_button # uiautomator index doesn't support last # and it's 0 indexed 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
[ "def", "last_button", "# uiautomator index doesn't support last", "# and it's 0 indexed", "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. @return [BUTTON]
[ "Find", "the", "last", "button", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/element/button.rb#L59-L70
11,845
appium/ruby_lib
lib/appium_lib/ios/element/text.rb
Appium.Ios.text
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
ruby
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
[ "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. @param value [String, Integer] the value to find. If int then the UIAStaticText|XCUIElementTypeStaticText at that index is returned. @return [UIA_STATIC_TEXT|XCUIELEMENT_TYPE_STATIC_TEXT]
[ "Find", "the", "first", "UIAStaticText|XCUIElementTypeStaticText", "that", "contains", "value", "or", "by", "index", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/ios/element/text.rb#L33-L37
11,846
appium/ruby_lib
lib/appium_lib/android/element/generic.rb
Appium.Android.scroll_to
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
ruby
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
[ "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. @param text [String] the text or resourceId to search for in the text value and content description @param scrollable_index [Integer] the index for scrollable views. @return [Element] the element scrolled to
[ "Scroll", "to", "the", "first", "element", "containing", "target", "text", "or", "description", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/element/generic.rb#L54-L66
11,847
appium/ruby_lib
lib/appium_lib/ios/common/helper.rb
Appium.Ios.page
def page(opts = {}) class_name = opts.is_a?(Hash) ? opts.fetch(:class, nil) : opts source = get_source # current_context may be nil which breaks start_with 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
ruby
def page(opts = {}) class_name = opts.is_a?(Hash) ? opts.fetch(:class, nil) : opts source = get_source # current_context may be nil which breaks start_with 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
[ "def", "page", "(", "opts", "=", "{", "}", ")", "class_name", "=", "opts", ".", "is_a?", "(", "Hash", ")", "?", "opts", ".", "fetch", "(", ":class", ",", "nil", ")", ":", "opts", "source", "=", "get_source", "# current_context may be nil which breaks start_with", "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. @example ```ruby page class: :UIAButton # filter on buttons page class: :UIAButton, window: 1 ``` @option visible [Symbol] visible value to filter on @option class [Symbol] class name to filter on @return [void]
[ "Prints", "a", "string", "of", "interesting", "elements", "to", "the", "console", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/ios/common/helper.rb#L73-L95
11,848
appium/ruby_lib
lib/appium_lib/ios/common/helper.rb
Appium.Ios.ele_index
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 # elements array is 0 indexed index -= 1 result = elements[index] end raise _no_such_element if result.nil? result end
ruby
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 # elements array is 0 indexed index -= 1 result = elements[index] end raise _no_such_element if result.nil? result end
[ "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", "# elements array is 0 indexed", "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. @param class_name [String] the class name to find @param index [Integer] the index @return [Element]
[ "Get", "the", "element", "of", "type", "class_name", "at", "matching", "index", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/ios/common/helper.rb#L108-L124
11,849
appium/ruby_lib
lib/appium_lib/ios/common/helper.rb
Appium.Ios._all_pred
def _all_pred(opts) predicate = opts[:predicate] raise 'predicate must be provided' unless predicate visible = opts.fetch :visible, true %($.mainApp().getAllWithPredicate("#{predicate}", #{visible});) end
ruby
def _all_pred(opts) predicate = opts[:predicate] raise 'predicate must be provided' unless predicate visible = opts.fetch :visible, true %($.mainApp().getAllWithPredicate("#{predicate}", #{visible});) end
[ "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 visible - if true, only visible elements are returned. default true
[ "predicate", "-", "the", "predicate", "to", "evaluate", "on", "the", "main", "app" ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/ios/common/helper.rb#L376-L382
11,850
appium/ruby_lib
lib/appium_lib/common/wait.rb
Appium.Common.wait_true
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
ruby
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
[ "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. Wait code from the selenium Ruby gem https://github.com/SeleniumHQ/selenium/blob/cf501dda3f0ed12233de51ce8170c0e8090f0c20/rb/lib/selenium/webdriver/common/wait.rb If only a number is provided then it's treated as the timeout value. @param [Hash|Numeric] opts Options. If the value is _Numeric_, the value is set as `{ timeout: value }` @option opts [Numeric] :timeout Seconds to wait before timing out. Set default by `appium_wait_timeout` (30). @option opts [Numeric] :interval Seconds to sleep between polls. Set default by `appium_wait_interval` (0.5). @option opts [String] :message Exception message if timed out. @option opts [Array, Exception] :ignore Exceptions to ignore while polling (default: Exception) @example wait_true(timeout: 20, interval: 0.2, message: 'custom message') { button_exact('Back') }.click wait_true(20) { button_exact('Back') }.click
[ "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", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/common/wait.rb#L44-L52
11,851
appium/ruby_lib
lib/appium_lib/android/element/textfield.rb
Appium.Android.textfield
def textfield(value) return ele_index EDIT_TEXT, value if value.is_a? Numeric complex_find_contains EDIT_TEXT, value end
ruby
def textfield(value) return ele_index EDIT_TEXT, value if value.is_a? Numeric complex_find_contains EDIT_TEXT, value end
[ "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. @param value [String, Integer] the text to match exactly. If int then the EditText at that index is returned. @return [EDIT_TEXT]
[ "Find", "the", "first", "EditText", "that", "contains", "value", "or", "by", "index", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/element/textfield.rb#L24-L28
11,852
appium/ruby_lib
lib/appium_lib/android/element/text.rb
Appium.Android.text
def text(value) return ele_index TEXT_VIEW, value if value.is_a? Numeric complex_find_contains TEXT_VIEW, value end
ruby
def text(value) return ele_index TEXT_VIEW, value if value.is_a? Numeric complex_find_contains TEXT_VIEW, value end
[ "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. @param value [String, Integer] the value to find. If int then the TextView at that index is returned. @return [TextView]
[ "Find", "the", "first", "TextView", "that", "contains", "value", "or", "by", "index", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/android/element/text.rb#L25-L29
11,853
appium/ruby_lib
lib/appium_lib/ios/element/button.rb
Appium.Ios.button
def button(value) # return button at index. return ele_index button_class, value if value.is_a? Numeric ele_by_json_visible_contains button_class, value end
ruby
def button(value) # return button at index. return ele_index button_class, value if value.is_a? Numeric ele_by_json_visible_contains button_class, value end
[ "def", "button", "(", "value", ")", "# return button at index.", "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. @param value [String, Integer] the value to exactly match. If int then the UIAButton|XCUIElementTypeButton at that index is returned. @return [UIA_BUTTON|XCUIELEMENT_TYPE_BUTTON]
[ "Find", "the", "first", "UIAButton|XCUIElementTypeButton", "that", "contains", "value", "or", "by", "index", "." ]
1f5898400dd1928bfe42ddd5f842d1f8738f2f76
https://github.com/appium/ruby_lib/blob/1f5898400dd1928bfe42ddd5f842d1f8738f2f76/lib/appium_lib/ios/element/button.rb#L33-L38
11,854
projectcypress/health-data-standards
lib/hqmf-parser/2.0/population_criteria.rb
HQMF2.PopulationCriteria.setup_derived_entry_elements
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') # If there are no measure observations, or there is a title, then there are no aggregations to extract 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
ruby
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') # If there are no measure observations, or there is a title, then there are no aggregations to extract 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
[ "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'", ")", "# If there are no measure observations, or there is a title, then there are no aggregations to extract", "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
[ "Handles", "extracting", "elements", "from", "the", "entry" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/population_criteria.rb#L42-L54
11,855
projectcypress/health-data-standards
lib/hqmf-parser/2.0/population_criteria.rb
HQMF2.PopulationCriteria.handle_preconditions
def handle_preconditions(id_generator) # Nest multiple preconditions under a single root precondition @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 # Remove uneeded nils from the array @preconditions.compact! end
ruby
def handle_preconditions(id_generator) # Nest multiple preconditions under a single root precondition @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 # Remove uneeded nils from the array @preconditions.compact! end
[ "def", "handle_preconditions", "(", "id_generator", ")", "# Nest multiple preconditions under a single root precondition", "@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", "# Remove uneeded nils from the array", "@preconditions", ".", "compact!", "end" ]
specifically handles extracting the preconditions for the population criteria
[ "specifically", "handles", "extracting", "the", "preconditions", "for", "the", "population", "criteria" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/population_criteria.rb#L57-L66
11,856
projectcypress/health-data-standards
lib/hqmf-parser/2.0/population_criteria.rb
HQMF2.PopulationCriteria.handle_observation_criteria
def handle_observation_criteria exp = @entry.at_xpath('./cda:measureObservationDefinition/cda:value/cda:expression/@value', HQMF2::Document::NAMESPACES) # Measure Observations criteria rely on computed expressions. If it doesn't have one, # then it is likely formatted improperly. 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) # Update reference_ids with any newly referenced data criteria dc.children_criteria.each { |cc| @doc.add_reference_id(cc) } unless dc.children_criteria.nil? dc end
ruby
def handle_observation_criteria exp = @entry.at_xpath('./cda:measureObservationDefinition/cda:value/cda:expression/@value', HQMF2::Document::NAMESPACES) # Measure Observations criteria rely on computed expressions. If it doesn't have one, # then it is likely formatted improperly. 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) # Update reference_ids with any newly referenced data criteria dc.children_criteria.each { |cc| @doc.add_reference_id(cc) } unless dc.children_criteria.nil? dc end
[ "def", "handle_observation_criteria", "exp", "=", "@entry", ".", "at_xpath", "(", "'./cda:measureObservationDefinition/cda:value/cda:expression/@value'", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", "# Measure Observations criteria rely on computed expressions. If it doesn't have one,", "# then it is likely formatted improperly.", "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", ")", "# Update reference_ids with any newly referenced data criteria", "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
[ "extracts", "out", "any", "measure", "observation", "definitons", "creating", "from", "them", "the", "proper", "criteria", "to", "generate", "a", "precondition" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/population_criteria.rb#L69-L81
11,857
projectcypress/health-data-standards
lib/hqmf-parser/2.0/population_criteria.rb
HQMF2.PopulationCriteria.parse_parts_to_dc
def parse_parts_to_dc(parts) case parts.length when 1 # If there is only one part, it is a reference to an existing data criteria's value @doc.find_criteria_by_lvn(parts.first.strip.split('.')[0]) when 2 # If there are two parts, there is a computation performed, specifically time difference, on the two criteria 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 # If there are neither one or 2 parts, the code should fail fail "No defined extraction method to handle #{parts.length} parts" end end
ruby
def parse_parts_to_dc(parts) case parts.length when 1 # If there is only one part, it is a reference to an existing data criteria's value @doc.find_criteria_by_lvn(parts.first.strip.split('.')[0]) when 2 # If there are two parts, there is a computation performed, specifically time difference, on the two criteria 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 # If there are neither one or 2 parts, the code should fail fail "No defined extraction method to handle #{parts.length} parts" end end
[ "def", "parse_parts_to_dc", "(", "parts", ")", "case", "parts", ".", "length", "when", "1", "# If there is only one part, it is a reference to an existing data criteria's value", "@doc", ".", "find_criteria_by_lvn", "(", "parts", ".", "first", ".", "strip", ".", "split", "(", "'.'", ")", "[", "0", "]", ")", "when", "2", "# If there are two parts, there is a computation performed, specifically time difference, on the two criteria", "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", "# If there are neither one or 2 parts, the code should fail", "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.
[ "generates", "the", "value", "given", "in", "an", "expression", "based", "on", "the", "number", "of", "criteria", "it", "references", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/population_criteria.rb#L84-L107
11,858
projectcypress/health-data-standards
lib/hqmf-parser/2.0/population_criteria.rb
HQMF2.PopulationCriteria.conjunction_code
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
ruby
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
[ "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 @return [String] conjunction code
[ "Get", "the", "conjunction", "code", "ALL_TRUE", "or", "AT_LEAST_ONE_TRUE" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/population_criteria.rb#L115-L126
11,859
projectcypress/health-data-standards
lib/hqmf-parser/2.0/types.rb
HQMF2.Value.inclusive_temporal_ref?
def inclusive_temporal_ref? # FIXME: NINF is used instead of 0 sometimes...? (not in the IG) # FIXME: Given nullFlavor, but IG uses it and nullValue everywhere... 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') # Both less and greater require lowClosed to be set to true (less_than_equal_tr || greater_than_equal_tr) && attr_val('../@lowClosed') == 'true' end
ruby
def inclusive_temporal_ref? # FIXME: NINF is used instead of 0 sometimes...? (not in the IG) # FIXME: Given nullFlavor, but IG uses it and nullValue everywhere... 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') # Both less and greater require lowClosed to be set to true (less_than_equal_tr || greater_than_equal_tr) && attr_val('../@lowClosed') == 'true' end
[ "def", "inclusive_temporal_ref?", "# FIXME: NINF is used instead of 0 sometimes...? (not in the IG)", "# FIXME: Given nullFlavor, but IG uses it and nullValue everywhere...", "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'", ")", "# Both less and greater require lowClosed to be set to true", "(", "less_than_equal_tr", "||", "greater_than_equal_tr", ")", "&&", "attr_val", "(", "'../@lowClosed'", ")", "==", "'true'", "end" ]
Check whether the temporal reference should be marked as inclusive
[ "Check", "whether", "the", "temporal", "reference", "should", "be", "marked", "as", "inclusive" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/types.rb#L47-L56
11,860
projectcypress/health-data-standards
lib/hqmf-parser/2.0/types.rb
HQMF2.Value.inclusive_length_of_stay?
def inclusive_length_of_stay? # lengthOfStay - EH111, EH108 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' # Both less and greater require that the type is PQ (less_than_equal_los || greater_than_equal_los) && attr_val('@xsi:type') == 'PQ' end
ruby
def inclusive_length_of_stay? # lengthOfStay - EH111, EH108 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' # Both less and greater require that the type is PQ (less_than_equal_los || greater_than_equal_los) && attr_val('@xsi:type') == 'PQ' end
[ "def", "inclusive_length_of_stay?", "# lengthOfStay - EH111, EH108", "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'", "# Both less and greater require that the type is PQ", "(", "less_than_equal_los", "||", "greater_than_equal_los", ")", "&&", "attr_val", "(", "'@xsi:type'", ")", "==", "'PQ'", "end" ]
Check whether the length of stay should be inclusive.
[ "Check", "whether", "the", "length", "of", "stay", "should", "be", "inclusive", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/types.rb#L59-L68
11,861
projectcypress/health-data-standards
lib/hqmf-parser/2.0/types.rb
HQMF2.Range.generate_any_value?
def generate_any_value?(lm, hm) (lm.nil? || lm.is_a?(HQMF::AnyValue)) && (hm.nil? || hm.is_a?(HQMF::AnyValue)) end
ruby
def generate_any_value?(lm, hm) (lm.nil? || lm.is_a?(HQMF::AnyValue)) && (hm.nil? || hm.is_a?(HQMF::AnyValue)) end
[ "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
[ "Check", "if", "are", "only", "AnyValue", "elements", "for", "low", "and", "high" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/types.rb#L153-L155
11,862
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb
HQMF2.DocumentPopulationHelper.remove_population_preconditions
def remove_population_preconditions(doc) # population sections pop_ids = doc.xpath("//cda:populationCriteriaSection/cda:component[@typeCode='COMP']/*/cda:id", HQMF2::Document::NAMESPACES) # find the population entries and get their ids 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
ruby
def remove_population_preconditions(doc) # population sections pop_ids = doc.xpath("//cda:populationCriteriaSection/cda:component[@typeCode='COMP']/*/cda:id", HQMF2::Document::NAMESPACES) # find the population entries and get their ids 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
[ "def", "remove_population_preconditions", "(", "doc", ")", "# population sections", "pop_ids", "=", "doc", ".", "xpath", "(", "\"//cda:populationCriteriaSection/cda:component[@typeCode='COMP']/*/cda:id\"", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", "# find the population entries and get their ids", "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
[ "If", "a", "precondition", "references", "a", "population", "remove", "it" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb#L21-L30
11,863
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb
HQMF2.DocumentPopulationHelper.extract_observations
def extract_observations has_observation = false # look for observation data in separate section but create a population for it if it exists 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' # This section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc. # This allows the populations to be more readable. The alternative would be to have the hqmf ids in the # populations, which would work, but is difficult to read the populations. 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
ruby
def extract_observations has_observation = false # look for observation data in separate section but create a population for it if it exists 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' # This section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc. # This allows the populations to be more readable. The alternative would be to have the hqmf ids in the # populations, which would work, but is difficult to read the populations. 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
[ "def", "extract_observations", "has_observation", "=", "false", "# look for observation data in separate section but create a population for it if it exists", "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'", "# This section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc.", "# This allows the populations to be more readable. The alternative would be to have the hqmf ids in the", "# populations, which would work, but is difficult to read the populations.", "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
[ "Extracts", "the", "measure", "observations", "will", "return", "true", "if", "one", "exists" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb#L64-L89
11,864
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb
HQMF2.DocumentPopulationHelper.handle_base_populations
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
ruby
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
[ "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
[ "Builds", "populations", "based", "an", "a", "predfined", "set", "of", "expected", "populations" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb#L92-L108
11,865
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb
HQMF2.DocumentPopulationHelper.handle_stratifications
def handle_stratifications(population_def, number_of_populations, population, id_def, population_index) # handle stratifications (EP137, EP155) 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| # Skip this Stratification if any precondition doesn't contain any preconditions 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
ruby
def handle_stratifications(population_def, number_of_populations, population, id_def, population_index) # handle stratifications (EP137, EP155) 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| # Skip this Stratification if any precondition doesn't contain any preconditions 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
[ "def", "handle_stratifications", "(", "population_def", ",", "number_of_populations", ",", "population", ",", "id_def", ",", "population_index", ")", "# handle stratifications (EP137, EP155)", "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", "|", "# Skip this Stratification if any precondition doesn't contain any preconditions", "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
[ "Generate", "the", "stratifications", "of", "populations", "if", "any", "exist" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb#L111-L133
11,866
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb
HQMF2.DocumentPopulationHelper.build_population_criteria
def build_population_criteria(criteria_def, criteria_id, population) criteria = PopulationCriteria.new(criteria_def, @document, @id_generator) # check to see if we have an identical population criteria. # this can happen since the hqmf 2.0 will export a DENOM, NUMER, etc for each population, even if identical. # if we have identical, just re-use it rather than creating DENOM_1, NUMER_1, etc. 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? # this section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc. # This allows the populations to be more readable. The alternative would be to have the hqmf ids in the # populations, which would work, but is difficult to read the populations. 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
ruby
def build_population_criteria(criteria_def, criteria_id, population) criteria = PopulationCriteria.new(criteria_def, @document, @id_generator) # check to see if we have an identical population criteria. # this can happen since the hqmf 2.0 will export a DENOM, NUMER, etc for each population, even if identical. # if we have identical, just re-use it rather than creating DENOM_1, NUMER_1, etc. 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? # this section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc. # This allows the populations to be more readable. The alternative would be to have the hqmf ids in the # populations, which would work, but is difficult to read the populations. 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
[ "def", "build_population_criteria", "(", "criteria_def", ",", "criteria_id", ",", "population", ")", "criteria", "=", "PopulationCriteria", ".", "new", "(", "criteria_def", ",", "@document", ",", "@id_generator", ")", "# check to see if we have an identical population criteria.", "# this can happen since the hqmf 2.0 will export a DENOM, NUMER, etc for each population, even if identical.", "# if we have identical, just re-use it rather than creating DENOM_1, NUMER_1, etc.", "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?", "# this section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc.", "# This allows the populations to be more readable. The alternative would be to have the hqmf ids in the", "# populations, which would work, but is difficult to read the populations.", "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
[ "Method", "to", "generate", "the", "criteria", "defining", "a", "population" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb#L136-L162
11,867
projectcypress/health-data-standards
lib/hqmf-parser/1.0/document.rb
HQMF1.Document.backfill_derived_code_lists
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
ruby
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
[ "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
[ "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" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/1.0/document.rb#L132-L143
11,868
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/population_criteria_converter.rb
HQMF.PopulationCriteriaConverter.get_unmatched_population_keys
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]]} # if we have a population without a reference, we cannot trust the results. return [] if with_ref_keys.include? nil all_target_keys - with_ref_keys end
ruby
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]]} # if we have a population without a reference, we cannot trust the results. return [] if with_ref_keys.include? nil all_target_keys - with_ref_keys end
[ "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", "]", "]", "}", "# if we have a population without a reference, we cannot trust the results.", "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
[ "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" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb#L115-L122
11,869
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/population_criteria_converter.rb
HQMF.PopulationCriteriaConverter.apply_to_submeasures
def apply_to_submeasures(subs, type, values, unpaired_type=nil, unpaired_keys=[]) new_subs = [] subs.each do |sub| # this unless prevents us from forcing an exclusion or excepion onto a measure that has a submeasure without # an exclusion or exception, but other populations with an exclusion or excepion. unless unpaired_keys.include? sub[unpaired_type] # duplicate each new value if it is set, otherwise set this key on each submeasure. 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
ruby
def apply_to_submeasures(subs, type, values, unpaired_type=nil, unpaired_keys=[]) new_subs = [] subs.each do |sub| # this unless prevents us from forcing an exclusion or excepion onto a measure that has a submeasure without # an exclusion or exception, but other populations with an exclusion or excepion. unless unpaired_keys.include? sub[unpaired_type] # duplicate each new value if it is set, otherwise set this key on each submeasure. 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
[ "def", "apply_to_submeasures", "(", "subs", ",", "type", ",", "values", ",", "unpaired_type", "=", "nil", ",", "unpaired_keys", "=", "[", "]", ")", "new_subs", "=", "[", "]", "subs", ".", "each", "do", "|", "sub", "|", "# this unless prevents us from forcing an exclusion or excepion onto a measure that has a submeasure without", "# an exclusion or exception, but other populations with an exclusion or excepion.", "unless", "unpaired_keys", ".", "include?", "sub", "[", "unpaired_type", "]", "# duplicate each new value if it is set, otherwise set this key on each submeasure.", "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
[ "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" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb#L126-L147
11,870
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document.rb
HQMF2.Document.setup_default_values
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') # TODO: -- figure out if this is the correct thing to do -- probably not, but is # necessary to get the bonnie comparison to work. Currently # defaulting measure period to a period of 1 year from 2012 to 2013 this is overriden during # calculation with correct year information . Need to investigate parsing mp from meaures. @measure_period = extract_measure_period_or_default(use_default_measure_period) # Extract measure attributes # TODO: Review @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 = {} # Used to keep track of referenced data criteria ids @reference_ids = [] end
ruby
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') # TODO: -- figure out if this is the correct thing to do -- probably not, but is # necessary to get the bonnie comparison to work. Currently # defaulting measure period to a period of 1 year from 2012 to 2013 this is overriden during # calculation with correct year information . Need to investigate parsing mp from meaures. @measure_period = extract_measure_period_or_default(use_default_measure_period) # Extract measure attributes # TODO: Review @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 = {} # Used to keep track of referenced data criteria ids @reference_ids = [] end
[ "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'", ")", "# TODO: -- figure out if this is the correct thing to do -- probably not, but is", "# necessary to get the bonnie comparison to work. Currently", "# defaulting measure period to a period of 1 year from 2012 to 2013 this is overriden during", "# calculation with correct year information . Need to investigate parsing mp from meaures.", "@measure_period", "=", "extract_measure_period_or_default", "(", "use_default_measure_period", ")", "# Extract measure attributes", "# TODO: Review", "@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", "=", "{", "}", "# Used to keep track of referenced data criteria ids", "@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
[ "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" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document.rb#L120-L150
11,871
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document.rb
HQMF2.Document.handle_attribute_code
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
ruby
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
[ "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
[ "Extracts", "the", "code", "used", "by", "a", "particular", "attribute" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document.rb#L201-L212
11,872
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document.rb
HQMF2.Document.handle_attribute_value
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
ruby
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
[ "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
[ "Extracts", "the", "value", "used", "by", "a", "particular", "attribute" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document.rb#L215-L236
11,873
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document.rb
HQMF2.Document.handle_specific_source_data_criteria_reference
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
ruby
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
[ "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.
[ "For", "specific", "occurrence", "data", "criteria", "make", "sure", "the", "source", "data", "criteria", "reference", "points", "to", "the", "correct", "source", "data", "criteria", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document.rb#L289-L301
11,874
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb
HQMF2.DataCriteriaPostProcessing.handle_mapping_template
def handle_mapping_template(mapping) if mapping if mapping[:valueset_path] && @entry.at_xpath(mapping[:valueset_path]) @code_list_xpath = mapping[:valueset_path] end @value = DataCriteriaMethods.parse_value(@entry, mapping[:result_path]) if mapping[:result_path] end end
ruby
def handle_mapping_template(mapping) if mapping if mapping[:valueset_path] && @entry.at_xpath(mapping[:valueset_path]) @code_list_xpath = mapping[:valueset_path] end @value = DataCriteriaMethods.parse_value(@entry, mapping[:result_path]) if mapping[:result_path] end end
[ "def", "handle_mapping_template", "(", "mapping", ")", "if", "mapping", "if", "mapping", "[", ":valueset_path", "]", "&&", "@entry", ".", "at_xpath", "(", "mapping", "[", ":valueset_path", "]", ")", "@code_list_xpath", "=", "mapping", "[", ":valueset_path", "]", "end", "@value", "=", "DataCriteriaMethods", ".", "parse_value", "(", "@entry", ",", "mapping", "[", ":result_path", "]", ")", "if", "mapping", "[", ":result_path", "]", "end", "end" ]
Set the value and code_list_xpath using the template mapping held in the ValueSetHelper class
[ "Set", "the", "value", "and", "code_list_xpath", "using", "the", "template", "mapping", "held", "in", "the", "ValueSetHelper", "class" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb#L41-L48
11,875
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb
HQMF2.DataCriteriaPostProcessing.handle_derived_specific_occurrences
def handle_derived_specific_occurrences return unless @definition == 'derived' # remove "_source" from source data critera. It gets added in in SpecificOccurrenceAndSource but # when it gets added we have not yet determined the definition of the data criteria so we cannot # skip adding it. Determining the definition before SpecificOccurrenceAndSource processes doesn't # work because we need to know if it is a specific occurrence to be able to figure out the definition @source_data_criteria = @source_data_criteria.gsub("_source",'') if @source_data_criteria # Adds a child if none exists (specifically the source criteria) @children_criteria << @source_data_criteria if @children_criteria.empty? return if @children_criteria.length != 1 || (@source_data_criteria.present? && @children_criteria.first != @source_data_criteria) # if child.first is nil, it will be caught in the second statement reference_criteria = @data_criteria_references[@children_criteria.first] return if reference_criteria.nil? @is_derived_specific_occurrence_variable = true # easier to track than all testing all features of these cases @subset_operators ||= reference_criteria.subset_operators @derivation_operator ||= reference_criteria.derivation_operator @description = reference_criteria.description @variable = reference_criteria.variable end
ruby
def handle_derived_specific_occurrences return unless @definition == 'derived' # remove "_source" from source data critera. It gets added in in SpecificOccurrenceAndSource but # when it gets added we have not yet determined the definition of the data criteria so we cannot # skip adding it. Determining the definition before SpecificOccurrenceAndSource processes doesn't # work because we need to know if it is a specific occurrence to be able to figure out the definition @source_data_criteria = @source_data_criteria.gsub("_source",'') if @source_data_criteria # Adds a child if none exists (specifically the source criteria) @children_criteria << @source_data_criteria if @children_criteria.empty? return if @children_criteria.length != 1 || (@source_data_criteria.present? && @children_criteria.first != @source_data_criteria) # if child.first is nil, it will be caught in the second statement reference_criteria = @data_criteria_references[@children_criteria.first] return if reference_criteria.nil? @is_derived_specific_occurrence_variable = true # easier to track than all testing all features of these cases @subset_operators ||= reference_criteria.subset_operators @derivation_operator ||= reference_criteria.derivation_operator @description = reference_criteria.description @variable = reference_criteria.variable end
[ "def", "handle_derived_specific_occurrences", "return", "unless", "@definition", "==", "'derived'", "# remove \"_source\" from source data critera. It gets added in in SpecificOccurrenceAndSource but", "# when it gets added we have not yet determined the definition of the data criteria so we cannot", "# skip adding it. Determining the definition before SpecificOccurrenceAndSource processes doesn't", "# work because we need to know if it is a specific occurrence to be able to figure out the definition", "@source_data_criteria", "=", "@source_data_criteria", ".", "gsub", "(", "\"_source\"", ",", "''", ")", "if", "@source_data_criteria", "# Adds a child if none exists (specifically the source criteria)", "@children_criteria", "<<", "@source_data_criteria", "if", "@children_criteria", ".", "empty?", "return", "if", "@children_criteria", ".", "length", "!=", "1", "||", "(", "@source_data_criteria", ".", "present?", "&&", "@children_criteria", ".", "first", "!=", "@source_data_criteria", ")", "# if child.first is nil, it will be caught in the second statement", "reference_criteria", "=", "@data_criteria_references", "[", "@children_criteria", ".", "first", "]", "return", "if", "reference_criteria", ".", "nil?", "@is_derived_specific_occurrence_variable", "=", "true", "# easier to track than all testing all features of these cases", "@subset_operators", "||=", "reference_criteria", ".", "subset_operators", "@derivation_operator", "||=", "reference_criteria", ".", "derivation_operator", "@description", "=", "reference_criteria", ".", "description", "@variable", "=", "reference_criteria", ".", "variable", "end" ]
Apply some elements from the reference_criteria to the derived specific occurrence
[ "Apply", "some", "elements", "from", "the", "reference_criteria", "to", "the", "derived", "specific", "occurrence" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb#L62-L83
11,876
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/data_criteria_converter.rb
HQMF.DataCriteriaConverter.create_group_data_criteria
def create_group_data_criteria(preconditions, type, value, parent_id, id, standard_category, qds_data_type) extract_group_data_criteria_tree(HQMF::DataCriteria::UNION,preconditions, type, parent_id) end
ruby
def create_group_data_criteria(preconditions, type, value, parent_id, id, standard_category, qds_data_type) extract_group_data_criteria_tree(HQMF::DataCriteria::UNION,preconditions, type, parent_id) end
[ "def", "create_group_data_criteria", "(", "preconditions", ",", "type", ",", "value", ",", "parent_id", ",", "id", ",", "standard_category", ",", "qds_data_type", ")", "extract_group_data_criteria_tree", "(", "HQMF", "::", "DataCriteria", "::", "UNION", ",", "preconditions", ",", "type", ",", "parent_id", ")", "end" ]
grouping data criteria are used to allow a single reference off of a temporal reference or subset operator grouping data criteria can reference either regular data criteria as children, or other grouping data criteria
[ "grouping", "data", "criteria", "are", "used", "to", "allow", "a", "single", "reference", "off", "of", "a", "temporal", "reference", "or", "subset", "operator", "grouping", "data", "criteria", "can", "reference", "either", "regular", "data", "criteria", "as", "children", "or", "other", "grouping", "data", "criteria" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb#L46-L48
11,877
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/data_criteria_converter.rb
HQMF.DataCriteriaConverter.extract_group_data_criteria_tree
def extract_group_data_criteria_tree(conjunction, preconditions, type, parent_id) children = [] preconditions.each do |precondition| if (precondition.comparison?) if (precondition.reference.id == HQMF::Document::MEASURE_PERIOD_ID) children << measure_period_criteria else children << v2_data_criteria_by_id[precondition.reference.id] end else converted_conjunction = convert_grouping_conjunction(precondition.conjunction_code) children << extract_group_data_criteria_tree(converted_conjunction, precondition.preconditions, type, parent_id) end end # if we have just one child element, just return it. An AND or OR of a single item is not useful. if (children.size > 1) build_group_data_criteria(children, type, parent_id, conjunction) else children.first end end
ruby
def extract_group_data_criteria_tree(conjunction, preconditions, type, parent_id) children = [] preconditions.each do |precondition| if (precondition.comparison?) if (precondition.reference.id == HQMF::Document::MEASURE_PERIOD_ID) children << measure_period_criteria else children << v2_data_criteria_by_id[precondition.reference.id] end else converted_conjunction = convert_grouping_conjunction(precondition.conjunction_code) children << extract_group_data_criteria_tree(converted_conjunction, precondition.preconditions, type, parent_id) end end # if we have just one child element, just return it. An AND or OR of a single item is not useful. if (children.size > 1) build_group_data_criteria(children, type, parent_id, conjunction) else children.first end end
[ "def", "extract_group_data_criteria_tree", "(", "conjunction", ",", "preconditions", ",", "type", ",", "parent_id", ")", "children", "=", "[", "]", "preconditions", ".", "each", "do", "|", "precondition", "|", "if", "(", "precondition", ".", "comparison?", ")", "if", "(", "precondition", ".", "reference", ".", "id", "==", "HQMF", "::", "Document", "::", "MEASURE_PERIOD_ID", ")", "children", "<<", "measure_period_criteria", "else", "children", "<<", "v2_data_criteria_by_id", "[", "precondition", ".", "reference", ".", "id", "]", "end", "else", "converted_conjunction", "=", "convert_grouping_conjunction", "(", "precondition", ".", "conjunction_code", ")", "children", "<<", "extract_group_data_criteria_tree", "(", "converted_conjunction", ",", "precondition", ".", "preconditions", ",", "type", ",", "parent_id", ")", "end", "end", "# if we have just one child element, just return it. An AND or OR of a single item is not useful.", "if", "(", "children", ".", "size", ">", "1", ")", "build_group_data_criteria", "(", "children", ",", "type", ",", "parent_id", ",", "conjunction", ")", "else", "children", ".", "first", "end", "end" ]
pull the children data criteria out of a set of preconditions
[ "pull", "the", "children", "data", "criteria", "out", "of", "a", "set", "of", "preconditions" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb#L73-L96
11,878
projectcypress/health-data-standards
lib/hqmf-parser/converter/pass1/data_criteria_converter.rb
HQMF.DataCriteriaConverter.create_measure_period_v1_data_criteria
def create_measure_period_v1_data_criteria(doc,measure_period,v1_data_criteria_by_id) attributes = doc[:attributes] attributes.keys.each {|key| attributes[key.to_s] = attributes[key]} measure_period_key = attributes['MEASUREMENT_PERIOD'][:id] measure_start_key = attributes['MEASUREMENT_START_DATE'][:id] measure_end_key = attributes['MEASUREMENT_END_DATE'][:id] @measure_period_v1_keys = {measure_start: measure_start_key, measure_end: measure_end_key, measure_period: measure_period_key} type = 'variable' code_list_id,negation_code_list_id,property,status,field_values,effective_time,inline_code_list,children_criteria,derivation_operator,temporal_references,subset_operators=nil ##### ## ######### SET MEASURE PERIOD ## ##### measure_period_id = HQMF::Document::MEASURE_PERIOD_ID value = measure_period measure_criteria = HQMF::DataCriteria.new(measure_period_id,measure_period_id,nil,measure_period_id,code_list_id,children_criteria,derivation_operator,measure_period_id,status, value,field_values,effective_time,inline_code_list, false, nil, temporal_references,subset_operators,nil,nil) # set the measure period data criteria for all measure period keys v1_data_criteria_by_id[measure_period_key] = measure_criteria v1_data_criteria_by_id[measure_start_key] = measure_criteria v1_data_criteria_by_id[measure_end_key] = measure_criteria @measure_period_criteria = measure_criteria end
ruby
def create_measure_period_v1_data_criteria(doc,measure_period,v1_data_criteria_by_id) attributes = doc[:attributes] attributes.keys.each {|key| attributes[key.to_s] = attributes[key]} measure_period_key = attributes['MEASUREMENT_PERIOD'][:id] measure_start_key = attributes['MEASUREMENT_START_DATE'][:id] measure_end_key = attributes['MEASUREMENT_END_DATE'][:id] @measure_period_v1_keys = {measure_start: measure_start_key, measure_end: measure_end_key, measure_period: measure_period_key} type = 'variable' code_list_id,negation_code_list_id,property,status,field_values,effective_time,inline_code_list,children_criteria,derivation_operator,temporal_references,subset_operators=nil ##### ## ######### SET MEASURE PERIOD ## ##### measure_period_id = HQMF::Document::MEASURE_PERIOD_ID value = measure_period measure_criteria = HQMF::DataCriteria.new(measure_period_id,measure_period_id,nil,measure_period_id,code_list_id,children_criteria,derivation_operator,measure_period_id,status, value,field_values,effective_time,inline_code_list, false, nil, temporal_references,subset_operators,nil,nil) # set the measure period data criteria for all measure period keys v1_data_criteria_by_id[measure_period_key] = measure_criteria v1_data_criteria_by_id[measure_start_key] = measure_criteria v1_data_criteria_by_id[measure_end_key] = measure_criteria @measure_period_criteria = measure_criteria end
[ "def", "create_measure_period_v1_data_criteria", "(", "doc", ",", "measure_period", ",", "v1_data_criteria_by_id", ")", "attributes", "=", "doc", "[", ":attributes", "]", "attributes", ".", "keys", ".", "each", "{", "|", "key", "|", "attributes", "[", "key", ".", "to_s", "]", "=", "attributes", "[", "key", "]", "}", "measure_period_key", "=", "attributes", "[", "'MEASUREMENT_PERIOD'", "]", "[", ":id", "]", "measure_start_key", "=", "attributes", "[", "'MEASUREMENT_START_DATE'", "]", "[", ":id", "]", "measure_end_key", "=", "attributes", "[", "'MEASUREMENT_END_DATE'", "]", "[", ":id", "]", "@measure_period_v1_keys", "=", "{", "measure_start", ":", "measure_start_key", ",", "measure_end", ":", "measure_end_key", ",", "measure_period", ":", "measure_period_key", "}", "type", "=", "'variable'", "code_list_id", ",", "negation_code_list_id", ",", "property", ",", "status", ",", "field_values", ",", "effective_time", ",", "inline_code_list", ",", "children_criteria", ",", "derivation_operator", ",", "temporal_references", ",", "subset_operators", "=", "nil", "#####", "##", "######### SET MEASURE PERIOD", "##", "#####", "measure_period_id", "=", "HQMF", "::", "Document", "::", "MEASURE_PERIOD_ID", "value", "=", "measure_period", "measure_criteria", "=", "HQMF", "::", "DataCriteria", ".", "new", "(", "measure_period_id", ",", "measure_period_id", ",", "nil", ",", "measure_period_id", ",", "code_list_id", ",", "children_criteria", ",", "derivation_operator", ",", "measure_period_id", ",", "status", ",", "value", ",", "field_values", ",", "effective_time", ",", "inline_code_list", ",", "false", ",", "nil", ",", "temporal_references", ",", "subset_operators", ",", "nil", ",", "nil", ")", "# set the measure period data criteria for all measure period keys", "v1_data_criteria_by_id", "[", "measure_period_key", "]", "=", "measure_criteria", "v1_data_criteria_by_id", "[", "measure_start_key", "]", "=", "measure_criteria", "v1_data_criteria_by_id", "[", "measure_end_key", "]", "=", "measure_criteria", "@measure_period_criteria", "=", "measure_criteria", "end" ]
this method creates V1 data criteria for the measurement period. These data criteria can be referenced properly within the restrictions
[ "this", "method", "creates", "V1", "data", "criteria", "for", "the", "measurement", "period", ".", "These", "data", "criteria", "can", "be", "referenced", "properly", "within", "the", "restrictions" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb#L214-L245
11,879
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb
HQMF2.DataCriteriaBaseExtractions.extract_child_criteria
def extract_child_criteria @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id", HQMF2::Document::NAMESPACES).collect do |ref| Reference.new(ref).id end.compact end
ruby
def extract_child_criteria @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id", HQMF2::Document::NAMESPACES).collect do |ref| Reference.new(ref).id end.compact end
[ "def", "extract_child_criteria", "@entry", ".", "xpath", "(", "\"./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id\"", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", ".", "collect", "do", "|", "ref", "|", "Reference", ".", "new", "(", "ref", ")", ".", "id", "end", ".", "compact", "end" ]
Generate a list of child criterias
[ "Generate", "a", "list", "of", "child", "criterias" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb#L22-L27
11,880
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb
HQMF2.DataCriteriaBaseExtractions.all_subset_operators
def all_subset_operators @entry.xpath('./*/cda:excerpt', HQMF2::Document::NAMESPACES).collect do |subset_operator| SubsetOperator.new(subset_operator) end end
ruby
def all_subset_operators @entry.xpath('./*/cda:excerpt', HQMF2::Document::NAMESPACES).collect do |subset_operator| SubsetOperator.new(subset_operator) end end
[ "def", "all_subset_operators", "@entry", ".", "xpath", "(", "'./*/cda:excerpt'", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", ".", "collect", "do", "|", "subset_operator", "|", "SubsetOperator", ".", "new", "(", "subset_operator", ")", "end", "end" ]
Extracts all subset operators contained in the entry xml
[ "Extracts", "all", "subset", "operators", "contained", "in", "the", "entry", "xml" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb#L56-L60
11,881
projectcypress/health-data-standards
lib/hqmf-parser/1.0/utilities.rb
HQMF1.Utilities.check_nil_conjunction_on_child
def check_nil_conjunction_on_child if (@preconditions.length == 1 && @preconditions.first.conjunction.nil?) bad_precondition = @preconditions.first if (bad_precondition.restrictions.empty? && bad_precondition.subset.nil? && bad_precondition.expression.nil?) @preconditions = @preconditions.first.preconditions #puts "\t FIXED PRECONDITION WITHOUT CONJUNCTION" else puts "\t PRECONDITION WITHOUT CONJUNCTION: Cannot be fixed" end end end
ruby
def check_nil_conjunction_on_child if (@preconditions.length == 1 && @preconditions.first.conjunction.nil?) bad_precondition = @preconditions.first if (bad_precondition.restrictions.empty? && bad_precondition.subset.nil? && bad_precondition.expression.nil?) @preconditions = @preconditions.first.preconditions #puts "\t FIXED PRECONDITION WITHOUT CONJUNCTION" else puts "\t PRECONDITION WITHOUT CONJUNCTION: Cannot be fixed" end end end
[ "def", "check_nil_conjunction_on_child", "if", "(", "@preconditions", ".", "length", "==", "1", "&&", "@preconditions", ".", "first", ".", "conjunction", ".", "nil?", ")", "bad_precondition", "=", "@preconditions", ".", "first", "if", "(", "bad_precondition", ".", "restrictions", ".", "empty?", "&&", "bad_precondition", ".", "subset", ".", "nil?", "&&", "bad_precondition", ".", "expression", ".", "nil?", ")", "@preconditions", "=", "@preconditions", ".", "first", ".", "preconditions", "#puts \"\\t FIXED PRECONDITION WITHOUT CONJUNCTION\"", "else", "puts", "\"\\t PRECONDITION WITHOUT CONJUNCTION: Cannot be fixed\"", "end", "end", "end" ]
Preconditions can have nil conjunctions as part of a DATEDIFF, we want to remove these and warn
[ "Preconditions", "can", "have", "nil", "conjunctions", "as", "part", "of", "a", "DATEDIFF", "we", "want", "to", "remove", "these", "and", "warn" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/1.0/utilities.rb#L41-L51
11,882
projectcypress/health-data-standards
lib/hqmf-model/document.rb
HQMF.Document.specific_occurrence_source_data_criteria
def specific_occurrence_source_data_criteria(force_sources=nil) return [] if @source_data_criteria.nil? matching = @source_data_criteria.select {|dc| !dc.specific_occurrence.nil?} if force_sources existing = matching.map(&:id) matching.concat @source_data_criteria.select {|dc| !existing.include?(dc.id) && force_sources.include?(dc.id)} end matching end
ruby
def specific_occurrence_source_data_criteria(force_sources=nil) return [] if @source_data_criteria.nil? matching = @source_data_criteria.select {|dc| !dc.specific_occurrence.nil?} if force_sources existing = matching.map(&:id) matching.concat @source_data_criteria.select {|dc| !existing.include?(dc.id) && force_sources.include?(dc.id)} end matching end
[ "def", "specific_occurrence_source_data_criteria", "(", "force_sources", "=", "nil", ")", "return", "[", "]", "if", "@source_data_criteria", ".", "nil?", "matching", "=", "@source_data_criteria", ".", "select", "{", "|", "dc", "|", "!", "dc", ".", "specific_occurrence", ".", "nil?", "}", "if", "force_sources", "existing", "=", "matching", ".", "map", "(", ":id", ")", "matching", ".", "concat", "@source_data_criteria", ".", "select", "{", "|", "dc", "|", "!", "existing", ".", "include?", "(", "dc", ".", "id", ")", "&&", "force_sources", ".", "include?", "(", "dc", ".", "id", ")", "}", "end", "matching", "end" ]
Get the source data criteria that are specific occurrences @return [Array] an array of HQMF::DataCriteria describing the data elements used by the measure that are specific occurrences
[ "Get", "the", "source", "data", "criteria", "that", "are", "specific", "occurrences" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-model/document.rb#L146-L156
11,883
projectcypress/health-data-standards
lib/hqmf-model/document.rb
HQMF.Document.attributes_for_code
def attributes_for_code(code, code_system) @attributes.find_all { |e| e.send(:code) == code && e.send(:code_obj).send(:system) == code_system } end
ruby
def attributes_for_code(code, code_system) @attributes.find_all { |e| e.send(:code) == code && e.send(:code_obj).send(:system) == code_system } end
[ "def", "attributes_for_code", "(", "code", ",", "code_system", ")", "@attributes", ".", "find_all", "{", "|", "e", "|", "e", ".", "send", "(", ":code", ")", "==", "code", "&&", "e", ".", "send", "(", ":code_obj", ")", ".", "send", "(", ":system", ")", "==", "code_system", "}", "end" ]
Get specific attributes by code. @param [String] code the attribute code @param [String] code_system the attribute code system @return [Array#Attribute] the matching attributes, raises an Exception if not found
[ "Get", "specific", "attributes", "by", "code", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-model/document.rb#L183-L185
11,884
projectcypress/health-data-standards
lib/hqmf-model/document.rb
HQMF.Document.backfill_patient_characteristics_with_codes
def backfill_patient_characteristics_with_codes(codes) [].concat(self.all_data_criteria).concat(self.source_data_criteria).each do |data_criteria| if (data_criteria.type == :characteristic and !data_criteria.property.nil?) if (codes) value_set = codes[data_criteria.code_list_id] puts "\tno value set for unknown patient characteristic: #{data_criteria.id}" unless value_set else puts "\tno code set to back fill: #{data_criteria.title}" next end if (data_criteria.property == :gender) next if value_set.nil? key = value_set.keys[0] data_criteria.value = HQMF::Coded.new('CD','Administrative Sex',value_set[key].first) else data_criteria.inline_code_list = value_set end elsif (data_criteria.type == :characteristic) if (codes) value_set = codes[data_criteria.code_list_id] if (value_set) # this is looking for a birthdate characteristic that is set as a generic characteristic but points to a loinc code set if (value_set['LOINC'] and value_set['LOINC'].first == '21112-8') data_criteria.definition = 'patient_characteristic_birthdate' end # this is looking for a gender characteristic that is set as a generic characteristic gender_key = (value_set.keys.select {|set| set == 'Administrative Sex' || set == 'AdministrativeSex'}).first if (gender_key and ['M','F'].include? value_set[gender_key].first) data_criteria.definition = 'patient_characteristic_gender' data_criteria.value = HQMF::Coded.new('CD','Gender',value_set[gender_key].first) end end end end end end
ruby
def backfill_patient_characteristics_with_codes(codes) [].concat(self.all_data_criteria).concat(self.source_data_criteria).each do |data_criteria| if (data_criteria.type == :characteristic and !data_criteria.property.nil?) if (codes) value_set = codes[data_criteria.code_list_id] puts "\tno value set for unknown patient characteristic: #{data_criteria.id}" unless value_set else puts "\tno code set to back fill: #{data_criteria.title}" next end if (data_criteria.property == :gender) next if value_set.nil? key = value_set.keys[0] data_criteria.value = HQMF::Coded.new('CD','Administrative Sex',value_set[key].first) else data_criteria.inline_code_list = value_set end elsif (data_criteria.type == :characteristic) if (codes) value_set = codes[data_criteria.code_list_id] if (value_set) # this is looking for a birthdate characteristic that is set as a generic characteristic but points to a loinc code set if (value_set['LOINC'] and value_set['LOINC'].first == '21112-8') data_criteria.definition = 'patient_characteristic_birthdate' end # this is looking for a gender characteristic that is set as a generic characteristic gender_key = (value_set.keys.select {|set| set == 'Administrative Sex' || set == 'AdministrativeSex'}).first if (gender_key and ['M','F'].include? value_set[gender_key].first) data_criteria.definition = 'patient_characteristic_gender' data_criteria.value = HQMF::Coded.new('CD','Gender',value_set[gender_key].first) end end end end end end
[ "def", "backfill_patient_characteristics_with_codes", "(", "codes", ")", "[", "]", ".", "concat", "(", "self", ".", "all_data_criteria", ")", ".", "concat", "(", "self", ".", "source_data_criteria", ")", ".", "each", "do", "|", "data_criteria", "|", "if", "(", "data_criteria", ".", "type", "==", ":characteristic", "and", "!", "data_criteria", ".", "property", ".", "nil?", ")", "if", "(", "codes", ")", "value_set", "=", "codes", "[", "data_criteria", ".", "code_list_id", "]", "puts", "\"\\tno value set for unknown patient characteristic: #{data_criteria.id}\"", "unless", "value_set", "else", "puts", "\"\\tno code set to back fill: #{data_criteria.title}\"", "next", "end", "if", "(", "data_criteria", ".", "property", "==", ":gender", ")", "next", "if", "value_set", ".", "nil?", "key", "=", "value_set", ".", "keys", "[", "0", "]", "data_criteria", ".", "value", "=", "HQMF", "::", "Coded", ".", "new", "(", "'CD'", ",", "'Administrative Sex'", ",", "value_set", "[", "key", "]", ".", "first", ")", "else", "data_criteria", ".", "inline_code_list", "=", "value_set", "end", "elsif", "(", "data_criteria", ".", "type", "==", ":characteristic", ")", "if", "(", "codes", ")", "value_set", "=", "codes", "[", "data_criteria", ".", "code_list_id", "]", "if", "(", "value_set", ")", "# this is looking for a birthdate characteristic that is set as a generic characteristic but points to a loinc code set", "if", "(", "value_set", "[", "'LOINC'", "]", "and", "value_set", "[", "'LOINC'", "]", ".", "first", "==", "'21112-8'", ")", "data_criteria", ".", "definition", "=", "'patient_characteristic_birthdate'", "end", "# this is looking for a gender characteristic that is set as a generic characteristic", "gender_key", "=", "(", "value_set", ".", "keys", ".", "select", "{", "|", "set", "|", "set", "==", "'Administrative Sex'", "||", "set", "==", "'AdministrativeSex'", "}", ")", ".", "first", "if", "(", "gender_key", "and", "[", "'M'", ",", "'F'", "]", ".", "include?", "value_set", "[", "gender_key", "]", ".", "first", ")", "data_criteria", ".", "definition", "=", "'patient_characteristic_gender'", "data_criteria", ".", "value", "=", "HQMF", "::", "Coded", ".", "new", "(", "'CD'", ",", "'Gender'", ",", "value_set", "[", "gender_key", "]", ".", "first", ")", "end", "end", "end", "end", "end", "end" ]
patient characteristics data criteria such as GENDER require looking at the codes to determine if the measure is interested in Males or Females. This process is awkward, and thus is done as a separate step after the document has been converted.
[ "patient", "characteristics", "data", "criteria", "such", "as", "GENDER", "require", "looking", "at", "the", "codes", "to", "determine", "if", "the", "measure", "is", "interested", "in", "Males", "or", "Females", ".", "This", "process", "is", "awkward", "and", "thus", "is", "done", "as", "a", "separate", "step", "after", "the", "document", "has", "been", "converted", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-model/document.rb#L197-L236
11,885
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.handle_known_template_id
def handle_known_template_id(template_id) case template_id when VARIABLE_TEMPLATE @derivation_operator = HQMF::DataCriteria::INTERSECT if @derivation_operator == HQMF::DataCriteria::XPRODUCT @definition ||= 'derived' @variable = true @negation = false when SATISFIES_ANY_TEMPLATE @definition = HQMF::DataCriteria::SATISFIES_ANY @negation = false when SATISFIES_ALL_TEMPLATE @definition = HQMF::DataCriteria::SATISFIES_ALL @derivation_operator = HQMF::DataCriteria::INTERSECT @negation = false else return false end true end
ruby
def handle_known_template_id(template_id) case template_id when VARIABLE_TEMPLATE @derivation_operator = HQMF::DataCriteria::INTERSECT if @derivation_operator == HQMF::DataCriteria::XPRODUCT @definition ||= 'derived' @variable = true @negation = false when SATISFIES_ANY_TEMPLATE @definition = HQMF::DataCriteria::SATISFIES_ANY @negation = false when SATISFIES_ALL_TEMPLATE @definition = HQMF::DataCriteria::SATISFIES_ALL @derivation_operator = HQMF::DataCriteria::INTERSECT @negation = false else return false end true end
[ "def", "handle_known_template_id", "(", "template_id", ")", "case", "template_id", "when", "VARIABLE_TEMPLATE", "@derivation_operator", "=", "HQMF", "::", "DataCriteria", "::", "INTERSECT", "if", "@derivation_operator", "==", "HQMF", "::", "DataCriteria", "::", "XPRODUCT", "@definition", "||=", "'derived'", "@variable", "=", "true", "@negation", "=", "false", "when", "SATISFIES_ANY_TEMPLATE", "@definition", "=", "HQMF", "::", "DataCriteria", "::", "SATISFIES_ANY", "@negation", "=", "false", "when", "SATISFIES_ALL_TEMPLATE", "@definition", "=", "HQMF", "::", "DataCriteria", "::", "SATISFIES_ALL", "@derivation_operator", "=", "HQMF", "::", "DataCriteria", "::", "INTERSECT", "@negation", "=", "false", "else", "return", "false", "end", "true", "end" ]
Given a template id, modify the variables inside this data criteria to reflect the template
[ "Given", "a", "template", "id", "modify", "the", "variables", "inside", "this", "data", "criteria", "to", "reflect", "the", "template" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L36-L54
11,886
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.extract_information_for_specific_variable
def extract_information_for_specific_variable reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) if reference ref_id = strip_tokens( "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}") end reference_criteria = @data_criteria_references[ref_id] if ref_id # if the reference is derived, pull from the original variable if reference_criteria && reference_criteria.definition == 'derived' reference_criteria = @data_criteria_references["GROUP_#{ref_id}"] end return unless reference_criteria handle_specific_variable_ref(reference_criteria) end
ruby
def extract_information_for_specific_variable reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) if reference ref_id = strip_tokens( "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}") end reference_criteria = @data_criteria_references[ref_id] if ref_id # if the reference is derived, pull from the original variable if reference_criteria && reference_criteria.definition == 'derived' reference_criteria = @data_criteria_references["GROUP_#{ref_id}"] end return unless reference_criteria handle_specific_variable_ref(reference_criteria) end
[ "def", "extract_information_for_specific_variable", "reference", "=", "@entry", ".", "at_xpath", "(", "'./*/cda:outboundRelationship/cda:criteriaReference'", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", "if", "reference", "ref_id", "=", "strip_tokens", "(", "\"#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}\"", ")", "end", "reference_criteria", "=", "@data_criteria_references", "[", "ref_id", "]", "if", "ref_id", "# if the reference is derived, pull from the original variable", "if", "reference_criteria", "&&", "reference_criteria", ".", "definition", "==", "'derived'", "reference_criteria", "=", "@data_criteria_references", "[", "\"GROUP_#{ref_id}\"", "]", "end", "return", "unless", "reference_criteria", "handle_specific_variable_ref", "(", "reference_criteria", ")", "end" ]
Extracts information from a reference for a specific
[ "Extracts", "information", "from", "a", "reference", "for", "a", "specific" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L73-L87
11,887
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.handle_specific_variable_ref
def handle_specific_variable_ref(reference_criteria) # if there are no referenced children, then it's a variable representing # a single data criteria, so just reference it if reference_criteria.children_criteria.empty? @children_criteria = [reference_criteria.id] # otherwise pull all the data criteria info from the reference else @field_values = reference_criteria.field_values @temporal_references = reference_criteria.temporal_references @subset_operators = reference_criteria.subset_operators @derivation_operator = reference_criteria.derivation_operator @definition = reference_criteria.definition @description = reference_criteria.description @status = reference_criteria.status @children_criteria = reference_criteria.children_criteria end end
ruby
def handle_specific_variable_ref(reference_criteria) # if there are no referenced children, then it's a variable representing # a single data criteria, so just reference it if reference_criteria.children_criteria.empty? @children_criteria = [reference_criteria.id] # otherwise pull all the data criteria info from the reference else @field_values = reference_criteria.field_values @temporal_references = reference_criteria.temporal_references @subset_operators = reference_criteria.subset_operators @derivation_operator = reference_criteria.derivation_operator @definition = reference_criteria.definition @description = reference_criteria.description @status = reference_criteria.status @children_criteria = reference_criteria.children_criteria end end
[ "def", "handle_specific_variable_ref", "(", "reference_criteria", ")", "# if there are no referenced children, then it's a variable representing", "# a single data criteria, so just reference it", "if", "reference_criteria", ".", "children_criteria", ".", "empty?", "@children_criteria", "=", "[", "reference_criteria", ".", "id", "]", "# otherwise pull all the data criteria info from the reference", "else", "@field_values", "=", "reference_criteria", ".", "field_values", "@temporal_references", "=", "reference_criteria", ".", "temporal_references", "@subset_operators", "=", "reference_criteria", ".", "subset_operators", "@derivation_operator", "=", "reference_criteria", ".", "derivation_operator", "@definition", "=", "reference_criteria", ".", "definition", "@description", "=", "reference_criteria", ".", "description", "@status", "=", "reference_criteria", ".", "status", "@children_criteria", "=", "reference_criteria", ".", "children_criteria", "end", "end" ]
Apply additional information to a specific occurrence's elements from the criteria it references.
[ "Apply", "additional", "information", "to", "a", "specific", "occurrence", "s", "elements", "from", "the", "criteria", "it", "references", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L90-L106
11,888
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb
HQMF2.DataCriteriaTypeAndDefinitionExtraction.definition_for_nil_entry
def definition_for_nil_entry reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) ref_id = nil unless reference.nil? ref_id = "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}" end reference_criteria = @data_criteria_references[strip_tokens(ref_id)] unless ref_id.nil? if reference_criteria # we only want to copy the reference criteria definition, status, and code_list_id if this is this is not a grouping criteria (i.e., there are no children) if @children_criteria.blank? @definition = reference_criteria.definition @status = reference_criteria.status if @specific_occurrence @title = reference_criteria.title @description = reference_criteria.description @code_list_id = reference_criteria.code_list_id end else # if this is a grouping data criteria (has children) mark it as derived and only pull title and description from the reference criteria @definition = 'derived' if @specific_occurrence @title = reference_criteria.title @description = reference_criteria.description end end else puts "MISSING_DC_REF: #{ref_id}" unless @variable @definition = 'variable' end end
ruby
def definition_for_nil_entry reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES) ref_id = nil unless reference.nil? ref_id = "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}" end reference_criteria = @data_criteria_references[strip_tokens(ref_id)] unless ref_id.nil? if reference_criteria # we only want to copy the reference criteria definition, status, and code_list_id if this is this is not a grouping criteria (i.e., there are no children) if @children_criteria.blank? @definition = reference_criteria.definition @status = reference_criteria.status if @specific_occurrence @title = reference_criteria.title @description = reference_criteria.description @code_list_id = reference_criteria.code_list_id end else # if this is a grouping data criteria (has children) mark it as derived and only pull title and description from the reference criteria @definition = 'derived' if @specific_occurrence @title = reference_criteria.title @description = reference_criteria.description end end else puts "MISSING_DC_REF: #{ref_id}" unless @variable @definition = 'variable' end end
[ "def", "definition_for_nil_entry", "reference", "=", "@entry", ".", "at_xpath", "(", "'./*/cda:outboundRelationship/cda:criteriaReference'", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", "ref_id", "=", "nil", "unless", "reference", ".", "nil?", "ref_id", "=", "\"#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}\"", "end", "reference_criteria", "=", "@data_criteria_references", "[", "strip_tokens", "(", "ref_id", ")", "]", "unless", "ref_id", ".", "nil?", "if", "reference_criteria", "# we only want to copy the reference criteria definition, status, and code_list_id if this is this is not a grouping criteria (i.e., there are no children)", "if", "@children_criteria", ".", "blank?", "@definition", "=", "reference_criteria", ".", "definition", "@status", "=", "reference_criteria", ".", "status", "if", "@specific_occurrence", "@title", "=", "reference_criteria", ".", "title", "@description", "=", "reference_criteria", ".", "description", "@code_list_id", "=", "reference_criteria", ".", "code_list_id", "end", "else", "# if this is a grouping data criteria (has children) mark it as derived and only pull title and description from the reference criteria", "@definition", "=", "'derived'", "if", "@specific_occurrence", "@title", "=", "reference_criteria", ".", "title", "@description", "=", "reference_criteria", ".", "description", "end", "end", "else", "puts", "\"MISSING_DC_REF: #{ref_id}\"", "unless", "@variable", "@definition", "=", "'variable'", "end", "end" ]
If there is no entry type, extract the entry type from what it references, and extract additional information for specific occurrences. If there are no outbound references, print an error and mark it as variable.
[ "If", "there", "is", "no", "entry", "type", "extract", "the", "entry", "type", "from", "what", "it", "references", "and", "extract", "additional", "information", "for", "specific", "occurrences", ".", "If", "there", "are", "no", "outbound", "references", "print", "an", "error", "and", "mark", "it", "as", "variable", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb#L132-L161
11,889
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb
HQMF2.DocumentUtilities.handle_variable
def handle_variable(data_criteria, collapsed_source_data_criteria) if data_criteria.is_derived_specific_occurrence_variable data_criteria.handle_derived_specific_occurrence_variable extract_source_data_criteria(data_criteria) return end tmp_id = data_criteria.id grouper_data_criteria = data_criteria.extract_variable_grouper return unless grouper_data_criteria @data_criteria_references[data_criteria.id] = data_criteria @data_criteria_references[grouper_data_criteria.id] = grouper_data_criteria # create a source data criteria for the grouping data critera we just created sdc = SourceDataCriteriaHelper.strip_non_sc_elements(grouper_data_criteria) @source_data_criteria << sdc # check if the original source has been collapsed when generating the SDC list (we need to reference the collapsed version in the sdc list) if collapsed_source_data_criteria[tmp_id] data_criteria.instance_variable_set(:@source_data_criteria, collapsed_source_data_criteria[tmp_id]) else # check if we need to add _source suffix (most source data criteria are segmented with '_source' suffixes) data_criteria_sdc = find(@source_data_criteria, :id, "#{tmp_id}_source") if data_criteria_sdc data_criteria.instance_variable_set(:@source_data_criteria, data_criteria_sdc.id) data_criteria_sdc.instance_variable_set(:@variable, false) # if it's not a derived data criteria then we may need to strip off temporal references, fields, etc as a new source data criteria elsif !['derived', 'satisfies_any', 'satisfies_all'].include?(data_criteria.definition) extract_source_data_criteria(data_criteria) end end @data_criteria << grouper_data_criteria end
ruby
def handle_variable(data_criteria, collapsed_source_data_criteria) if data_criteria.is_derived_specific_occurrence_variable data_criteria.handle_derived_specific_occurrence_variable extract_source_data_criteria(data_criteria) return end tmp_id = data_criteria.id grouper_data_criteria = data_criteria.extract_variable_grouper return unless grouper_data_criteria @data_criteria_references[data_criteria.id] = data_criteria @data_criteria_references[grouper_data_criteria.id] = grouper_data_criteria # create a source data criteria for the grouping data critera we just created sdc = SourceDataCriteriaHelper.strip_non_sc_elements(grouper_data_criteria) @source_data_criteria << sdc # check if the original source has been collapsed when generating the SDC list (we need to reference the collapsed version in the sdc list) if collapsed_source_data_criteria[tmp_id] data_criteria.instance_variable_set(:@source_data_criteria, collapsed_source_data_criteria[tmp_id]) else # check if we need to add _source suffix (most source data criteria are segmented with '_source' suffixes) data_criteria_sdc = find(@source_data_criteria, :id, "#{tmp_id}_source") if data_criteria_sdc data_criteria.instance_variable_set(:@source_data_criteria, data_criteria_sdc.id) data_criteria_sdc.instance_variable_set(:@variable, false) # if it's not a derived data criteria then we may need to strip off temporal references, fields, etc as a new source data criteria elsif !['derived', 'satisfies_any', 'satisfies_all'].include?(data_criteria.definition) extract_source_data_criteria(data_criteria) end end @data_criteria << grouper_data_criteria end
[ "def", "handle_variable", "(", "data_criteria", ",", "collapsed_source_data_criteria", ")", "if", "data_criteria", ".", "is_derived_specific_occurrence_variable", "data_criteria", ".", "handle_derived_specific_occurrence_variable", "extract_source_data_criteria", "(", "data_criteria", ")", "return", "end", "tmp_id", "=", "data_criteria", ".", "id", "grouper_data_criteria", "=", "data_criteria", ".", "extract_variable_grouper", "return", "unless", "grouper_data_criteria", "@data_criteria_references", "[", "data_criteria", ".", "id", "]", "=", "data_criteria", "@data_criteria_references", "[", "grouper_data_criteria", ".", "id", "]", "=", "grouper_data_criteria", "# create a source data criteria for the grouping data critera we just created", "sdc", "=", "SourceDataCriteriaHelper", ".", "strip_non_sc_elements", "(", "grouper_data_criteria", ")", "@source_data_criteria", "<<", "sdc", "# check if the original source has been collapsed when generating the SDC list (we need to reference the collapsed version in the sdc list)", "if", "collapsed_source_data_criteria", "[", "tmp_id", "]", "data_criteria", ".", "instance_variable_set", "(", ":@source_data_criteria", ",", "collapsed_source_data_criteria", "[", "tmp_id", "]", ")", "else", "# check if we need to add _source suffix (most source data criteria are segmented with '_source' suffixes)", "data_criteria_sdc", "=", "find", "(", "@source_data_criteria", ",", ":id", ",", "\"#{tmp_id}_source\"", ")", "if", "data_criteria_sdc", "data_criteria", ".", "instance_variable_set", "(", ":@source_data_criteria", ",", "data_criteria_sdc", ".", "id", ")", "data_criteria_sdc", ".", "instance_variable_set", "(", ":@variable", ",", "false", ")", "# if it's not a derived data criteria then we may need to strip off temporal references, fields, etc as a new source data criteria", "elsif", "!", "[", "'derived'", ",", "'satisfies_any'", ",", "'satisfies_all'", "]", ".", "include?", "(", "data_criteria", ".", "definition", ")", "extract_source_data_criteria", "(", "data_criteria", ")", "end", "end", "@data_criteria", "<<", "grouper_data_criteria", "end" ]
Create grouper data criteria for encapsulating variable data criteria and update document data criteria list and references map
[ "Create", "grouper", "data", "criteria", "for", "encapsulating", "variable", "data", "criteria", "and", "update", "document", "data", "criteria", "list", "and", "references", "map" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb#L6-L41
11,890
projectcypress/health-data-standards
lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb
HQMF2.DocumentUtilities.complex_coverage
def complex_coverage(data_criteria, check_criteria) same_value = data_criteria.value.nil? || data_criteria.value.try(:to_model).try(:to_json) == check_criteria.value.try(:to_model).try(:to_json) same_field_values = same_field_values_check(data_criteria, check_criteria) same_negation_values = data_criteria.negation_code_list_id.nil? || data_criteria.negation_code_list_id == check_criteria.negation_code_list_id same_value && same_negation_values && same_field_values end
ruby
def complex_coverage(data_criteria, check_criteria) same_value = data_criteria.value.nil? || data_criteria.value.try(:to_model).try(:to_json) == check_criteria.value.try(:to_model).try(:to_json) same_field_values = same_field_values_check(data_criteria, check_criteria) same_negation_values = data_criteria.negation_code_list_id.nil? || data_criteria.negation_code_list_id == check_criteria.negation_code_list_id same_value && same_negation_values && same_field_values end
[ "def", "complex_coverage", "(", "data_criteria", ",", "check_criteria", ")", "same_value", "=", "data_criteria", ".", "value", ".", "nil?", "||", "data_criteria", ".", "value", ".", "try", "(", ":to_model", ")", ".", "try", "(", ":to_json", ")", "==", "check_criteria", ".", "value", ".", "try", "(", ":to_model", ")", ".", "try", "(", ":to_json", ")", "same_field_values", "=", "same_field_values_check", "(", "data_criteria", ",", "check_criteria", ")", "same_negation_values", "=", "data_criteria", ".", "negation_code_list_id", ".", "nil?", "||", "data_criteria", ".", "negation_code_list_id", "==", "check_criteria", ".", "negation_code_list_id", "same_value", "&&", "same_negation_values", "&&", "same_field_values", "end" ]
Check elements that do not already exist; else, if they do, check if those elements are the same in a different, potentially matching, data criteria
[ "Check", "elements", "that", "do", "not", "already", "exist", ";", "else", "if", "they", "do", "check", "if", "those", "elements", "are", "the", "same", "in", "a", "different", "potentially", "matching", "data", "criteria" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb#L107-L117
11,891
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria_helpers/dc_specific_occurrences_and_source_data_criteria_extract.rb
HQMF2.SpecificOccurrenceAndSource.handle_specific_and_source
def handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root, specific_occurrence_const, specific_occurrence) source_data_criteria = "#{source_data_criteria_extension}_#{source_data_criteria_root}_source" if !occurrence_identifier.blank? # if it doesn't exist, add extracted occurrence to the map # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}" @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier specific_occurrence ||= occurrence_identifier specific_occurrence_const = "#{source_data_criteria}".upcase else # create variable occurrences that do not already exist if @is_variable # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}" @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier end occurrence = @occurrences_map.try(:[], strip_tokens(source_data_criteria)) unless occurrence fail "Could not find occurrence mapping for #{source_data_criteria}, #{source_data_criteria_root}" end # puts "\tUsing #{occurrence} for #{@id}" specific_occurrence ||= occurrence end specific_occurrence = 'A' unless specific_occurrence specific_occurrence_const = source_data_criteria.upcase unless specific_occurrence_const [source_data_criteria, source_data_criteria_root, source_data_criteria_extension, specific_occurrence, specific_occurrence_const] end
ruby
def handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root, specific_occurrence_const, specific_occurrence) source_data_criteria = "#{source_data_criteria_extension}_#{source_data_criteria_root}_source" if !occurrence_identifier.blank? # if it doesn't exist, add extracted occurrence to the map # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}" @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier specific_occurrence ||= occurrence_identifier specific_occurrence_const = "#{source_data_criteria}".upcase else # create variable occurrences that do not already exist if @is_variable # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}" @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier end occurrence = @occurrences_map.try(:[], strip_tokens(source_data_criteria)) unless occurrence fail "Could not find occurrence mapping for #{source_data_criteria}, #{source_data_criteria_root}" end # puts "\tUsing #{occurrence} for #{@id}" specific_occurrence ||= occurrence end specific_occurrence = 'A' unless specific_occurrence specific_occurrence_const = source_data_criteria.upcase unless specific_occurrence_const [source_data_criteria, source_data_criteria_root, source_data_criteria_extension, specific_occurrence, specific_occurrence_const] end
[ "def", "handle_specific_and_source", "(", "occurrence_identifier", ",", "source_data_criteria_extension", ",", "source_data_criteria_root", ",", "specific_occurrence_const", ",", "specific_occurrence", ")", "source_data_criteria", "=", "\"#{source_data_criteria_extension}_#{source_data_criteria_root}_source\"", "if", "!", "occurrence_identifier", ".", "blank?", "# if it doesn't exist, add extracted occurrence to the map", "# puts \"\\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}\"", "@occurrences_map", "[", "strip_tokens", "(", "source_data_criteria", ")", "]", "||=", "occurrence_identifier", "specific_occurrence", "||=", "occurrence_identifier", "specific_occurrence_const", "=", "\"#{source_data_criteria}\"", ".", "upcase", "else", "# create variable occurrences that do not already exist", "if", "@is_variable", "# puts \"\\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}\"", "@occurrences_map", "[", "strip_tokens", "(", "source_data_criteria", ")", "]", "||=", "occurrence_identifier", "end", "occurrence", "=", "@occurrences_map", ".", "try", "(", ":[]", ",", "strip_tokens", "(", "source_data_criteria", ")", ")", "unless", "occurrence", "fail", "\"Could not find occurrence mapping for #{source_data_criteria}, #{source_data_criteria_root}\"", "end", "# puts \"\\tUsing #{occurrence} for #{@id}\"", "specific_occurrence", "||=", "occurrence", "end", "specific_occurrence", "=", "'A'", "unless", "specific_occurrence", "specific_occurrence_const", "=", "source_data_criteria", ".", "upcase", "unless", "specific_occurrence_const", "[", "source_data_criteria", ",", "source_data_criteria_root", ",", "source_data_criteria_extension", ",", "specific_occurrence", ",", "specific_occurrence_const", "]", "end" ]
Handle setting the specific and source instance variables with a given occurrence identifier
[ "Handle", "setting", "the", "specific", "and", "source", "instance", "variables", "with", "a", "given", "occurrence", "identifier" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria_helpers/dc_specific_occurrences_and_source_data_criteria_extract.rb#L52-L79
11,892
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.basic_setup
def basic_setup @status = attr_val('./*/cda:statusCode/@code') @id_xpath = './*/cda:id/@extension' @id = "#{attr_val('./*/cda:id/@extension')}_#{attr_val('./*/cda:id/@root')}" @comments = @entry.xpath("./#{CRITERIA_GLOB}/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()", HQMF2::Document::NAMESPACES).map(&:content) @code_list_xpath = './*/cda:code' @value_xpath = './*/cda:value' @is_derived_specific_occurrence_variable = false simple_extractions = DataCriteriaBaseExtractions.new(@entry) @template_ids = simple_extractions.extract_template_ids @local_variable_name = simple_extractions.extract_local_variable_name @temporal_references = simple_extractions.extract_temporal_references @derivation_operator = simple_extractions.extract_derivation_operator @children_criteria = simple_extractions.extract_child_criteria @subset_operators = simple_extractions.extract_subset_operators @negation, @negation_code_list_id = simple_extractions.extract_negation end
ruby
def basic_setup @status = attr_val('./*/cda:statusCode/@code') @id_xpath = './*/cda:id/@extension' @id = "#{attr_val('./*/cda:id/@extension')}_#{attr_val('./*/cda:id/@root')}" @comments = @entry.xpath("./#{CRITERIA_GLOB}/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()", HQMF2::Document::NAMESPACES).map(&:content) @code_list_xpath = './*/cda:code' @value_xpath = './*/cda:value' @is_derived_specific_occurrence_variable = false simple_extractions = DataCriteriaBaseExtractions.new(@entry) @template_ids = simple_extractions.extract_template_ids @local_variable_name = simple_extractions.extract_local_variable_name @temporal_references = simple_extractions.extract_temporal_references @derivation_operator = simple_extractions.extract_derivation_operator @children_criteria = simple_extractions.extract_child_criteria @subset_operators = simple_extractions.extract_subset_operators @negation, @negation_code_list_id = simple_extractions.extract_negation end
[ "def", "basic_setup", "@status", "=", "attr_val", "(", "'./*/cda:statusCode/@code'", ")", "@id_xpath", "=", "'./*/cda:id/@extension'", "@id", "=", "\"#{attr_val('./*/cda:id/@extension')}_#{attr_val('./*/cda:id/@root')}\"", "@comments", "=", "@entry", ".", "xpath", "(", "\"./#{CRITERIA_GLOB}/cda:text/cda:xml/cda:qdmUserComments/cda:item/text()\"", ",", "HQMF2", "::", "Document", "::", "NAMESPACES", ")", ".", "map", "(", ":content", ")", "@code_list_xpath", "=", "'./*/cda:code'", "@value_xpath", "=", "'./*/cda:value'", "@is_derived_specific_occurrence_variable", "=", "false", "simple_extractions", "=", "DataCriteriaBaseExtractions", ".", "new", "(", "@entry", ")", "@template_ids", "=", "simple_extractions", ".", "extract_template_ids", "@local_variable_name", "=", "simple_extractions", ".", "extract_local_variable_name", "@temporal_references", "=", "simple_extractions", ".", "extract_temporal_references", "@derivation_operator", "=", "simple_extractions", ".", "extract_derivation_operator", "@children_criteria", "=", "simple_extractions", ".", "extract_child_criteria", "@subset_operators", "=", "simple_extractions", ".", "extract_subset_operators", "@negation", ",", "@negation_code_list_id", "=", "simple_extractions", ".", "extract_negation", "end" ]
Handles elments that can be extracted directly from the xml. Utilises the "BaseExtractions" class.
[ "Handles", "elments", "that", "can", "be", "extracted", "directly", "from", "the", "xml", ".", "Utilises", "the", "BaseExtractions", "class", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L184-L201
11,893
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.duplicate_child_info
def duplicate_child_info(child_ref) @title ||= child_ref.title @type ||= child_ref.subset_operators @definition ||= child_ref.definition @status ||= child_ref.status @code_list_id ||= child_ref.code_list_id @temporal_references = child_ref.temporal_references if @temporal_references.empty? @subset_operators ||= child_ref.subset_operators @variable ||= child_ref.variable @value ||= child_ref.value end
ruby
def duplicate_child_info(child_ref) @title ||= child_ref.title @type ||= child_ref.subset_operators @definition ||= child_ref.definition @status ||= child_ref.status @code_list_id ||= child_ref.code_list_id @temporal_references = child_ref.temporal_references if @temporal_references.empty? @subset_operators ||= child_ref.subset_operators @variable ||= child_ref.variable @value ||= child_ref.value end
[ "def", "duplicate_child_info", "(", "child_ref", ")", "@title", "||=", "child_ref", ".", "title", "@type", "||=", "child_ref", ".", "subset_operators", "@definition", "||=", "child_ref", ".", "definition", "@status", "||=", "child_ref", ".", "status", "@code_list_id", "||=", "child_ref", ".", "code_list_id", "@temporal_references", "=", "child_ref", ".", "temporal_references", "if", "@temporal_references", ".", "empty?", "@subset_operators", "||=", "child_ref", ".", "subset_operators", "@variable", "||=", "child_ref", ".", "variable", "@value", "||=", "child_ref", ".", "value", "end" ]
Duplicates information from a child element to this data criteria if none exits. If the duplication requires that come values should be overwritten, do so only in the function calling this.
[ "Duplicates", "information", "from", "a", "child", "element", "to", "this", "data", "criteria", "if", "none", "exits", ".", "If", "the", "duplication", "requires", "that", "come", "values", "should", "be", "overwritten", "do", "so", "only", "in", "the", "function", "calling", "this", "." ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L233-L243
11,894
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.retrieve_field_values_model_for_model
def retrieve_field_values_model_for_model field_values = {} @field_values.each_pair do |id, val| field_values[id] = val.to_model end @code_list_id ||= code_list_id # Model transfers as a field if %w(transfer_to transfer_from).include? @definition field_code_list_id = @code_list_id @code_list_id = nil unless field_code_list_id field_code_list_id = attr_val("./#{CRITERIA_GLOB}/cda:outboundRelationship/#{CRITERIA_GLOB}/cda:value/@valueSet") end field_values[@definition.upcase] = HQMF::Coded.for_code_list(field_code_list_id, title) end return field_values unless field_values.empty? end
ruby
def retrieve_field_values_model_for_model field_values = {} @field_values.each_pair do |id, val| field_values[id] = val.to_model end @code_list_id ||= code_list_id # Model transfers as a field if %w(transfer_to transfer_from).include? @definition field_code_list_id = @code_list_id @code_list_id = nil unless field_code_list_id field_code_list_id = attr_val("./#{CRITERIA_GLOB}/cda:outboundRelationship/#{CRITERIA_GLOB}/cda:value/@valueSet") end field_values[@definition.upcase] = HQMF::Coded.for_code_list(field_code_list_id, title) end return field_values unless field_values.empty? end
[ "def", "retrieve_field_values_model_for_model", "field_values", "=", "{", "}", "@field_values", ".", "each_pair", "do", "|", "id", ",", "val", "|", "field_values", "[", "id", "]", "=", "val", ".", "to_model", "end", "@code_list_id", "||=", "code_list_id", "# Model transfers as a field", "if", "%w(", "transfer_to", "transfer_from", ")", ".", "include?", "@definition", "field_code_list_id", "=", "@code_list_id", "@code_list_id", "=", "nil", "unless", "field_code_list_id", "field_code_list_id", "=", "attr_val", "(", "\"./#{CRITERIA_GLOB}/cda:outboundRelationship/#{CRITERIA_GLOB}/cda:value/@valueSet\"", ")", "end", "field_values", "[", "@definition", ".", "upcase", "]", "=", "HQMF", "::", "Coded", ".", "for_code_list", "(", "field_code_list_id", ",", "title", ")", "end", "return", "field_values", "unless", "field_values", ".", "empty?", "end" ]
Generate the models of the field values
[ "Generate", "the", "models", "of", "the", "field", "values" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L246-L264
11,895
projectcypress/health-data-standards
lib/hqmf-parser/2.0/data_criteria.rb
HQMF2.DataCriteria.retrieve_title_and_description_for_model
def retrieve_title_and_description_for_model # drop "* Value Set" from titles exact_desc = title.split(' ')[0...-3].join(' ') # don't drop anything for patient characterstic titles exact_desc = title if @definition.start_with?('patient_characteristic') && !title.end_with?('Value Set') # remove * Value Set from title title_match = title.match(/(.*) \w+ [Vv]alue [Ss]et/) @title = title_match[1] if title_match && title_match.length > 1 @description = "#{@description}: #{exact_desc}" end
ruby
def retrieve_title_and_description_for_model # drop "* Value Set" from titles exact_desc = title.split(' ')[0...-3].join(' ') # don't drop anything for patient characterstic titles exact_desc = title if @definition.start_with?('patient_characteristic') && !title.end_with?('Value Set') # remove * Value Set from title title_match = title.match(/(.*) \w+ [Vv]alue [Ss]et/) @title = title_match[1] if title_match && title_match.length > 1 @description = "#{@description}: #{exact_desc}" end
[ "def", "retrieve_title_and_description_for_model", "# drop \"* Value Set\" from titles", "exact_desc", "=", "title", ".", "split", "(", "' '", ")", "[", "0", "...", "-", "3", "]", ".", "join", "(", "' '", ")", "# don't drop anything for patient characterstic titles", "exact_desc", "=", "title", "if", "@definition", ".", "start_with?", "(", "'patient_characteristic'", ")", "&&", "!", "title", ".", "end_with?", "(", "'Value Set'", ")", "# remove * Value Set from title", "title_match", "=", "title", ".", "match", "(", "/", "\\w", "/", ")", "@title", "=", "title_match", "[", "1", "]", "if", "title_match", "&&", "title_match", ".", "length", ">", "1", "@description", "=", "\"#{@description}: #{exact_desc}\"", "end" ]
Generate the title and description used when producing the model
[ "Generate", "the", "title", "and", "description", "used", "when", "producing", "the", "model" ]
252d4f0927c513eacde6b9ea41b76faa1423c34b
https://github.com/projectcypress/health-data-standards/blob/252d4f0927c513eacde6b9ea41b76faa1423c34b/lib/hqmf-parser/2.0/data_criteria.rb#L267-L278
11,896
Shopify/doggy
lib/doggy/model.rb
Doggy.Model.save_local
def save_local ensure_read_only! self.path ||= Doggy.object_root.join("#{prefix}-#{id}.json") File.open(@path, 'w') { |f| f.write(JSON.pretty_generate(to_h)) } end
ruby
def save_local ensure_read_only! self.path ||= Doggy.object_root.join("#{prefix}-#{id}.json") File.open(@path, 'w') { |f| f.write(JSON.pretty_generate(to_h)) } end
[ "def", "save_local", "ensure_read_only!", "self", ".", "path", "||=", "Doggy", ".", "object_root", ".", "join", "(", "\"#{prefix}-#{id}.json\"", ")", "File", ".", "open", "(", "@path", ",", "'w'", ")", "{", "|", "f", "|", "f", ".", "write", "(", "JSON", ".", "pretty_generate", "(", "to_h", ")", ")", "}", "end" ]
class << self
[ "class", "<<", "self" ]
5c5a08698925c26eb1118eae7a81a5ad39dc086f
https://github.com/Shopify/doggy/blob/5c5a08698925c26eb1118eae7a81a5ad39dc086f/lib/doggy/model.rb#L184-L188
11,897
chef/chef-zero
lib/chef_zero/server.rb
ChefZero.Server.url
def url sch = @options[:ssl] ? "https" : "http" hosts = Array(@options[:host]) @url ||= if hosts.first.include?(":") URI("#{sch}://[#{hosts.first}]:#{port}").to_s else URI("#{sch}://#{hosts.first}:#{port}").to_s end end
ruby
def url sch = @options[:ssl] ? "https" : "http" hosts = Array(@options[:host]) @url ||= if hosts.first.include?(":") URI("#{sch}://[#{hosts.first}]:#{port}").to_s else URI("#{sch}://#{hosts.first}:#{port}").to_s end end
[ "def", "url", "sch", "=", "@options", "[", ":ssl", "]", "?", "\"https\"", ":", "\"http\"", "hosts", "=", "Array", "(", "@options", "[", ":host", "]", ")", "@url", "||=", "if", "hosts", ".", "first", ".", "include?", "(", "\":\"", ")", "URI", "(", "\"#{sch}://[#{hosts.first}]:#{port}\"", ")", ".", "to_s", "else", "URI", "(", "\"#{sch}://#{hosts.first}:#{port}\"", ")", ".", "to_s", "end", "end" ]
The URL for this Chef Zero server. If the given host is an IPV6 address, it is escaped in brackets according to RFC-2732. @see http://www.ietf.org/rfc/rfc2732.txt RFC-2732 @return [String]
[ "The", "URL", "for", "this", "Chef", "Zero", "server", ".", "If", "the", "given", "host", "is", "an", "IPV6", "address", "it", "is", "escaped", "in", "brackets", "according", "to", "RFC", "-", "2732", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/server.rb#L167-L175
11,898
chef/chef-zero
lib/chef_zero/server.rb
ChefZero.Server.listen
def listen(hosts, port) hosts.each do |host| @server.listen(host, port) end true rescue Errno::EADDRINUSE ChefZero::Log.warn("Port #{port} not available") @server.listeners.each { |l| l.close } @server.listeners.clear false end
ruby
def listen(hosts, port) hosts.each do |host| @server.listen(host, port) end true rescue Errno::EADDRINUSE ChefZero::Log.warn("Port #{port} not available") @server.listeners.each { |l| l.close } @server.listeners.clear false end
[ "def", "listen", "(", "hosts", ",", "port", ")", "hosts", ".", "each", "do", "|", "host", "|", "@server", ".", "listen", "(", "host", ",", "port", ")", "end", "true", "rescue", "Errno", "::", "EADDRINUSE", "ChefZero", "::", "Log", ".", "warn", "(", "\"Port #{port} not available\"", ")", "@server", ".", "listeners", ".", "each", "{", "|", "l", "|", "l", ".", "close", "}", "@server", ".", "listeners", ".", "clear", "false", "end" ]
Start a Chef Zero server in a forked process. This method returns the PID to the forked process. @param [Fixnum] wait the number of seconds to wait for the server to start @return [Thread] the thread the background process is running in
[ "Start", "a", "Chef", "Zero", "server", "in", "a", "forked", "process", ".", "This", "method", "returns", "the", "PID", "to", "the", "forked", "process", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/server.rb#L270-L280
11,899
chef/chef-zero
lib/chef_zero/server.rb
ChefZero.Server.stop
def stop(wait = 5) if @running @server.shutdown if @server @thread.join(wait) if @thread end rescue Timeout::Error if @thread ChefZero::Log.error("Chef Zero did not stop within #{wait} seconds! Killing...") @thread.kill SocketlessServerMap.deregister(port) end ensure @server = nil @thread = nil end
ruby
def stop(wait = 5) if @running @server.shutdown if @server @thread.join(wait) if @thread end rescue Timeout::Error if @thread ChefZero::Log.error("Chef Zero did not stop within #{wait} seconds! Killing...") @thread.kill SocketlessServerMap.deregister(port) end ensure @server = nil @thread = nil end
[ "def", "stop", "(", "wait", "=", "5", ")", "if", "@running", "@server", ".", "shutdown", "if", "@server", "@thread", ".", "join", "(", "wait", ")", "if", "@thread", "end", "rescue", "Timeout", "::", "Error", "if", "@thread", "ChefZero", "::", "Log", ".", "error", "(", "\"Chef Zero did not stop within #{wait} seconds! Killing...\"", ")", "@thread", ".", "kill", "SocketlessServerMap", ".", "deregister", "(", "port", ")", "end", "ensure", "@server", "=", "nil", "@thread", "=", "nil", "end" ]
Gracefully stop the Chef Zero server. @param [Fixnum] wait the number of seconds to wait before raising force-terminating the server
[ "Gracefully", "stop", "the", "Chef", "Zero", "server", "." ]
5873d906942770a34f0cf0fed05973ec3240a275
https://github.com/chef/chef-zero/blob/5873d906942770a34f0cf0fed05973ec3240a275/lib/chef_zero/server.rb#L358-L372