health-data-standards 3.6.1 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (434) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -2
  3. data/Rakefile +2 -1
  4. data/lib/health-data-standards.rb +22 -1
  5. data/lib/health-data-standards/export/cat_1.rb +25 -6
  6. data/lib/health-data-standards/export/cat_1_r2.rb +8 -2
  7. data/lib/health-data-standards/export/cat_3.rb +8 -7
  8. data/lib/health-data-standards/export/exceptions.rb +13 -0
  9. data/lib/health-data-standards/export/helper/cat1_view_helper.rb +17 -11
  10. data/lib/health-data-standards/export/helper/html_view_helper.rb +13 -7
  11. data/lib/health-data-standards/export/helper/scooped_view_helper.rb +68 -25
  12. data/lib/health-data-standards/export/html.rb +9 -4
  13. data/lib/health-data-standards/export/qrda/entry_template_resolver.rb +29 -11
  14. data/lib/health-data-standards/export/qrda/hqmf-qrda-oids.json +89 -5
  15. data/lib/health-data-standards/export/rendering_context.rb +2 -2
  16. data/lib/health-data-standards/export/template_helper.rb +7 -2
  17. data/lib/health-data-standards/export/view_helper.rb +107 -39
  18. data/lib/health-data-standards/import/bulk_record_importer.rb +8 -5
  19. data/lib/health-data-standards/import/bundle/importer.rb +21 -14
  20. data/lib/health-data-standards/import/c32/care_goal_importer.rb +1 -1
  21. data/lib/health-data-standards/import/c32/immunization_importer.rb +1 -1
  22. data/lib/health-data-standards/import/cat1/clinical_trial_participant_importer.rb +20 -0
  23. data/lib/health-data-standards/import/cat1/device_order_importer.rb +20 -0
  24. data/lib/health-data-standards/import/cat1/diagnosis_active_importer.rb +4 -9
  25. data/lib/health-data-standards/import/cat1/diagnosis_importer.rb +15 -0
  26. data/lib/health-data-standards/import/cat1/diagnosis_inactive_importer.rb +1 -1
  27. data/lib/health-data-standards/import/cat1/diagnostic_study_order_importer.rb +6 -0
  28. data/lib/health-data-standards/import/cat1/encounter_order_act_importer.rb +19 -0
  29. data/lib/health-data-standards/import/cat1/encounter_performed_act_importer.rb +19 -0
  30. data/lib/health-data-standards/import/cat1/encounter_performed_importer.rb +16 -0
  31. data/lib/health-data-standards/import/cat1/immunization_administered_importer.rb +14 -0
  32. data/lib/health-data-standards/import/cat1/medication_dispensed_act_importer.rb +18 -0
  33. data/lib/health-data-standards/import/cat1/patient_importer.rb +44 -17
  34. data/lib/health-data-standards/import/cat1/procedure_order_importer.rb +4 -4
  35. data/lib/health-data-standards/import/cat1/procedure_performed_importer.rb +1 -0
  36. data/lib/health-data-standards/import/cat1/transfer_from_act_importer.rb +18 -0
  37. data/lib/health-data-standards/import/cat1/transfer_from_importer.rb +24 -0
  38. data/lib/health-data-standards/import/cat1/transfer_to_act_importer.rb +18 -0
  39. data/lib/health-data-standards/import/cat1/transfer_to_importer.rb +23 -0
  40. data/lib/health-data-standards/import/cda/allergy_importer.rb +1 -1
  41. data/lib/health-data-standards/import/cda/communication_importer.rb +55 -0
  42. data/lib/health-data-standards/import/cda/condition_importer.rb +17 -1
  43. data/lib/health-data-standards/import/cda/encounter_importer.rb +23 -21
  44. data/lib/health-data-standards/import/cda/medical_equipment_importer.rb +1 -0
  45. data/lib/health-data-standards/import/cda/medication_importer.rb +14 -4
  46. data/lib/health-data-standards/import/cda/procedure_importer.rb +4 -4
  47. data/lib/health-data-standards/import/cda/result_importer.rb +1 -1
  48. data/lib/health-data-standards/import/cda/section_importer.rb +59 -18
  49. data/lib/health-data-standards/models/assessment.rb +3 -0
  50. data/lib/health-data-standards/models/care_experience.rb +2 -0
  51. data/lib/health-data-standards/models/care_goal.rb +4 -0
  52. data/lib/health-data-standards/models/communication.rb +3 -0
  53. data/lib/health-data-standards/models/condition.rb +12 -9
  54. data/lib/health-data-standards/models/cqm/bundle.rb +2 -1
  55. data/lib/health-data-standards/models/cqm/measure.rb +2 -1
  56. data/lib/health-data-standards/models/cqm/patient_cache.rb +7 -3
  57. data/lib/health-data-standards/models/cqm/query_cache.rb +2 -0
  58. data/lib/health-data-standards/models/encounter.rb +14 -1
  59. data/lib/health-data-standards/models/encounter_principal_diagnosis.rb +36 -0
  60. data/lib/health-data-standards/models/entry.rb +5 -1
  61. data/lib/health-data-standards/models/family_history.rb +4 -0
  62. data/lib/health-data-standards/models/immunization.rb +1 -0
  63. data/lib/health-data-standards/models/lab_result.rb +10 -1
  64. data/lib/health-data-standards/models/medical_equipment.rb +2 -1
  65. data/lib/health-data-standards/models/medication.rb +19 -2
  66. data/lib/health-data-standards/models/patient_preference.rb +5 -0
  67. data/lib/health-data-standards/models/procedure.rb +16 -3
  68. data/lib/health-data-standards/models/provider.rb +17 -1
  69. data/lib/health-data-standards/models/provider_preference.rb +5 -0
  70. data/lib/health-data-standards/models/record.rb +8 -9
  71. data/lib/health-data-standards/models/reference.rb +1 -1
  72. data/lib/health-data-standards/models/svs/value_set.rb +28 -10
  73. data/lib/health-data-standards/models/transfer.rb +6 -1
  74. data/lib/health-data-standards/tasks/bundle.rake +5 -3
  75. data/lib/health-data-standards/util/hqmf_template_helper.rb +20 -14
  76. data/lib/health-data-standards/util/hqmfr2_template_oid_map.json +382 -0
  77. data/lib/health-data-standards/util/nlm_helper.rb +14 -0
  78. data/lib/health-data-standards/util/vs_api.rb +72 -54
  79. data/lib/health-data-standards/validate/measure_validator.rb +8 -3
  80. data/lib/health-data-standards/validate/performance_rate_validator.rb +1 -1
  81. data/lib/health-data-standards/validate/qrda_qdm_template_validator.rb +253 -0
  82. data/lib/health-data-standards/validate/reported_result_extractor.rb +5 -1
  83. data/lib/health-data-standards/validate/schematron_validator.rb +6 -0
  84. data/lib/health-data-standards/validate/validators.rb +49 -1
  85. data/lib/hqmf-generator/document.xml.erb +6 -5
  86. data/lib/hqmf-generator/field.xml.erb +1 -0
  87. data/lib/hqmf-generator/hqmf-generator.rb +85 -41
  88. data/lib/hqmf-generator/subset.xml.erb +15 -0
  89. data/lib/hqmf-generator/temporal_relationship.xml.erb +8 -3
  90. data/lib/hqmf-generator/temporal_relationship_attribute.xml.erb +10 -0
  91. data/lib/hqmf-generator/value.xml.erb +2 -2
  92. data/lib/hqmf-model/data_criteria.json +88 -17
  93. data/lib/hqmf-model/data_criteria.rb +144 -72
  94. data/lib/hqmf-model/population_criteria.rb +20 -18
  95. data/lib/hqmf-model/precondition.rb +6 -3
  96. data/lib/hqmf-model/types.rb +1 -1
  97. data/lib/hqmf-parser.rb +9 -0
  98. data/lib/hqmf-parser/1.0/utilities.rb +1 -1
  99. data/lib/hqmf-parser/2.0/data_criteria.rb +293 -319
  100. data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb +80 -0
  101. data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb +201 -0
  102. data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb +85 -0
  103. data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_specific_occurrences_and_source_data_criteria_extract.rb +117 -0
  104. data/lib/hqmf-parser/2.0/document.rb +246 -222
  105. data/lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb +175 -0
  106. data/lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb +131 -0
  107. data/lib/hqmf-parser/2.0/field_value_helper.rb +251 -0
  108. data/lib/hqmf-parser/2.0/population_criteria.rb +101 -32
  109. data/lib/hqmf-parser/2.0/precondition.rb +61 -35
  110. data/lib/hqmf-parser/2.0/source_data_criteria_helper.rb +112 -0
  111. data/lib/hqmf-parser/2.0/types.rb +253 -73
  112. data/lib/hqmf-parser/2.0/utilities.rb +27 -12
  113. data/lib/hqmf-parser/2.0/value_set_helper.rb +101 -0
  114. data/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb +6 -1
  115. data/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb +34 -30
  116. data/lib/hqmf-parser/parser.rb +5 -5
  117. data/resources/schematron/qrda/cat_1/{CDAR2_QRDA_I_R1_D3_2015MAY_Schematron.sch → HL7_CDAR2_QRDA_Category_I_2_12_16.sch} +4692 -4675
  118. data/resources/schematron/qrda/cat_1_r3_1/HL7 QRDA Category I STU 3.1.sch +3573 -0
  119. data/resources/schematron/qrda/cat_1_r3_1/HL7 QRDA Category III STU 1.1.sch +464 -0
  120. data/resources/schematron/qrda/cat_1_r3_1/QRDA Category I STU Release 3.1.sch +5394 -0
  121. data/resources/schematron/qrda/cat_1_r3_1/voc.xml +1229 -0
  122. data/resources/schematron/qrda/cat_1_r4/HL7 QRDA Category I STU 4.sch +3526 -0
  123. data/resources/schematron/qrda/cat_1_r4/voc.xml +1186 -0
  124. data/resources/schematron/qrda/cat_3_r1_1/HL7 QRDA Category III STU 1.1.sch +528 -0
  125. data/resources/schematron/qrda/cat_3_r1_1/voc.xml +8 -0
  126. data/resources/schematron/qrda/cat_3_r2/HL7 QRDA Category III STU 2.sch +677 -0
  127. data/resources/schematron/qrda/cat_3_r2/voc.xml +1186 -0
  128. data/resources/schematron/qrda/cat_3_r2_1/HL7 QRDA Category III STU 2.1.sch +678 -0
  129. data/resources/schematron/qrda/cat_3_r2_1/voc.xml +1186 -0
  130. data/templates/c32/_medical_equipment.c32.erb +1 -1
  131. data/templates/c32/_vital_signs.c32.erb +1 -1
  132. data/templates/cat1/{_2.16.840.1.113883.10.20.22.4.85.cat1.erb → r2/_2.16.840.1.113883.10.20.22.4.85.cat1.erb} +1 -1
  133. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.1.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.1.cat1.erb} +3 -3
  134. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.101.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.101.cat1.erb} +1 -1
  135. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.103.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.103.cat1.erb} +9 -5
  136. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.105.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.105.cat1.erb} +18 -10
  137. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.11.cat1.erb +88 -0
  138. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.12.cat1.erb +50 -0
  139. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.13.cat1.erb +54 -0
  140. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.135.cat1.erb +70 -0
  141. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.136.cat1.erb +52 -0
  142. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.14.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.14.cat1.erb} +24 -6
  143. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.140.cat1.erb +39 -0
  144. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.17.cat1.erb +23 -0
  145. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.18.cat1.erb +25 -0
  146. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.2.cat1.erb +29 -0
  147. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.20.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.20.cat1.erb} +4 -4
  148. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.22.cat1.erb +22 -0
  149. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.23.cat1.erb +114 -0
  150. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.26.cat1.erb +20 -0
  151. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.28.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.28.cat1.erb} +2 -2
  152. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.3.cat1.erb +25 -0
  153. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.31.cat1.erb +23 -0
  154. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.32.cat1.erb +20 -0
  155. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.34.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.34.cat1.erb} +6 -6
  156. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.37.cat1.erb +22 -0
  157. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.38.cat1.erb +20 -0
  158. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.4.cat1.erb +29 -0
  159. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.40.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.40.cat1.erb} +3 -3
  160. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.41.cat1.erb +46 -0
  161. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.42.cat1.erb +38 -0
  162. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.43.cat1.erb +24 -0
  163. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.44.cat1.erb +25 -0
  164. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.45.cat1.erb +26 -0
  165. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.46.cat1.erb +30 -0
  166. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.47.cat1.erb +47 -0
  167. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.51.cat1.erb +14 -0
  168. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.54.cat1.erb +32 -0
  169. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.55.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.55.cat1.erb} +0 -0
  170. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.57.cat1.erb +23 -0
  171. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.59.cat1.erb +22 -0
  172. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.62.cat1.erb +36 -0
  173. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.63.cat1.erb +21 -0
  174. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.64.cat1.erb +52 -0
  175. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.66.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.66.cat1.erb} +6 -6
  176. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.69.cat1.erb +23 -0
  177. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.7.cat1.erb +33 -0
  178. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.76.cat1.erb → r2/_2.16.840.1.113883.10.20.24.3.76.cat1.erb} +5 -3
  179. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.81.cat1.erb +23 -0
  180. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.82.cat1.erb +23 -0
  181. data/templates/cat1/r2/_2.16.840.1.113883.10.20.24.3.9.cat1.erb +64 -0
  182. data/templates/cat1/r2/_2.16.840.1.113883.10.20.28.3.6.cat1.erb +17 -0
  183. data/templates/cat1/{_address.cat1.erb → r2/_address.cat1.erb} +0 -0
  184. data/templates/cat1/{_author.cat1.erb → r2/_author.cat1.erb} +0 -0
  185. data/templates/cat1/r2/_fulfills.cat1.erb +14 -0
  186. data/templates/cat1/{_id.cat1.erb → r2/_id.cat1.erb} +0 -0
  187. data/templates/cat1/{_measures.cat1.erb → r2/_measures.cat1.erb} +1 -1
  188. data/templates/cat1/{_medication_details.cat1.erb → r2/_medication_details.cat1.erb} +3 -2
  189. data/templates/cat1/r2/_medication_dispense.cat1.erb +22 -0
  190. data/templates/cat1/{_ordinality.cat1.erb → r2/_ordinality.cat1.erb} +0 -0
  191. data/templates/cat1/{_organization.cat1.erb → r2/_organization.cat1.erb} +0 -0
  192. data/templates/cat1/{_patient_data.cat1.erb → r2/_patient_data.cat1.erb} +4 -1
  193. data/templates/cat1/r2/_patient_data_r3_1.cat1.erb +17 -0
  194. data/templates/cat1/r2/_providers.cat1.erb +76 -0
  195. data/templates/cat1/r2/_reason.cat1.erb +45 -0
  196. data/templates/cat1/{_record_target.cat1.erb → r2/_record_target.cat1.erb} +3 -0
  197. data/templates/cat1/r2/_reporting_parameters.cat1.erb +31 -0
  198. data/templates/cat1/{_result_value.cat1.erb → r2/_result_value.cat1.erb} +1 -1
  199. data/templates/cat1/{_telecom.cat1.erb → r2/_telecom.cat1.erb} +0 -0
  200. data/templates/cat1/{show.cat1.erb → r2/show.cat1.erb} +52 -5
  201. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.1.cat1.erb +14 -0
  202. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.103.cat1.erb +17 -0
  203. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.105.cat1.erb +68 -0
  204. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.11.cat1.erb +58 -0
  205. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.12.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.12.cat1.erb} +4 -5
  206. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.13.cat1.erb +39 -0
  207. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.14.cat1.erb +39 -0
  208. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.17.cat1.erb +23 -0
  209. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.18.cat1.erb +25 -0
  210. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.2.cat1.erb +29 -0
  211. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.22.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.22.cat1.erb} +6 -5
  212. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.23.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.23.cat1.erb} +26 -30
  213. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.26.cat1.erb +20 -0
  214. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.3.cat1.erb +25 -0
  215. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.31.cat1.erb +23 -0
  216. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.32.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.32.cat1.erb} +4 -4
  217. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.37.cat1.erb +22 -0
  218. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.38.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.38.cat1.erb} +3 -3
  219. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.4.cat1.erb +29 -0
  220. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.41.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.41.cat1.erb} +8 -10
  221. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.42.cat1.erb +38 -0
  222. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.43.cat1.erb +24 -0
  223. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.44.cat1.erb +25 -0
  224. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.45.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.45.cat1.erb} +5 -5
  225. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.46.cat1.erb +30 -0
  226. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.47.cat1.erb +47 -0
  227. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.51.cat1.erb +14 -0
  228. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.54.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.54.cat1.erb} +4 -4
  229. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.55.cat1.erb +18 -0
  230. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.57.cat1.erb +23 -0
  231. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.59.cat1.erb +22 -0
  232. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.62.cat1.erb +36 -0
  233. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.63.cat1.erb → r3/_2.16.840.1.113883.10.20.24.3.63.cat1.erb} +6 -8
  234. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.64.cat1.erb +51 -0
  235. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.69.cat1.erb +23 -0
  236. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.7.cat1.erb +33 -0
  237. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.76.cat1.erb +19 -0
  238. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.81.cat1.erb +24 -0
  239. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.82.cat1.erb +24 -0
  240. data/templates/cat1/r3/_2.16.840.1.113883.10.20.24.3.9.cat1.erb +57 -0
  241. data/templates/cat1/r3/_address.cat1.erb +9 -0
  242. data/templates/{cat3/_author.cat3.erb → cat1/r3/_author.cat1.erb} +0 -0
  243. data/templates/cat1/{_fulfills.cat1.erb → r3/_fulfills.cat1.erb} +0 -0
  244. data/templates/{cat3/_id.cat3.erb → cat1/r3/_id.cat1.erb} +0 -0
  245. data/templates/cat1/r3/_measures.cat1.erb +93 -0
  246. data/templates/cat1/r3/_medication_details.cat1.erb +16 -0
  247. data/templates/cat1/{_medication_dispense.cat1.erb → r3/_medication_dispense.cat1.erb} +3 -3
  248. data/templates/cat1/r3/_ordinality.cat1.erb +10 -0
  249. data/templates/cat1/r3/_organization.cat1.erb +9 -0
  250. data/templates/cat1/r3/_patient_data.cat1.erb +17 -0
  251. data/templates/cat1/r3/_providers.cat1.erb +76 -0
  252. data/templates/cat1/r3/_reason.cat1.erb +34 -0
  253. data/templates/cat1/r3/_record_target.cat1.erb +56 -0
  254. data/templates/cat1/r3/_reporting_parameters.cat1.erb +31 -0
  255. data/templates/cat1/r3/_result_value.cat1.erb +28 -0
  256. data/templates/{cat3/_telecom.cat3.erb → cat1/r3/_telecom.cat1.erb} +0 -0
  257. data/templates/cat1/r3/show.cat1.erb +183 -0
  258. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.1.cat1.erb +14 -0
  259. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.103.cat1.erb +17 -0
  260. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.105.cat1.erb +68 -0
  261. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.12.cat1.erb +53 -0
  262. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.135.cat1.erb +71 -0
  263. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.136.cat1.erb +52 -0
  264. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.140.cat1.erb +39 -0
  265. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.17.cat1.erb +23 -0
  266. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.18.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.18.cat1.erb} +3 -3
  267. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.2.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.2.cat1.erb} +2 -2
  268. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.22.cat1.erb +30 -0
  269. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.23.cat1.erb +116 -0
  270. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.26.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.26.cat1.erb} +4 -2
  271. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.3.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.3.cat1.erb} +2 -2
  272. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.31.cat1.erb +24 -0
  273. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.32.cat1.erb +21 -0
  274. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.37.cat1.erb +22 -0
  275. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.38.cat1.erb +21 -0
  276. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.4.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.4.cat1.erb} +2 -2
  277. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.41.cat1.erb +45 -0
  278. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.42.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.42.cat1.erb} +4 -4
  279. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.43.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.43.cat1.erb} +3 -3
  280. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.44.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.44.cat1.erb} +3 -3
  281. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.45.cat1.erb +35 -0
  282. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.46.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.46.cat1.erb} +4 -4
  283. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.47.cat1.erb +47 -0
  284. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.51.cat1.erb +14 -0
  285. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.54.cat1.erb +32 -0
  286. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.55.cat1.erb +18 -0
  287. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.57.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.57.cat1.erb} +3 -3
  288. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.59.cat1.erb +22 -0
  289. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.62.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.62.cat1.erb} +5 -5
  290. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.63.cat1.erb +21 -0
  291. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.64.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.64.cat1.erb} +7 -7
  292. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.69.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.69.cat1.erb} +2 -2
  293. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.7.cat1.erb → r3_1/_2.16.840.1.113883.10.20.24.3.7.cat1.erb} +12 -9
  294. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.81.cat1.erb +33 -0
  295. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.82.cat1.erb +33 -0
  296. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.24.3.9.cat1.erb +41 -0
  297. data/templates/cat1/r3_1/_2.16.840.1.113883.10.20.28.3.6.cat1.erb +17 -0
  298. data/templates/cat1/r3_1/_address.cat1.erb +9 -0
  299. data/templates/cat1/r3_1/_author.cat1.erb +28 -0
  300. data/templates/cat1/r3_1/_fulfills.cat1.erb +14 -0
  301. data/templates/cat1/r3_1/_id.cat1.erb +1 -0
  302. data/templates/cat1/r3_1/_measures.cat1.erb +93 -0
  303. data/templates/cat1/r3_1/_medication_details.cat1.erb +16 -0
  304. data/templates/cat1/r3_1/_medication_dispense.cat1.erb +22 -0
  305. data/templates/cat1/r3_1/_ordinality.cat1.erb +10 -0
  306. data/templates/cat1/r3_1/_organization.cat1.erb +9 -0
  307. data/templates/cat1/r3_1/_patient_data.cat1.erb +17 -0
  308. data/templates/cat1/r3_1/_providers.cat1.erb +76 -0
  309. data/templates/cat1/r3_1/_reason.cat1.erb +34 -0
  310. data/templates/cat1/r3_1/_record_target.cat1.erb +56 -0
  311. data/templates/cat1/r3_1/_reporting_parameters.cat1.erb +31 -0
  312. data/templates/cat1/r3_1/_result_value.cat1.erb +28 -0
  313. data/templates/cat1/r3_1/_telecom.cat1.erb +1 -0
  314. data/templates/cat1/r3_1/show.cat1.erb +183 -0
  315. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.1.cat1.erb +14 -0
  316. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.103.cat1.erb +17 -0
  317. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.105.cat1.erb +68 -0
  318. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.12.cat1.erb +53 -0
  319. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.135.cat1.erb +75 -0
  320. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.136.cat1.erb +52 -0
  321. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.140.cat1.erb +39 -0
  322. data/templates/cat1/{_2.16.840.1.113883.10.20.24.3.59.cat1.erb → r4/_2.16.840.1.113883.10.20.24.3.144.cat1.erb} +6 -6
  323. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.145.cat1.erb +24 -0
  324. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.17.cat1.erb +23 -0
  325. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.18.cat1.erb +25 -0
  326. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.2.cat1.erb +29 -0
  327. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.22.cat1.erb +30 -0
  328. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.23.cat1.erb +116 -0
  329. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.3.cat1.erb +25 -0
  330. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.31.cat1.erb +24 -0
  331. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.32.cat1.erb +21 -0
  332. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.37.cat1.erb +22 -0
  333. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.38.cat1.erb +21 -0
  334. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.4.cat1.erb +29 -0
  335. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.41.cat1.erb +45 -0
  336. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.42.cat1.erb +38 -0
  337. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.43.cat1.erb +24 -0
  338. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.44.cat1.erb +25 -0
  339. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.45.cat1.erb +35 -0
  340. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.46.cat1.erb +30 -0
  341. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.47.cat1.erb +47 -0
  342. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.51.cat1.erb +14 -0
  343. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.54.cat1.erb +32 -0
  344. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.55.cat1.erb +18 -0
  345. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.57.cat1.erb +23 -0
  346. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.59.cat1.erb +22 -0
  347. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.62.cat1.erb +36 -0
  348. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.63.cat1.erb +21 -0
  349. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.64.cat1.erb +52 -0
  350. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.7.cat1.erb +33 -0
  351. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.81.cat1.erb +33 -0
  352. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.82.cat1.erb +33 -0
  353. data/templates/cat1/r4/_2.16.840.1.113883.10.20.24.3.9.cat1.erb +41 -0
  354. data/templates/cat1/r4/_2.16.840.1.113883.10.20.28.3.6.cat1.erb +17 -0
  355. data/templates/cat1/r4/_address.cat1.erb +7 -0
  356. data/templates/cat1/r4/_author.cat1.erb +28 -0
  357. data/templates/cat1/r4/_fulfills.cat1.erb +14 -0
  358. data/templates/cat1/r4/_id.cat1.erb +1 -0
  359. data/templates/cat1/r4/_measures.cat1.erb +93 -0
  360. data/templates/cat1/r4/_medication_details.cat1.erb +16 -0
  361. data/templates/cat1/r4/_medication_dispense.cat1.erb +22 -0
  362. data/templates/cat1/r4/_ordinality.cat1.erb +10 -0
  363. data/templates/cat1/r4/_organization.cat1.erb +9 -0
  364. data/templates/cat1/r4/_patient_data.cat1.erb +17 -0
  365. data/templates/cat1/r4/_providers.cat1.erb +76 -0
  366. data/templates/cat1/r4/_reason.cat1.erb +34 -0
  367. data/templates/cat1/r4/_record_target.cat1.erb +54 -0
  368. data/templates/cat1/r4/_reporting_parameters.cat1.erb +31 -0
  369. data/templates/cat1/r4/_result_value.cat1.erb +28 -0
  370. data/templates/cat1/r4/_telecom.cat1.erb +1 -0
  371. data/templates/cat1/r4/show.cat1.erb +192 -0
  372. data/templates/cat3/{_address.cat3.erb → r1/_address.cat3.erb} +0 -0
  373. data/templates/cat3/r1/_author.cat3.erb +28 -0
  374. data/templates/cat3/{_continuous_variable_value.cat3.erb → r1/_continuous_variable_value.cat3.erb} +0 -0
  375. data/templates/cat3/r1/_id.cat3.erb +1 -0
  376. data/templates/cat3/{_measure_data.cat3.erb → r1/_measure_data.cat3.erb} +7 -6
  377. data/templates/cat3/{_organization.cat3.erb → r1/_organization.cat3.erb} +0 -0
  378. data/templates/cat3/{_performance_rate.cat3.erb → r1/_performance_rate.cat3.erb} +1 -3
  379. data/templates/cat3/{_providers.cat3.erb → r1/_providers.cat3.erb} +0 -0
  380. data/templates/cat3/{_reporting_parameters.cat3.erb → r1/_reporting_parameters.cat3.erb} +0 -0
  381. data/templates/cat3/{_supplemental_data.cat3.erb → r1/_supplemental_data.cat3.erb} +2 -0
  382. data/templates/cat3/r1/_telecom.cat3.erb +1 -0
  383. data/templates/cat3/{show.cat3.erb → r1/show.cat3.erb} +5 -5
  384. data/templates/cat3/r1_1/_address.cat3.erb +9 -0
  385. data/templates/cat3/r1_1/_author.cat3.erb +28 -0
  386. data/templates/cat3/r1_1/_continuous_variable_value.cat3.erb +20 -0
  387. data/templates/cat3/r1_1/_id.cat3.erb +1 -0
  388. data/templates/cat3/r1_1/_measure_data.cat3.erb +136 -0
  389. data/templates/cat3/r1_1/_organization.cat3.erb +6 -0
  390. data/templates/cat3/r1_1/_performance_rate.cat3.erb +18 -0
  391. data/templates/{cat1/_providers.cat1.erb → cat3/r1_1/_providers.cat3.erb} +18 -18
  392. data/templates/{cat1/_reporting_parameters.cat1.erb → cat3/r1_1/_reporting_parameters.cat3.erb} +5 -1
  393. data/templates/cat3/r1_1/_supplemental_data.cat3.erb +38 -0
  394. data/templates/cat3/r1_1/_telecom.cat3.erb +1 -0
  395. data/templates/cat3/r1_1/show.cat3.erb +150 -0
  396. data/templates/cat3/r2/_address.cat3.erb +9 -0
  397. data/templates/cat3/r2/_author.cat3.erb +28 -0
  398. data/templates/cat3/r2/_continuous_variable_value.cat3.erb +20 -0
  399. data/templates/cat3/r2/_id.cat3.erb +1 -0
  400. data/templates/cat3/r2/_measure_data.cat3.erb +136 -0
  401. data/templates/cat3/r2/_organization.cat3.erb +6 -0
  402. data/templates/cat3/r2/_performance_rate.cat3.erb +19 -0
  403. data/templates/cat3/r2/_providers.cat3.erb +57 -0
  404. data/templates/cat3/r2/_reporting_parameters.cat3.erb +29 -0
  405. data/templates/cat3/r2/_supplemental_data.cat3.erb +38 -0
  406. data/templates/cat3/r2/_telecom.cat3.erb +1 -0
  407. data/templates/cat3/r2/show.cat3.erb +150 -0
  408. data/templates/cat3/r2_1/_address.cat3.erb +9 -0
  409. data/templates/cat3/r2_1/_author.cat3.erb +28 -0
  410. data/templates/cat3/r2_1/_continuous_variable_value.cat3.erb +20 -0
  411. data/templates/cat3/r2_1/_id.cat3.erb +1 -0
  412. data/templates/cat3/r2_1/_measure_data.cat3.erb +136 -0
  413. data/templates/cat3/r2_1/_organization.cat3.erb +6 -0
  414. data/templates/cat3/r2_1/_performance_rate.cat3.erb +19 -0
  415. data/templates/cat3/r2_1/_providers.cat3.erb +57 -0
  416. data/templates/cat3/r2_1/_reporting_parameters.cat3.erb +20 -0
  417. data/templates/cat3/r2_1/_reporting_parameters_act.cat3.erb +10 -0
  418. data/templates/cat3/r2_1/_supplemental_data.cat3.erb +38 -0
  419. data/templates/cat3/r2_1/_telecom.cat3.erb +1 -0
  420. data/templates/cat3/r2_1/show.cat3.erb +153 -0
  421. data/templates/ccda/_medical_equipment.ccda.erb +1 -1
  422. data/templates/ccda/_social_history.ccda.erb +2 -2
  423. data/templates/ccda/_vital_signs.ccda.erb +1 -1
  424. data/templates/html/_entries_by_section.html.erb +1 -1
  425. metadata +425 -153
  426. data/lib/health-data-standards/import/cat1/procedure_importer.rb +0 -42
  427. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.11.cat1.erb +0 -55
  428. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.13.cat1.erb +0 -38
  429. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.17.cat1.erb +0 -22
  430. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.31.cat1.erb +0 -22
  431. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.37.cat1.erb +0 -20
  432. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.47.cat1.erb +0 -27
  433. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.51.cat1.erb +0 -13
  434. data/templates/cat1/_reason.cat1.erb +0 -23
@@ -0,0 +1,175 @@
1
+ module HQMF2
2
+ # Handles generation of populations for the main document
3
+ class DocumentPopulationHelper
4
+ include HQMF2::Utilities
5
+
6
+ def initialize(entry, doc, document, id_generator, reference_ids = {})
7
+ @entry = entry
8
+ @doc = doc
9
+ remove_population_preconditions(@doc)
10
+ @document = document
11
+ @id_generator = id_generator
12
+ @reference_ids = reference_ids
13
+ @populations = []
14
+ @population_criteria = []
15
+ @stratifications = []
16
+ @ids_by_hqmf_id = {}
17
+ @population_counters = {}
18
+ end
19
+
20
+ # If a precondition references a population, remove it
21
+ def remove_population_preconditions(doc)
22
+ # population sections
23
+ pop_ids = doc.xpath("//cda:populationCriteriaSection/cda:component[@typeCode='COMP']/*/cda:id",
24
+ HQMF2::Document::NAMESPACES)
25
+ # find the population entries and get their ids
26
+ pop_ids.each do |p_id|
27
+ doc.xpath("//cda:precondition[./cda:criteriaReference/cda:id[@extension='#{p_id['extension']}' and @root='#{p_id['root']}']]",
28
+ HQMF2::Document::NAMESPACES).remove
29
+ end
30
+ end
31
+
32
+ # Returns the population descriptions and criteria found in this document
33
+ def extract_populations_and_criteria
34
+ has_observation = extract_observations
35
+ document_populations = @doc.xpath('cda:QualityMeasureDocument/cda:component/cda:populationCriteriaSection',
36
+ HQMF2::Document::NAMESPACES)
37
+ # Sort the populations based on the id/extension, since the populations may be out of order; there doesn't seem to
38
+ # be any other way that order is indicated in the HQMF
39
+ document_populations = document_populations.sort_by do |pop|
40
+ pop.at_xpath('cda:id/@extension', HQMF2::Document::NAMESPACES).try(:value)
41
+ end
42
+ number_of_populations = document_populations.length
43
+ document_populations.each_with_index do |population_def, population_index|
44
+ population = {}
45
+ handle_base_populations(population_def, population)
46
+
47
+ id_def = population_def.at_xpath('cda:id/@extension', HQMF2::Document::NAMESPACES)
48
+ population['id'] = id_def ? id_def.value : "Population#{population_index}"
49
+ title_def = population_def.at_xpath('cda:title/@value', HQMF2::Document::NAMESPACES)
50
+ population['title'] = title_def ? title_def.value : "Population #{population_index}"
51
+
52
+ population['OBSERV'] = 'OBSERV' if has_observation
53
+ @populations << population
54
+
55
+ handle_stratifications(population_def, number_of_populations, population, id_def, population_index)
56
+ end
57
+
58
+ # Push in the stratification populations after the unstratified populations
59
+ @populations.concat(@stratifications)
60
+ [@populations, @population_criteria]
61
+ end
62
+
63
+ # Extracts the measure observations, will return true if one exists
64
+ def extract_observations
65
+ has_observation = false
66
+ # look for observation data in separate section but create a population for it if it exists
67
+ observation_section = @doc.xpath('/cda:QualityMeasureDocument/cda:component/cda:measureObservationSection',
68
+ HQMF2::Document::NAMESPACES)
69
+ unless observation_section.empty?
70
+ observation_section.xpath('cda:definition', HQMF2::Document::NAMESPACES).each do |criteria_def|
71
+ criteria_id = 'OBSERV'
72
+ criteria = PopulationCriteria.new(criteria_def, @document, @id_generator)
73
+ criteria.type = 'OBSERV'
74
+ # This section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc.
75
+ # This allows the populations to be more readable. The alternative would be to have the hqmf ids in the
76
+ # populations, which would work, but is difficult to read the populations.
77
+ if @ids_by_hqmf_id["#{criteria.hqmf_id}"]
78
+ criteria.create_human_readable_id(@ids_by_hqmf_id[criteria.hqmf_id])
79
+ else
80
+ criteria.create_human_readable_id(population_id_with_counter(criteria_id))
81
+ @ids_by_hqmf_id["#{criteria.hqmf_id}"] = criteria.id
82
+ end
83
+
84
+ @population_criteria << criteria
85
+ has_observation = true
86
+ end
87
+ end
88
+ has_observation
89
+ end
90
+
91
+ # Builds populations based an a predfined set of expected populations
92
+ def handle_base_populations(population_def, population)
93
+ {
94
+ HQMF::PopulationCriteria::IPP => 'initialPopulationCriteria',
95
+ HQMF::PopulationCriteria::DENOM => 'denominatorCriteria',
96
+ HQMF::PopulationCriteria::NUMER => 'numeratorCriteria',
97
+ HQMF::PopulationCriteria::NUMEX => 'numeratorExclusionCriteria',
98
+ HQMF::PopulationCriteria::DENEXCEP => 'denominatorExceptionCriteria',
99
+ HQMF::PopulationCriteria::DENEX => 'denominatorExclusionCriteria',
100
+ HQMF::PopulationCriteria::MSRPOPL => 'measurePopulationCriteria',
101
+ HQMF::PopulationCriteria::MSRPOPLEX => 'measurePopulationExclusionCriteria'
102
+ }.each_pair do |criteria_id, criteria_element_name|
103
+ criteria_def = population_def.at_xpath("cda:component[cda:#{criteria_element_name}]", HQMF2::Document::NAMESPACES)
104
+ if criteria_def
105
+ build_population_criteria(criteria_def, criteria_id, population)
106
+ end
107
+ end
108
+ end
109
+
110
+ # Generate the stratifications of populations, if any exist
111
+ def handle_stratifications(population_def, number_of_populations, population, id_def, population_index)
112
+ # handle stratifications (EP137, EP155)
113
+ stratifier_criteria_xpath = "cda:component/cda:stratifierCriteria[not(cda:component/cda:measureAttribute/cda:code[@code = 'SDE'])]/.."
114
+ population_def.xpath(stratifier_criteria_xpath, HQMF2::Document::NAMESPACES)
115
+ .each_with_index do |criteria_def, criteria_def_index|
116
+ # Skip this Stratification if any precondition doesn't contain any preconditions
117
+ next unless PopulationCriteria.new(criteria_def, @document, @id_generator)
118
+ .preconditions.all? { |prcn| prcn.preconditions.length > 0 }
119
+
120
+ index = number_of_populations + ((population_index - 1) * criteria_def.xpath('./*/cda:precondition').length) +
121
+ criteria_def_index
122
+ criteria_id = HQMF::PopulationCriteria::STRAT
123
+ stratified_population = population.dup
124
+ stratified_population['stratification'] = criteria_def.at_xpath('./*/cda:id/@root').try(:value) ||
125
+ "#{criteria_id}-#{criteria_def_index}"
126
+ build_population_criteria(criteria_def, criteria_id, stratified_population)
127
+
128
+ stratified_population['id'] = id_def ? "#{id_def.value} - Stratification #{criteria_def_index + 1}" : "Population#{index}"
129
+ title_def = population_def.at_xpath('cda:title/@value', HQMF2::Document::NAMESPACES)
130
+ stratified_population['title'] = title_def ? "#{title_def.value} - Stratification #{criteria_def_index + 1}" : "Population #{index}"
131
+ @stratifications << stratified_population
132
+ end
133
+ end
134
+
135
+ # Method to generate the criteria defining a population
136
+ def build_population_criteria(criteria_def, criteria_id, population)
137
+ criteria = PopulationCriteria.new(criteria_def, @document, @id_generator)
138
+
139
+ # check to see if we have an identical population criteria.
140
+ # this can happen since the hqmf 2.0 will export a DENOM, NUMER, etc for each population, even if identical.
141
+ # if we have identical, just re-use it rather than creating DENOM_1, NUMER_1, etc.
142
+ identical = @population_criteria.select { |pc| pc.to_model.hqmf_id == criteria.to_model.hqmf_id }
143
+
144
+ @reference_ids.concat(criteria.to_model.referenced_data_criteria)
145
+
146
+ if identical.empty?
147
+ # this section constructs a human readable id. The first IPP will be IPP, the second will be IPP_1, etc.
148
+ # This allows the populations to be more readable. The alternative would be to have the hqmf ids in the
149
+ # populations, which would work, but is difficult to read the populations.
150
+ if @ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"]
151
+ criteria.create_human_readable_id(@ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"])
152
+ else
153
+ criteria.create_human_readable_id(population_id_with_counter(criteria_id))
154
+ @ids_by_hqmf_id["#{criteria.hqmf_id}-#{population['stratification']}"] = criteria.id
155
+ end
156
+
157
+ @population_criteria << criteria
158
+ population[criteria_id] = criteria.id
159
+ else
160
+ population[criteria_id] = identical.first.id
161
+ end
162
+ end
163
+
164
+ # Returns a unique id for a given population (increments the id if already present)
165
+ def population_id_with_counter(criteria_id)
166
+ if @population_counters[criteria_id]
167
+ @population_counters[criteria_id] += 1
168
+ "#{criteria_id}_#{@population_counters[criteria_id]}"
169
+ else
170
+ @population_counters[criteria_id] = 0
171
+ criteria_id
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,131 @@
1
+ module HQMF2
2
+ # Utilities used by the document parser to handle generic tasks
3
+ module DocumentUtilities
4
+ # Create grouper data criteria for encapsulating variable data criteria
5
+ # and update document data criteria list and references map
6
+ def handle_variable(data_criteria, collapsed_source_data_criteria)
7
+
8
+ if data_criteria.is_derived_specific_occurrence_variable
9
+ data_criteria.handle_derived_specific_occurrence_variable
10
+ extract_source_data_criteria(data_criteria)
11
+ return
12
+ end
13
+
14
+ tmp_id = data_criteria.id
15
+
16
+ grouper_data_criteria = data_criteria.extract_variable_grouper
17
+ return unless grouper_data_criteria
18
+ @data_criteria_references[data_criteria.id] = data_criteria
19
+ @data_criteria_references[grouper_data_criteria.id] = grouper_data_criteria
20
+
21
+ # create a source data criteria for the grouping data critera we just created
22
+ sdc = SourceDataCriteriaHelper.strip_non_sc_elements(grouper_data_criteria)
23
+ @source_data_criteria << sdc
24
+
25
+ # check if the original source has been collapsed when generating the SDC list (we need to reference the collapsed version in the sdc list)
26
+ if collapsed_source_data_criteria[tmp_id]
27
+ data_criteria.instance_variable_set(:@source_data_criteria, collapsed_source_data_criteria[tmp_id])
28
+ else
29
+ # check if we need to add _source suffix (most source data criteria are segmented with '_source' suffixes)
30
+ data_criteria_sdc = find(@source_data_criteria, :id, "#{tmp_id}_source")
31
+ if data_criteria_sdc
32
+ data_criteria.instance_variable_set(:@source_data_criteria, data_criteria_sdc.id)
33
+ data_criteria_sdc.instance_variable_set(:@variable, false)
34
+ # if it's not a derived data criteria then we may need to strip off temporal references, fields, etc as a new source data criteria
35
+ elsif !['derived', 'satisfies_any', 'satisfies_all'].include?(data_criteria.definition)
36
+ extract_source_data_criteria(data_criteria)
37
+ end
38
+ end
39
+
40
+ @data_criteria << grouper_data_criteria
41
+ end
42
+
43
+ def extract_source_data_criteria (data_criteria)
44
+ # check if we have temporal references other non-SDC elements on this data criteria.
45
+ # if we do, we need to create a new SDC to reference
46
+ if !SourceDataCriteriaHelper.already_stripped?(data_criteria)
47
+ candidate_sdc = SourceDataCriteriaHelper.strip_non_sc_elements(data_criteria.clone)
48
+ candidate_sdc.instance_variable_set(:@id, "#{candidate_sdc.id}_source")
49
+ candidate_sdc.instance_variable_set(:@source_data_criteria, candidate_sdc.id)
50
+
51
+ existing_candidate = SourceDataCriteriaHelper.find_existing_source_data_criteria(@source_data_criteria, candidate_sdc)
52
+ if existing_candidate
53
+ candidate_sdc = existing_candidate
54
+ else
55
+ @source_data_criteria << candidate_sdc
56
+ # Specific occurrence variables need a copy of the source in the data criteria to display variable results
57
+ @data_criteria << candidate_sdc if data_criteria.is_derived_specific_occurrence_variable
58
+ end
59
+
60
+ data_criteria.instance_variable_set(:@source_data_criteria, candidate_sdc.id)
61
+ end
62
+ end
63
+
64
+ # Checks if one data criteria is covered by another (has all the appropriate elements of)
65
+ def criteria_covered_by_criteria?(dc)
66
+ @reference_ids.uniq
67
+
68
+ base_criteria_defs = %w(patient_characteristic_ethnicity patient_characteristic_gender patient_characteristic_payer patient_characteristic_race)
69
+ to_reject = true
70
+ # don't reject if anything refers directly to this criteria
71
+ to_reject &&= @reference_ids.index(dc.id).nil?
72
+ # don't reject if it is a "base" criteria (no references but must exist)
73
+ to_reject &&= !base_criteria_defs.include?(dc.definition)
74
+ # keep referral occurrence
75
+ to_reject &&= dc.specific_occurrence_const.nil? ||
76
+ dc.code_list_id != '2.16.840.1.113883.3.464.1003.101.12.1046'
77
+ to_reject && !@data_criteria.detect do |dc2|
78
+ similar_criteria = true
79
+ similar_criteria &&= dc != dc2 # Don't check against itself
80
+ similar_criteria &&= dc.code_list_id == dc2.code_list_id # Ensure code list ids are the same
81
+ similar_criteria && detect_criteria_covered_by_criteria(dc, dc2)
82
+ end.nil? # don't reject unless there is a similar element
83
+ end
84
+
85
+ # Check if one data criteria contains the others information by checking that one has everything the other has
86
+ # (or more)
87
+ def detect_criteria_covered_by_criteria(data_criteria, check_criteria)
88
+ base_checks = true
89
+
90
+ # Check whether basic features are the same
91
+ base_checks &&= data_criteria.definition == check_criteria.definition # same definition
92
+ base_checks &&= data_criteria.status == check_criteria.status # same status
93
+ # same children
94
+ base_checks &&= data_criteria.children_criteria.sort.join(',') == check_criteria.children_criteria.sort.join(',')
95
+ # Ensure it doesn't contain basic elements that should not be removed
96
+ base_checks &&= !data_criteria.variable # Ensure it's not a variable
97
+ base_checks &&= data_criteria.derivation_operator.nil? # Ensure it doesn't have a derivation operator
98
+ base_checks &&= data_criteria.subset_operators.empty? # Ensure it doesn't have a subset operator
99
+ # Ensure it doesn't have Temporal References
100
+ base_checks &&= data_criteria.temporal_references.nil? || data_criteria.temporal_references.empty?
101
+
102
+ base_checks && complex_coverage(data_criteria, check_criteria)
103
+ end
104
+
105
+ # Check elements that do not already exist; else, if they do, check if those elements are the same
106
+ # in a different, potentially matching, data criteria
107
+ def complex_coverage(data_criteria, check_criteria)
108
+ same_value = data_criteria.value.nil? ||
109
+ data_criteria.value.try(:to_model).try(:to_json) == check_criteria.value.try(:to_model).try(:to_json)
110
+
111
+ same_field_values = same_field_values_check(data_criteria, check_criteria)
112
+
113
+ same_negation_values = data_criteria.negation_code_list_id.nil? ||
114
+ data_criteria.negation_code_list_id == check_criteria.negation_code_list_id
115
+
116
+ same_value && same_negation_values && same_field_values
117
+ end
118
+
119
+ def same_field_values_check(data_criteria, check_criteria)
120
+ empty = data_criteria.field_values.nil? || data_criteria.field_values.empty?
121
+ # Ignore STATUS (and ORDINAL for CMS172v5)
122
+ # The meaning of status has changed over time. Laboratory test and procedure now use status differently.
123
+ # This change is causing superficial discrepencies between the simplexml and hqmf regarding STATUS.
124
+ dc_filtered = data_criteria.field_values.except('STATUS').except('ORDINAL')
125
+ cc_filtered = check_criteria.field_values.except('STATUS').except('ORDINAL')
126
+ left = dc_filtered.nil? || dc_filtered.empty? ? nil : dc_filtered.try(:to_json)
127
+ right = cc_filtered.nil? || cc_filtered.empty? ? nil : cc_filtered.try(:to_json)
128
+ return empty || left == right
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,251 @@
1
+ module HQMF2
2
+ # Generates field values based on understanding of the HQMF 2.1 spec
3
+ class FieldValueHelper
4
+ def self.parse_field_values(entry)
5
+ return if entry.nil?
6
+ criteria = entry.at_xpath('./cda:actCriteria | ./cda:observationCriteria | ./cda:encounterCriteria |
7
+ ./cda:procedureCriteria | ./cda:supplyCriteria |
8
+ ./cda:substanceAdministrationCriteria | ./cda:grouperCriteria')
9
+
10
+ return {} if criteria.nil?
11
+ fields = {}
12
+ # Negation is handled in the data criteria parsing class and not as a field value.
13
+ # Not using the reasonCode element because the QDM HQMF ig states that reason is in an outbound relationship.
14
+ # parse_dset_cd(criteria.at_xpath('./cda:reasonCode', HQMF2::Document::NAMESPACES), 'REASON', fields) unless
15
+ # negated.
16
+ parse_dset_cd(criteria.at_xpath('./cda:priorityCode', HQMF2::Document::NAMESPACES), 'ORDINAL', fields)
17
+ parse_date_fields(criteria, fields)
18
+
19
+ handle_fields_per_criteria(criteria, fields)
20
+
21
+ fields
22
+ end
23
+
24
+ def self.handle_fields_per_criteria(criteria, fields)
25
+ case criteria.name
26
+ when 'encounterCriteria'
27
+ parse_encounter_fields(criteria, fields)
28
+ when 'actCriteria'
29
+ parse_act_criteria_fields(criteria, fields)
30
+ when 'observationCriteria'
31
+ parse_observation_fields(criteria, fields)
32
+ when 'procedureCriteria'
33
+ parse_procedure_fields(criteria, fields)
34
+ when 'supplyCriteria'
35
+ parse_supply_fields(criteria, fields)
36
+ when 'substanceAdministrationCriteria'
37
+ parse_substance_administration_fields(criteria, fields)
38
+ when 'grouperCriteria'
39
+ parse_grouper_fields(criteria, fields)
40
+ end
41
+ end
42
+
43
+ # The next group of "parse_" methods handle extracting values for different types of criteria
44
+
45
+ def self.parse_dset_cd(element, field, fields)
46
+ if element
47
+ item = element.at_xpath('./cda:item')
48
+ any = any_flavor(item) || any_flavor(element)
49
+ fields[field] = AnyValue.new if any
50
+ fields[field] = Coded.new(item) if item && !any
51
+ end
52
+ end
53
+
54
+ # The next group of "parse_" methods also first check if the value is of the "ANY" type, and only parse if it isn't
55
+
56
+ def self.parse_cd(element, field, fields)
57
+ any = check_and_set_if_any(element, field, fields)
58
+ fields[field] = Coded.new(element) if element && !any
59
+ end
60
+
61
+ def self.parse_ts(element, field, fields)
62
+ any = check_and_set_if_any(element, field, fields)
63
+ fields[field] = Value.new(element) if element && !any
64
+ end
65
+
66
+ def self.parse_ivl_int(element, field, fields)
67
+ any = check_and_set_if_any(element, field, fields)
68
+ fields[field] = Range.new(element) if element && !any
69
+ end
70
+
71
+ def self.parse_cs(element, field, fields)
72
+ # Only possible result is AnyValue
73
+ check_and_set_if_any(element, field, fields)
74
+ end
75
+
76
+ def self.parse_pq(element, field, fields)
77
+ any = check_and_set_if_any(element, field, fields)
78
+ fields[field] = Range.new(element) if element && !any
79
+ end
80
+
81
+ def self.parse_value(element, field, fields)
82
+ any = check_and_set_if_any(element, field, fields)
83
+ fields[field] = DateCriteria.parse_value(element) if element && !any
84
+ end
85
+
86
+ # handle any value
87
+ def self.parse_any(element, field, fields)
88
+ any = check_and_set_if_any(element, field, fields)
89
+ fields[field] = DateCriteria.parse_value(element) if element && !any
90
+ end
91
+
92
+ # Use when checking if the element is a "ANY" type, sets the field key if it is
93
+ def self.check_and_set_if_any(element, field, fields)
94
+ any = any_flavor(element)
95
+ fields[field] = AnyValue.new if any
96
+ any
97
+ end
98
+
99
+ def self.any_flavor(element)
100
+ element && (element['flavorId'] == 'ANY.NONNULL' ||
101
+ element.at_xpath('@xsi:type', HQMF2::Document::NAMESPACES) == 'ANY')
102
+ end
103
+
104
+ def self.parse_date_fields(entry, fields)
105
+ # handle embded date fields
106
+ times = [{ key: 'signeddatetime', field: 'SIGNED_DATETIME', highlow: 'high' },
107
+ { key: 'startdatetime', field: 'START_DATETIME', highlow: 'low' },
108
+ { key: 'stopdatetime', field: 'STOP_DATETIME', highlow: 'high' },
109
+ { key: 'recordeddatetime', field: 'RECORDED_DATETIME', highlow: 'high' }
110
+ ]
111
+ times.each do |e|
112
+ date = entry.at_xpath("cda:participation[@typeCode='AUT']/cda:role/cda:id/cda:item[@extension = '#{e[:key]}']/../../../cda:time")
113
+ fields[e[:field]] = Range.new(date, 'IVL_PQ') if date
114
+ end
115
+
116
+ # Special case handle effectiveTime element , by default low is start datetime
117
+ # and high is stop datetime. This changes for certain elements
118
+ template_ids = extract_template_ids(entry)
119
+ low = entry.at_xpath('./cda:effectiveTime/cda:low/..')
120
+ high = entry.at_xpath('./cda:effectiveTime/cda:high/..')
121
+
122
+ fields[low_field_name(template_ids)] = Range.new(low, 'IVL_PQ') if low
123
+
124
+ fields[high_field_name(template_ids)] = Range.new(high, 'IVL_PQ') if high
125
+ end
126
+
127
+ # Returns the proper name for the low field given the list of template ids
128
+ def self.low_field_name(template_ids)
129
+ if template_ids.include?('2.16.840.1.113883.10.20.28.3.51')
130
+ 'ACTIVE_DATETIME'
131
+ elsif template_ids.include?('2.16.840.1.113883.10.20.28.3.110') ||
132
+ template_ids.include?('2.16.840.1.113883.10.20.28.3.116')
133
+ 'ONSET_DATETIME'
134
+ else
135
+ 'ADMISSION_DATETIME'
136
+ end
137
+ end
138
+
139
+ # Returns the proper name for the high field given the list of template ids
140
+ def self.high_field_name(template_ids)
141
+ if template_ids.include?('2.16.840.1.113883.10.20.28.3.13')
142
+ 'REMOVAL_DATETIME'
143
+ elsif template_ids.include?('2.16.840.1.113883.10.20.28.3.110') ||
144
+ template_ids.include?('2.16.840.1.113883.10.20.28.3.116')
145
+ 'ABATEMENT_DATETIME'
146
+ else
147
+ 'DISCHARGE_DATETIME'
148
+ end
149
+ end
150
+
151
+ # If type code for this field value is LOC, handle specifics
152
+ def self.handle_loc(entry, fields)
153
+ loc = entry.at_xpath("./cda:participation[@typeCode='LOC']/cda:role[@classCode='SDLOC']",
154
+ HQMF2::Document::NAMESPACES)
155
+ return unless loc
156
+ # does it have an effective time?
157
+ low = loc.at_xpath('./cda:effectiveTime/cda:low/..')
158
+ high = loc.at_xpath('./cda:effectiveTime/cda:high/..')
159
+ code = loc.at_xpath('./cda:code')
160
+ # looking at the 2.4.0 measure bundle these values are set to null if they exist
161
+ # so that is what I am doing for now
162
+ fields['FACILITY_LOCATION_ARRIVAL_DATETIME'] = AnyValue.new if low
163
+ fields['FACILITY_LOCATION_DEPARTURE_DATETIME'] = AnyValue.new if high
164
+ fields['FACILITY_LOCATION'] = Coded.new(code) if code
165
+ end
166
+
167
+ # Extract template ids from the given entry
168
+ def self.extract_template_ids(entry)
169
+ entry.xpath('./cda:templateId/cda:item', HQMF2::Document::NAMESPACES).collect do |template_def|
170
+ HQMF2::Utilities.attr_val(template_def, '@root')
171
+ end
172
+ end
173
+
174
+ # The "parse_"s after this point handle extraction of data criteria based on field names
175
+
176
+ def self.parse_act_criteria_fields(_entry, _fields)
177
+ end
178
+
179
+ def self.parse_substance_administration_fields(entry, fields)
180
+ parse_dset_cd(entry.at_xpath('./cda:methodCode', HQMF2::Document::NAMESPACES), 'METHOD', fields)
181
+ parse_dset_cd(entry.at_xpath('./cda:approachSiteCode', HQMF2::Document::NAMESPACES),
182
+ 'ANATOMICAL_APPROACH_SITE', fields)
183
+ parse_dset_cd(entry.at_xpath('./cda:targetSiteCode', HQMF2::Document::NAMESPACES),
184
+ 'ANATOMICAL_LOCATION_SITE', fields)
185
+ parse_cd(entry.at_xpath('./cda:routeCode', HQMF2::Document::NAMESPACES), 'ROUTE', fields)
186
+ parse_pq(entry.at_xpath('./cda:doseQuantity', HQMF2::Document::NAMESPACES), 'DOSE', fields)
187
+ parse_pq(entry.at_xpath('./cda:repeatNumber', HQMF2::Document::NAMESPACES), 'REFILLS', fields)
188
+ end
189
+
190
+ def self.parse_observation_fields(entry, fields)
191
+ parse_dset_cd(entry.at_xpath('./cda:methodCode', HQMF2::Document::NAMESPACES), 'METHOD', fields)
192
+ parse_dset_cd(entry.at_xpath('./cda:targetSiteCode', HQMF2::Document::NAMESPACES),
193
+ 'ANATOMICAL_LOCATION_SITE', fields)
194
+ parse_cd(entry.at_xpath("./cda:participation[@typeCode='SBJ']/cda:role[@classCode='PRS']/cda:code",
195
+ HQMF2::Document::NAMESPACES),
196
+ 'RELATIONSHIP', fields)
197
+ parse_pq(entry.at_xpath("./cda:outboundRelationship[@typeCode='REFV']/cda:observationCriteria/cda:value/cda:high",
198
+ HQMF2::Document::NAMESPACES),
199
+ 'REFERENCE_RANGE_HIGH', fields)
200
+ parse_pq(entry.at_xpath("./cda:outboundRelationship[@typeCode='REFV']/cda:observationCriteria/cda:value/cda:low",
201
+ HQMF2::Document::NAMESPACES),
202
+ 'REFERENCE_RANGE_LOW', fields)
203
+ end
204
+
205
+ # Ignoring line limits here as it would be hard to create the deep xPaths with these limits.
206
+ # rubocop:disable Metrics/LineLength
207
+ def self.parse_encounter_fields(entry, fields)
208
+ # Added a check for Principal Diagnosis and Diagnosis. QDM 4.2 Update
209
+ principal = entry.at_xpath("./cda:outboundRelationship[@typeCode='REFR']/cda:actCriteria/cda:code[@code='52534-5']",
210
+ HQMF2::Document::NAMESPACES)
211
+ if principal
212
+ parse_cd(
213
+ entry.at_xpath(
214
+ "./cda:outboundRelationship[@typeCode='REFR']/cda:actCriteria/cda:outboundRelationship[@typeCode='SUBJ']/cda:observationCriteria/cda:value",
215
+ HQMF2::Document::NAMESPACES
216
+ ), 'PRINCIPAL_DIAGNOSIS', fields)
217
+ end
218
+
219
+ diagnosis = entry.at_xpath("./cda:outboundRelationship[@typeCode='REFR']/cda:actCriteria/cda:code[@code='29308-4']",
220
+ HQMF2::Document::NAMESPACES)
221
+ if diagnosis
222
+ parse_cd(
223
+ entry.at_xpath(
224
+ "./cda:outboundRelationship[@typeCode='REFR']/cda:actCriteria/cda:outboundRelationship[@typeCode='SUBJ']/cda:observationCriteria/cda:value",
225
+ HQMF2::Document::NAMESPACES
226
+ ), 'DIAGNOSIS', fields)
227
+ end
228
+
229
+ parse_pq(entry.at_xpath('./cda:lengthOfStayQuantity', HQMF2::Document::NAMESPACES), 'LENGTH_OF_STAY', fields)
230
+ parse_cd(entry.at_xpath('./cda:dischargeDispositionCode', HQMF2::Document::NAMESPACES), 'DISCHARGE_STATUS', fields)
231
+
232
+ handle_loc(entry, fields)
233
+ end
234
+
235
+ # rubocop:enable Metrics/LineLength
236
+
237
+ def self.parse_procedure_fields(entry, fields)
238
+ parse_dset_cd(entry.at_xpath('./cda:methodCode', HQMF2::Document::NAMESPACES), 'METHOD', fields)
239
+ parse_dset_cd(entry.at_xpath('./cda:approachSiteCode', HQMF2::Document::NAMESPACES),
240
+ 'ANATOMICAL_APPROACH_SITE', fields)
241
+ parse_dset_cd(entry.at_xpath('./cda:targetSiteCode', HQMF2::Document::NAMESPACES),
242
+ 'ANATOMICAL_LOCATION_SITE', fields)
243
+ end
244
+
245
+ def self.parse_supply_fields(_entry, _fields)
246
+ end
247
+
248
+ def self.parse_grouper_fields(_entry, _fields)
249
+ end
250
+ end
251
+ end