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
data/Gemfile CHANGED
@@ -15,4 +15,9 @@ group :test do
15
15
  gem "cane", '~> 2.3.0'
16
16
  gem 'simplecov', :require => false
17
17
  gem 'webmock'
18
+
19
+ gem 'minitest'
20
+ gem 'turn', :require => false
21
+ gem 'awesome_print', :require => 'ap'
22
+
18
23
  end
@@ -5,6 +5,8 @@ require 'uuid'
5
5
  require 'builder'
6
6
  require 'csv'
7
7
  require 'nokogiri'
8
+ require 'ostruct'
9
+ require 'log4r'
8
10
 
9
11
  # Freedom patches
10
12
  require_relative 'health-data-standards/ext/symbol'
@@ -22,9 +24,11 @@ require_relative 'health-data-standards/export/c32'
22
24
  require_relative 'health-data-standards/export/ccda'
23
25
  require_relative 'health-data-standards/export/ccr'
24
26
  require_relative 'health-data-standards/export/csv'
27
+ require_relative 'health-data-standards/export/helper/html_view_helper'
25
28
  require_relative 'health-data-standards/export/html'
26
29
  require_relative 'health-data-standards/export/hdata/metadata'
27
30
 
31
+ require_relative 'health-data-standards/export/helper/gc32_view_helper'
28
32
  require_relative 'health-data-standards/export/green_c32/record'
29
33
  require_relative 'health-data-standards/export/green_c32/entry'
30
34
  require_relative 'health-data-standards/export/green_c32/export_generator'
@@ -69,20 +73,28 @@ require_relative 'health-data-standards/models/metadata/change_info'
69
73
  require_relative 'health-data-standards/models/metadata/link_info'
70
74
  require_relative 'health-data-standards/models/metadata/pedigree'
71
75
 
72
- require_relative 'health-data-standards/import/c32/locatable_import_utils'
73
- require_relative 'health-data-standards/import/c32/section_importer'
74
- require_relative 'health-data-standards/import/c32/allergy_importer'
75
- require_relative 'health-data-standards/import/c32/encounter_importer'
76
+ require_relative 'health-data-standards/export/qrda/entry_template_resolver'
77
+ require_relative 'health-data-standards/export/helper/cat1_view_helper'
78
+ require_relative 'health-data-standards/export/cat_1'
79
+
80
+ require_relative 'health-data-standards/import/cda/narrative_reference_handler'
81
+ require_relative 'health-data-standards/import/cda/entry_finder'
82
+ require_relative 'health-data-standards/import/cda/locatable_import_utils'
83
+ require_relative 'health-data-standards/import/cda/section_importer'
84
+ require_relative 'health-data-standards/import/cda/provider_importer'
85
+ require_relative 'health-data-standards/import/cda/organization_importer'
86
+ require_relative 'health-data-standards/import/cda/allergy_importer'
87
+ require_relative 'health-data-standards/import/cda/condition_importer'
88
+ require_relative 'health-data-standards/import/cda/encounter_importer'
89
+ require_relative 'health-data-standards/import/cda/medical_equipment_importer'
90
+ require_relative 'health-data-standards/import/cda/medication_importer'
91
+ require_relative 'health-data-standards/import/cda/procedure_importer'
92
+ require_relative 'health-data-standards/import/cda/result_importer'
93
+ require_relative 'health-data-standards/import/cda/vital_sign_importer'
94
+
76
95
  require_relative 'health-data-standards/import/c32/condition_importer'
77
96
  require_relative 'health-data-standards/import/c32/immunization_importer'
78
- require_relative 'health-data-standards/import/c32/medication_importer'
79
- require_relative 'health-data-standards/import/c32/procedure_importer'
80
- require_relative 'health-data-standards/import/c32/result_importer'
81
- require_relative 'health-data-standards/import/c32/vital_sign_importer'
82
97
  require_relative 'health-data-standards/import/c32/patient_importer'
83
- require_relative 'health-data-standards/import/c32/provider_importer'
84
- require_relative 'health-data-standards/import/c32/organization_importer'
85
- require_relative 'health-data-standards/import/c32/medical_equipment_importer'
86
98
  require_relative 'health-data-standards/import/c32/insurance_provider_importer'
87
99
  require_relative 'health-data-standards/import/c32/care_goal_importer'
88
100
 
@@ -119,4 +131,35 @@ require_relative 'health-data-standards/import/green_c32/immunization_importer'
119
131
  require_relative 'health-data-standards/import/green_c32/support_importer'
120
132
  require_relative 'health-data-standards/import/green_c32/advance_directive_importer'
121
133
  require_relative 'health-data-standards/import/green_c32/medical_equipment_importer'
122
- require_relative 'health-data-standards/import/green_c32/care_goal_importer'
134
+ require_relative 'health-data-standards/import/green_c32/care_goal_importer'
135
+
136
+ require_relative 'health-data-standards/import/cat1/gestational_age_importer'
137
+ require_relative 'health-data-standards/import/cat1/procedure_intolerance_importer'
138
+ require_relative 'health-data-standards/import/cat1/procedure_order_importer'
139
+ require_relative 'health-data-standards/import/cat1/diagnosis_active_importer'
140
+ require_relative 'health-data-standards/import/cat1/diagnosis_inactive_importer'
141
+ require_relative 'health-data-standards/import/cat1/patient_importer'
142
+ require_relative 'health-data-standards/import/cat1/lab_order_importer'
143
+ require_relative 'health-data-standards/import/cat1/medication_dispensed_importer'
144
+ require_relative 'health-data-standards/import/cat1/encounter_order_importer'
145
+ require_relative 'health-data-standards/import/cat1/diagnostic_study_order_importer'
146
+ require_relative 'health-data-standards/import/cat1/tobacco_use_importer'
147
+ require_relative 'health-data-standards/import/cat1/entry_package'
148
+
149
+ require_relative 'health-data-standards/models/cqm/bundle'
150
+ require_relative 'health-data-standards/models/cqm/measure'
151
+ require_relative 'health-data-standards/import/bundle/importer'
152
+
153
+
154
+ module HealthDataStandards
155
+ class << self
156
+ attr_accessor :logger
157
+ end
158
+ end
159
+
160
+ if defined?(Rails)
161
+ require_relative 'health-data-standards/railtie'
162
+ else
163
+ HealthDataStandards.logger = Log4r::Logger.new("Health Data Standards")
164
+ HealthDataStandards.logger.outputters = Log4r::Outputter.stdout
165
+ end
@@ -1,14 +1,15 @@
1
1
  module HealthDataStandards
2
2
  module Export
3
- module C32
4
- include TemplateHelper
3
+ class C32
4
+ def initialize
5
+ template_helper = TemplateHelper.new('c32', 'c32')
6
+ @rendering_context = RenderingContext.new
7
+ @rendering_context.template_helper = template_helper
8
+ end
5
9
 
6
10
  def export(patient)
7
- self.template_format = "c32"
8
- render(:template => 'show', :locals => {:patient => patient})
11
+ @rendering_context.render(:template => 'show', :locals => {:patient => patient})
9
12
  end
10
-
11
- extend self
12
13
  end
13
14
  end
14
15
  end
@@ -0,0 +1,18 @@
1
+ module HealthDataStandards
2
+ module Export
3
+ class Cat1
4
+ def initialize
5
+ template_helper = HealthDataStandards::Export::TemplateHelper.new('cat1', 'cat1')
6
+ @rendering_context = HealthDataStandards::Export::RenderingContext.new
7
+ @rendering_context.template_helper = template_helper
8
+ @rendering_context.extensions = [HealthDataStandards::Export::Helper::Cat1ViewHelper]
9
+ end
10
+
11
+ @@vs_map = nil
12
+ def export(patient, measures, start_date, end_date)
13
+ @rendering_context.render(:template => 'show', :locals => {:patient => patient, :measures => measures,
14
+ :start_date => start_date, :end_date => end_date})
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,15 +1,15 @@
1
1
  module HealthDataStandards
2
2
  module Export
3
- module CCDA
4
- include TemplateHelper
5
-
6
- def export(patient)
7
- self.template_format = "ccda"
8
- self.template_subdir = "ccda"
9
- render(:template => 'show', :locals => {:patient => patient})
3
+ class CCDA
4
+ def initialize
5
+ template_helper = TemplateHelper.new('ccda', 'ccda')
6
+ @rendering_context = RenderingContext.new
7
+ @rendering_context.template_helper = template_helper
10
8
  end
11
9
 
12
- extend self
10
+ def export(patient)
11
+ @rendering_context.render(:template => 'show', :locals => {:patient => patient})
12
+ end
13
13
  end
14
14
  end
15
15
  end
@@ -1,14 +1,17 @@
1
1
  module HealthDataStandards
2
2
  module Export
3
3
  module GreenC32
4
- module Entry
5
- include TemplateHelper
4
+ class Entry
5
+ def initialize
6
+ template_helper = TemplateHelper.new('gc32', 'gc32')
7
+ @rendering_context = RenderingContext.new
8
+ @rendering_context.template_helper = template_helper
9
+ @rendering_context.extensions = [HealthDataStandards::Export::Helper::GC32ViewHelper]
10
+ end
6
11
 
7
12
  def export(object, object_type)
8
- self.template_format = "gc32"
9
- render(partial: object_type, locals: {object_type => object, type: object_type})
13
+ @rendering_context.render(partial: object_type, locals: {object_type => object, type: object_type})
10
14
  end
11
- extend self
12
15
  end
13
16
  end
14
17
  end
@@ -12,7 +12,7 @@ module HealthDataStandards
12
12
  def create_exporter_for(section)
13
13
  object = Object.new
14
14
  object.define_singleton_method(:export) do |section_instance|
15
- HealthDataStandards::Export::GreenC32::Entry.export(section_instance, section)
15
+ HealthDataStandards::Export::GreenC32::Entry.new.export(section_instance, section)
16
16
  end
17
17
  object
18
18
  end
@@ -1,14 +1,17 @@
1
1
  module HealthDataStandards
2
2
  module Export
3
3
  module GreenC32
4
- module Record
5
- include TemplateHelper
6
-
7
- def export(object)
8
- self.template_format = "gc32"
9
- render(template: "record", locals: {record: object})
4
+ class Record
5
+ def initialize
6
+ template_helper = TemplateHelper.new('gc32', 'gc32')
7
+ @rendering_context = RenderingContext.new
8
+ @rendering_context.template_helper = template_helper
9
+ @rendering_context.extensions = [HealthDataStandards::Export::Helper::GC32ViewHelper]
10
+ end
11
+
12
+ def export(patient)
13
+ @rendering_context.render(:template => 'record', :locals => {:record => patient})
10
14
  end
11
- extend self
12
15
  end
13
16
  end
14
17
  end
@@ -1,15 +1,16 @@
1
1
  module HealthDataStandards
2
2
  module Export
3
3
  module Hdata
4
- module Metadata
5
- include TemplateHelper
4
+ class Metadata
5
+ def initialize
6
+ template_helper = TemplateHelper.new('hdata')
7
+ @rendering_context = RenderingContext.new
8
+ @rendering_context.template_helper = template_helper
9
+ end
6
10
 
7
11
  def export(entry, metadata)
8
- self.template_format = "hdata"
9
- render(:template => 'metadata', :locals => {entry: entry, metadata: metadata})
12
+ @rendering_context.render(:template => 'metadata', :locals => {entry: entry, metadata: metadata})
10
13
  end
11
-
12
- extend self
13
14
  end
14
15
  end
15
16
  end
@@ -0,0 +1,133 @@
1
+ module HealthDataStandards
2
+ module Export
3
+ module Helper
4
+ module Cat1ViewHelper
5
+ include HealthDataStandards::Util
6
+ include HealthDataStandards::SVS
7
+
8
+ def value_set_map
9
+ @@vs_map ||= Hash[*ValueSet.all.map{ |p| [p.oid, p] }.flatten]
10
+ end
11
+
12
+ # Find all of the entries on a patient that match the given data criteria
13
+ def entries_for_data_criteria(data_criteria, patient)
14
+ data_criteria_oid = HQMFTemplateHelper.template_id_by_definition_and_status(data_criteria.definition,
15
+ data_criteria.status || '',
16
+ data_criteria.negation)
17
+ filtered_entries = []
18
+ case data_criteria_oid
19
+ when '2.16.840.1.113883.3.560.1.404'
20
+ filtered_entries = handle_patient_expired(patient)
21
+ when '2.16.840.1.113883.3.560.1.401'
22
+ filtered_entries = handle_clinical_trial_participant(patient)
23
+ when '2.16.840.1.113883.3.560.1.405'
24
+ filtered_entries = handle_payer_information(patient)
25
+ else
26
+ entries = patient.entries_for_oid(data_criteria_oid)
27
+ codes = []
28
+ vs = value_set_map[data_criteria.code_list_id]
29
+ if vs
30
+ codes = vs.code_set_map
31
+ else
32
+ HealthDataStandards.logger.warn("No codes for #{data_criteria.code_list_id}")
33
+ end
34
+ filtered_entries = entries.find_all do |entry|
35
+ # This special case is for when the code list is a reason
36
+ if data_criteria.code_list_id =~ /2\.16\.840\.1\.113883\.3\.526\.3\.100[7-9]/
37
+ entry.negation_reason.present? && codes.first['values'].include?(entry.negation_reason['code'])
38
+ else
39
+ # The !! hack makes sure that negation_ind is a boolean
40
+ entry.is_in_code_set?(codes) && !!entry.negation_ind == data_criteria.negation
41
+ end
42
+ end
43
+ end
44
+ if filtered_entries.empty?
45
+ HealthDataStandards.logger.debug("No entries for #{data_criteria.title}")
46
+ end
47
+
48
+ filtered_entries
49
+ end
50
+
51
+ # Given a set of measures, find the data criteria/value set pairs that are unique across all of them
52
+ # Returns an Array of Hashes. Hashes will have a three key/value pairs. One for the data criteria oid,
53
+ # one for the value set oid and one for the data criteria itself
54
+ def unique_data_criteria(measures)
55
+ all_data_criteria = measures.map {|measure| measure.all_data_criteria}.flatten
56
+ dc_oids_and_vs_oids = all_data_criteria.map do |data_criteria|
57
+ data_criteria_oid = HQMFTemplateHelper.template_id_by_definition_and_status(data_criteria.definition,
58
+ (data_criteria.status || ""),
59
+ data_criteria.negation)
60
+ value_set_oid = data_criteria.code_list_id
61
+ {'data_criteria_oid' => data_criteria_oid, 'value_set_oid' => value_set_oid, 'data_criteria' => data_criteria}
62
+ end
63
+ dc_oids_and_vs_oids.uniq_by {|thingy| [thingy['data_criteria_oid'], thingy['value_set_oid']]}
64
+ end
65
+
66
+ def render_data_criteria(dc_oid, vs_oid, entries)
67
+ html_array = entries.map do |entry|
68
+ if dc_oid == '2.16.840.1.113883.3.560.1.1001'
69
+ # This is a special case. This HQMF OID maps to more than one QRDA OID.
70
+ # So we need to try to figure out what template we should use based on the
71
+ # content of the entry
72
+ if vs_oid == '2.16.840.1.113883.3.526.3.1279'
73
+ # Patient Characteristic Observation Assertion template for
74
+ # Patient Characteristic: ECOG Performance Status-Poor
75
+ render(:partial => '2.16.840.1.113883.10.20.24.3.103', :locals => {:entry => entry,
76
+ :value_set_oid => vs_oid})
77
+ elsif vs_oid == "2.16.840.1.113883.3.117.1.7.1.402" || vs_oid == "2.16.840.1.113883.3.117.1.7.1.403"
78
+ # Patient Charasteristic Gestational Age
79
+ render(:partial => '2.16.840.1.113883.10.20.24.3.101', :locals => {:entry => entry,
80
+ :value_set_oid => vs_oid})
81
+ elsif vs_oid == "2.16.840.1.113883.3.526.3.1189" || vs_oid == "2.16.840.1.113883.3.526.3.1170"
82
+ # Patient Characteristic Tobacco User/Non-User
83
+ render(:partial => '2.16.840.1.113883.10.20.22.4.85', :locals => {:entry => entry,
84
+ :value_set_oid => vs_oid})
85
+ end
86
+ else
87
+ render(:partial => HealthDataStandards::Export::QRDA::EntryTemplateResolver.partial_for(dc_oid), :locals => {:entry => entry,
88
+ :value_set_oid => vs_oid})
89
+ end
90
+ end
91
+ html_array.join("\n")
92
+ end
93
+
94
+ def render_patient_data(patient, measures)
95
+ udcs = unique_data_criteria(measures)
96
+ data_criteria_html = udcs.map do |udc|
97
+ entries = entries_for_data_criteria(udc['data_criteria'], patient)
98
+ render_data_criteria(udc['data_criteria_oid'], udc['value_set_oid'], entries)
99
+ end
100
+ data_criteria_html.compact.join("\n")
101
+ end
102
+
103
+ def negation_indicator(entry)
104
+ if entry.negation_ind
105
+ 'negationInd="true"'
106
+ else
107
+ ''
108
+ end
109
+ end
110
+
111
+ def handle_clinical_trial_participant(patient)
112
+ if patient.clinical_trial_participant
113
+ [{dummy_entry: true}]
114
+ else
115
+ []
116
+ end
117
+ end
118
+
119
+ def handle_patient_expired(patient)
120
+ if patient.expired
121
+ [OpenStruct.new(start_date: patient.deathdate)]
122
+ else
123
+ []
124
+ end
125
+ end
126
+
127
+ def handle_payer_information(patient)
128
+ patient.insurance_providers
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,39 @@
1
+ module HealthDataStandards
2
+ module Export
3
+ module Helper
4
+ module GC32ViewHelper
5
+ def gc32_code_display(entry, options={})
6
+ code_display(entry, options.merge("exclude_null_flavor" => true))
7
+ end
8
+
9
+ def gc32_effective_time(entry)
10
+ if entry.time
11
+ "<effectiveTime value=\"#{Time.at(entry.time).xmlschema}\" />"
12
+ elsif entry.start_time || entry.end_time
13
+ gc32_interval(entry, "effectiveTime", :start_time, :end_time)
14
+ else
15
+ "<effectiveTime />"
16
+ end
17
+ end
18
+
19
+ def gc32_interval(entry, tag_name, start_attribute, end_attribute)
20
+ time = "<#{tag_name}>"
21
+ time += "<start value=\"#{Time.at(entry.send(start_attribute)).xmlschema}\" />" if entry.send(start_attribute)
22
+ time += "<end value=\"#{Time.at(entry.send(end_attribute)).xmlschema}\" />" if entry.send(end_attribute)
23
+ time += "</#{tag_name}>"
24
+ end
25
+
26
+ def quantity_display(value, tag_name="value")
27
+ return unless value
28
+ if value.respond_to?(:scalar)
29
+ "<#{tag_name} amount=\"#{value.scalar}\" unit=\"#{value.units}\" />"
30
+ elsif value['scalar'].present?
31
+ "<#{tag_name} amount=\"#{value['scalar']}\" unit=\"#{value['units']}\" />"
32
+ else
33
+ "<#{tag_name} amount=\"#{value['value']}\" unit=\"#{value['unit']}\" />"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ module HealthDataStandards
2
+ module Export
3
+ module Helper
4
+ module HTMLViewHelper
5
+ def decode_hqmf_section(section, oid)
6
+ if oid
7
+ HealthDataStandards::Util::HQMFTemplateHelper.definition_for_template_id(oid)['definition'].pluralize.to_sym
8
+ else
9
+ section
10
+ end
11
+ end
12
+
13
+ def decode_hqmf_status(status, oid)
14
+ if oid
15
+ HealthDataStandards::Util::HQMFTemplateHelper.definition_for_template_id(oid)['status']
16
+ else
17
+ status
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end