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,80 @@
1
+ module HQMF2
2
+ # Contains extraction methods which are self-contained (rely only on the xml and an xpath, no other instance
3
+ # variables)
4
+ class DataCriteriaBaseExtractions
5
+ include HQMF2::Utilities
6
+ CONJUNCTION_CODE_TO_DERIVATION_OP = {
7
+ 'OR' => 'UNION',
8
+ 'AND' => 'XPRODUCT'
9
+ }
10
+
11
+ def initialize(entry)
12
+ @entry = entry
13
+ end
14
+
15
+ # Extract the local variable name (held in the value of the localVariableName element)
16
+ def extract_local_variable_name
17
+ lvn = @entry.at_xpath('./cda:localVariableName')
18
+ lvn['value'] if lvn
19
+ end
20
+
21
+ # Generate a list of child criterias
22
+ def extract_child_criteria
23
+ @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id",
24
+ HQMF2::Document::NAMESPACES).collect do |ref|
25
+ Reference.new(ref).id
26
+ end.compact
27
+ end
28
+
29
+ # Extracts the derivation operator to be used by the data criteria, and fails out if it finds more than one (should
30
+ # not be valid)
31
+ def extract_derivation_operator
32
+ codes = @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:conjunctionCode/@code",
33
+ HQMF2::Document::NAMESPACES)
34
+ codes.inject(nil) do |d_op, code|
35
+ if d_op && d_op != CONJUNCTION_CODE_TO_DERIVATION_OP[code.value]
36
+ fail 'More than one derivation operator in data criteria'
37
+ end
38
+ CONJUNCTION_CODE_TO_DERIVATION_OP[code.value]
39
+ end
40
+ end
41
+
42
+ def extract_temporal_references
43
+ @entry.xpath('./*/cda:temporallyRelatedInformation', HQMF2::Document::NAMESPACES).collect do |temporal_reference|
44
+ TemporalReference.new(temporal_reference)
45
+ end
46
+ end
47
+
48
+ # Filters all the subset operators to only include the ones of type 'UNION' and 'XPRODUCT'
49
+ def extract_subset_operators
50
+ all_subset_operators.select do |operator|
51
+ operator.type != 'UNION' && operator.type != 'XPRODUCT'
52
+ end
53
+ end
54
+
55
+ # Extracts all subset operators contained in the entry xml
56
+ def all_subset_operators
57
+ @entry.xpath('./*/cda:excerpt', HQMF2::Document::NAMESPACES).collect do |subset_operator|
58
+ SubsetOperator.new(subset_operator)
59
+ end
60
+ end
61
+
62
+ def extract_template_ids
63
+ @entry.xpath('./*/cda:templateId/cda:item', HQMF2::Document::NAMESPACES).collect do |template_def|
64
+ HQMF2::Utilities.attr_val(template_def, '@root')
65
+ end
66
+ end
67
+
68
+ # Extract the negation (and the negation_code_list_id if appropriate)
69
+ def extract_negation
70
+ negation = (attr_val('./*/@actionNegationInd') == 'true')
71
+ negation_code_list_id = nil
72
+ if negation
73
+ res = @entry.at_xpath('./*/cda:outboundRelationship/*/cda:code[@code="410666004"]/../cda:value/@valueSet',
74
+ HQMF2::Document::NAMESPACES)
75
+ negation_code_list_id = res.value if res
76
+ end
77
+ [negation, negation_code_list_id]
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,201 @@
1
+ module HQMF2
2
+ # Extracts the type, and modifies the data criteria, based on the template id or definition
3
+ module DataCriteriaTypeAndDefinitionExtraction
4
+ VARIABLE_TEMPLATE = '0.1.2.3.4.5.6.7.8.9.1'
5
+ SATISFIES_ANY_TEMPLATE = '2.16.840.1.113883.10.20.28.3.108'
6
+ SATISFIES_ALL_TEMPLATE = '2.16.840.1.113883.10.20.28.3.109'
7
+ def extract_definition_from_template_or_type
8
+ # Try to determine what kind of data criteria we are dealing with
9
+ # First we look for a template id and if we find one just use the definition
10
+ # status and negation associated with that
11
+ # If no template id or not one we recognize then try to determine type from
12
+ # the definition element
13
+ extract_definition_from_type unless extract_definition_from_template_id
14
+ end
15
+
16
+ # Given a template id, derive (if available) the definition for the template.
17
+ # The definitions are stored in hqmf-model/data_criteria.json.
18
+ def extract_definition_from_template_id
19
+ found = false
20
+
21
+ @template_ids.each do |template_id|
22
+ defs = HQMF::DataCriteria.definition_for_template_id(template_id, 'r2')
23
+ if defs
24
+ @definition = defs['definition']
25
+ @status = defs['status'].length > 0 ? defs['status'] : nil
26
+ found ||= true
27
+ else
28
+ found ||= handle_known_template_id(template_id)
29
+ end
30
+ end
31
+
32
+ found
33
+ end
34
+
35
+ # Given a template id, modify the variables inside this data criteria to reflect the template
36
+ def handle_known_template_id(template_id)
37
+ case template_id
38
+ when VARIABLE_TEMPLATE
39
+ @derivation_operator = HQMF::DataCriteria::INTERSECT if @derivation_operator == HQMF::DataCriteria::XPRODUCT
40
+ @definition ||= 'derived'
41
+ @variable = true
42
+ @negation = false
43
+ when SATISFIES_ANY_TEMPLATE
44
+ @definition = HQMF::DataCriteria::SATISFIES_ANY
45
+ @negation = false
46
+ when SATISFIES_ALL_TEMPLATE
47
+ @definition = HQMF::DataCriteria::SATISFIES_ALL
48
+ @derivation_operator = HQMF::DataCriteria::INTERSECT
49
+ @negation = false
50
+ else
51
+ return false
52
+ end
53
+ true
54
+ end
55
+
56
+ # Extract the definition (sometimes status, sometimes other elements) of the data criteria based on the type
57
+ def extract_definition_from_type
58
+ # If we have a specific occurrence of a variable, pull attributes from the reference.
59
+ # IDEA set this up to be called from dc_specific_and_source_extract, the number of
60
+ # fields changed by handle_specific_variable_ref may pose an issue.
61
+ extract_information_for_specific_variable if @variable && @specific_occurrence
62
+
63
+ if @entry.at_xpath('./cda:grouperCriteria')
64
+ @definition ||= 'derived'
65
+ return
66
+ end
67
+ # See if we can find a match for the entry definition value and status.
68
+ entry_type = attr_val('./*/cda:definition/*/cda:id/@extension')
69
+ handle_entry_type(entry_type)
70
+ end
71
+
72
+ # Extracts information from a reference for a specific
73
+ def extract_information_for_specific_variable
74
+ reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference',
75
+ HQMF2::Document::NAMESPACES)
76
+ if reference
77
+ ref_id = strip_tokens(
78
+ "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}")
79
+ end
80
+ reference_criteria = @data_criteria_references[ref_id] if ref_id
81
+ # if the reference is derived, pull from the original variable
82
+ if reference_criteria && reference_criteria.definition == 'derived'
83
+ reference_criteria = @data_criteria_references["GROUP_#{ref_id}"]
84
+ end
85
+ return unless reference_criteria
86
+ handle_specific_variable_ref(reference_criteria)
87
+ end
88
+
89
+ # Apply additional information to a specific occurrence's elements from the criteria it references.
90
+ def handle_specific_variable_ref(reference_criteria)
91
+ # if there are no referenced children, then it's a variable representing
92
+ # a single data criteria, so just reference it
93
+ if reference_criteria.children_criteria.empty?
94
+ @children_criteria = [reference_criteria.id]
95
+ # otherwise pull all the data criteria info from the reference
96
+ else
97
+ @field_values = reference_criteria.field_values
98
+ @temporal_references = reference_criteria.temporal_references
99
+ @subset_operators = reference_criteria.subset_operators
100
+ @derivation_operator = reference_criteria.derivation_operator
101
+ @definition = reference_criteria.definition
102
+ @description = reference_criteria.description
103
+ @status = reference_criteria.status
104
+ @children_criteria = reference_criteria.children_criteria
105
+ end
106
+ end
107
+
108
+ # Generate the definition and/or status from the entry type in most cases.
109
+ # If the entry type is nil, and the value is a specific occurrence, more parsing may be necessary.
110
+ def handle_entry_type(entry_type)
111
+ # settings is required to trigger exceptions, which set the definition
112
+ HQMF::DataCriteria.get_settings_for_definition(entry_type, @status)
113
+ @definition = entry_type
114
+ rescue
115
+ # if no exact match then try a string match just using entry definition value
116
+ case entry_type
117
+ when 'Medication', 'Medications'
118
+ @definition = 'medication'
119
+ @status = 'active' unless @status
120
+ when 'RX'
121
+ @definition = 'medication'
122
+ @status = 'dispensed' unless @status
123
+ when nil
124
+ definition_for_nil_entry
125
+ else
126
+ @definition = extract_definition_from_entry_type(entry_type)
127
+ end
128
+ end
129
+
130
+ # If there is no entry type, extract the entry type from what it references, and extract additional information for
131
+ # specific occurrences. If there are no outbound references, print an error and mark it as variable.
132
+ def definition_for_nil_entry
133
+ reference = @entry.at_xpath('./*/cda:outboundRelationship/cda:criteriaReference', HQMF2::Document::NAMESPACES)
134
+ ref_id = nil
135
+ unless reference.nil?
136
+ ref_id = "#{HQMF2::Utilities.attr_val(reference, 'cda:id/@extension')}_#{HQMF2::Utilities.attr_val(reference, 'cda:id/@root')}"
137
+ end
138
+ reference_criteria = @data_criteria_references[strip_tokens(ref_id)] unless ref_id.nil?
139
+ if reference_criteria
140
+ # we only want to copy the reference criteria definition, status, and code_list_id if this is this is not a grouping criteria (i.e., there are no children)
141
+ if @children_criteria.blank?
142
+ @definition = reference_criteria.definition
143
+ @status = reference_criteria.status
144
+ if @specific_occurrence
145
+ @title = reference_criteria.title
146
+ @description = reference_criteria.description
147
+ @code_list_id = reference_criteria.code_list_id
148
+ end
149
+ else
150
+ # if this is a grouping data criteria (has children) mark it as derived and only pull title and description from the reference criteria
151
+ @definition = 'derived'
152
+ if @specific_occurrence
153
+ @title = reference_criteria.title
154
+ @description = reference_criteria.description
155
+ end
156
+ end
157
+ else
158
+ puts "MISSING_DC_REF: #{ref_id}" unless @variable
159
+ @definition = 'variable'
160
+ end
161
+ end
162
+
163
+ # Given an entry type (which describes the criteria's purpose) return the appropriate defintino
164
+ def extract_definition_from_entry_type(entry_type)
165
+ case entry_type
166
+ when 'Problem', 'Problems'
167
+ 'diagnosis'
168
+ when 'Encounter', 'Encounters'
169
+ 'encounter'
170
+ when 'LabResults', 'Results'
171
+ 'laboratory_test'
172
+ when 'Procedure', 'Procedures'
173
+ 'procedure'
174
+ when 'Demographics'
175
+ definition_for_demographic
176
+ when 'Derived'
177
+ 'derived'
178
+ else
179
+ fail "Unknown data criteria template identifier [#{entry_type}]"
180
+ end
181
+ end
182
+
183
+ # Return the definition for a known subset of patient characteristics
184
+ def definition_for_demographic
185
+ demographic_type = attr_val('./cda:observationCriteria/cda:code/@code')
186
+ demographic_translation = {
187
+ '21112-8' => 'patient_characteristic_birthdate',
188
+ '424144002' => 'patient_characteristic_age',
189
+ '263495000' => 'patient_characteristic_gender',
190
+ '102902016' => 'patient_characteristic_languages',
191
+ '125680007' => 'patient_characteristic_marital_status',
192
+ '103579009' => 'patient_characteristic_race'
193
+ }
194
+ if demographic_translation[demographic_type]
195
+ demographic_translation[demographic_type]
196
+ else
197
+ fail "Unknown demographic identifier [#{demographic_type}]"
198
+ end
199
+ end
200
+ end
201
+ end
@@ -0,0 +1,85 @@
1
+ module HQMF2
2
+ # Processing on data criteria after the initial extractions have taken place
3
+ module DataCriteriaPostProcessing
4
+ # Handles settings values after (most) values have been setup
5
+ def post_processing
6
+ extract_code_list_path_and_result_value
7
+
8
+ # prefix ids that start with numerical values, and strip tokens from others
9
+ @id = strip_tokens(@id)
10
+ @children_criteria.map! { |cc| strip_tokens(cc) }
11
+
12
+ # append "_source" to the criteria since all the source criteria are separated from the non-source with the "_source" identifier
13
+ # "_source" is added to the SDC ids so that we are not duplicating ids between source and non source data criteria lists
14
+ # the derived source data criteria maintain their original ids since they are duplicated in the data criteria and source data criteria lists from the simple xml
15
+ @source_data_criteria = "#{@id}_source" unless (@definition == 'derived' || @definition == 'satisfies_all' || @definition == 'satisfies_any')
16
+ @source_data_criteria = strip_tokens(@source_data_criteria) unless @source_data_criteria.nil?
17
+ @specific_occurrence_const = strip_tokens(@specific_occurrence_const) unless @specific_occurrence_const.nil?
18
+ change_xproduct_to_intersection
19
+ handle_derived_specific_occurrences
20
+ end
21
+
22
+ # Extract the code_list_xpath and the criteria's value from either the location related to the specific occurrence,
23
+ # or from any of the template ids (if multiple exist)
24
+ def extract_code_list_path_and_result_value
25
+ if @template_ids.empty? && @specific_occurrence
26
+ template = @entry.document.at_xpath(
27
+ "//cda:id[@root='#{@source_data_criteria_root}' and @extension='#{@source_data_criteria_extension}']/../cda:templateId/cda:item/@root")
28
+ if template
29
+ mapping = ValueSetHelper.get_mapping_for_template(template.to_s)
30
+ handle_mapping_template(mapping)
31
+ end
32
+ end
33
+ @template_ids.each do |t|
34
+ mapping = ValueSetHelper.get_mapping_for_template(t)
35
+ handle_mapping_template(mapping)
36
+ break if mapping # quit if one template id with a mapping has set these values
37
+ end
38
+ end
39
+
40
+ # Set the value and code_list_xpath using the template mapping held in the ValueSetHelper class
41
+ def handle_mapping_template(mapping)
42
+ if mapping
43
+ if mapping[:valueset_path] && @entry.at_xpath(mapping[:valueset_path])
44
+ @code_list_xpath = mapping[:valueset_path]
45
+ end
46
+ @value = DataCriteriaMethods.parse_value(@entry, mapping[:result_path]) if mapping[:result_path]
47
+ end
48
+ end
49
+
50
+ # Changes XPRODUCT data criteria that has an associated tempalte(s) to an INTERSETION criteria.
51
+ # UNION is used for all other cases.
52
+ def change_xproduct_to_intersection
53
+ # Need to handle grouper criteria that do not have template ids -- these will be union of and intersection
54
+ # criteria
55
+ return unless @template_ids.empty?
56
+ # Change the XPRODUCT to an INTERSECT otherwise leave it as a UNION
57
+ @derivation_operator = HQMF::DataCriteria::INTERSECT if @derivation_operator == HQMF::DataCriteria::XPRODUCT
58
+ @description ||= (@derivation_operator == HQMF::DataCriteria::INTERSECT) ? 'Intersect' : 'Union'
59
+ end
60
+
61
+ # Apply some elements from the reference_criteria to the derived specific occurrence
62
+ def handle_derived_specific_occurrences
63
+ return unless @definition == 'derived'
64
+
65
+ # remove "_source" from source data critera. It gets added in in SpecificOccurrenceAndSource but
66
+ # when it gets added we have not yet determined the definition of the data criteria so we cannot
67
+ # skip adding it. Determining the definition before SpecificOccurrenceAndSource processes doesn't
68
+ # work because we need to know if it is a specific occurrence to be able to figure out the definition
69
+ @source_data_criteria = @source_data_criteria.gsub("_source",'') if @source_data_criteria
70
+
71
+ # Adds a child if none exists (specifically the source criteria)
72
+ @children_criteria << @source_data_criteria if @children_criteria.empty?
73
+ return if @children_criteria.length != 1 ||
74
+ (@source_data_criteria.present? && @children_criteria.first != @source_data_criteria)
75
+ # if child.first is nil, it will be caught in the second statement
76
+ reference_criteria = @data_criteria_references[@children_criteria.first]
77
+ return if reference_criteria.nil?
78
+ @is_derived_specific_occurrence_variable = true # easier to track than all testing all features of these cases
79
+ @subset_operators ||= reference_criteria.subset_operators
80
+ @derivation_operator ||= reference_criteria.derivation_operator
81
+ @description = reference_criteria.description
82
+ @variable = reference_criteria.variable
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,117 @@
1
+ module HQMF2
2
+ # Handles various tasks that the Data Criteria needs performed to obtain and
3
+ # modify secific occurrences
4
+ class SpecificOccurrenceAndSource
5
+ include HQMF2::Utilities
6
+
7
+ def initialize(entry, id, local_variable_name, data_criteria_references, occurrences_map)
8
+ @entry = entry
9
+ @id = id
10
+ @local_variable_name = local_variable_name
11
+ @occurrences_map = occurrences_map
12
+ @is_variable = DataCriteriaMethods.extract_variable(@local_variable_name, @id)
13
+ @data_criteria_references = data_criteria_references
14
+ end
15
+
16
+ # Retrieve the specific occurrence and source data criteria information (or just source if there is no specific)
17
+ def extract_specific_occurrences_and_source_data_criteria
18
+ specific_def = @entry.at_xpath('./*/cda:outboundRelationship[@typeCode="OCCR"]', HQMF2::Document::NAMESPACES)
19
+ source_def = @entry.at_xpath('./*/cda:outboundRelationship[cda:subsetCode/@code="SOURCE"]',
20
+ HQMF2::Document::NAMESPACES)
21
+ if specific_def
22
+ source_data_criteria_extension = HQMF2::Utilities.attr_val(specific_def,
23
+ './cda:criteriaReference/cda:id/@extension')
24
+ source_data_criteria_root = HQMF2::Utilities.attr_val(specific_def, './cda:criteriaReference/cda:id/@root')
25
+
26
+ occurrence_criteria = @data_criteria_references[strip_tokens("#{source_data_criteria_extension}_#{source_data_criteria_root}")]
27
+
28
+ return if occurrence_criteria.nil?
29
+ specific_occurrence_const = HQMF2::Utilities.attr_val(specific_def,
30
+ './cda:localVariableName/@controlInformationRoot')
31
+ specific_occurrence = HQMF2::Utilities.attr_val(specific_def,
32
+ './cda:localVariableName/@controlInformationExtension')
33
+
34
+ # FIXME: Remove debug statements after cleaning up occurrence handling
35
+ # build regex for extracting alpha-index of specific occurrences
36
+ occurrence_identifier = obtain_occurrence_identifier(strip_tokens(@id),
37
+ strip_tokens(@local_variable_name) || '',
38
+ strip_tokens(source_data_criteria_extension),
39
+ @is_variable)
40
+
41
+ handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root,
42
+ specific_occurrence_const, specific_occurrence)
43
+
44
+ elsif source_def
45
+ extension = HQMF2::Utilities.attr_val(source_def, './cda:criteriaReference/cda:id/@extension')
46
+ root = HQMF2::Utilities.attr_val(source_def, './cda:criteriaReference/cda:id/@root')
47
+ ["#{extension}_#{root}_source", root, extension] # return the soruce data criteria itself, the rest will be blank
48
+ end
49
+ end
50
+
51
+ # Handle setting the specific and source instance variables with a given occurrence identifier
52
+ def handle_specific_and_source(occurrence_identifier, source_data_criteria_extension, source_data_criteria_root,
53
+ specific_occurrence_const, specific_occurrence)
54
+ source_data_criteria = "#{source_data_criteria_extension}_#{source_data_criteria_root}_source"
55
+ if !occurrence_identifier.blank?
56
+ # if it doesn't exist, add extracted occurrence to the map
57
+ # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}"
58
+ @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier
59
+ specific_occurrence ||= occurrence_identifier
60
+ specific_occurrence_const = "#{source_data_criteria}".upcase
61
+ else
62
+ # create variable occurrences that do not already exist
63
+ if @is_variable
64
+ # puts "\tSetting #{@source_data_criteria}-#{@source_data_criteria_root} to #{occurrence_identifier}"
65
+ @occurrences_map[strip_tokens(source_data_criteria)] ||= occurrence_identifier
66
+ end
67
+ occurrence = @occurrences_map.try(:[], strip_tokens(source_data_criteria))
68
+ unless occurrence
69
+ fail "Could not find occurrence mapping for #{source_data_criteria}, #{source_data_criteria_root}"
70
+ end
71
+ # puts "\tUsing #{occurrence} for #{@id}"
72
+ specific_occurrence ||= occurrence
73
+ end
74
+
75
+ specific_occurrence = 'A' unless specific_occurrence
76
+ specific_occurrence_const = source_data_criteria.upcase unless specific_occurrence_const
77
+ [source_data_criteria, source_data_criteria_root, source_data_criteria_extension,
78
+ specific_occurrence, specific_occurrence_const]
79
+ end
80
+
81
+ # Using the id, source data criteria id, and local variable name (and whether or not it's a variable),
82
+ # extract the occurrence identifiter (if one exists).
83
+ def obtain_occurrence_identifier(stripped_id, stripped_lvn, stripped_sdc, is_variable)
84
+ if is_variable || (stripped_sdc.include? 'qdm_var')
85
+ occurrence_lvn_regex = 'occ[A-Z]of_qdm_var'
86
+ occurrence_id_regex = 'occ[A-Z]of_qdm_var'
87
+ occ_index = 3
88
+ return handle_occurrence_var(stripped_id, stripped_lvn, stripped_sdc, occurrence_id_regex, occurrence_lvn_regex, occ_index)
89
+ else
90
+ occurrence_lvn_regex = 'Occurrence[A-Z]of'
91
+ occurrence_id_regex = 'Occurrence[A-Z]_'
92
+ occ_index = 10
93
+
94
+ occurrence_identifier = handle_occurrence_var(
95
+ stripped_id, stripped_lvn, stripped_sdc,
96
+ "#{occurrence_id_regex}#{stripped_sdc}", "#{occurrence_lvn_regex}#{stripped_sdc}",
97
+ occ_index)
98
+ return occurrence_identifier if occurrence_identifier.present?
99
+
100
+ stripped_sdc[occ_index] if stripped_sdc.match(
101
+ /(^#{occurrence_id_regex}| ^#{occurrence_id_regex}qdm_var_| ^#{occurrence_lvn_regex})| ^#{occurrence_lvn_regex}qdm_var_/)
102
+ end
103
+ end
104
+
105
+ # If the occurrence is a variable, extract the occurrence identifier (if present)
106
+ def handle_occurrence_var(stripped_id, stripped_lvn, stripped_sdc, occurrence_id_compare, occurrence_lvn_compare, occ_index)
107
+ # TODO: Handle specific occurrences of variables that don't self-reference?
108
+ if stripped_id.match(/^#{occurrence_id_compare}/)
109
+ return stripped_id[occ_index]
110
+ elsif stripped_lvn.match(/^#{occurrence_lvn_compare}/)
111
+ return stripped_lvn[occ_index]
112
+ elsif stripped_sdc.match(/^#{occurrence_id_compare}/)
113
+ return stripped_sdc[occ_index]
114
+ end
115
+ end
116
+ end
117
+ end