cqm-reports 2.0.0 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +1 -1
  3. data/README.md +8 -6
  4. data/lib/cqm_report.rb +1 -3
  5. data/lib/qrda-export/catI-r5/qrda_templates/allergy_intolerance.mustache +1 -6
  6. data/lib/qrda-export/catI-r5/qrda_templates/communication_performed.mustache +6 -4
  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/diagnosis.mustache +1 -6
  10. data/lib/qrda-export/catI-r5/qrda_templates/encounter_order.mustache +4 -4
  11. data/lib/qrda-export/catI-r5/qrda_templates/encounter_performed.mustache +4 -4
  12. data/lib/qrda-export/catI-r5/qrda_templates/encounter_recommended.mustache +4 -4
  13. data/lib/qrda-export/catI-r5/qrda_templates/immunization_administered.mustache +1 -1
  14. data/lib/qrda-export/catI-r5/qrda_templates/medication_discharge.mustache +0 -3
  15. data/lib/qrda-export/catI-r5/qrda_templates/medication_dispensed.mustache +4 -4
  16. data/lib/qrda-export/catI-r5/qrda_templates/physical_exam_performed.mustache +4 -0
  17. data/lib/qrda-export/catI-r5/qrda_templates/symptom.mustache +1 -6
  18. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_immunization_details.mustache +2 -2
  19. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_medication_details.mustache +5 -1
  20. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_medication_supply_request.mustache +1 -1
  21. data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_results.mustache +0 -12
  22. data/lib/qrda-export/helper/aggregate_object_helper.rb +1 -1
  23. data/lib/qrda-export/helper/cat1_view_helper.rb +9 -0
  24. data/lib/qrda-import/base-importers/section_importer.rb +30 -26
  25. data/lib/qrda-import/data-element-importers/assessment_order_importer.rb +2 -0
  26. data/lib/qrda-import/data-element-importers/assessment_performed_importer.rb +2 -0
  27. data/lib/qrda-import/data-element-importers/assessment_recommended_importer.rb +2 -0
  28. data/lib/qrda-import/data-element-importers/communication_performed_importer.rb +1 -2
  29. data/lib/qrda-import/data-element-importers/device_applied_importer.rb +2 -0
  30. data/lib/qrda-import/data-element-importers/device_order_importer.rb +2 -0
  31. data/lib/qrda-import/data-element-importers/device_recommended_importer.rb +2 -0
  32. data/lib/qrda-import/data-element-importers/diagnostic_study_order_importer.rb +2 -0
  33. data/lib/qrda-import/data-element-importers/diagnostic_study_performed_importer.rb +2 -0
  34. data/lib/qrda-import/data-element-importers/encounter_order_importer.rb +2 -0
  35. data/lib/qrda-import/data-element-importers/encounter_recommended_importer.rb +2 -0
  36. data/lib/qrda-import/data-element-importers/immunization_administered_importer.rb +2 -0
  37. data/lib/qrda-import/data-element-importers/immunization_order_importer.rb +2 -0
  38. data/lib/qrda-import/data-element-importers/intervention_order_importer.rb +2 -0
  39. data/lib/qrda-import/data-element-importers/intervention_performed_importer.rb +2 -0
  40. data/lib/qrda-import/data-element-importers/intervention_recommended_importer.rb +2 -0
  41. data/lib/qrda-import/data-element-importers/laboratory_test_order_importer.rb +2 -0
  42. data/lib/qrda-import/data-element-importers/laboratory_test_performed_importer.rb +2 -0
  43. data/lib/qrda-import/data-element-importers/laboratory_test_recommended_importer.rb +2 -0
  44. data/lib/qrda-import/data-element-importers/medication_administered_importer.rb +2 -0
  45. data/lib/qrda-import/data-element-importers/medication_dispensed_importer.rb +0 -1
  46. data/lib/qrda-import/data-element-importers/medication_order_importer.rb +2 -0
  47. data/lib/qrda-import/data-element-importers/patient_characteristic_clinical_trial_participant_importer.rb +2 -0
  48. data/lib/qrda-import/data-element-importers/physical_exam_order_importer.rb +2 -0
  49. data/lib/qrda-import/data-element-importers/physical_exam_performed_importer.rb +2 -0
  50. data/lib/qrda-import/data-element-importers/physical_exam_recommended_importer.rb +2 -0
  51. data/lib/qrda-import/data-element-importers/procedure_order_importer.rb +2 -0
  52. data/lib/qrda-import/data-element-importers/procedure_performed_importer.rb +2 -0
  53. data/lib/qrda-import/data-element-importers/procedure_recommended_importer.rb +2 -0
  54. data/lib/qrda-import/data-element-importers/substance_administered_importer.rb +0 -1
  55. data/lib/qrda-import/data-element-importers/substance_order_importer.rb +2 -0
  56. data/lib/qrda-import/data-element-importers/substance_recommended_importer.rb +2 -0
  57. data/lib/qrda-import/patient_importer.rb +28 -7
  58. metadata +16 -17
  59. data/lib/ext/code.rb +0 -11
  60. data/lib/ext/data_element.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 9f52ee70f2be4c43ccf9c3d918ed805a323d942d1768d5621967c9232ea303c5
4
- data.tar.gz: c866224aca04b6760a35a3fd0f8d78e03c5fe85d9bff0a4d41a8af907eebf995
2
+ SHA1:
3
+ metadata.gz: dd0b9911f4358fceaa323afe6557281f181c2357
4
+ data.tar.gz: 2c2ba002d028ff2870fb7d6622231984611d0b9d
5
5
  SHA512:
6
- metadata.gz: 42797a2e8c76511344a48f803034e6d5bc4bf1468b5fcd8853f53a10cea295413a96fea7299767dbfcef6b0cf7663e9f9e648715c3f3c7bb412e09391e08bb68
7
- data.tar.gz: 94dc517b00e37117d00eea8ca516103bc3fa21af59457c7697e4299a4d2c92d8f46090fca4103cdfdbaede0aa6e130e3a52e3af1395564d447ccff712959cbd7
6
+ metadata.gz: 7980f689cd77ad9e2ba0869f89abdd1867a065108cbe8b9e534c7547de51fe3ded3169fc67e49826240bfe821e7bba779e0a1dc02a34955505e26afb6197e396
7
+ data.tar.gz: d37767e44596b127a5ea5197cb9c18dcdb36450661c23817ca84366e9a04ab7eebe4744d4e26e69682c76f4dd82bcd237667d46138cb4ec32f85a2b710b0df83
data/Gemfile CHANGED
@@ -28,6 +28,6 @@ group :test do
28
28
  gem 'minitest', '~> 5.3'
29
29
  gem 'minitest-reporters'
30
30
  gem 'awesome_print', :require => 'ap'
31
- gem 'cqm-validators', git: 'https://github.com/projecttacoma/cqm-validators.git', branch: 'master'
31
+ gem 'cqm-validators'
32
32
  gem 'nokogiri-diff'
33
33
  end
data/README.md CHANGED
@@ -4,15 +4,17 @@ A library for import and export of reports for use with electronic Clinical Qual
4
4
  Versioning
5
5
  ==========
6
6
 
7
- Starting with version **1.0.0.0** released on 5/22/2019, cqm-reports versioning has the format **W.X.Y.Z**, where:
7
+ Starting with version **2.0.0** released on 6/20/2019, cqm-reports versioning has the format **X.Y.Z**, where:
8
8
 
9
- * **W** maps to a version of QRDA Category 1 and QRDA Category 3. See the table below to see the existing mapping to QRDA versions.
9
+ * **X** maps to a version of QRDA. See the table below to see the existing mapping to QRDA versions.
10
10
 
11
- | W | QRDA Cat 1 | QRDA Cat 3 |
11
+ | X | QRDA Cat 1 | QRDA Cat 3 |
12
12
  | --- | --- | --- |
13
- | 1 | R1 STU5.1 | R1 STU2.1 |
13
+ | 2 | R1 STU5.1 | R1 STU2.1 |
14
14
 
15
- * **X.Y.Z** uses [SemVer](http://semver.org/) for versioning. **X.Y.Z** starts at 0.0.0 when **W** is incremented.
15
+ * **Y** indicates major changes (incompatible API changes)
16
+
17
+ * **Z** indicates minor changes (added functionality in a backwards-compatible manner) and patch changes (backwards-compatible bug fixes)
16
18
 
17
19
  For the versions available, see [tags on this repository](https://github.com/projecttacoma/cqm-validators/tags).
18
20
 
@@ -24,4 +26,4 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
24
26
 
25
27
  http://www.apache.org/licenses/LICENSE-2.0
26
28
 
27
- Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
29
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@@ -72,6 +72,4 @@ require_relative 'qrda-import/data-element-importers/substance_administered_impo
72
72
  require_relative 'qrda-import/data-element-importers/substance_order_importer.rb'
73
73
  require_relative 'qrda-import/data-element-importers/substance_recommended_importer.rb'
74
74
  require_relative 'qrda-import/data-element-importers/symptom_importer.rb'
75
- require_relative 'qrda-import/patient_importer.rb'
76
- require_relative 'ext/data_element.rb'
77
- require_relative 'ext/code.rb'
75
+ require_relative 'qrda-import/patient_importer.rb'
@@ -6,13 +6,8 @@
6
6
  <templateId root="2.16.840.1.113883.10.20.24.3.147" extension="2017-08-01"/>
7
7
  <id root="1.3.6.1.4.1.115" extension="{{object_id}}"/>
8
8
  <code code="ASSERTION" codeSystem="2.16.840.1.113883.5.4"/>
9
- {{#prevalencePeriod}}
10
- {{#completed_prevalence_period}}
11
9
  <statusCode code="completed" />
12
- {{/completed_prevalence_period}}
13
- {{^completed_prevalence_period}}
14
- <statusCode code="active" />
15
- {{/completed_prevalence_period}}
10
+ {{#prevalencePeriod}}
16
11
  <!-- QDM Attribute: Prevalence Period -->
17
12
  {{{prevalence_period}}}
18
13
  {{/prevalencePeriod}}
@@ -6,6 +6,10 @@
6
6
  <!-- QDM Attribute: Category -->
7
7
  <code {{> _code}}/>
8
8
  {{/category}}
9
+ {{^category}}
10
+ <!-- QDM Attribute: Category -->
11
+ <code nullFlavor="NA"/>
12
+ {{/category}}
9
13
  <statusCode code="completed"/>
10
14
  {{#relevantPeriod}}
11
15
  <!-- QDM Attribute: Relevant Period -->
@@ -42,10 +46,9 @@
42
46
  <!-- QDM Attribute: Negation Rationale -->
43
47
  {{> qrda_templates/template_partials/_reason}}
44
48
  {{/negationRationale}}
45
- {{^negationRationale}}
46
- <entryRelationship typeCode="RSON">
49
+ <entryRelationship typeCode="REFR">
47
50
  <observation classCode="OBS" moodCode="EVN">
48
- <templateId root="2.16.840.1.113883.10.20.24.3.88" extension="2014-12-01"/>
51
+ <templateId root="2.16.840.1.113883.10.20.24.3.88" extension="2017-08-01"/>
49
52
  <id root="1.3.6.1.4.1.115" extension="{{object_id}}" />
50
53
  <code code="77301-0" codeSystem="2.16.840.1.113883.6.1" displayName="reason" codeSystemName="LOINC"/>
51
54
  <statusCode code="completed"/>
@@ -53,7 +56,6 @@
53
56
  {{> qrda_templates/template_partials/_data_element_codes_as_values}}
54
57
  </observation>
55
58
  </entryRelationship>
56
- {{/negationRationale}}
57
59
  {{#relatedTo}}
58
60
  <!-- QDM Attribute: relatedTo -->
59
61
  {{> qrda_templates/template_partials/_related_to}}
@@ -28,11 +28,11 @@
28
28
  <!-- QDM Attribute: Reason -->
29
29
  {{> qrda_templates/template_partials/_reason}}
30
30
  {{/reason}}
31
- {{#negationRationale}}
32
- <!-- QDM Attribute: Negation Rationale -->
33
- {{> qrda_templates/template_partials/_reason}}
34
- {{/negationRationale}}
35
31
  </supply>
36
32
  </entryRelationship>
33
+ {{#negationRationale}}
34
+ <!-- QDM Attribute: Negation Rationale -->
35
+ {{> qrda_templates/template_partials/_reason}}
36
+ {{/negationRationale}}
37
37
  </act>
38
38
  </entry>
@@ -27,11 +27,11 @@
27
27
  <!-- QDM Attribute: Reason -->
28
28
  {{> qrda_templates/template_partials/_reason}}
29
29
  {{/reason}}
30
- {{#negationRationale}}
31
- <!-- QDM Attribute: Negation Rationale -->
32
- {{> qrda_templates/template_partials/_reason}}
33
- {{/negationRationale}}
34
30
  </supply>
35
31
  </entryRelationship>
32
+ {{#negationRationale}}
33
+ <!-- QDM Attribute: Negation Rationale -->
34
+ {{> qrda_templates/template_partials/_reason}}
35
+ {{/negationRationale}}
36
36
  </act>
37
37
  </entry>
@@ -25,13 +25,8 @@
25
25
  <code code="29308-4" codeSystem="2.16.840.1.113883.6.1">
26
26
  <translation code="282291009" codeSystem="2.16.840.1.113883.6.96"/>
27
27
  </code>
28
- {{#prevalencePeriod}}
29
- {{#completed_prevalence_period}}
30
28
  <statusCode code="completed" />
31
- {{/completed_prevalence_period}}
32
- {{^completed_prevalence_period}}
33
- <statusCode code="active" />
34
- {{/completed_prevalence_period}}
29
+ {{#prevalencePeriod}}
35
30
  <!-- QDM Attribute: Prevalence Period -->
36
31
  {{{prevalence_period}}}
37
32
  {{/prevalencePeriod}}
@@ -25,11 +25,11 @@
25
25
  <!-- QDM Attribute: Reason -->
26
26
  {{> qrda_templates/template_partials/_reason}}
27
27
  {{/reason}}
28
- {{#negationRationale}}
29
- <!-- QDM Attribute: Negation Rationale -->
30
- {{> qrda_templates/template_partials/_reason}}
31
- {{/negationRationale}}
32
28
  </encounter>
33
29
  </entryRelationship>
30
+ {{#negationRationale}}
31
+ <!-- QDM Attribute: Negation Rationale -->
32
+ {{> qrda_templates/template_partials/_reason}}
33
+ {{/negationRationale}}
34
34
  </act>
35
35
  </entry>
@@ -42,11 +42,11 @@
42
42
  <!-- QDM Attribute: Diagnoses -->
43
43
  {{> qrda_templates/template_partials/_encounter_diagnosis}}
44
44
  {{/diagnoses}}
45
- {{#negationRationale}}
46
- <!-- QDM Attribute: Negation Rationale -->
47
- {{> qrda_templates/template_partials/_reason}}
48
- {{/negationRationale}}
49
45
  </encounter>
50
46
  </entryRelationship>
47
+ {{#negationRationale}}
48
+ <!-- QDM Attribute: Negation Rationale -->
49
+ {{> qrda_templates/template_partials/_reason}}
50
+ {{/negationRationale}}
51
51
  </act>
52
52
  </entry>
@@ -27,11 +27,11 @@
27
27
  <!-- QDM Attribute: Reason -->
28
28
  {{> qrda_templates/template_partials/_reason}}
29
29
  {{/reason}}
30
- {{#negationRationale}}
31
- <!-- QDM Attribute: Negation Rationale -->
32
- {{> qrda_templates/template_partials/_reason}}
33
- {{/negationRationale}}
34
30
  </encounter>
35
31
  </entryRelationship>
32
+ {{#negationRationale}}
33
+ <!-- QDM Attribute: Negation Rationale -->
34
+ {{> qrda_templates/template_partials/_reason}}
35
+ {{/negationRationale}}
36
36
  </act>
37
37
  </entry>
@@ -1,7 +1,7 @@
1
1
  <entry>
2
2
  <substanceAdministration classCode="SBADM" moodCode="EVN" {{{negation_ind}}}>
3
3
  <!-- C-CDA R2 Immunization Activity -->
4
- <templateId root="2.16.840.1.113883.10.20.22.4.52" extension="2014-06-09"/>
4
+ <templateId root="2.16.840.1.113883.10.20.22.4.52" extension="2015-08-01"/>
5
5
  <!-- Immunization Administered -->
6
6
  <templateId root="2.16.840.1.113883.10.20.24.3.140" extension="2017-08-01"/>
7
7
  <id root="1.3.6.1.4.1.115" extension="{{object_id}}"/>
@@ -35,9 +35,6 @@
35
35
  {{#authorDatetime}}
36
36
  {{> qrda_templates/template_partials/_author_participation}}
37
37
  {{/authorDatetime}}
38
- {{#negationRationale}}
39
- {{> qrda_templates/template_partials/_reason}}
40
- {{/negationRationale}}
41
38
  </substanceAdministration>
42
39
  </entryRelationship>
43
40
  {{#reason}}
@@ -60,11 +60,11 @@
60
60
  {{> qrda_templates/template_partials/_medication_supply_request}}
61
61
  </entryRelationship>
62
62
  {{/supply}}
63
- {{#negationRationale}}
64
- <!-- QDM Attribute: Negation Rationale -->
65
- {{> qrda_templates/template_partials/_reason}}
66
- {{/negationRationale}}
67
63
  </supply>
68
64
  </entryRelationship>
65
+ {{#negationRationale}}
66
+ <!-- QDM Attribute: Negation Rationale -->
67
+ {{> qrda_templates/template_partials/_reason}}
68
+ {{/negationRationale}}
69
69
  </act>
70
70
  </entry>
@@ -17,6 +17,10 @@
17
17
  <!-- QDM Attribute: Result -->
18
18
  {{{result_value}}}
19
19
  {{/result}}
20
+ {{^result}}
21
+ <!-- QDM Attribute: Result -->
22
+ <value xsi:type="CD" nullFlavor="UNK"/>
23
+ {{/result}}
20
24
  {{#method}}
21
25
  <!-- QDM Attribute: Method -->
22
26
  {{> qrda_templates/template_partials/_method}}
@@ -25,13 +25,8 @@
25
25
  <code code="75325-1" codeSystem="2.16.840.1.113883.6.1">
26
26
  <translation code="418799008" displayName="Symptom" codeSystem="2.16.840.1.113883.6.96"/>
27
27
  </code>
28
- {{#prevalencePeriod}}
29
- {{#completed_prevalence_period}}
30
28
  <statusCode code="completed" />
31
- {{/completed_prevalence_period}}
32
- {{^completed_prevalence_period}}
33
- <statusCode code="active" />
34
- {{/completed_prevalence_period}}
29
+ {{#prevalencePeriod}}
35
30
  <!-- QDM Attribute: Prevalence Period -->
36
31
  {{{prevalence_period}}}
37
32
  {{/prevalencePeriod}}
@@ -8,7 +8,7 @@
8
8
  {{/negated}}
9
9
  {{^negated}}
10
10
  {{#dosage}}
11
- <!-- QDM Attribute: Dosage -->
12
- <doseQuantity value="{{value}}" unit="{{unit}}"/>
11
+ <!-- QDM Attribute: Dosage -->
12
+ {{{dose_quantity_value}}}
13
13
  {{/dosage}}
14
14
  {{/negated}}
@@ -30,7 +30,11 @@
30
30
  {{/negated}}
31
31
  {{^negated}}
32
32
  {{#dosage}}
33
+ <!-- QDM Attribute: Dosage -->
34
+ {{{dose_quantity_value}}}
35
+ {{/dosage}}
36
+ {{^dosage}}
33
37
  <!-- QDM Attribute: Dosage -->
34
- <doseQuantity value="{{value}}" unit="{{unit}}"/>
38
+ <doseQuantity nullFlavor="UNK"/>
35
39
  {{/dosage}}
36
40
  {{/negated}}
@@ -13,5 +13,5 @@
13
13
  {{{author_effective_time}}}
14
14
  {{/authorDatetime}}
15
15
  {{/relevantPeriod}}
16
- <quantity value="{{value}}"/>
16
+ <quantity value="{{{value_as_float}}}"/>
17
17
  </supply>
@@ -5,19 +5,7 @@
5
5
  <id root="1.3.6.1.4.1.115" extension="{{random_id}}"/>
6
6
  {{> _codes}}
7
7
  <statusCode code="completed"/>
8
- {{#resultDatetime}}
9
8
  {{{result_date_time}}}
10
- {{/resultDatetime}}
11
- {{^resultDatetime}}
12
- {{#relevantPeriod}}
13
- {{{relevant_period_as_value}}}
14
- {{/relevantPeriod}}
15
- {{^relevantPeriod}}
16
- {{#authorDatetime}}
17
- {{{author_effective_time}}}
18
- {{/authorDatetime}}
19
- {{/relevantPeriod}}
20
- {{/resultDatetime}}
21
9
  {{{result_value}}}
22
10
  </observation>
23
11
  </entryRelationship>
@@ -120,7 +120,7 @@ module Qrda
120
120
  end
121
121
  entry_populations << population if population
122
122
  end
123
- return if population_groups.find {|pg| pg.populations.collect(&:id).sort == entry_populations.collect(&:id).sort }
123
+ return if population_groups.find {|pg| pg.populations.collect(&:id).compact.sort == entry_populations.collect(&:id).compact.sort }
124
124
 
125
125
  pg = PopulationGroup.new
126
126
  pg.populations = entry_populations
@@ -51,6 +51,15 @@ module Qrda
51
51
  translation_list
52
52
  end
53
53
 
54
+ def value_as_float
55
+ self['value'].to_f
56
+ end
57
+
58
+ def dose_quantity_value
59
+ return "<doseQuantity value=\"#{value_as_float}\" unit=\"#{self['unit']}\"/>" if self['unit']
60
+ "<doseQuantity value=\"#{value_as_float}\" />"
61
+ end
62
+
54
63
  def result_value
55
64
  return "<value xsi:type=\"CD\" nullFlavor=\"UNK\"/>" unless self['result']
56
65
 
@@ -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
 
@@ -95,13 +95,13 @@ module QRDA
95
95
  high_time = DateTime.parse(parent_element.at_xpath(interval_xpath)['value'])
96
96
  end
97
97
  if parent_element.at_xpath("#{interval_xpath}/cda:low")
98
- 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
99
101
  end
100
102
  if parent_element.at_xpath("#{interval_xpath}/cda:high")
101
103
  high_time = if parent_element.at_xpath("#{interval_xpath}/cda:high")['value']
102
104
  DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:high")['value'])
103
- else
104
- DateTime.new(9999,1,1)
105
105
  end
106
106
  end
107
107
  if parent_element.at_xpath("#{interval_xpath}/cda:center")
@@ -125,8 +125,7 @@ module QRDA
125
125
  # If a Direct Reference Code isn't found, return nil
126
126
  return nil unless key
127
127
  # If a Direct Reference Code is found, return that code
128
- oid = value[:codeSystem] || value[:codeSystemOid]
129
- QDM::Code.new(key, oid)
128
+ QDM::Code.new(key, value[:code_system])
130
129
  end
131
130
 
132
131
  def extract_frequency_in_hours(parent_element, frequency_xpath)
@@ -140,7 +139,8 @@ module QRDA
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,32 +158,36 @@ 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
193
  entry.dataElementCodes = [{ code: code_element['sdtc:valueSet'], codeSystemOid: '1.2.3.4.5.6.7.8.9.10' }]
@@ -193,9 +197,9 @@ module QRDA
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)