Class: HQMF::DataCriteria
- Inherits:
-
Object
- Object
- HQMF::DataCriteria
- Includes:
- Conversion::Utilities
- Defined in:
- lib/hqmf-model/data_criteria.rb
Overview
Represents a data criteria specification
Direct Known Subclasses
Constant Summary collapse
- SOURCE_DATA_CRITERIA_TEMPLATE_ID =
'2.16.840.1.113883.3.100.1.1'
- SOURCE_DATA_CRITERIA_TEMPLATE_TITLE =
'Source data criteria'
- XPRODUCT =
'XPRODUCT'
- UNION =
'UNION'
- INTERSECT =
'INTERSECT'
- SATISFIES_ALL =
'satisfies_all'
- SATISFIES_ANY =
'satisfies_any'
- VARIABLE =
'variable'
- FIELDS =
An object containing metadata information for all attributes that are used within the measure data criteria being parsed.
fields include: ‘title`: The QDM human readable title for the attribute. `coded_entry_method`: this appears to be a way that fields here are referenced within Bonnie. `field_type`: The type of whatever will be stored for this attribute. This will often be `:timestamp` or `:value`. `code`: The code for the entry. This should be included to make HQMF generation work properly. This is whatever code is dictated in the HQMF. For Diagnosis, this is in [HQMF QDM IG](www.hl7.org/implement/standards/product_brief.cfm?product_id=346) vol 2 page 155 and is `29308-4`. `code_system`: This is the oid for whatever code system contains `code`. For Diagnosis, this is LOINC: `2.16.840.1.113883.6.1`. This is also located at (www.hl7.org/implement/standards/product_brief.cfm?product_id=346) vol 2 page 155. `template_id`: These appear to be related to HQMFr1 template ids. These appear to be dangerously out of date. Don’t use.
{'ABATEMENT_DATETIME' => {title:'Abatement Datetime', coded_entry_method: :end_date, field_type: :timestamp}, # ABATEMENT_DATETIME is no longer used. 'ACTIVE_DATETIME' => {title:'Active Date/Time', coded_entry_method: :active_datetime, field_type: :timestamp}, # ADMISSION_DATETIME is no longer used. 'ADMISSION_DATETIME' => {title:'Admission Date/Time', coded_entry_method: :admit_time, code: '399423000', code_system:'2.16.840.1.113883.6.96', field_type: :timestamp}, # QDM 5.0 addition. This is the same as FACILITY_LOCATION. # TODO: (LDY 10/5/2016) this is a new attribute from QDM 5.0. We do not yet have the code or template_id for this. This should be updated when we do. 'ADMISSION_SOURCE' => {title:'Admission Source', coded_entry_method: :admission_source, field_type: :value}, # ANATOMICAL_APPROACH_SITE is no longer used. 'ANATOMICAL_APPROACH_SITE' => {title:'Anatomical Approach Site', coded_entry_method: :anatomical_approach, field_type: :value}, 'ANATOMICAL_LOCATION_SITE' => {title:'Anatomical Location Site', coded_entry_method: :anatomical_location, field_type: :value}, # ANATOMICAL_STRUCTURE is no longer used. 'ANATOMICAL_STRUCTURE' => {title:'Anatomical Structure', coded_entry_method: :anatomical_structure, code: '91723000', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1000.2', field_type: :value}, # Added in QDM 5.4 'CATEGORY' => {title:'Category', coded_entry_method: :category, field_type: :value}, 'CAUSE' => {title:'Cause', coded_entry_method: :cause_of_death, code: '42752001', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1017.2', field_type: :value}, # TODO: Determine actual code and code_system for component attribute 'COMPONENT' => {title: 'Component', coded_entry_method: :components, field_type: :value}, # CUMULATIVE_MEDICATION_DURATION is no longer used. 'CUMULATIVE_MEDICATION_DURATION' => {title:'Cumulative Medication Duration', coded_entry_method: :cumulative_medication_duration, code: '261773006', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1001.3', field_type: :value}, # MISSING Date - The date that the patient passed away. - Patient Characteristic Expired # Could not find a code and code_system for this data criteria (days supplied) in HQMF QDM IG v3 'DAYS_SUPPLIED' => {title:'Days Supplied', coded_entry_method: :days_supplied, field_type: :value}, 'DIAGNOSIS' => {title:'Diagnosis', coded_entry_method: :diagnosis, field_type: :value}, # DISCHARGE_DATETIME is no longer used. 'DISCHARGE_DATETIME' => {title:'Discharge Date/Time', coded_entry_method: :discharge_time, code: '442864001', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1025.1', field_type: :timestamp}, # TODO: (LDY 10/5/2016) this changed from "discharge status" to "discharge disposition". likely there is a code and template id change necessary. these are not yet known. # DISCHARGE_STATUS is no longer used. 'DISCHARGE_STATUS' => {title:'Discharge Disposition', coded_entry_method: :discharge_disposition, code: '309039003', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1003.2', field_type: :value}, 'DISPENSER_IDENTIFIER' => {title:'Dispenser Identifier', coded_entry_method: :dispenser_identifier, field_type: :value}, # TODO: (LDY 10/4/2016) this changed from "dose" to "dosage". it's possible that there's another code associated with this. this code was not available at the time of this change. 'DOSE' => {title:'Dosage', coded_entry_method: :dose, code: '398232005', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1004.1', field_type: :value}, 'FACILITY_LOCATION' => {title:'Facility Location', coded_entry_method: :facility, code: 'SDLOC', field_type: :value}, # TODO: (LDY 10/5/2016) this changed from 'facility arrival/departure' to 'location period'. likely there is a code and template id change necessary. these are not yet known. 'FACILITY_LOCATION_ARRIVAL_DATETIME' => {title:'Location Period Start Date/Time', coded_entry_method: :facility_arrival, code: 'SDLOC_ARRIVAL', field_type: :nested_timestamp}, 'FACILITY_LOCATION_DEPARTURE_DATETIME' => {title:'Location Period End Date/Time', coded_entry_method: :facility_departure, code: 'SDLOC_DEPARTURE', field_type: :nested_timestamp}, 'FREQUENCY' => {title:'Frequency', coded_entry_method: :administration_timing, code: '307430002', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1006.1', field_type: :value}, # HEALTH_RECORD_FIELD is no longer used. 'HEALTH_RECORD_FIELD' => {title: 'Health Record Field', coded_entry_method: :health_record_field, code: '395676008', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.10.20.28.3.102:2014-11-24', field_type: :value}, 'INCISION_DATETIME' => {title:'Incision Date/Time', coded_entry_method: :incision_time, code: '34896006', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.10.20.24.3.89', field_type: :timestamp}, # LATERALITY is no longer used. 'LATERALITY' => {title:'Laterality', coded_entry_method: :laterality, code: '272741003', code_system:'2.16.840.1.113883.6.96', template_id: '', field_type: :value}, 'LENGTH_OF_STAY' => {title:'Length of Stay', coded_entry_method: :length_of_stay, code: '183797002', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1029.3', field_type: :value}, # Added in QDM 5.4 'MEDIUM' => {title:'Medium', coded_entry_method: :medium, field_type: :value}, 'METHOD' => {title:'Method', coded_entry_method: :method, template_id: '', field_type: :value}, # Negation Rationale isn't encoded # ONSET_AGE is no longer used. 'ONSET_AGE' => {title:'Onset Age', coded_entry_method: :onset_age, code: '445518008', code_system:'2.16.840.1.113883.6.96', template_id: '', field_type: :value}, # ONSET_DATETIME is no longer used. 'ONSET_DATETIME' => {title:'Onset Datetime', coded_entry_method: :start_date, field_type: :timestamp}, # ORDINAL is no longer used. 'ORDINAL' => {title:'Ordinality', coded_entry_method: :ordinality, code: '117363000', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1012.2', field_type: :value}, # previous 'ORDINALITY' => {title:'Ordinality', coded_entry_method: :ordinality, code: '117363000', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1012.2', field_type: :value}, # PATIENT_PREFERENCE is no longer used. 'PATIENT_PREFERENCE' => {title:'Patient Preference', coded_entry_method: :patient_preference, code: 'PAT', code_system: '2.16.840.1.113883.5.8', template_id: '2.16.840.1.113883.10.20.24.3.83', field_type: :value}, 'PRESCRIBER_IDENTIFIER' => {title:'Prescriber Identifier', coded_entry_method: :prescriber_identifier, field_type: :value}, 'PRINCIPAL_DIAGNOSIS' => {title:'Principal Diagnosis', coded_entry_method: :principal_diagnosis, field_type: :value}, # PROVIDER_PREFERENCE is no longer used. 'PROVIDER_PREFERENCE' => {title:'Provider Preference', coded_entry_method: :provider_preference, code: '103323008', code_system: '2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.10.20.24.3.84', field_type: :value}, # RADIATION_DOSAGE is no longer used. 'RADIATION_DOSAGE' => {title:'Radiation Dosage', coded_entry_method: :radiation_dose, code: '228815006', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.10.20.24.3.91', field_type: :value}, # RADIATION_DURATION is no longer used. 'RADIATION_DURATION' => {title:'Radiation Duration', coded_entry_method: :radiation_duration, code: '306751006', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.10.20.24.3.91', field_type: :value}, # REACTION is no longer used. 'REACTION'=> {title:'Reaction', coded_entry_method: :reaction, code: '263851003', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.10.20.24.3.85', field_type: :value}, 'REASON' => {title:'Reason', coded_entry_method: :reason, code: '410666004', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.10.20.24.3.88', field_type: :value}, # Added in QDM 5.4 'RECIPIENT' => {title:'Recipient', coded_entry_method: :recipient, field_type: :value}, # RECORDED_DATETIME is no longer used. 'RECORDED_DATETIME' => {title:'Recorded Datetime', coded_entry_method: :start_date, field_type: :timestamp}, 'REFERENCE_RANGE_HIGH' => {title:'Reference Range - High', coded_entry_method: :reference_range_high, field_type: :value}, 'REFERENCE_RANGE_LOW' => {title:'Reference Range - Low', coded_entry_method: :reference_range_low, field_type: :value}, 'REFILLS' => {title:'Refills', coded_entry_method: :refills, field_type: :value}, 'RELATED_TO' => {title:'Related To', coded_entry_method: :related_to, code: 'REL', codeSystem: '2.16.840.1.113883.1.11.11603', field_type: :value}, 'RELATIONSHIP' => {title:'Relationship', coded_entry_method: :relationship_to_patient, field_type: :value}, # REMOVAL_DATETIME is no longer used. 'REMOVAL_DATETIME' => {title:'Removal Date/Time', coded_entry_method: :removal_time, code: '118292001', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1032.1', field_type: :timestamp}, # Result isn't encoded # TODO: (LDY 10/4/2016) RESULT_DATETIME is a new attribute in QDM 5.0. We do not yet have codes/template information for this. 'RESULT_DATETIME' => {title:'Result Date/Time', coded_entry_method: :result_date_time, field_type: :timestamp}, 'ROUTE' => {title:'Route', coded_entry_method: :route, code: '263513008', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1020.2', field_type: :value}, # Added in QDM 5.4 'SENDER' => {title:'Sender', coded_entry_method: :sender, field_type: :value}, 'SETTING' => {title:'Setting', coded_entry_method: :setting, field_type: :value}, 'SEVERITY' => {title:'Severity', coded_entry_method: :severity, code: 'SEV', code_system:'2.16.840.1.113883.5.4', template_id: '2.16.840.1.113883.10.20.22.4.8', field_type: :value}, # SIGNED_DATETIME is no longer used. 'SIGNED_DATETIME' => {title:'Signed Date/Time', coded_entry_method: :signed_date_time, field_type: :timestamp}, # START_DATETIME is no longer used. 'START_DATETIME' => {title:'Start Date/Time', coded_entry_method: :start_date, code: '398201009', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1027.1', field_type: :timestamp}, # STATUS is referenced in the code as `qdm_status` because entry/Record already has a `status`/`status_code` field which has a different meaning 'STATUS' => {title: 'Status', coded_entry_method: :qdm_status, code: '33999-4', code_system:'2.16.840.1.113883.6.1', field_type: :value}, # STOP_DATETIME is no longer used. 'STOP_DATETIME' => {title:'Stop Date/Time', coded_entry_method: :end_date, code: '397898000', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.1026.1', field_type: :timestamp}, # TODO: (LDY 10/4/2016) SUPPLY is a new attribute in QDM 5.0. We do not yet have codes/template information for this. 'SUPPLY' => {title:'Supply', coded_entry_method: :supply, field_type: :value}, 'TARGET_OUTCOME' => {title:'Target Outcome', coded_entry_method: :target_outcome, code: '385676005', code_system:'2.16.840.1.113883.6.96', template_id: '', field_type: :value}, # Custom field values # QDM 5.3 Update: "Related To" replaces Fulfills. We are keeping the fulfills code and only make changes to the UI. 'FLFS' => {title:'Related To', coded_entry_method: :fulfills, code: 'FLFS', field_type: :reference}, 'SOURCE' => {title:'Source', coded_entry_method: :source, code: '260753009', code_system:'2.16.840.1.113883.6.96', template_id: '2.16.840.1.113883.3.560.1.2001.2', field_type: :value}, # TRANSFER_FROM, TRANSFER_FROM_DATETIME, TRANSFER_TO, and TRANSFER_TO_DATETIME are no longer used. 'TRANSFER_FROM' => {title:'Transfer From', coded_entry_method: :transfer_from, code: 'TRANSFER_FROM', template_id: '2.16.840.1.113883.10.20.24.3.81', field_type: :value}, 'TRANSFER_FROM_DATETIME' => {title:'Transfer From Date/Time', coded_entry_method: :transfer_from_time, code: 'ORG_TIME', template_id: '2.16.840.1.113883.10.20.24.3.81', field_type: :nested_timestamp}, 'TRANSFER_TO' => {title:'Transfer To', coded_entry_method: :transfer_to, code: 'TRANSFER_TO', template_id: '2.16.840.1.113883.10.20.24.3.82', field_type: :value}, 'TRANSFER_TO_DATETIME' => {title:'Transfer To Date/Time', coded_entry_method: :transfer_to_time, code: 'DST_TIME', template_id: '2.16.840.1.113883.10.20.24.3.82', field_type: :nested_timestamp} }
- VALUE_FIELDS =
maps attribute codes to the attribute keys
{'399423000' => 'ADMISSION_DATETIME', '42752001' => 'CAUSE', '261773006' => 'CUMULATIVE_MEDICATION_DURATION', '363819003' => 'CUMULATIVE_MEDICATION_DURATION', # previous '442864001' => 'DISCHARGE_DATETIME', '309039003' => 'DISCHARGE_STATUS', '398232005' => 'DOSE', 'SDLOC' => 'FACILITY_LOCATION', 'SDLOC_ARRIVAL' => 'FACILITY_LOCATION_ARRIVAL_DATETIME', 'SDLOC_DEPARTURE' => 'FACILITY_LOCATION_DEPARTURE_DATETIME', '307430002' => 'FREQUENCY', '260864003' => 'FREQUENCY', # previous '395676008' => 'HEALTH_RECORD_FIELD', '34896006' => 'INCISION_DATETIME', '272741003' => 'LATERALITY', '183797002' => 'LENGTH_OF_STAY', '445518008' => 'ONSET_AGE', '117363000' => 'ORDINALITY', 'PAT' => 'PATIENT_PREFERENCE', '103323008' => 'PROVIDER_PREFERENCE', '228815006' => 'RADIATION_DOSAGE', '306751006' => 'RADIATION_DURATION', '263851003' => 'REACTION', '410666004' => 'REASON', 'REL' => 'RELATED_TO', '118292001' => 'REMOVAL_DATETIME', '263513008' => 'ROUTE', 'SEV' => 'SEVERITY', '398201009' => 'START_DATETIME', '33999-4' => 'STATUS', '397898000' => 'STOP_DATETIME', '385676005' => 'TARGET_OUTCOME', # Custom field values '91723000' => 'ANATOMICAL_STRUCTURE', 'FLFS' => 'FLFS', '260753009' => 'SOURCE', 'TRANSFER_FROM' => 'TRANSFER_FROM', 'ORG_TIME' => 'TRANSFER_FROM_DATETIME', 'TRANSFER_TO' => 'TRANSFER_TO', 'DST_TIME' => 'TRANSFER_TO_DATETIME' }
Instance Attribute Summary collapse
-
#children_criteria ⇒ Object
Returns the value of attribute children_criteria.
-
#code_list_id ⇒ Object
readonly
Returns the value of attribute code_list_id.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#derivation_operator ⇒ Object
readonly
Returns the value of attribute derivation_operator.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#effective_time ⇒ Object
Returns the value of attribute effective_time.
-
#field_values ⇒ Object
Returns the value of attribute field_values.
-
#id ⇒ Object
Returns the value of attribute id.
-
#inline_code_list ⇒ Object
Returns the value of attribute inline_code_list.
-
#negation ⇒ Object
Returns the value of attribute negation.
-
#negation_code_list_id ⇒ Object
Returns the value of attribute negation_code_list_id.
-
#source_data_criteria ⇒ Object
readonly
Returns the value of attribute source_data_criteria.
-
#specific_occurrence ⇒ Object
readonly
Returns the value of attribute specific_occurrence.
-
#specific_occurrence_const ⇒ Object
readonly
Returns the value of attribute specific_occurrence_const.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subset_operators ⇒ Object
Returns the value of attribute subset_operators.
-
#temporal_references ⇒ Object
Returns the value of attribute temporal_references.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#value ⇒ Object
Returns the value of attribute value.
-
#variable ⇒ Object
readonly
Returns the value of attribute variable.
Class Method Summary collapse
-
.create_from_category(id, title, description, code_list_id, category, sub_category = nil, negation = false, negation_code_list_id = nil) ⇒ Object
create a new data criteria given a category and sub_category.
- .definition_for_template_id(template_id, version = 'r1') ⇒ Object
-
.from_json(id, json) ⇒ Object
Create a new data criteria instance from a JSON hash keyed with symbols.
- .get_settings_for_definition(definition, status) ⇒ Object
- .get_settings_map ⇒ Object
- .get_template_id_map(version = "r1") ⇒ Object
- .statuses_by_definition ⇒ Object
- .template_id_for_definition(definition, status, negation, version = "r1") ⇒ Object
- .title_for_template_id(template_id, version = 'r1') ⇒ Object
Instance Method Summary collapse
- #all_code_set_oids ⇒ Object
- #base_json ⇒ Object
- #hard_status ⇒ Object
- #has_subset(subset_operator) ⇒ Object
- #has_temporal(temporal_reference) ⇒ Object
-
#initialize(id, title, display_name, description, code_list_id, children_criteria, derivation_operator, definition, status, value, field_values, effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators, specific_occurrence, specific_occurrence_const, source_data_criteria = nil, comments = nil, variable = false) ⇒ DataCriteria
constructor
Create a new data criteria instance.
- #is_same_type?(criteria) ⇒ Boolean
- #patient_api_function ⇒ Object
- #property ⇒ Object
- #referenced_data_criteria(document) ⇒ Object
- #to_json ⇒ Object
- #type ⇒ Object
- #update_copy(hard_status, title, description, derivation_operator, definition) ⇒ Object
Methods included from Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Constructor Details
#initialize(id, title, display_name, description, code_list_id, children_criteria, derivation_operator, definition, status, value, field_values, effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators, specific_occurrence, specific_occurrence_const, source_data_criteria = nil, comments = nil, variable = false) ⇒ DataCriteria
Create a new data criteria instance
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/hqmf-model/data_criteria.rb', line 208 def initialize(id, title, display_name, description, code_list_id, children_criteria, derivation_operator, definition, status, value, field_values, effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators, specific_occurrence, specific_occurrence_const, source_data_criteria=nil, comments=nil, variable=false) status = normalize_status(definition, status) @settings = HQMF::DataCriteria.get_settings_for_definition(definition, status) @id = id @title = title @description = description @code_list_id = code_list_id @negation_code_list_id = negation_code_list_id @children_criteria = children_criteria @derivation_operator = derivation_operator @definition = definition @status = status @value = value @field_values = field_values @effective_time = effective_time @inline_code_list = inline_code_list @negation = negation @negation_code_list_id = negation_code_list_id @temporal_references = temporal_references @subset_operators = subset_operators @specific_occurrence = specific_occurrence @specific_occurrence_const = specific_occurrence_const @source_data_criteria = source_data_criteria || id @comments = comments @variable = variable end |
Instance Attribute Details
#children_criteria ⇒ Object
Returns the value of attribute children_criteria.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def children_criteria @children_criteria end |
#code_list_id ⇒ Object (readonly)
Returns the value of attribute code_list_id.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def code_list_id @code_list_id end |
#comments ⇒ Object
Returns the value of attribute comments.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def comments @comments end |
#definition ⇒ Object
Returns the value of attribute definition.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def definition @definition end |
#derivation_operator ⇒ Object (readonly)
Returns the value of attribute derivation_operator.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def derivation_operator @derivation_operator end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def description @description end |
#display_name ⇒ Object
Returns the value of attribute display_name.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def display_name @display_name end |
#effective_time ⇒ Object
Returns the value of attribute effective_time.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def effective_time @effective_time end |
#field_values ⇒ Object
Returns the value of attribute field_values.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def field_values @field_values end |
#id ⇒ Object
Returns the value of attribute id.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def id @id end |
#inline_code_list ⇒ Object
Returns the value of attribute inline_code_list.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def inline_code_list @inline_code_list end |
#negation ⇒ Object
Returns the value of attribute negation.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def negation @negation end |
#negation_code_list_id ⇒ Object
Returns the value of attribute negation_code_list_id.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def negation_code_list_id @negation_code_list_id end |
#source_data_criteria ⇒ Object (readonly)
Returns the value of attribute source_data_criteria.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def source_data_criteria @source_data_criteria end |
#specific_occurrence ⇒ Object (readonly)
Returns the value of attribute specific_occurrence.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def specific_occurrence @specific_occurrence end |
#specific_occurrence_const ⇒ Object (readonly)
Returns the value of attribute specific_occurrence_const.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def specific_occurrence_const @specific_occurrence_const end |
#status ⇒ Object
Returns the value of attribute status.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def status @status end |
#subset_operators ⇒ Object
Returns the value of attribute subset_operators.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def subset_operators @subset_operators end |
#temporal_references ⇒ Object
Returns the value of attribute temporal_references.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def temporal_references @temporal_references end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def title @title end |
#value ⇒ Object
Returns the value of attribute value.
182 183 184 |
# File 'lib/hqmf-model/data_criteria.rb', line 182 def value @value end |
#variable ⇒ Object (readonly)
Returns the value of attribute variable.
181 182 183 |
# File 'lib/hqmf-model/data_criteria.rb', line 181 def variable @variable end |
Class Method Details
.create_from_category(id, title, description, code_list_id, category, sub_category = nil, negation = false, negation_code_list_id = nil) ⇒ Object
create a new data criteria given a category and sub_category. A sub category can either be a status or a sub category
238 239 240 241 |
# File 'lib/hqmf-model/data_criteria.rb', line 238 def self.create_from_category(id, title, description, code_list_id, category, sub_category=nil, negation=false, negation_code_list_id=nil) settings = HQMF::DataCriteria.get_settings_for_definition(category, sub_category) HQMF::DataCriteria.new(id, title, nil, description, code_list_id, nil, nil, settings['definition'], settings['status'], nil, nil, nil, nil, negation, negation_code_list_id, nil, nil, nil,nil) end |
.definition_for_template_id(template_id, version = 'r1') ⇒ Object
413 414 415 |
# File 'lib/hqmf-model/data_criteria.rb', line 413 def self.definition_for_template_id(template_id, version='r1') get_template_id_map(version)[template_id] end |
.from_json(id, json) ⇒ Object
Create a new data criteria instance from a JSON hash keyed with symbols
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/hqmf-model/data_criteria.rb', line 271 def self.from_json(id, json) title = json["title"] if json["title"] display_name = json["display_name"] if json["display_name"] description = json["description"] if json["description"] code_list_id = json["code_list_id"] if json["code_list_id"] children_criteria = json["children_criteria"] if json["children_criteria"] derivation_operator = json["derivation_operator"] if json["derivation_operator"] definition = json["definition"] if json["definition"] status = json["status"] if json["status"] value = convert_value(json["value"]) if json["value"] field_values = json["field_values"].inject({}){|memo,(k,v)| memo[k.to_s] = convert_value(v); memo} if json["field_values"] effective_time = HQMF::Range.from_json(json["effective_time"]) if json["effective_time"] inline_code_list = json["inline_code_list"].inject({}){|memo,(k,v)| memo[k.to_s] = v; memo} if json["inline_code_list"] negation = json["negation"] || false negation_code_list_id = json['negation_code_list_id'] if json['negation_code_list_id'] temporal_references = json["temporal_references"].map {|reference| HQMF::TemporalReference.from_json(reference)} if json["temporal_references"] subset_operators = json["subset_operators"].map {|operator| HQMF::SubsetOperator.from_json(operator)} if json["subset_operators"] specific_occurrence = json['specific_occurrence'] if json['specific_occurrence'] specific_occurrence_const = json['specific_occurrence_const'] if json['specific_occurrence_const'] source_data_criteria = json['source_data_criteria'] if json['source_data_criteria'] comments = json['comments'] if json['comments'] variable = json['variable'] || false HQMF::DataCriteria.new(id, title, display_name, description, code_list_id, children_criteria, derivation_operator, definition, status, value, field_values, effective_time, inline_code_list, negation, negation_code_list_id, temporal_references, subset_operators,specific_occurrence,specific_occurrence_const,source_data_criteria, comments, variable) end |
.get_settings_for_definition(definition, status) ⇒ Object
402 403 404 405 406 407 408 409 410 411 |
# File 'lib/hqmf-model/data_criteria.rb', line 402 def self.get_settings_for_definition(definition, status) settings_file = File.('../data_criteria.json', __FILE__) settings_map = get_settings_map key = definition + ((status.nil? || status.empty?) ? '' : "_#{status}") settings = settings_map[key] raise "data criteria is not supported #{key}" if settings.nil? || settings["not_supported"] settings end |
.get_settings_map ⇒ Object
396 397 398 399 400 |
# File 'lib/hqmf-model/data_criteria.rb', line 396 def self.get_settings_map return @settings_map if @settings_map settings_file = File.('../data_criteria.json', __FILE__) @settings_map = JSON.parse(File.read(settings_file)) end |
.get_template_id_map(version = "r1") ⇒ Object
437 438 439 |
# File 'lib/hqmf-model/data_criteria.rb', line 437 def self.get_template_id_map(version="r1") read_template_id_map(version) end |
.statuses_by_definition ⇒ Object
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/hqmf-model/data_criteria.rb', line 330 def self.statuses_by_definition settings_file = File.('../data_criteria.json', __FILE__) settings_map = JSON.parse(File.read(settings_file)) all_defs = (settings_map.map {|key, value| {category: value['category'],definition:value['definition'],status:(value['status'].empty? ? nil : value['status']), sub_category: value['sub_category'],title:value['title']} unless value['not_supported']}).compact by_categories = {} all_defs.each do |definition| by_categories[definition[:category]]||={} status = definition[:status] def_key = definition[:definition] if status.nil? and definition[:sub_category] and !definition[:sub_category].empty? status = definition[:sub_category] def_key = def_key.gsub("_#{status}",'') end by_categories[definition[:category]][def_key]||={category:def_key,statuses:[]} by_categories[definition[:category]][def_key][:statuses] << status unless status.nil? end status_by_category = {} by_categories.each {|key, value| status_by_category[key] = value.values} status_by_category.delete('derived') status_by_category.delete('variable') status_by_category.delete('measurement_period') status_by_category.values.flatten end |
.template_id_for_definition(definition, status, negation, version = "r1") ⇒ Object
417 418 419 420 421 |
# File 'lib/hqmf-model/data_criteria.rb', line 417 def self.template_id_for_definition(definition, status, negation, version="r1") # in r2 negation uses the same template as a positive assertion negation = false if version == "r2" get_template_id_map(version).key({'definition' => definition, 'status' => status || '', 'negation' => negation}) end |
.title_for_template_id(template_id, version = 'r1') ⇒ Object
423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File 'lib/hqmf-model/data_criteria.rb', line 423 def self.title_for_template_id(template_id, version='r1') value = get_template_id_map(version)[template_id] if value settings = self.get_settings_for_definition(value['definition'], value['status']) if settings settings['title'] else 'Unknown data criteria' end else 'Unknown template id' end end |
Instance Method Details
#all_code_set_oids ⇒ Object
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/hqmf-model/data_criteria.rb', line 376 def all_code_set_oids # root oid referenced_oids = [code_list_id] # value oid referenced_oids << value.code_list_id if value != nil and value.type == 'CD' # negation oid referenced_oids << negation_code_list_id if negation_code_list_id != nil # field oids if field_values != nil referenced_oids.concat (field_values.map {|key,field| field.code_list_id if field != nil and field.type == 'CD'}) end referenced_oids end |
#base_json ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/hqmf-model/data_criteria.rb', line 309 def base_json x = nil json = build_hash(self, [:title,:display_name,:description,:code_list_id,:children_criteria, :derivation_operator, :property, :type, :definition, :status, :hard_status, :negation, :negation_code_list_id,:specific_occurrence,:specific_occurrence_const,:source_data_criteria,:variable]) json[:children_criteria] = @children_criteria unless @children_criteria.nil? || @children_criteria.empty? json[:value] = ((@value.is_a? String) ? @value : @value.to_json) if @value json[:field_values] = @field_values.inject({}) {|memo,(k,v)| memo[k] = (!v.nil? ? v.to_json : nil); memo} if @field_values json[:effective_time] = @effective_time.to_json if @effective_time json[:inline_code_list] = @inline_code_list if @inline_code_list json[:temporal_references] = x if x = json_array(@temporal_references) json[:subset_operators] = x if x = json_array(@subset_operators) json[:comments] = @comments if @comments json end |
#hard_status ⇒ Object
251 252 253 |
# File 'lib/hqmf-model/data_criteria.rb', line 251 def hard_status @settings['hard_status'] end |
#has_subset(subset_operator) ⇒ Object
326 327 328 |
# File 'lib/hqmf-model/data_criteria.rb', line 326 def has_subset(subset_operator) @subset_operators.reduce(false) {|found, item| found ||= item == subset_operator } end |
#has_temporal(temporal_reference) ⇒ Object
323 324 325 |
# File 'lib/hqmf-model/data_criteria.rb', line 323 def has_temporal(temporal_reference) @temporal_references.reduce(false) {|found, item| found ||= item == temporal_reference } end |
#is_same_type?(criteria) ⇒ Boolean
299 300 301 302 |
# File 'lib/hqmf-model/data_criteria.rb', line 299 def is_same_type?(criteria) return @definition == criteria.definition && @hard_status == criteria.hard_status && @negation == criteria.negation && all_code_set_oids.sort == criteria.all_code_set_oids.sort end |
#patient_api_function ⇒ Object
248 249 250 |
# File 'lib/hqmf-model/data_criteria.rb', line 248 def patient_api_function @settings['patient_api_function'].to_sym unless @settings['patient_api_function'].empty? end |
#property ⇒ Object
245 246 247 |
# File 'lib/hqmf-model/data_criteria.rb', line 245 def property @settings['property'].to_sym unless @settings['property'].nil? end |
#referenced_data_criteria(document) ⇒ Object
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/hqmf-model/data_criteria.rb', line 354 def referenced_data_criteria(document) referenced = [] if (@children_criteria) @children_criteria.each do |id| dc = document.data_criteria(id) referenced << id referenced.concat(dc.referenced_data_criteria(document)) end end if (@temporal_references) @temporal_references.each do |tr| id = tr.reference.id if (id != HQMF::Document::MEASURE_PERIOD_ID) dc = document.data_criteria(id) referenced << id referenced.concat(dc.referenced_data_criteria(document)) end end end referenced end |
#to_json ⇒ Object
304 305 306 307 |
# File 'lib/hqmf-model/data_criteria.rb', line 304 def to_json json = base_json {self.id.to_s.to_sym => json} end |
#type ⇒ Object
242 243 244 |
# File 'lib/hqmf-model/data_criteria.rb', line 242 def type @settings['category'].to_sym end |
#update_copy(hard_status, title, description, derivation_operator, definition) ⇒ Object
254 255 256 257 258 259 260 |
# File 'lib/hqmf-model/data_criteria.rb', line 254 def update_copy(hard_status, title, description, derivation_operator, definition) @settings['hard_status'] = hard_status @title = title @description = description @derivation_operator = derivation_operator @definition = definition end |