Class: HQMF2::DataCriteria
- Inherits:
-
Object
- Object
- HQMF2::DataCriteria
- Includes:
- Utilities
- Defined in:
- lib/hqmf-parser/2.0/data_criteria.rb
Overview
Represents a data criteria specification
Instance Attribute Summary collapse
-
#children_criteria ⇒ Object
readonly
Returns the value of attribute children_criteria.
-
#derivation_operator ⇒ Object
readonly
Returns the value of attribute derivation_operator.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#effective_time ⇒ Object
readonly
Returns the value of attribute effective_time.
-
#field_values ⇒ Object
readonly
Returns the value of attribute field_values.
-
#is_source_data_criteria ⇒ Object
readonly
Returns the value of attribute is_source_data_criteria.
-
#negation ⇒ Object
readonly
Returns the value of attribute negation.
-
#negation_code_list_id ⇒ Object
readonly
Returns the value of attribute negation_code_list_id.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#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
readonly
Returns the value of attribute status.
-
#subset_operators ⇒ Object
readonly
Returns the value of attribute subset_operators.
-
#temporal_references ⇒ Object
readonly
Returns the value of attribute temporal_references.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#code_list_id ⇒ String
Get the code list OID of the criteria, used as an index to the code list database.
- #extract_type_from_definition ⇒ Object
- #extract_type_from_template_id ⇒ Object
-
#id ⇒ String
Get the identifier of the criteria, used elsewhere within the document for referencing.
-
#initialize(entry) ⇒ DataCriteria
constructor
Create a new instance based on the supplied HQMF entry.
- #inline_code_list ⇒ Object
- #patch_xpaths_for_criteria_type ⇒ Object
-
#title ⇒ String
Get the title of the criteria, provides a human readable description.
- #to_model ⇒ Object
- #to_s ⇒ Object
Methods included from Utilities
Methods included from HQMF::Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Constructor Details
#initialize(entry) ⇒ DataCriteria
Create a new instance based on the supplied HQMF entry
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 15 def initialize(entry) @entry = entry @status = attr_val('./*/cda:statusCode/@code') @description = attr_val('./*/cda:text/@value') extract_negation() extract_specific_or_source() @effective_time = extract_effective_time @temporal_references = extract_temporal_references @derivation_operator = extract_derivation_operator @field_values = extract_field_values @subset_operators = extract_subset_operators @children_criteria = extract_child_criteria @id_xpath = './*/cda:id/cda:item/@extension' @code_list_xpath = './*/cda:code' @value_xpath = './*/cda:value' # Try to determine what kind of data criteria we are dealing with # First we look for a template id and if we find one just use the definition # status and negation associated with that if !extract_type_from_template_id() # If no template id or not one we recognize then try to determine type from # the definition element extract_type_from_definition() end patch_xpaths_for_criteria_type() end |
Instance Attribute Details
#children_criteria ⇒ Object (readonly)
Returns the value of attribute children_criteria.
8 9 10 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 8 def children_criteria @children_criteria end |
#derivation_operator ⇒ Object (readonly)
Returns the value of attribute derivation_operator.
9 10 11 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 9 def derivation_operator @derivation_operator end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 9 def description @description end |
#effective_time ⇒ Object (readonly)
Returns the value of attribute effective_time.
7 8 9 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 7 def effective_time @effective_time end |
#field_values ⇒ Object (readonly)
Returns the value of attribute field_values.
10 11 12 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 10 def field_values @field_values end |
#is_source_data_criteria ⇒ Object (readonly)
Returns the value of attribute is_source_data_criteria.
11 12 13 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 11 def is_source_data_criteria @is_source_data_criteria end |
#negation ⇒ Object (readonly)
Returns the value of attribute negation.
9 10 11 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 9 def negation @negation end |
#negation_code_list_id ⇒ Object (readonly)
Returns the value of attribute negation_code_list_id.
9 10 11 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 9 def negation_code_list_id @negation_code_list_id end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
7 8 9 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 7 def property @property end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
7 8 9 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 7 def section @section end |
#source_data_criteria ⇒ Object (readonly)
Returns the value of attribute source_data_criteria.
10 11 12 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 10 def source_data_criteria @source_data_criteria end |
#specific_occurrence ⇒ Object (readonly)
Returns the value of attribute specific_occurrence.
11 12 13 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 11 def specific_occurrence @specific_occurrence end |
#specific_occurrence_const ⇒ Object (readonly)
Returns the value of attribute specific_occurrence_const.
10 11 12 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 10 def specific_occurrence_const @specific_occurrence_const end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 7 def status @status end |
#subset_operators ⇒ Object (readonly)
Returns the value of attribute subset_operators.
8 9 10 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 8 def subset_operators @subset_operators end |
#temporal_references ⇒ Object (readonly)
Returns the value of attribute temporal_references.
8 9 10 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 8 def temporal_references @temporal_references end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 7 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 7 def value @value end |
Instance Method Details
#code_list_id ⇒ String
Get the code list OID of the criteria, used as an index to the code list database
149 150 151 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 149 def code_list_id attr_val("#{@code_list_xpath}/@valueSet") end |
#extract_type_from_definition ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 67 def extract_type_from_definition # See if we can find a match for the entry definition value and status. entry_type = attr_val('./*/cda:definition/*/cda:id/@extension') begin settings = HQMF::DataCriteria.get_settings_for_definition(entry_type, @status) @definition = entry_type rescue # if no exact match then try a string match just using entry definition value case entry_type when 'Problem', 'Problems' @definition = 'diagnosis' when 'Encounter', 'Encounters' @definition = 'encounter' when 'LabResults', 'Results' @definition = 'laboratory_test' when 'Procedure', 'Procedures' @definition = 'procedure' when 'Medication', 'Medications' @definition = 'medication' if !@status @status = 'active' end when 'RX' @definition = 'medication' if !@status @status = 'dispensed' end when 'Demographics' @definition = definition_for_demographic when 'Derived' @definition = 'derived' when nil @definition = 'variable' else raise "Unknown data criteria template identifier [#{entry_type}]" end end end |
#extract_type_from_template_id ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 106 def extract_type_from_template_id template_ids = @entry.xpath('./*/cda:templateId/cda:item', HQMF2::Document::NAMESPACES).collect do |template_def| HQMF2::Utilities.attr_val(template_def, '@root') end if template_ids.include?(HQMF::DataCriteria::SOURCE_DATA_CRITERIA_TEMPLATE_ID) @is_source_data_criteria = true end template_ids.each do |template_id| defs = HQMF::DataCriteria.definition_for_template_id(template_id) if defs @definition = defs['definition'] @status = defs['status'].length > 0 ? defs['status'] : nil @negation = defs['negation'] return true end end false end |
#id ⇒ String
Get the identifier of the criteria, used elsewhere within the document for referencing
137 138 139 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 137 def id attr_val(@id_xpath) end |
#inline_code_list ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 153 def inline_code_list codeSystem = attr_val("#{@code_list_xpath}/@codeSystem") if codeSystem codeSystemName = HealthDataStandards::Util::CodeSystemHelper.code_system_for(codeSystem) else codeSystemName = attr_val("#{@code_list_xpath}/@codeSystemName") end codeValue = attr_val("#{@code_list_xpath}/@code") if codeSystemName && codeValue {codeSystemName => [codeValue]} else nil end end |
#patch_xpaths_for_criteria_type ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 43 def patch_xpaths_for_criteria_type # Patch xpaths when necessary, HQMF data criteria are irregular in structure so # the same information is found in different places depending on the type of # criteria # Assumes @definition and @status are already set case @definition when 'diagnosis', 'diagnosis_family_history' @code_list_xpath = './cda:observationCriteria/cda:value' when 'risk_category_assessment', 'procedure_result', 'laboratory_test', 'diagnostic_study_result', 'functional_status_result', 'intervention_result' @value = extract_value when 'medication' case @status when 'dispensed', 'ordered' @code_list_xpath = './cda:supplyCriteria/cda:participation/cda:role/cda:code' else # active or administered @code_list_xpath = './cda:substanceAdministrationCriteria/cda:participation/cda:role/cda:code' end when 'patient_characteristic', 'patient_characteristic_birthdate', 'patient_characteristic_clinical_trial_participant', 'patient_characteristic_expired', 'patient_characteristic_gender', 'patient_characteristic_age', 'patient_characteristic_languages', 'patient_characteristic_marital_status', 'patient_characteristic_race' @value = extract_value when 'variable' @value = extract_value end end |
#title ⇒ String
Get the title of the criteria, provides a human readable description
143 144 145 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 143 def title attr_val("#{@code_list_xpath}/cda:displayName/@value") || id end |
#to_model ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 168 def to_model mv = value ? value.to_model : nil met = effective_time ? effective_time.to_model : nil mtr = temporal_references.collect {|ref| ref.to_model} mso = subset_operators.collect {|opr| opr.to_model} field_values = {} @field_values.each_pair do |id, val| field_values[id] = val.to_model end HQMF::DataCriteria.new(id, title, nil, description, code_list_id, children_criteria, derivation_operator, @definition, status, mv, field_values, met, inline_code_list, @negation, @negation_code_list_id, mtr, mso, @specific_occurrence, @specific_occurrence_const, @source_data_criteria) end |
#to_s ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'lib/hqmf-parser/2.0/data_criteria.rb', line 125 def to_s props = { :property => property, :type => type, :status => status, :section => section } "DataCriteria#{props.to_s}" end |