cqm-reports 1.0.0.0 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +8 -6
  4. data/lib/html-export/qdm-patient/data_element/_data_element_codes.mustache +1 -1
  5. data/lib/html-export/qdm-patient/qdm_patient.rb +5 -1
  6. data/lib/qrda-export/catI-r5/qrda_templates/communication_performed.mustache +5 -3
  7. data/lib/qrda-export/catI-r5/qrda_templates/device_order.mustache +4 -4
  8. data/lib/qrda-export/catI-r5/qrda_templates/device_recommended.mustache +4 -4
  9. data/lib/qrda-export/catI-r5/qrda_templates/encounter_order.mustache +4 -4
  10. data/lib/qrda-export/catI-r5/qrda_templates/encounter_performed.mustache +4 -4
  11. data/lib/qrda-export/catI-r5/qrda_templates/encounter_recommended.mustache +4 -4
  12. data/lib/qrda-export/catI-r5/qrda_templates/medication_discharge.mustache +0 -3
  13. data/lib/qrda-export/catI-r5/qrda_templates/medication_dispensed.mustache +4 -4
  14. data/lib/qrda-export/catI-r5/qrda_templates/physical_exam_performed.mustache +4 -0
  15. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_immunization_details.mustache +2 -2
  16. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_medication_details.mustache +5 -1
  17. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_medication_supply_request.mustache +1 -1
  18. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_results.mustache +0 -12
  19. data/lib/qrda-export/catIII-r2-1/_header.mustache +7 -0
  20. data/lib/qrda-export/catIII-r2-1/_measure_data.mustache +2 -0
  21. data/lib/qrda-export/catIII-r2-1/_measure_section.mustache +3 -0
  22. data/lib/qrda-export/catIII-r2-1/_supplemental_data.mustache +8 -1
  23. data/lib/qrda-export/catIII-r2-1/qrda3_r21.mustache +0 -1
  24. data/lib/qrda-export/catIII-r2-1/qrda3_r21.rb +16 -1
  25. data/lib/qrda-export/catIII-r2-1/qrda_header/_information_recipient.mustache +7 -0
  26. data/lib/qrda-export/catIII-r2-1/qrda_header/_participant_ehr.mustache +6 -0
  27. data/lib/qrda-export/catIII-r2-1/qrda_header/_participant_location.mustache +13 -0
  28. data/lib/qrda-export/helper/aggregate_object_helper.rb +1 -1
  29. data/lib/qrda-export/helper/cat1_view_helper.rb +18 -10
  30. data/lib/qrda-import/base-importers/demographics_importer.rb +3 -3
  31. data/lib/qrda-import/base-importers/section_importer.rb +37 -33
  32. data/lib/qrda-import/data-element-importers/assessment_order_importer.rb +2 -0
  33. data/lib/qrda-import/data-element-importers/assessment_performed_importer.rb +2 -0
  34. data/lib/qrda-import/data-element-importers/assessment_recommended_importer.rb +2 -0
  35. data/lib/qrda-import/data-element-importers/communication_performed_importer.rb +1 -2
  36. data/lib/qrda-import/data-element-importers/device_applied_importer.rb +2 -0
  37. data/lib/qrda-import/data-element-importers/device_order_importer.rb +2 -0
  38. data/lib/qrda-import/data-element-importers/device_recommended_importer.rb +2 -0
  39. data/lib/qrda-import/data-element-importers/diagnostic_study_order_importer.rb +2 -0
  40. data/lib/qrda-import/data-element-importers/diagnostic_study_performed_importer.rb +2 -0
  41. data/lib/qrda-import/data-element-importers/encounter_order_importer.rb +2 -0
  42. data/lib/qrda-import/data-element-importers/encounter_recommended_importer.rb +2 -0
  43. data/lib/qrda-import/data-element-importers/immunization_administered_importer.rb +2 -0
  44. data/lib/qrda-import/data-element-importers/immunization_order_importer.rb +2 -0
  45. data/lib/qrda-import/data-element-importers/intervention_order_importer.rb +2 -0
  46. data/lib/qrda-import/data-element-importers/intervention_performed_importer.rb +2 -0
  47. data/lib/qrda-import/data-element-importers/intervention_recommended_importer.rb +2 -0
  48. data/lib/qrda-import/data-element-importers/laboratory_test_order_importer.rb +2 -0
  49. data/lib/qrda-import/data-element-importers/laboratory_test_performed_importer.rb +2 -0
  50. data/lib/qrda-import/data-element-importers/laboratory_test_recommended_importer.rb +2 -0
  51. data/lib/qrda-import/data-element-importers/medication_administered_importer.rb +2 -0
  52. data/lib/qrda-import/data-element-importers/medication_dispensed_importer.rb +0 -1
  53. data/lib/qrda-import/data-element-importers/medication_order_importer.rb +2 -0
  54. data/lib/qrda-import/data-element-importers/patient_characteristic_clinical_trial_participant_importer.rb +2 -0
  55. data/lib/qrda-import/data-element-importers/physical_exam_order_importer.rb +2 -0
  56. data/lib/qrda-import/data-element-importers/physical_exam_performed_importer.rb +2 -0
  57. data/lib/qrda-import/data-element-importers/physical_exam_recommended_importer.rb +2 -0
  58. data/lib/qrda-import/data-element-importers/procedure_order_importer.rb +2 -0
  59. data/lib/qrda-import/data-element-importers/procedure_performed_importer.rb +2 -0
  60. data/lib/qrda-import/data-element-importers/procedure_recommended_importer.rb +2 -0
  61. data/lib/qrda-import/data-element-importers/substance_administered_importer.rb +0 -1
  62. data/lib/qrda-import/data-element-importers/substance_order_importer.rb +2 -0
  63. data/lib/qrda-import/data-element-importers/substance_recommended_importer.rb +2 -0
  64. data/lib/qrda-import/patient_importer.rb +1 -1
  65. data/lib/util/code_system_helper.rb +3 -24
  66. metadata +20 -18
@@ -9,7 +9,7 @@ module QRDA
9
9
  patient.qdmPatient.birthDatetime = DateTime.parse(patient_element.at_xpath('cda:birthTime')['value'])
10
10
  pcbd = QDM::PatientCharacteristicBirthdate.new
11
11
  pcbd.birthDatetime = patient.qdmPatient.birthDatetime
12
- pcbd.dataElementCodes = [{ code: '21112-8', codeSystem: 'LOINC' }]
12
+ pcbd.dataElementCodes = [{ code: '21112-8', codeSystemOid: '2.16.840.1.113883.6.1' }]
13
13
  patient.qdmPatient.dataElements << pcbd
14
14
 
15
15
  pcs = QDM::PatientCharacteristicSex.new
@@ -29,9 +29,9 @@ module QRDA
29
29
  end
30
30
 
31
31
  def code_if_present(code_element)
32
- return unless code_element && code_element['codeSystem'] && code_element['code']
32
+ return unless code_element && code_element['code'] && code_element['codeSystem']
33
33
 
34
- QDM::Code.new(code_element['code'], HQMF::Util::CodeSystemHelper.code_system_for(code_element['codeSystem']))
34
+ QDM::Code.new(code_element['code'], code_element['codeSystem'])
35
35
  end
36
36
  end
37
37
  end
@@ -49,7 +49,7 @@ module QRDA
49
49
  if @result_xpath
50
50
  entry.result = extract_result_values(entry_element)
51
51
  end
52
- extract_reason_or_negation(entry_element, entry)
52
+ extract_negation(entry_element, entry)
53
53
  entry
54
54
  end
55
55
 
@@ -79,9 +79,8 @@ module QRDA
79
79
  end
80
80
 
81
81
  def code_if_present(code_element)
82
- return unless code_element && code_element['codeSystem'] && code_element['code']
83
-
84
- QDM::Code.new(code_element['code'], HQMF::Util::CodeSystemHelper.code_system_for(code_element['codeSystem']))
82
+ return unless code_element && code_element['code'] && code_element['codeSystem']
83
+ QDM::Code.new(code_element['code'], code_element['codeSystem'])
85
84
  end
86
85
 
87
86
  def extract_dates(parent_element, entry)
@@ -96,13 +95,13 @@ module QRDA
96
95
  high_time = DateTime.parse(parent_element.at_xpath(interval_xpath)['value'])
97
96
  end
98
97
  if parent_element.at_xpath("#{interval_xpath}/cda:low")
99
- low_time = DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:low")['value'])
98
+ low_time = if parent_element.at_xpath("#{interval_xpath}/cda:low")['value']
99
+ DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:low")['value'])
100
+ end
100
101
  end
101
102
  if parent_element.at_xpath("#{interval_xpath}/cda:high")
102
103
  high_time = if parent_element.at_xpath("#{interval_xpath}/cda:high")['value']
103
104
  DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:high")['value'])
104
- else
105
- DateTime.new(9999,1,1)
106
105
  end
107
106
  end
108
107
  if parent_element.at_xpath("#{interval_xpath}/cda:center")
@@ -122,25 +121,26 @@ module QRDA
122
121
  # If a frequency interval is not found, return nil
123
122
  return nil unless frequency[:low]
124
123
  # If a frequency interval is found, search for a corresponding Direct Reference Code
125
- key, value = Qrda::Export::Helper::FrequencyHelper::FREQUENCY_CODE_MAP.select { |_k,v| v[:low] == frequency['low'] && v[:high] == frequency['high'] && v[:institution_specified] == frequency['institution_specified'] && v[:unit] == frequency['unit'] }.first
124
+ key, value = Qrda::Export::Helper::FrequencyHelper::FREQUENCY_CODE_MAP.select { |_k,v| v[:low] == frequency[:low] && v[:high] == frequency[:high] && v[:institution_specified] == frequency[:institution_specified] && v[:unit] == frequency[:unit] }.first
126
125
  # If a Direct Reference Code isn't found, return nil
127
126
  return nil unless key
128
127
  # If a Direct Reference Code is found, return that code
129
- QDM::Code.new(key, HQMF::Util::CodeSystemHelper.code_system_for(value[:codeSystem]))
128
+ QDM::Code.new(key, value[:code_system])
130
129
  end
131
130
 
132
131
  def extract_frequency_in_hours(parent_element, frequency_xpath)
133
132
  # Need to go get low, high and institutionspecified
134
- low = parent_element.at_xpath("#{frequency_xpath}/@value").value if parent_element.at_xpath("#{frequency_xpath}/@value")
135
- low = parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:low/@value").value if parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:low/@value")
133
+ low = parent_element.at_xpath("#{frequency_xpath}/@value").value.to_i if parent_element.at_xpath("#{frequency_xpath}/@value")
134
+ low = parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:low/@value").value.to_i if parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:low/@value")
136
135
  unit = parent_element.at_xpath("#{frequency_xpath}/@unit").value if parent_element.at_xpath("#{frequency_xpath}/@unit")
137
136
  unit = parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:low/@unit").value if parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:low/@unit")
138
- high = parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:high/@value").value if parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:high/@value")
137
+ high = parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:high/@value").value.to_i if parent_element.at_xpath("#{frequency_xpath}/cda:period/cda:high/@value")
139
138
  institution_specified = parent_element.at_xpath("#{frequency_xpath}/@institutionSpecified") || false
140
139
  # Expected units are H (hours) and D (days)
141
140
  if unit && unit.upcase == 'D'
142
141
  low = low * 24 if low
143
- high = high * 34 if high
142
+ high = high * 24 if high
143
+ unit = 'h'
144
144
  end
145
145
  { low: low, high: high, unit: unit, institution_specified: institution_specified }
146
146
  end
@@ -158,44 +158,48 @@ module QRDA
158
158
 
159
159
  value = value_element['value']
160
160
  if value.present?
161
- return value.strip.to_i if (value_element['unit'] == "1" || value_element['unit'].nil?)
161
+ return value.strip.to_f if (value_element['unit'] == "1" || value_element['unit'].nil?)
162
162
 
163
- return QDM::Quantity.new(value.strip.to_i, value_element['unit'])
163
+ return QDM::Quantity.new(value.strip.to_f, value_element['unit'])
164
164
  elsif value_element['code'].present?
165
165
  return code_if_present(value_element)
166
166
  end
167
167
  end
168
168
 
169
- # extracts the reason or negation data. if an element is negated and the code has a null flavor, a random code is assigned for calculation
170
- # coded_parent_element is the 'parent' element when the coded is nested (e.g., medication order)
171
- def extract_reason_or_negation(parent_element, entry, coded_parent_element = nil)
172
- coded_parent_element ||= parent_element
173
- reason_element = parent_element.xpath(".//cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value | .//cda:entryRelationship[@typeCode='RSON']/cda:act[cda:templateId/@root='2.16.840.1.113883.10.20.1.27']/cda:code")
169
+ def extract_reason(parent_element)
170
+ return unless @reason_xpath
171
+ reason_element = parent_element.xpath(@reason_xpath)
174
172
  negation_indicator = parent_element['negationInd']
175
- unless reason_element.blank?
176
- if negation_indicator.eql?('true')
177
- entry.negationRationale = code_if_present(reason_element.first)
178
- else
179
- entry.reason = code_if_present(reason_element.first) unless @entry_does_not_have_reason
180
- end
181
- end
182
- extract_negated_code(coded_parent_element, entry)
173
+ # Return and do not set reason attribute if the entry is negated
174
+ return nil if negation_indicator.eql?('true')
175
+
176
+ reason_element.blank? ? nil : code_if_present(reason_element.first)
177
+ end
178
+
179
+ def extract_negation(parent_element, entry)
180
+ negation_element = parent_element.xpath("./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value")
181
+ negation_indicator = parent_element['negationInd']
182
+ # Return and do not set negationRationale attribute if the entry is not negated
183
+ return unless negation_indicator.eql?('true')
184
+
185
+ entry.negationRationale = code_if_present(negation_element.first) unless negation_element.blank?
186
+ extract_negated_code(parent_element, entry)
183
187
  end
184
188
 
185
- def extract_negated_code(coded_parent_element, entry)
186
- code_elements = coded_parent_element.xpath(@code_xpath)
189
+ def extract_negated_code(parent_element, entry)
190
+ code_elements = parent_element.xpath(@code_xpath)
187
191
  code_elements.each do |code_element|
188
192
  if code_element['nullFlavor'] == 'NA' && code_element['sdtc:valueSet']
189
- entry.dataElementCodes = [{ code: code_element['sdtc:valueSet'], codeSystem: 'NA_VALUESET' }]
193
+ entry.dataElementCodes = [{ code: code_element['sdtc:valueSet'], codeSystemOid: '1.2.3.4.5.6.7.8.9.10' }]
190
194
  end
191
195
  end
192
196
  end
193
197
 
194
198
  def extract_scalar(parent_element, scalar_xpath)
195
199
  scalar_element = parent_element.at_xpath(scalar_xpath)
196
- return unless scalar_element
200
+ return unless scalar_element && scalar_element['value'].present?
197
201
 
198
- QDM::Quantity.new(scalar_element['value'].to_i, scalar_element['unit'])
202
+ QDM::Quantity.new(scalar_element['value'].to_f, scalar_element['unit'])
199
203
  end
200
204
 
201
205
  def extract_components(parent_element)
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:id'
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::AssessmentOrder
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  assessment_order = super
15
+ assessment_order.reason = extract_reason(entry_element)
14
16
  assessment_order
15
17
  end
16
18
 
@@ -9,6 +9,7 @@ module QRDA
9
9
  @result_xpath = "./cda:value"
10
10
  @method_xpath = './cda:methodCode'
11
11
  @components_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.149']"
12
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
12
13
  @entry_class = QDM::AssessmentPerformed
13
14
  end
14
15
 
@@ -16,6 +17,7 @@ module QRDA
16
17
  assessment_performed = super
17
18
  assessment_performed.method = code_if_present(entry_element.at_xpath(@method_xpath))
18
19
  assessment_performed.components = extract_components(entry_element)
20
+ assessment_performed.reason = extract_reason(entry_element)
19
21
  assessment_performed
20
22
  end
21
23
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:id'
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::AssessmentRecommended
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  assessment_recommended = super
15
+ assessment_recommended.reason = extract_reason(entry_element)
14
16
  assessment_recommended
15
17
  end
16
18
 
@@ -3,9 +3,8 @@ module QRDA
3
3
  class CommunicationPerformedImporter < SectionImporter
4
4
  def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.156']"))
5
5
  super(entry_finder)
6
- @entry_does_not_have_reason = true
7
6
  @id_xpath = './cda:id'
8
- @code_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
7
+ @code_xpath = "./cda:entryRelationship[@typeCode='REFR']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
8
  @author_datetime_xpath = "./cda:author/cda:time"
10
9
  @relevant_period_xpath = "./cda:effectiveTime"
11
10
  @related_to_xpath = "./sdtc:inFulfillmentOf1/sdtc:actReference"
@@ -8,12 +8,14 @@ module QRDA
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
9
  @relevant_period_xpath = "./cda:effectiveTime"
10
10
  @anatomical_location_site_xpath = "./cda:targetSiteCode"
11
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
11
12
  @entry_class = QDM::DeviceApplied
12
13
  end
13
14
 
14
15
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
15
16
  device_applied = super
16
17
  device_applied.anatomicalLocationSite = code_if_present(entry_element.at_xpath(@anatomical_location_site_xpath))
18
+ device_applied.reason = extract_reason(entry_element)
17
19
  device_applied
18
20
  end
19
21
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.9']/cda:id"
7
7
  @code_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.9']/cda:participant/cda:participantRole/cda:playingDevice/cda:code"
8
8
  @author_datetime_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.9']/cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.9']/cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::DeviceOrder
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  device_order = super
15
+ device_order.reason = extract_reason(entry_element)
14
16
  device_order
15
17
  end
16
18
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.10']/cda:id"
7
7
  @code_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.10']/cda:participant/cda:participantRole/cda:playingDevice/cda:code"
8
8
  @author_datetime_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.10']/cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.10']/cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::DeviceRecommended
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  device_recommended = super
15
+ device_recommended.reason = extract_reason(entry_element)
14
16
  device_recommended
15
17
  end
16
18
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:id'
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::DiagnosticStudyOrder
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  diagnostic_study_order = super
15
+ diagnostic_study_order.reason = extract_reason(entry_element)
14
16
  diagnostic_study_order
15
17
  end
16
18
 
@@ -13,6 +13,7 @@ module QRDA
13
13
  @method_xpath = './cda:methodCode'
14
14
  @facility_locations_xpath = "./cda:participant[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.100']"
15
15
  @components_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.149']"
16
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
16
17
  @entry_class = QDM::DiagnosticStudyPerformed
17
18
  end
18
19
 
@@ -24,6 +25,7 @@ module QRDA
24
25
  diagnostic_study_performed.method = code_if_present(entry_element.at_xpath(@method_xpath))
25
26
  diagnostic_study_performed.facilityLocation = extract_facility_locations(entry_element)[0]
26
27
  diagnostic_study_performed.components = extract_components(entry_element)
28
+ diagnostic_study_performed.reason = extract_reason(entry_element)
27
29
  diagnostic_study_performed
28
30
  end
29
31
 
@@ -7,12 +7,14 @@ module QRDA
7
7
  @code_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.22']/cda:code"
8
8
  @author_datetime_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.22']/cda:author/cda:time"
9
9
  @facility_locations_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.22']/cda:participant[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.100']"
10
+ @reason_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.22']/cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
10
11
  @entry_class = QDM::EncounterOrder
11
12
  end
12
13
 
13
14
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
14
15
  encounter_order = super
15
16
  encounter_order.facilityLocation = extract_facility_locations(entry_element)[0]
17
+ encounter_order.reason = extract_reason(entry_element)
16
18
  encounter_order
17
19
  end
18
20
 
@@ -7,12 +7,14 @@ module QRDA
7
7
  @code_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.24']/cda:code"
8
8
  @author_datetime_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.24']/cda:author/cda:time"
9
9
  @facility_locations_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.24']/cda:participant[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.100']"
10
+ @reason_xpath = "./cda:entryRelationship/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.24']/cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
10
11
  @entry_class = QDM::EncounterRecommended
11
12
  end
12
13
 
13
14
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
14
15
  encounter_recommended = super
15
16
  encounter_recommended.facilityLocation = extract_facility_locations(entry_element)[0]
17
+ encounter_recommended.reason = extract_reason(entry_element)
16
18
  encounter_recommended
17
19
  end
18
20
 
@@ -8,6 +8,7 @@ module QRDA
8
8
  @author_datetime_xpath = "./cda:effectiveTime"
9
9
  @dosage_xpath = "./cda:doseQuantity"
10
10
  @route_xpath = "./cda:routeCode"
11
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
11
12
  @entry_class = QDM::ImmunizationAdministered
12
13
  end
13
14
 
@@ -15,6 +16,7 @@ module QRDA
15
16
  immunization_administered = super
16
17
  immunization_administered.dosage = extract_scalar(entry_element, @dosage_xpath)
17
18
  immunization_administered.route = code_if_present(entry_element.at_xpath(@route_xpath))
19
+ immunization_administered.reason = extract_reason(entry_element)
18
20
  immunization_administered
19
21
  end
20
22
 
@@ -10,6 +10,7 @@ module QRDA
10
10
  @dosage_xpath = "./cda:doseQuantity"
11
11
  @supply_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.99']/cda:quantity"
12
12
  @route_xpath = "./cda:routeCode"
13
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
13
14
  @entry_class = QDM::ImmunizationOrder
14
15
  end
15
16
 
@@ -19,6 +20,7 @@ module QRDA
19
20
  immunization_order.dosage = extract_scalar(entry_element, @dosage_xpath)
20
21
  immunization_order.supply = extract_scalar(entry_element, @supply_xpath)
21
22
  immunization_order.route = code_if_present(entry_element.at_xpath(@route_xpath))
23
+ immunization_order.reason = extract_reason(entry_element)
22
24
  immunization_order
23
25
  end
24
26
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:id'
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::InterventionOrder
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  intervention_order = super
15
+ intervention_order.reason = extract_reason(entry_element)
14
16
  intervention_order
15
17
  end
16
18
 
@@ -9,12 +9,14 @@ module QRDA
9
9
  @author_datetime_xpath = "./cda:author/cda:time"
10
10
  @result_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.2']/cda:value"
11
11
  @status_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.93']/cda:value"
12
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
12
13
  @entry_class = QDM::InterventionPerformed
13
14
  end
14
15
 
15
16
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
16
17
  intervention_performed = super
17
18
  intervention_performed.status = code_if_present(entry_element.at_xpath(@status_xpath))
19
+ intervention_performed.reason = extract_reason(entry_element)
18
20
  intervention_performed
19
21
  end
20
22
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:id'
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::InterventionRecommended
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  intervention_recommended = super
15
+ intervention_recommended.reason = extract_reason(entry_element)
14
16
  intervention_recommended
15
17
  end
16
18
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:id'
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::LaboratoryTestOrder
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  laboratory_test_order = super
15
+ laboratory_test_order.reason = extract_reason(entry_element)
14
16
  laboratory_test_order
15
17
  end
16
18
 
@@ -12,6 +12,7 @@ module QRDA
12
12
  @result_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.2']/cda:value"
13
13
  @result_datetime_xpath = "./cda:entryRelationship[@typeCode='REFR']/cda:observation/cda:effectiveTime"
14
14
  @components_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.149']"
15
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
15
16
  @entry_class = QDM::LaboratoryTestPerformed
16
17
  end
17
18
 
@@ -21,6 +22,7 @@ module QRDA
21
22
  laboratory_test_performed.method = code_if_present(entry_element.at_xpath(@method_xpath))
22
23
  laboratory_test_performed.resultDatetime = extract_time(entry_element, @result_datetime_xpath)
23
24
  laboratory_test_performed.components = extract_components(entry_element)
25
+ laboratory_test_performed.reason = extract_reason(entry_element)
24
26
  laboratory_test_performed
25
27
  end
26
28
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:id'
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
9
10
  @entry_class = QDM::LaboratoryTestRecommended
10
11
  end
11
12
 
12
13
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
13
14
  laboratory_test_recommended = super
15
+ laboratory_test_recommended.reason = extract_reason(entry_element)
14
16
  laboratory_test_recommended
15
17
  end
16
18