cqm-parsers 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +5 -5
  2. data/lib/qrda-export/catI-r5/qrda_templates/device_ordered.mustache +3 -3
  3. data/lib/qrda-export/catI-r5/qrda_templates/encounter_ordered.mustache +3 -3
  4. data/lib/qrda-export/catI-r5/qrda_templates/medication_discharge.mustache +3 -3
  5. data/lib/qrda-export/catI-r5/qrda_templates/medication_dispensed.mustache +3 -3
  6. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_medication_details.mustache +1 -1
  7. data/lib/qrda-export/helper/cat_1_view_helper.rb +4 -0
  8. data/lib/qrda-import/base-importers/section_importer.rb +32 -25
  9. data/lib/qrda-import/data-element-importers/assessment_performed_importer.rb +2 -0
  10. data/lib/qrda-import/data-element-importers/device_applied_importer.rb +2 -0
  11. data/lib/qrda-import/data-element-importers/device_order_importer.rb +2 -0
  12. data/lib/qrda-import/data-element-importers/diagnostic_study_order_importer.rb +2 -0
  13. data/lib/qrda-import/data-element-importers/diagnostic_study_performed_importer.rb +2 -0
  14. data/lib/qrda-import/data-element-importers/encounter_order_importer.rb +2 -0
  15. data/lib/qrda-import/data-element-importers/immunization_administered_importer.rb +2 -0
  16. data/lib/qrda-import/data-element-importers/intervention_order_importer.rb +2 -0
  17. data/lib/qrda-import/data-element-importers/intervention_performed_importer.rb +2 -0
  18. data/lib/qrda-import/data-element-importers/laboratory_test_order_importer.rb +2 -0
  19. data/lib/qrda-import/data-element-importers/laboratory_test_performed_importer.rb +2 -0
  20. data/lib/qrda-import/data-element-importers/medication_administered_importer.rb +2 -0
  21. data/lib/qrda-import/data-element-importers/medication_order_importer.rb +2 -0
  22. data/lib/qrda-import/data-element-importers/physical_exam_performed_importer.rb +2 -0
  23. data/lib/qrda-import/data-element-importers/procedure_order_importer.rb +2 -0
  24. data/lib/qrda-import/data-element-importers/procedure_performed_importer.rb +2 -0
  25. data/lib/qrda-import/data-element-importers/substance_administered_importer.rb +2 -2
  26. data/lib/qrda-import/patient_importer.rb +1 -1
  27. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 9485682c59342822202fe6a253ce7bbcbb67b92a428fa04558a093d0995d9765
4
- data.tar.gz: e68e467aa5d71626f960a79df31e08569b35cc7faa8c6c35ca893532818e60ae
2
+ SHA1:
3
+ metadata.gz: 5ae0c0edc66dbccfb1f7bff982ed28472220b223
4
+ data.tar.gz: a244b962a1ba17b061ac9fbacdb1ce27ef3d9ae0
5
5
  SHA512:
6
- metadata.gz: 1bc35e9ea6bfadd995d234619315ef036f2f3cfc61e4a3dc8bc35f20bb7f48efe798049642061019fd4351861b906a16989dc54a451dfe32c3bcd56778e72937
7
- data.tar.gz: 5fe9cbb48856d6585c433bf33727129d985afd25a71df22f688aab9289904466ac0defbdd7779c9c2fba422c2607d601f4b1519f605970d2bc74ad334e5beea6
6
+ metadata.gz: aa00da03f1b87750f4dd0fdaa9a60b67616afba80c41f741a35b74b2a2e989b738220d28c5cbfab6ed9087f3b71da829c9a0c3da50e276588ea648d2490853dc
7
+ data.tar.gz: 29f3149e4f031808f4e956c9d29584ae1acc9cc60b6798192fd4a880fdf41fad302d6da47a0cf1add996a42fccb802e3f5d844a4421d85bc97ca1ba8beb39f45
@@ -22,10 +22,10 @@
22
22
  </playingDevice>
23
23
  </participantRole>
24
24
  </participant>
25
- {{#negationRationale}}
26
- {{> qrda_templates/template_partials/_reason}}
27
- {{/negationRationale}}
28
25
  </supply>
29
26
  </entryRelationship>
27
+ {{#negationRationale}}
28
+ {{> qrda_templates/template_partials/_reason}}
29
+ {{/negationRationale}}
30
30
  </act>
31
31
  </entry>
@@ -15,10 +15,10 @@
15
15
  {{#authorDatetime}}
16
16
  {{> qrda_templates/template_partials/_author}}
17
17
  {{/authorDatetime}}
18
- {{#negationRationale}}
19
- {{> qrda_templates/template_partials/_reason}}
20
- {{/negationRationale}}
21
18
  </encounter>
22
19
  </entryRelationship>
20
+ {{#negationRationale}}
21
+ {{> qrda_templates/template_partials/_reason}}
22
+ {{/negationRationale}}
23
23
  </act>
24
24
  </entry>
@@ -46,10 +46,10 @@
46
46
  {{#authorDatetime}}
47
47
  {{> qrda_templates/template_partials/_author_participation}}
48
48
  {{/authorDatetime}}
49
- {{#negationRationale}}
50
- {{> qrda_templates/template_partials/_reason}}
51
- {{/negationRationale}}
52
49
  </substanceAdministration>
53
50
  </entryRelationship>
51
+ {{#negationRationale}}
52
+ {{> qrda_templates/template_partials/_reason}}
53
+ {{/negationRationale}}
54
54
  </act>
55
55
  </entry>
@@ -30,10 +30,10 @@
30
30
  {{#authorDatetime}}
31
31
  {{> qrda_templates/template_partials/_author}}
32
32
  {{/authorDatetime}}
33
- {{#negationRationale}}
34
- {{> qrda_templates/template_partials/_reason}}
35
- {{/negationRationale}}
36
33
  </supply>
37
34
  </entryRelationship>
35
+ {{#negationRationale}}
36
+ {{> qrda_templates/template_partials/_reason}}
37
+ {{/negationRationale}}
38
38
  </act>
39
39
  </entry>
@@ -6,6 +6,6 @@
6
6
  {{/negated}}
7
7
  {{^negated}}
8
8
  {{#dosage}}
9
- <doseQuantity value="{{value}}" unit="{{unit}}"/>
9
+ <doseQuantity value="{{value_as_float}}"/>
10
10
  {{/dosage}}
11
11
  {{/negated}}
@@ -123,6 +123,10 @@ module Qrda
123
123
  translation_list
124
124
  end
125
125
 
126
+ def value_as_float
127
+ self['value'].to_f
128
+ end
129
+
126
130
  def result_value
127
131
  return "<value xsi:type=\"CD\" nullFlavor=\"UNK\"/>" unless self['result']
128
132
  result_string = if self['result'].is_a? Array
@@ -38,14 +38,17 @@ module QRDA
38
38
 
39
39
  def create_entry(entry_element, _nrh = NarrativeReferenceHandler.new)
40
40
  entry = @entry_class.new
41
- @entry_id_map[extract_id(entry_element, @id_xpath).value] ||= []
42
- @entry_id_map[extract_id(entry_element, @id_xpath).value] << entry.id
41
+ entry_qrda_id = extract_id(entry_element, @id_xpath)
42
+ # Create a hash to map all of entry.ids to the same QRDA ids. This will be used to merge QRDA entries
43
+ # that represent the same event.
44
+ @entry_id_map["#{entry_qrda_id.value}_#{entry_qrda_id.namingSystem}"] ||= []
45
+ @entry_id_map["#{entry_qrda_id.value}_#{entry_qrda_id.namingSystem}"] << entry.id
43
46
  entry.dataElementCodes = extract_codes(entry_element, @code_xpath)
44
47
  extract_dates(entry_element, entry)
45
48
  if @result_xpath
46
49
  entry.result = extract_result_values(entry_element)
47
50
  end
48
- extract_reason_or_negation(entry_element, entry)
51
+ extract_negation(entry_element, entry)
49
52
  entry
50
53
  end
51
54
 
@@ -55,7 +58,7 @@ module QRDA
55
58
  id_element = parent_element.at_xpath(id_xpath)
56
59
  return unless id_element
57
60
  # If an extension is not included, use the root as the value. Other wise use the extension
58
- value = id_element['extension'] ? id_element['extension'] : id_element['root']
61
+ value = id_element['extension'] || id_element['root']
59
62
  identifier = QDM::Id.new(value: value, namingSystem: id_element['root'])
60
63
  identifier
61
64
  end
@@ -90,13 +93,13 @@ module QRDA
90
93
  high_time = DateTime.parse(parent_element.at_xpath(interval_xpath)['value'])
91
94
  end
92
95
  if parent_element.at_xpath("#{interval_xpath}/cda:low")
93
- low_time = DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:low")['value'])
96
+ low_time = if parent_element.at_xpath("#{interval_xpath}/cda:low")['value']
97
+ DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:low")['value'])
98
+ end
94
99
  end
95
100
  if parent_element.at_xpath("#{interval_xpath}/cda:high")
96
101
  high_time = if parent_element.at_xpath("#{interval_xpath}/cda:high")['value']
97
102
  DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:high")['value'])
98
- else
99
- DateTime.new(9999,1,1)
100
103
  end
101
104
  end
102
105
  if parent_element.at_xpath("#{interval_xpath}/cda:center")
@@ -122,31 +125,35 @@ module QRDA
122
125
  return unless value_element && !value_element['nullFlavor']
123
126
  value = value_element['value']
124
127
  if value.present?
125
- return value.strip.to_i if (value_element['unit'] == "1" || value_element['unit'].nil?)
126
- return QDM::Quantity.new(value.strip.to_i, value_element['unit'])
128
+ return value.strip.to_f if (value_element['unit'] == "1" || value_element['unit'].nil?)
129
+ return QDM::Quantity.new(value.strip.to_f, value_element['unit'])
127
130
  elsif value_element['code'].present?
128
131
  return code_if_present(value_element)
129
132
  end
130
133
  end
131
134
 
132
- # 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
133
- # coded_parent_element is the 'parent' element when the coded is nested (e.g., medication order)
134
- def extract_reason_or_negation(parent_element, entry, coded_parent_element = nil)
135
- coded_parent_element ||= parent_element
136
- 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")
135
+ def extract_reason(parent_element)
136
+ return unless @reason_xpath
137
+ reason_element = parent_element.xpath(@reason_xpath)
137
138
  negation_indicator = parent_element['negationInd']
138
- unless reason_element.blank?
139
- if negation_indicator.eql?('true')
140
- entry.negationRationale = code_if_present(reason_element.first)
141
- else
142
- entry.reason = code_if_present(reason_element.first) unless @entry_does_not_have_reason
143
- end
144
- end
145
- extract_negated_code(coded_parent_element, entry)
139
+ # Return and do not set reason attribute if the entry is negated
140
+ return nil if negation_indicator.eql?('true')
141
+
142
+ reason_element.blank? ? nil : code_if_present(reason_element.first)
143
+ end
144
+
145
+ def extract_negation(parent_element, entry)
146
+ 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")
147
+ negation_indicator = parent_element['negationInd']
148
+ # Return and do not set negationRationale attribute if the entry is not negated
149
+ return unless negation_indicator.eql?('true')
150
+
151
+ entry.negationRationale = code_if_present(negation_element.first) unless negation_element.blank?
152
+ extract_negated_code(parent_element, entry)
146
153
  end
147
154
 
148
- def extract_negated_code(coded_parent_element, entry)
149
- code_elements = coded_parent_element.xpath(@code_xpath)
155
+ def extract_negated_code(parent_element, entry)
156
+ code_elements = parent_element.xpath(@code_xpath)
150
157
  code_elements.each do |code_element|
151
158
  if code_element['nullFlavor'] == 'NA' && code_element['sdtc:valueSet']
152
159
  entry.dataElementCodes = [{ code: code_element['sdtc:valueSet'], codeSystem: 'NA_VALUESET' }]
@@ -157,7 +164,7 @@ module QRDA
157
164
  def extract_scalar(parent_element, scalar_xpath)
158
165
  scalar_element = parent_element.at_xpath(scalar_xpath)
159
166
  return unless scalar_element
160
- QDM::Quantity.new(scalar_element['value'].to_i, scalar_element['unit'])
167
+ QDM::Quantity.new(scalar_element['value'].to_f, scalar_element['unit'])
161
168
  end
162
169
 
163
170
  def extract_components(parent_element)
@@ -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
 
@@ -9,6 +9,7 @@ module QRDA
9
9
  @relevant_period_xpath = "./cda:effectiveTime"
10
10
  @anatomical_location_site_xpath = "./cda:targetSiteCode"
11
11
  @anatomical_approach_site_xpath = "./cda:approachSiteCode"
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::DeviceApplied
13
14
  end
14
15
 
@@ -16,6 +17,7 @@ module QRDA
16
17
  device_applied = super
17
18
  device_applied.anatomicalLocationSite = code_if_present(entry_element.at_xpath(@anatomical_location_site_xpath))
18
19
  device_applied.anatomicalApproachSite = code_if_present(entry_element.at_xpath(@anatomical_approach_site_xpath))
20
+ device_applied.reason = extract_reason(entry_element)
19
21
  device_applied
20
22
  end
21
23
 
@@ -6,11 +6,13 @@ module QRDA
6
6
  @id_xpath = './cda:entryRelationship/cda:supply/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
 
@@ -7,12 +7,14 @@ module QRDA
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
9
  @method_xpath = './cda:methodCode'
10
+ @reason_xpath = "./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::DiagnosticStudyOrder
11
12
  end
12
13
 
13
14
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
14
15
  diagnostic_study_order = super
15
16
  diagnostic_study_order.method = code_if_present(entry_element.at_xpath(@method_xpath))
17
+ diagnostic_study_order.reason = extract_reason(entry_element)
16
18
  diagnostic_study_order
17
19
  end
18
20
 
@@ -13,6 +13,7 @@ module QRDA
13
13
  @method_xpath = './cda:methodCode'
14
14
  @facility_location_xpath = "./cda:participant[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.100']/cda:participantRole[@classCode='SDLOC']/cda:code"
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
 
@@ -23,6 +24,7 @@ module QRDA
23
24
  diagnostic_study_performed.method = code_if_present(entry_element.at_xpath(@method_xpath))
24
25
  diagnostic_study_performed.facilityLocation = code_if_present(entry_element.at_xpath(@facility_location_xpath))
25
26
  diagnostic_study_performed.components = extract_components(entry_element)
27
+ diagnostic_study_performed.reason = extract_reason(entry_element)
26
28
  diagnostic_study_performed
27
29
  end
28
30
 
@@ -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_location_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']/cda:participantRole[@classCode='SDLOC']/cda:code"
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 = code_if_present(entry_element.at_xpath(@facility_location_xpath))
17
+ encounter_order.reason = extract_reason(entry_element)
16
18
  encounter_order
17
19
  end
18
20
 
@@ -5,11 +5,13 @@ module QRDA
5
5
  super(entry_finder)
6
6
  @relevant_period_xpath = nil
7
7
  @author_datetime_xpath = "./cda:effectiveTime"
8
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
8
9
  @entry_class = QDM::ImmunizationAdministered
9
10
  end
10
11
 
11
12
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
12
13
  immunization_administered = super
14
+ immunization_administered.reason = extract_reason(entry_element)
13
15
  immunization_administered
14
16
  end
15
17
 
@@ -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[@typeCode='REFR']/cda:observation/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
 
@@ -7,12 +7,14 @@ module QRDA
7
7
  @code_xpath = './cda:code'
8
8
  @author_datetime_xpath = "./cda:author/cda:time"
9
9
  @method_xpath = './cda:methodCode'
10
+ @reason_xpath = "./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::LaboratoryTestOrder
11
12
  end
12
13
 
13
14
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
14
15
  laboratory_test_order = super
15
16
  laboratory_test_order.method = code_if_present(entry_element.at_xpath(@method_xpath))
17
+ laboratory_test_order.reason = extract_reason(entry_element)
16
18
  laboratory_test_order
17
19
  end
18
20
 
@@ -12,6 +12,7 @@ module QRDA
12
12
  @result_xpath = "./cda:entryRelationship[@typeCode='REFR']/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:templateId/@root = '2.16.840.1.113883.10.20.22.4.2']/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
 
@@ -4,11 +4,13 @@ module QRDA
4
4
  def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.42']"))
5
5
  super(entry_finder)
6
6
  @route_xpath = "./cda:routeCode"
7
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
7
8
  @entry_class = QDM::MedicationAdministered
8
9
  end
9
10
 
10
11
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
11
12
  medication_administered = super
13
+ medication_administered.reason = extract_reason(entry_element)
12
14
  medication_administered
13
15
  end
14
16
 
@@ -3,11 +3,13 @@ module QRDA
3
3
  class MedicationOrderImporter < MedicationImporter
4
4
  def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.47']"))
5
5
  super(entry_finder)
6
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
6
7
  @entry_class = QDM::MedicationOrder
7
8
  end
8
9
 
9
10
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
10
11
  medication_order = super
12
+ medication_order.reason = extract_reason(entry_element)
11
13
  medication_order
12
14
  end
13
15
 
@@ -11,6 +11,7 @@ module QRDA
11
11
  @result_xpath = "./cda:value"
12
12
  @anatomical_location_site_xpath = "./cda:targetSiteCode"
13
13
  @components_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.149']"
14
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
14
15
  @entry_class = QDM::PhysicalExamPerformed
15
16
  end
16
17
 
@@ -19,6 +20,7 @@ module QRDA
19
20
  physical_exam_performed.method = code_if_present(entry_element.at_xpath(@method_xpath))
20
21
  physical_exam_performed.anatomicalLocationSite = code_if_present(entry_element.at_xpath(@anatomical_location_site_xpath))
21
22
  physical_exam_performed.components = extract_components(entry_element)
23
+ physical_exam_performed.reason = extract_reason(entry_element)
22
24
  physical_exam_performed
23
25
  end
24
26
 
@@ -10,6 +10,7 @@ module QRDA
10
10
  @anatomical_approach_site_xpath = "./cda:approachSiteCode"
11
11
  @anatomical_location_site_xpath = "./cda:targetSiteCode"
12
12
  @ordinality_xpath = "./cda:priorityCode"
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::ProcedureOrder
14
15
  end
15
16
 
@@ -19,6 +20,7 @@ module QRDA
19
20
  procedure_order.anatomicalApproachSite = code_if_present(entry_element.at_xpath(@anatomical_approach_site_xpath))
20
21
  procedure_order.anatomicalLocationSite = code_if_present(entry_element.at_xpath(@anatomical_location_site_xpath))
21
22
  procedure_order.ordinality = code_if_present(entry_element.at_xpath(@ordinality_xpath))
23
+ procedure_order.reason = extract_reason(entry_element)
22
24
  procedure_order
23
25
  end
24
26
 
@@ -15,6 +15,7 @@ module QRDA
15
15
  @ordinality_xpath = "./cda:priorityCode"
16
16
  @incision_datetime_xpath = "./cda:entryRelationship/cda:procedure[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.89']/cda:effectiveTime"
17
17
  @components_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.149']"
18
+ @reason_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
18
19
  @entry_class = QDM::ProcedurePerformed
19
20
  end
20
21
 
@@ -27,6 +28,7 @@ module QRDA
27
28
  procedure_performed.ordinality = code_if_present(entry_element.at_xpath(@ordinality_xpath))
28
29
  procedure_performed.incisionDatetime = extract_time(entry_element, @incision_datetime_xpath)
29
30
  procedure_performed.components = extract_components(entry_element)
31
+ procedure_performed.reason = extract_reason(entry_element)
30
32
  procedure_performed
31
33
  end
32
34
 
@@ -1,9 +1,9 @@
1
1
  module QRDA
2
2
  module Cat1
3
- class SubstanceAdministeredImporter < MedicationAdministeredImporter
3
+ class SubstanceAdministeredImporter < MedicationImporter
4
4
  def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.42']"))
5
5
  super(entry_finder)
6
- @entry_does_not_have_reason = true
6
+ @route_xpath = "./cda:routeCode"
7
7
  @entry_class = QDM::SubstanceAdministered
8
8
  end
9
9
 
@@ -92,7 +92,7 @@ module QRDA
92
92
  next unless data_element.respond_to?(:relatedTo) && data_element.relatedTo
93
93
  relations_to_add = []
94
94
  data_element.relatedTo.each do |related_to|
95
- relations_to_add << entry_id_map[related_to.value]
95
+ relations_to_add << entry_id_map["#{related_to.value}_#{related_to.namingSystem}"]
96
96
  end
97
97
  data_element.relatedTo.destroy
98
98
  relations_to_add.each do |relation_to_add|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cqm-parsers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - The MITRE Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-30 00:00:00.000000000 Z
11
+ date: 2019-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustache
@@ -411,7 +411,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
411
411
  version: '0'
412
412
  requirements: []
413
413
  rubyforge_project:
414
- rubygems_version: 2.7.9
414
+ rubygems_version: 2.6.14
415
415
  signing_key:
416
416
  specification_version: 4
417
417
  summary: A library for parsing HQMF documents.