health-data-standards 2.2.1 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. data/Gemfile +5 -0
  2. data/lib/health-data-standards.rb +55 -12
  3. data/lib/health-data-standards/export/c32.rb +7 -6
  4. data/lib/health-data-standards/export/cat_1.rb +18 -0
  5. data/lib/health-data-standards/export/ccda.rb +8 -8
  6. data/lib/health-data-standards/export/green_c32/entry.rb +8 -5
  7. data/lib/health-data-standards/export/green_c32/export_generator.rb +1 -1
  8. data/lib/health-data-standards/export/green_c32/record.rb +10 -7
  9. data/lib/health-data-standards/export/hdata/metadata.rb +7 -6
  10. data/lib/health-data-standards/export/helper/cat1_view_helper.rb +133 -0
  11. data/lib/health-data-standards/export/helper/gc32_view_helper.rb +39 -0
  12. data/lib/health-data-standards/export/helper/html_view_helper.rb +23 -0
  13. data/lib/health-data-standards/export/html.rb +22 -10
  14. data/lib/health-data-standards/export/qrda/entry_template_resolver.rb +31 -0
  15. data/lib/health-data-standards/export/qrda/hqmf-qrda-oids.json +638 -0
  16. data/lib/health-data-standards/export/rendering_context.rb +37 -3
  17. data/lib/health-data-standards/export/template_helper.rb +20 -23
  18. data/lib/health-data-standards/export/view_helper.rb +8 -42
  19. data/lib/health-data-standards/import/bundle/importer.rb +148 -0
  20. data/lib/health-data-standards/import/c32/care_goal_importer.rb +14 -26
  21. data/lib/health-data-standards/import/c32/condition_importer.rb +12 -51
  22. data/lib/health-data-standards/import/c32/immunization_importer.rb +9 -27
  23. data/lib/health-data-standards/import/c32/insurance_provider_importer.rb +24 -21
  24. data/lib/health-data-standards/import/c32/patient_importer.rb +27 -34
  25. data/lib/health-data-standards/import/cat1/diagnosis_active_importer.rb +19 -0
  26. data/lib/health-data-standards/import/cat1/diagnosis_inactive_importer.rb +19 -0
  27. data/lib/health-data-standards/import/cat1/diagnostic_study_order_importer.rb +24 -0
  28. data/lib/health-data-standards/import/cat1/encounter_order_importer.rb +24 -0
  29. data/lib/health-data-standards/import/cat1/entry_package.rb +25 -0
  30. data/lib/health-data-standards/import/cat1/gestational_age_importer.rb +42 -0
  31. data/lib/health-data-standards/import/cat1/lab_order_importer.rb +24 -0
  32. data/lib/health-data-standards/import/cat1/medication_dispensed_importer.rb +13 -0
  33. data/lib/health-data-standards/import/cat1/patient_importer.rb +104 -0
  34. data/lib/health-data-standards/import/cat1/procedure_intolerance_importer.rb +13 -0
  35. data/lib/health-data-standards/import/cat1/procedure_order_importer.rb +38 -0
  36. data/lib/health-data-standards/import/cat1/tobacco_use_importer.rb +19 -0
  37. data/lib/health-data-standards/import/ccda/allergy_importer.rb +2 -8
  38. data/lib/health-data-standards/import/ccda/care_goal_importer.rb +1 -1
  39. data/lib/health-data-standards/import/ccda/condition_importer.rb +2 -3
  40. data/lib/health-data-standards/import/ccda/encounter_importer.rb +2 -5
  41. data/lib/health-data-standards/import/ccda/immunization_importer.rb +1 -3
  42. data/lib/health-data-standards/import/ccda/insurance_provider_importer.rb +1 -1
  43. data/lib/health-data-standards/import/ccda/medical_equipment_importer.rb +2 -4
  44. data/lib/health-data-standards/import/ccda/medication_importer.rb +2 -4
  45. data/lib/health-data-standards/import/ccda/patient_importer.rb +1 -1
  46. data/lib/health-data-standards/import/ccda/procedure_importer.rb +2 -6
  47. data/lib/health-data-standards/import/ccda/result_importer.rb +2 -5
  48. data/lib/health-data-standards/import/ccda/vital_sign_importer.rb +2 -3
  49. data/lib/health-data-standards/import/cda/allergy_importer.rb +32 -0
  50. data/lib/health-data-standards/import/cda/condition_importer.rb +51 -0
  51. data/lib/health-data-standards/import/{c32 → cda}/encounter_importer.rb +9 -35
  52. data/lib/health-data-standards/import/cda/entry_finder.rb +22 -0
  53. data/lib/health-data-standards/import/{c32 → cda}/locatable_import_utils.rb +2 -3
  54. data/lib/health-data-standards/import/cda/medical_equipment_importer.rb +24 -0
  55. data/lib/health-data-standards/import/{c32 → cda}/medication_importer.rb +13 -15
  56. data/lib/health-data-standards/import/cda/narrative_reference_handler.rb +35 -0
  57. data/lib/health-data-standards/import/{c32 → cda}/organization_importer.rb +1 -1
  58. data/lib/health-data-standards/import/cda/procedure_importer.rb +35 -0
  59. data/lib/health-data-standards/import/{c32 → cda}/provider_importer.rb +4 -8
  60. data/lib/health-data-standards/import/cda/result_importer.rb +31 -0
  61. data/lib/health-data-standards/import/{c32 → cda}/section_importer.rb +26 -48
  62. data/lib/health-data-standards/import/{c32 → cda}/vital_sign_importer.rb +2 -3
  63. data/lib/health-data-standards/import/green_c32/section_importer.rb +8 -6
  64. data/lib/health-data-standards/import/provider_import_utils.rb +2 -2
  65. data/lib/health-data-standards/models/address.rb +1 -1
  66. data/lib/health-data-standards/models/condition.rb +7 -6
  67. data/lib/health-data-standards/models/cqm/bundle.rb +45 -0
  68. data/lib/health-data-standards/models/cqm/measure.rb +36 -0
  69. data/lib/health-data-standards/models/guarantor.rb +1 -0
  70. data/lib/health-data-standards/models/insurance_provider.rb +2 -0
  71. data/lib/health-data-standards/models/order_information.rb +2 -0
  72. data/lib/health-data-standards/models/record.rb +6 -5
  73. data/lib/health-data-standards/models/svs/value_set.rb +1 -1
  74. data/lib/health-data-standards/railtie.rb +11 -0
  75. data/lib/health-data-standards/tasks/bundle.rake +107 -0
  76. data/lib/health-data-standards/util/code_system_helper.rb +9 -1
  77. data/lib/hqmf-generator/attribute.xml.erb +11 -0
  78. data/lib/hqmf-generator/characteristic_criteria.xml.erb +21 -0
  79. data/lib/hqmf-generator/code.xml.erb +13 -0
  80. data/lib/hqmf-generator/condition_criteria.xml.erb +22 -0
  81. data/lib/hqmf-generator/derivation.xml.erb +6 -0
  82. data/lib/hqmf-generator/description.xml.erb +1 -0
  83. data/lib/hqmf-generator/document.xml.erb +63 -0
  84. data/lib/hqmf-generator/effective_time.xml.erb +4 -0
  85. data/lib/hqmf-generator/encounter_criteria.xml.erb +21 -0
  86. data/lib/hqmf-generator/field.xml.erb +28 -0
  87. data/lib/hqmf-generator/hqmf-generator.rb +292 -0
  88. data/lib/hqmf-generator/observation_criteria.xml.erb +25 -0
  89. data/lib/hqmf-generator/population_criteria.xml.erb +23 -0
  90. data/lib/hqmf-generator/precondition.xml.erb +14 -0
  91. data/lib/hqmf-generator/procedure_criteria.xml.erb +22 -0
  92. data/lib/hqmf-generator/reason.xml.erb +3 -0
  93. data/lib/hqmf-generator/reference.xml.erb +3 -0
  94. data/lib/hqmf-generator/source.xml.erb +6 -0
  95. data/lib/hqmf-generator/specific_occurrence.xml.erb +7 -0
  96. data/lib/hqmf-generator/subset.xml.erb +8 -0
  97. data/lib/hqmf-generator/substance_criteria.xml.erb +26 -0
  98. data/lib/hqmf-generator/supply_criteria.xml.erb +26 -0
  99. data/lib/hqmf-generator/template_id.xml.erb +5 -0
  100. data/lib/hqmf-generator/temporal_relationship.xml.erb +6 -0
  101. data/lib/hqmf-generator/value.xml.erb +24 -0
  102. data/lib/hqmf-generator/variable_criteria.xml.erb +12 -0
  103. data/lib/hqmf-model/attribute.rb +35 -0
  104. data/lib/hqmf-model/data_criteria.json +1123 -0
  105. data/lib/hqmf-model/data_criteria.rb +344 -0
  106. data/lib/hqmf-model/document.rb +178 -0
  107. data/lib/hqmf-model/population_criteria.rb +96 -0
  108. data/lib/hqmf-model/precondition.rb +91 -0
  109. data/lib/hqmf-model/types.rb +319 -0
  110. data/lib/hqmf-model/utilities.rb +52 -0
  111. data/lib/hqmf-parser.rb +56 -0
  112. data/lib/hqmf-parser/1.0/attribute.rb +68 -0
  113. data/lib/hqmf-parser/1.0/comparison.rb +34 -0
  114. data/lib/hqmf-parser/1.0/data_criteria.rb +92 -0
  115. data/lib/hqmf-parser/1.0/data_criteria_oid_xpath.json +91 -0
  116. data/lib/hqmf-parser/1.0/document.rb +203 -0
  117. data/lib/hqmf-parser/1.0/expression.rb +58 -0
  118. data/lib/hqmf-parser/1.0/observation.rb +61 -0
  119. data/lib/hqmf-parser/1.0/population_criteria.rb +75 -0
  120. data/lib/hqmf-parser/1.0/precondition.rb +89 -0
  121. data/lib/hqmf-parser/1.0/range.rb +65 -0
  122. data/lib/hqmf-parser/1.0/restriction.rb +160 -0
  123. data/lib/hqmf-parser/1.0/utilities.rb +41 -0
  124. data/lib/hqmf-parser/2.0/data_criteria.rb +319 -0
  125. data/lib/hqmf-parser/2.0/document.rb +165 -0
  126. data/lib/hqmf-parser/2.0/population_criteria.rb +53 -0
  127. data/lib/hqmf-parser/2.0/precondition.rb +44 -0
  128. data/lib/hqmf-parser/2.0/types.rb +223 -0
  129. data/lib/hqmf-parser/2.0/utilities.rb +30 -0
  130. data/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb +252 -0
  131. data/lib/hqmf-parser/converter/pass1/document_converter.rb +185 -0
  132. data/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb +165 -0
  133. data/lib/hqmf-parser/converter/pass1/precondition_converter.rb +173 -0
  134. data/lib/hqmf-parser/converter/pass1/precondition_extractor.rb +188 -0
  135. data/lib/hqmf-parser/converter/pass1/simple_data_criteria.rb +26 -0
  136. data/lib/hqmf-parser/converter/pass1/simple_operator.rb +89 -0
  137. data/lib/hqmf-parser/converter/pass1/simple_population_criteria.rb +10 -0
  138. data/lib/hqmf-parser/converter/pass1/simple_precondition.rb +51 -0
  139. data/lib/hqmf-parser/converter/pass1/simple_restriction.rb +64 -0
  140. data/lib/hqmf-parser/converter/pass2/comparison_converter.rb +112 -0
  141. data/lib/hqmf-parser/converter/pass2/operator_converter.rb +102 -0
  142. data/lib/hqmf-parser/parser.rb +54 -0
  143. data/lib/hqmf-parser/value_sets/value_set_parser.rb +241 -0
  144. data/lib/util/counter.rb +20 -0
  145. data/templates/{_allergies.c32.erb → c32/_allergies.c32.erb} +0 -0
  146. data/templates/{_allergies_no_current.c32.erb → c32/_allergies_no_current.c32.erb} +0 -0
  147. data/templates/{_care_goals.c32.erb → c32/_care_goals.c32.erb} +0 -0
  148. data/templates/{_code_with_reference.c32.erb → c32/_code_with_reference.c32.erb} +0 -0
  149. data/templates/{_conditions.c32.erb → c32/_conditions.c32.erb} +0 -0
  150. data/templates/{_conditions_no_current.c32.erb → c32/_conditions_no_current.c32.erb} +0 -0
  151. data/templates/{_encounters.c32.erb → c32/_encounters.c32.erb} +0 -0
  152. data/templates/{_immunizations.c32.erb → c32/_immunizations.c32.erb} +0 -0
  153. data/templates/{_medical_equipment.c32.erb → c32/_medical_equipment.c32.erb} +0 -0
  154. data/templates/{_medications.c32.erb → c32/_medications.c32.erb} +0 -0
  155. data/templates/{_medications_no_current.c32.erb → c32/_medications_no_current.c32.erb} +0 -0
  156. data/templates/{_narrative_block.c32.erb → c32/_narrative_block.c32.erb} +0 -0
  157. data/templates/{_procedures.c32.erb → c32/_procedures.c32.erb} +0 -0
  158. data/templates/{_results.c32.erb → c32/_results.c32.erb} +0 -0
  159. data/templates/{_social_history.c32.erb → c32/_social_history.c32.erb} +0 -0
  160. data/templates/{_vital_signs.c32.erb → c32/_vital_signs.c32.erb} +0 -0
  161. data/templates/{show.c32.erb → c32/show.c32.erb} +0 -0
  162. data/templates/cat1/_2.16.840.1.113883.10.20.22.4.85.cat1.erb +18 -0
  163. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.1.cat1.erb +14 -0
  164. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.101.cat1.erb +25 -0
  165. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.103.cat1.erb +12 -0
  166. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.105.cat1.erb +60 -0
  167. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.11.cat1.erb +41 -0
  168. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.12.cat1.erb +50 -0
  169. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.13.cat1.erb +37 -0
  170. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.14.cat1.erb +35 -0
  171. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.17.cat1.erb +22 -0
  172. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.18.cat1.erb +21 -0
  173. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.2.cat1.erb +28 -0
  174. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.20.cat1.erb +20 -0
  175. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.22.cat1.erb +21 -0
  176. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.23.cat1.erb +71 -0
  177. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.28.cat1.erb +20 -0
  178. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.3.cat1.erb +24 -0
  179. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.31.cat1.erb +20 -0
  180. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.32.cat1.erb +15 -0
  181. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.34.cat1.erb +58 -0
  182. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.37.cat1.erb +20 -0
  183. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.38.cat1.erb +16 -0
  184. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.4.cat1.erb +27 -0
  185. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.40.cat1.erb +17 -0
  186. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.41.cat1.erb +38 -0
  187. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.42.cat1.erb +38 -0
  188. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.43.cat1.erb +24 -0
  189. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.44.cat1.erb +24 -0
  190. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.45.cat1.erb +26 -0
  191. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.46.cat1.erb +30 -0
  192. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.47.cat1.erb +26 -0
  193. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.51.cat1.erb +13 -0
  194. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.54.cat1.erb +16 -0
  195. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.55.cat1.erb +10 -0
  196. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.57.cat1.erb +19 -0
  197. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.59.cat1.erb +17 -0
  198. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.62.cat1.erb +36 -0
  199. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.63.cat1.erb +23 -0
  200. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.64.cat1.erb +29 -0
  201. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.66.cat1.erb +34 -0
  202. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.69.cat1.erb +23 -0
  203. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.7.cat1.erb +30 -0
  204. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.76.cat1.erb +32 -0
  205. data/templates/cat1/_measures.cat1.erb +66 -0
  206. data/templates/cat1/_medication_details.cat1.erb +9 -0
  207. data/templates/cat1/_ordinality.cat1.erb +4 -0
  208. data/templates/cat1/_patient_data.cat1.erb +14 -0
  209. data/templates/cat1/_reason.cat1.erb +16 -0
  210. data/templates/cat1/_record_target.cat1.erb +39 -0
  211. data/templates/cat1/_reporting_parameters.cat1.erb +24 -0
  212. data/templates/cat1/_result_value.cat1.erb +16 -0
  213. data/templates/cat1/show.cat1.erb +125 -0
  214. data/templates/{_address.gc32.erb → gc32/_address.gc32.erb} +1 -1
  215. data/templates/gc32/_advance_directive.gc32.erb +5 -0
  216. data/templates/gc32/_allergy.gc32.erb +12 -0
  217. data/templates/{_care_goal.gc32.erb → gc32/_care_goal.gc32.erb} +1 -1
  218. data/templates/gc32/_condition.gc32.erb +10 -0
  219. data/templates/gc32/_encounter.gc32.erb +28 -0
  220. data/templates/gc32/_entry.gc32.erb +3 -0
  221. data/templates/gc32/_entry_attributes.gc32.erb +10 -0
  222. data/templates/gc32/_immunization.gc32.erb +9 -0
  223. data/templates/gc32/_insurance_provider.gc32.erb +28 -0
  224. data/templates/gc32/_medical_equipment.gc32.erb +6 -0
  225. data/templates/gc32/_medication.gc32.erb +91 -0
  226. data/templates/{_name.gc32.erb → gc32/_name.gc32.erb} +0 -0
  227. data/templates/gc32/_organization.gc32.erb +10 -0
  228. data/templates/gc32/_person_attributes.gc32.erb +7 -0
  229. data/templates/gc32/_procedure.gc32.erb +9 -0
  230. data/templates/gc32/_provider.gc32.erb +9 -0
  231. data/templates/gc32/_result.gc32.erb +12 -0
  232. data/templates/gc32/_social_history.gc32.erb +6 -0
  233. data/templates/{_support.gc32.erb → gc32/_support.gc32.erb} +4 -3
  234. data/templates/gc32/_telecom.gc32.erb +1 -0
  235. data/templates/gc32/_vital_sign.gc32.erb +4 -0
  236. data/templates/{record.gc32.erb → gc32/record.gc32.erb} +26 -10
  237. data/templates/html/_entries_by_encounter.html.erb +2 -2
  238. data/templates/html/_entries_by_section.html.erb +1 -1
  239. data/templates/html/_entry.html.erb +16 -21
  240. data/templates/html/_header.html.erb +1 -1
  241. data/templates/html/_section.html.erb +1 -1
  242. data/templates/html/show.html.erb +23 -2
  243. data/templates/metadata.hdata.erb +3 -3
  244. metadata +282 -54
  245. data/lib/health-data-standards/import/c32/allergy_importer.rb +0 -47
  246. data/lib/health-data-standards/import/c32/medical_equipment_importer.rb +0 -45
  247. data/lib/health-data-standards/import/c32/procedure_importer.rb +0 -62
  248. data/lib/health-data-standards/import/c32/result_importer.rb +0 -56
  249. data/templates/_advance_directive.gc32.erb +0 -8
  250. data/templates/_allergy.gc32.erb +0 -23
  251. data/templates/_condition.gc32.erb +0 -9
  252. data/templates/_encounter.gc32.erb +0 -26
  253. data/templates/_entry.gc32.erb +0 -14
  254. data/templates/_immunization.gc32.erb +0 -11
  255. data/templates/_insurance_provider.gc32.erb +0 -0
  256. data/templates/_medical_equipment.gc32.erb +0 -7
  257. data/templates/_medication.gc32.erb +0 -72
  258. data/templates/_organization.gc32.erb +0 -10
  259. data/templates/_procedure.gc32.erb +0 -10
  260. data/templates/_provider.gc32.erb +0 -19
  261. data/templates/_result.gc32.erb +0 -16
  262. data/templates/_social_history.gc32.erb +0 -8
  263. data/templates/_telecom.gc32.erb +0 -1
  264. data/templates/_vital_sign.gc32.erb +0 -7
@@ -0,0 +1,45 @@
1
+ module HealthDataStandards
2
+ module CQM
3
+
4
+ class Bundle
5
+ include Mongoid::Document
6
+ store_in collection: 'bundles'
7
+ field :title, type: String
8
+ field :version, type: String
9
+ field :license, type: String
10
+ field :extensions, type: Array
11
+ field :effective_date
12
+ field :measure_period_start
13
+ field :records, type: Array
14
+ field :active, type: Boolean
15
+
16
+ validates_presence_of :version
17
+
18
+ def self.active
19
+ self.where({active: true})
20
+ end
21
+
22
+ def measures
23
+ HealthDataStandards::CQM::Measure.where({bundle_id: self.id}).order_by([["id", :asc],["sub_id",:asc]])
24
+ end
25
+
26
+ def records
27
+ Record.where(bundle_id: self._id, test_id: nil).order_by([["last", :asc]])
28
+ end
29
+
30
+
31
+ def value_sets
32
+ HealthDataStandards::SVS::ValueSet.in(bundle_id: self.id)
33
+ end
34
+
35
+ def delete
36
+ self.measures.destroy
37
+ self.records.destroy
38
+ self.value_sets.destroy
39
+ super
40
+ end
41
+
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,36 @@
1
+ module HealthDataStandards
2
+ module CQM
3
+
4
+ class Measure
5
+ include Mongoid::Document
6
+ store_in collection: 'measures'
7
+ field :id, type: String
8
+ field :sub_id, type: String
9
+ field :name, type: String
10
+ field :subtitle, type: String
11
+ field :short_subtitle, type: String
12
+ field :hqmf_id, type: String
13
+ field :hqmf_set_id, type: String
14
+ field :hqmf_version_number, type: String
15
+ field :nqf_id, type: String
16
+ field :type, type: String
17
+ field :category, type: String
18
+ field :population_ids , type: Hash
19
+ field :oids, type: Array
20
+ field :data_criteria, type: Array
21
+ scope :top_level_by_type , ->(type){where({"type"=> type}).any_of({"sub_id" => nil}, {"sub_id" => "a"})}
22
+ scope :top_level , any_of({"sub_id" => nil}, {"sub_id" => "a"})
23
+ scope :order_by_id_sub_id, order_by([["id", :asc],["sub_id", :asc]])
24
+ index({oids: 1})
25
+ index({hqmf_id: 1})
26
+ index({category: 1})
27
+ index "bundle_id" => 1
28
+
29
+ validates_presence_of :id
30
+ validates_presence_of :name
31
+
32
+
33
+
34
+ end
35
+ end
36
+ end
@@ -4,6 +4,7 @@ class Guarantor
4
4
  embeds_one :organization
5
5
  embeds_one :person
6
6
 
7
+ field :time, type: Integer
7
8
  field :start_time, type: Integer
8
9
  field :end_time, type: Integer
9
10
 
@@ -1,5 +1,6 @@
1
1
  class InsuranceProvider
2
2
  include Mongoid::Document
3
+ include ThingWithCodes
3
4
 
4
5
  embedded_in :record, class_name: 'Record'
5
6
  embeds_one :payer, class_name: "Organization"
@@ -14,5 +15,6 @@ class InsuranceProvider
14
15
  field :relationship, type: Hash
15
16
  field :financial_responsibility_type, type: Hash
16
17
  field :name, type: String
18
+ field :free_text, type: String
17
19
 
18
20
  end
@@ -7,6 +7,8 @@ class OrderInformation
7
7
  field :orderExpirationDateTime, type: Integer
8
8
  field :orderDateTime, type: Integer
9
9
 
10
+ belongs_to :provider
11
+
10
12
  alias :order_number :orderNumber
11
13
  alias :order_number= :orderNumber=
12
14
  alias :quantity_ordered :quantityOrdered
@@ -1,25 +1,26 @@
1
1
  class Record
2
2
  include Mongoid::Document
3
3
 
4
- field :title, type: String # TODO
4
+ field :title, type: String
5
5
  field :first, type: String
6
6
  field :last, type: String
7
7
  field :gender, type: String
8
8
  field :birthdate, type: Integer
9
- field :deathdate, type: Integer # TODO
10
- field :religious_affilication, type: Hash # TODO
9
+ field :deathdate, type: Integer
10
+ field :religious_affiliation, type: Hash
11
11
  field :effective_time, type: Integer
12
12
  field :race, type: Hash
13
13
  field :ethnicity, type: Hash
14
- field :languages, type: Array
14
+ field :languages, type: Array, default: []
15
15
  field :test_id, type: Moped::BSON::ObjectId
16
- field :marital_status, type: Hash # TODO
16
+ field :marital_status, type: Hash
17
17
  field :medical_record_number, type: String
18
18
  field :expired, type: Boolean
19
19
  field :clinicalTrialParticipant, type: Boolean # Currently not implemented in the C32 importer
20
20
  # because it cannot be easily represented in a
21
21
  # HITSP C32
22
22
 
23
+ index "last" => 1
23
24
  embeds_many :allergies
24
25
  embeds_many :care_goals, class_name: "Entry" # This can be any number of different entry types
25
26
  embeds_many :conditions
@@ -14,7 +14,7 @@ module HealthDataStandards
14
14
  index "concepts.code_system" => 1
15
15
  index "concepts.code_system_name" => 1
16
16
  index "concepts.display_name" => 1
17
-
17
+ index "bundle_id" => 1
18
18
  scope :by_oid, ->(oid){where(:oid => oid)}
19
19
 
20
20
  # Provides an Array of Hashes. Each code system gets its own Hash
@@ -0,0 +1,11 @@
1
+ module HealthDataStandards
2
+ class Railtie < Rails::Railtie
3
+ initializer 'Rails logger' do
4
+ HealthDataStandards.logger = Rails.logger
5
+ end
6
+ rake_tasks do
7
+ Dir[File.join(File.dirname(__FILE__),'tasks/*.rake')].each { |f| load f }
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,107 @@
1
+ require 'health-data-standards'
2
+
3
+ db_name = ENV['DB_NAME'] || 'test'
4
+
5
+ namespace :bundle do
6
+ desc 'Import a quality bundle into the database.'
7
+ task :import, [:bundle_path, :delete_existing, :update_measures, :type] => [:environment] do |task, args|
8
+ raise "The path to the measures zip file must be specified" unless args.bundle_path
9
+ options = {:clear_db => (args.delete_existing == "true"),
10
+ :type => args.type ,
11
+ :update_measures => (args.update_measures == "true")
12
+ }
13
+
14
+ bundle = File.open(args.bundle_path)
15
+ importer = HealthDataStandards::Import::Bundle::Importer
16
+ bundle_contents = importer.import(bundle, options)
17
+
18
+ puts "Successfully imported bundle at: #{args.bundle_path}"
19
+ puts "\t Imported into environment: #{Rails.env.upcase}" if defined? Rails
20
+ puts "\t Loaded #{args.type || 'all'} measures"
21
+ puts "\t Measures Loaded: #{bundle_contents.measures.count}"
22
+ puts "\t Test Patients Loaded: #{bundle_contents.records.count}"
23
+ puts "\t Extensions Loaded: #{bundle_contents[:extensions].count}"
24
+ end
25
+
26
+ # this task is most likely temporary. Once Bonnie can handle both EP and EH measures together, this would no longer be required.
27
+ desc 'Merge two bundles into one.'
28
+ task :merge, [:bundle_one,:bundle_two] do |t, args|
29
+ raise "Two bundle zip file paths to be merged must be specified" unless args.bundle_one && args.bundle_two
30
+
31
+ tmpdir = Dir.mktmpdir
32
+ ['measures','patients','library_functions','results', 'sources', 'value_sets'].each do |dir|
33
+
34
+ FileUtils.mkdir_p(File.join(tmpdir, 'output', dir))
35
+
36
+ end
37
+
38
+ begin
39
+
40
+ ({'one'=>args.bundle_one,'two'=>args.bundle_two}).each do |key, source|
41
+ Zip::ZipFile.open(source) do |zip_file|
42
+ zip_file.each do |f|
43
+ f_path=File.join(tmpdir, key, f.name)
44
+ FileUtils.mkdir_p(File.dirname(f_path))
45
+ zip_file.extract(f, f_path) unless File.exist?(f_path)
46
+ end
47
+ end
48
+ end
49
+
50
+
51
+ ['measures','patients','library_functions', 'sources'].each do |dir|
52
+ ['one','two'].each do |key|
53
+ FileUtils.mv(Dir.glob(File.join(tmpdir,key,dir,'*')), File.join(tmpdir,'output',dir))
54
+ end
55
+ end
56
+
57
+ ['value_sets'].each do |dir|
58
+ FileUtils.mkdir_p(File.join(tmpdir,'output',dir,'json'))
59
+ FileUtils.mkdir_p(File.join(tmpdir,'output',dir,'xml'))
60
+ ['one','two'].each do |key|
61
+ ['json', 'xml'].each do |type|
62
+ FileUtils.mv(Dir.glob(File.join(tmpdir,key,dir,type,'*')), File.join(tmpdir,'output',dir,type))
63
+ end
64
+ end
65
+ end
66
+
67
+ Dir.glob(File.join(tmpdir,'one','results','*.json')).each do |result_path_one|
68
+ json_one = JSON.parse(File.new(result_path_one).read)
69
+ result_filename = Pathname.new(result_path_one).basename.to_s
70
+ json_two = JSON.parse(File.new(File.join(tmpdir,'two','results',result_filename)).read)
71
+ File.open(File.join(tmpdir,'output','results',result_filename), 'w') {|f| f.write(JSON.pretty_generate(json_one + json_two)) }
72
+ end
73
+
74
+ json_one = JSON.parse(File.new(File.join(tmpdir,'one','bundle.json')).read)
75
+ json_two = JSON.parse(File.new(File.join(tmpdir,'two','bundle.json')).read)
76
+ json_out = {}
77
+
78
+ json_out.merge! json_one
79
+
80
+ ['measures','patients','extensions'].each do |key|
81
+ json_out[key] = (json_one[key] + json_two[key]).uniq
82
+ end
83
+
84
+ version = json_out['version']
85
+
86
+ File.open(File.join(tmpdir,'output','bundle.json'), 'w') {|f| f.write(JSON.pretty_generate(json_out)) }
87
+ date_string = Time.now.strftime("%Y-%m-%d")
88
+
89
+ out_zip = File.join('tmp','bundles',"bundle-merged-#{date_string}-#{version}.zip")
90
+ FileUtils.remove_entry_secure out_zip if File.exists?(out_zip)
91
+ Zip::ZipFile.open(out_zip, 'w') do |zipfile|
92
+ path = File.join(tmpdir,'output')
93
+ Dir[File.join(path,'**','**')].each do |file|
94
+ zipfile.add(file.sub(path+'/',''),file)
95
+ end
96
+ end
97
+
98
+ puts "wrote merged bundle to: #{out_zip}"
99
+
100
+ ensure
101
+ FileUtils.remove_entry_secure tmpdir
102
+ end
103
+
104
+
105
+ end
106
+
107
+ end
@@ -13,17 +13,25 @@ module HealthDataStandards
13
13
  '2.16.840.1.113883.6.4' => 'ICD-10-PCS',
14
14
  '2.16.840.1.113883.6.90' => 'ICD-10-CM',
15
15
  '2.16.840.1.113883.6.14' => 'HCPCS',
16
+ '2.16.840.1.113883.5.2' => "HL7 Marital Status",
16
17
  '2.16.840.1.113883.6.59' => 'CVX',
17
18
  '2.16.840.1.113883.5.83' => 'HITSP C80 Observation Status',
18
19
  '2.16.840.1.113883.3.26.1.1' => 'NCI Thesaurus',
19
20
  '2.16.840.1.113883.3.88.12.80.20' => 'FDA',
21
+ "2.16.840.1.113883.4.9" => "UNII",
22
+ "2.16.840.1.113883.6.69" => "NDC",
20
23
  '2.16.840.1.113883.5.14' => 'HL7 ActStatus',
21
24
  '2.16.840.1.113883.6.259' => 'HL7 Healthcare Service Location',
22
25
  '2.16.840.1.113883.12.112' => 'DischargeDisposition',
23
26
  '2.16.840.1.113883.5.4' => 'HL7 Act Code',
24
27
  '2.16.840.1.113883.1.11.18877' => 'HL7 Relationship Code',
25
28
  '2.16.840.1.113883.6.238' => 'CDC Race',
26
- '2.16.840.1.113883.6.177' => 'NLM MeSH'
29
+ '2.16.840.1.113883.6.177' => 'NLM MeSH',
30
+ '2.16.840.1.113883.5.1076' => "Religious Affiliation",
31
+ '2.16.840.1.113883.1.11.19717' => "HL7 ActNoImmunicationReason",
32
+ '2.16.840.1.113883.3.88.12.80.33' => "NUBC",
33
+ '2.16.840.1.113883.1.11.78' => "HL7 Observation Interpretation",
34
+ '2.16.840.1.114222.4.11.3591' => "Source of Payment Typology"
27
35
  }
28
36
 
29
37
  CODE_SYSTEM_ALIASES = {
@@ -0,0 +1,11 @@
1
+ <subjectOf>
2
+ <measureAttribute>
3
+ <id root="2.16.840.1.113883.3.100.1" extension="<%= attribute.id %>"/>
4
+ <code code="<%= attribute.code %>">
5
+ <displayName value="<%= attribute.name %>"/>
6
+ </code>
7
+ <%- if attribute.value -%>
8
+ <value xsi:type="ED" value="<%= attribute.value %>"/>
9
+ <%- end -%>
10
+ </measureAttribute>
11
+ </subjectOf>
@@ -0,0 +1,21 @@
1
+ <entry typeCode="DRIV">
2
+ <observationCriteria moodCode="EVN" classCode="OBS">
3
+ <%= xml_for_template(criteria, is_source_data_criteria) %>
4
+ <id>
5
+ <item root="2.16.840.1.113883.3.100.1" extension="<%= criteria.id %>"/>
6
+ </id>
7
+ <%= xml_for_code(criteria) %>
8
+ <%= xml_for_description(criteria) %>
9
+ <%= xml_for_effective_time(criteria) %>
10
+ <%- if criteria.value -%>
11
+ <%= xml_for_value(criteria.value) %>
12
+ <%- end -%>
13
+ <definition>
14
+ <observationReference moodCode="EVN" classCode="OBS">
15
+ <id root="2.16.840.1.113883.3.100.1" extension="<%= section_name(criteria) %>"/>
16
+ </observationReference>
17
+ </definition>
18
+ <%= xml_for_temporal_references(criteria) %>
19
+ <%= xml_for_fields(criteria) %>
20
+ </observationCriteria>
21
+ </entry>
@@ -0,0 +1,13 @@
1
+ <%- if criteria.inline_code_list -%>
2
+ <%- code_system_name = criteria.inline_code_list.keys[0] -%>
3
+ <%- code = criteria.inline_code_list[code_system_name][0] -%>
4
+ <%- code_system_oid = oid_for_name(code_system_name) -%>
5
+ <<%= name %> codeSystemName="<%= code_system_name %>" codeSystem="<%= code_system_oid %>"
6
+ code="<%= code %>">
7
+ <displayName value="<%= criteria.title %>"/>
8
+ </<%= name %>>
9
+ <%- elsif criteria.code_list_id -%>
10
+ <<%= name %><%= " xsi:type=\"CD\"" if include_type %> valueSet="<%= criteria.code_list_id %>">
11
+ <displayName value="<%= criteria.title %>"/>
12
+ </<%= name %>>
13
+ <%- end -%>
@@ -0,0 +1,22 @@
1
+ <entry typeCode="DRIV">
2
+ <observationCriteria moodCode="EVN" classCode="OBS"<%= " actionNegationInd='true'" if criteria.negation %>>
3
+ <%= xml_for_template(criteria, is_source_data_criteria) %>
4
+ <id>
5
+ <item root="2.16.840.1.113883.3.100.1" extension="<%= criteria.id %>"/>
6
+ </id>
7
+ <%= xml_for_description(criteria) %>
8
+ <%= "<statusCode code=\"#{criteria.status}\"/>" if criteria.status %>
9
+ <%= xml_for_effective_time(criteria) %>
10
+ <%= xml_for_reason(criteria) %>
11
+ <%= xml_for_code(criteria, 'value') %>
12
+ <definition>
13
+ <observationReference moodCode="EVN" classCode="OBS">
14
+ <id root="2.16.840.1.113883.3.100.1" extension="<%= section_name(criteria) %>"/>
15
+ </observationReference>
16
+ </definition>
17
+ <%= xml_for_temporal_references(criteria) %>
18
+ <%= xml_for_fields(criteria) %>
19
+ <%= xml_for_derivation(criteria) %>
20
+ <%= xml_for_subsets(criteria) %>
21
+ </observationCriteria>
22
+ </entry>
@@ -0,0 +1,6 @@
1
+ <excerpt typeCode="XCRPT">
2
+ <subsetCode code="<%= criteria.derivation_operator %>"/>
3
+ <%- criteria.children_criteria.each do |child_id| -%>
4
+ <%= xml_for_reference_id(child_id) %>
5
+ <%- end -%>
6
+ </excerpt>
@@ -0,0 +1 @@
1
+ <text value="<%= text %>"/>
@@ -0,0 +1,63 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <QualityMeasureDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <id root="2.16.840.1.113883.3.100.1" extension="<%= doc.hqmf_id %>" />
4
+ <code code="57024-2" codeSystem="2.16.840.1.113883.6.1"/>
5
+ <title value="<%= doc.title %>"/>
6
+ <text value="<%= doc.description %>"/>
7
+ <statusCode code="completed" />
8
+ <setId root="2.16.840.1.113883.3.100.1" extension="<%= doc.hqmf_set_id %>" />
9
+ <versionNumber value="<%= doc.hqmf_version_number %>"/>
10
+ <author typeCode="AUT" contextControlCode="OP">
11
+ <responsibleParty classCode="ASSIGNED" />
12
+ </author>
13
+ <custodian typeCode="CST">
14
+ <responsibleParty classCode="ASSIGNED" />
15
+ </custodian>
16
+ <controlVariable>
17
+ <measurePeriod>
18
+ <code code="MSRTP" codeSystem="2.16.840.1.113883.3.560">
19
+ <displayName value="Measurement period"/>
20
+ </code>
21
+ <value>
22
+ <low value="<%= doc.measure_period.low.value %>" />
23
+ <high value="<%= doc.measure_period.high.value %>" />
24
+ </value>
25
+ </measurePeriod>
26
+ </controlVariable>
27
+ <%- doc.attributes.each do |attribute| -%>
28
+ <%= xml_for_attribute(attribute) %>
29
+ <%- end -%>
30
+ <component>
31
+ <dataCriteriaSection>
32
+ <code code="57025-9" codeSystem="2.16.840.1.113883.6.1"/>
33
+ <title value="Data Criteria Section"/>
34
+ <text>This section describes the data criteria.</text>
35
+ <%- doc.all_data_criteria.each do |data_criteria| -%>
36
+ <%= xml_for_data_criteria(data_criteria, false) %>
37
+ <%- end -%>
38
+ <%- doc.source_data_criteria.each do |data_criteria| -%>
39
+ <%= xml_for_data_criteria(data_criteria, true) %>
40
+ <%- end -%>
41
+ </dataCriteriaSection>
42
+ </component>
43
+ <%- doc.populations.each_with_index do |population, population_index| -%>
44
+ <component>
45
+ <populationCriteriaSection>
46
+ <%- if population['stratification'] -%>
47
+ <templateId>
48
+ <item root="<%= HQMF::Document::STRATIFIED_POPULATION_TEMPLATE_ID %>" identifierName="<%= HQMF::Document::STRATIFIED_POPULATION_TEMPLATE_TITLE %>" controlInformationRoot="<%= population['stratification'] %>"/>
49
+ </templateId>
50
+ <%- end -%>
51
+ <id root="2.16.840.1.113883.3.100.1" extension="<%= population['id'] || "Population#{population_index}" %>"/>
52
+ <code code="57026-7" codeSystem="2.16.840.1.113883.6.1"/>
53
+ <title value="<%= population['title'] %>"/>
54
+ <text>This section describes the Initial Patient Population,
55
+ Numerator, Denominator, Denominator Exceptions, and Measure
56
+ Populations</text>
57
+ <%- population.keys.each do |criteria_id| -%>
58
+ <%= xml_for_population_criteria(population, criteria_id) %>
59
+ <%- end -%>
60
+ </populationCriteriaSection>
61
+ </component>
62
+ <%- end -%>
63
+ </QualityMeasureDocument>