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.
- data/Gemfile +5 -0
- data/lib/health-data-standards.rb +55 -12
- data/lib/health-data-standards/export/c32.rb +7 -6
- data/lib/health-data-standards/export/cat_1.rb +18 -0
- data/lib/health-data-standards/export/ccda.rb +8 -8
- data/lib/health-data-standards/export/green_c32/entry.rb +8 -5
- data/lib/health-data-standards/export/green_c32/export_generator.rb +1 -1
- data/lib/health-data-standards/export/green_c32/record.rb +10 -7
- data/lib/health-data-standards/export/hdata/metadata.rb +7 -6
- data/lib/health-data-standards/export/helper/cat1_view_helper.rb +133 -0
- data/lib/health-data-standards/export/helper/gc32_view_helper.rb +39 -0
- data/lib/health-data-standards/export/helper/html_view_helper.rb +23 -0
- data/lib/health-data-standards/export/html.rb +22 -10
- data/lib/health-data-standards/export/qrda/entry_template_resolver.rb +31 -0
- data/lib/health-data-standards/export/qrda/hqmf-qrda-oids.json +638 -0
- data/lib/health-data-standards/export/rendering_context.rb +37 -3
- data/lib/health-data-standards/export/template_helper.rb +20 -23
- data/lib/health-data-standards/export/view_helper.rb +8 -42
- data/lib/health-data-standards/import/bundle/importer.rb +148 -0
- data/lib/health-data-standards/import/c32/care_goal_importer.rb +14 -26
- data/lib/health-data-standards/import/c32/condition_importer.rb +12 -51
- data/lib/health-data-standards/import/c32/immunization_importer.rb +9 -27
- data/lib/health-data-standards/import/c32/insurance_provider_importer.rb +24 -21
- data/lib/health-data-standards/import/c32/patient_importer.rb +27 -34
- data/lib/health-data-standards/import/cat1/diagnosis_active_importer.rb +19 -0
- data/lib/health-data-standards/import/cat1/diagnosis_inactive_importer.rb +19 -0
- data/lib/health-data-standards/import/cat1/diagnostic_study_order_importer.rb +24 -0
- data/lib/health-data-standards/import/cat1/encounter_order_importer.rb +24 -0
- data/lib/health-data-standards/import/cat1/entry_package.rb +25 -0
- data/lib/health-data-standards/import/cat1/gestational_age_importer.rb +42 -0
- data/lib/health-data-standards/import/cat1/lab_order_importer.rb +24 -0
- data/lib/health-data-standards/import/cat1/medication_dispensed_importer.rb +13 -0
- data/lib/health-data-standards/import/cat1/patient_importer.rb +104 -0
- data/lib/health-data-standards/import/cat1/procedure_intolerance_importer.rb +13 -0
- data/lib/health-data-standards/import/cat1/procedure_order_importer.rb +38 -0
- data/lib/health-data-standards/import/cat1/tobacco_use_importer.rb +19 -0
- data/lib/health-data-standards/import/ccda/allergy_importer.rb +2 -8
- data/lib/health-data-standards/import/ccda/care_goal_importer.rb +1 -1
- data/lib/health-data-standards/import/ccda/condition_importer.rb +2 -3
- data/lib/health-data-standards/import/ccda/encounter_importer.rb +2 -5
- data/lib/health-data-standards/import/ccda/immunization_importer.rb +1 -3
- data/lib/health-data-standards/import/ccda/insurance_provider_importer.rb +1 -1
- data/lib/health-data-standards/import/ccda/medical_equipment_importer.rb +2 -4
- data/lib/health-data-standards/import/ccda/medication_importer.rb +2 -4
- data/lib/health-data-standards/import/ccda/patient_importer.rb +1 -1
- data/lib/health-data-standards/import/ccda/procedure_importer.rb +2 -6
- data/lib/health-data-standards/import/ccda/result_importer.rb +2 -5
- data/lib/health-data-standards/import/ccda/vital_sign_importer.rb +2 -3
- data/lib/health-data-standards/import/cda/allergy_importer.rb +32 -0
- data/lib/health-data-standards/import/cda/condition_importer.rb +51 -0
- data/lib/health-data-standards/import/{c32 → cda}/encounter_importer.rb +9 -35
- data/lib/health-data-standards/import/cda/entry_finder.rb +22 -0
- data/lib/health-data-standards/import/{c32 → cda}/locatable_import_utils.rb +2 -3
- data/lib/health-data-standards/import/cda/medical_equipment_importer.rb +24 -0
- data/lib/health-data-standards/import/{c32 → cda}/medication_importer.rb +13 -15
- data/lib/health-data-standards/import/cda/narrative_reference_handler.rb +35 -0
- data/lib/health-data-standards/import/{c32 → cda}/organization_importer.rb +1 -1
- data/lib/health-data-standards/import/cda/procedure_importer.rb +35 -0
- data/lib/health-data-standards/import/{c32 → cda}/provider_importer.rb +4 -8
- data/lib/health-data-standards/import/cda/result_importer.rb +31 -0
- data/lib/health-data-standards/import/{c32 → cda}/section_importer.rb +26 -48
- data/lib/health-data-standards/import/{c32 → cda}/vital_sign_importer.rb +2 -3
- data/lib/health-data-standards/import/green_c32/section_importer.rb +8 -6
- data/lib/health-data-standards/import/provider_import_utils.rb +2 -2
- data/lib/health-data-standards/models/address.rb +1 -1
- data/lib/health-data-standards/models/condition.rb +7 -6
- data/lib/health-data-standards/models/cqm/bundle.rb +45 -0
- data/lib/health-data-standards/models/cqm/measure.rb +36 -0
- data/lib/health-data-standards/models/guarantor.rb +1 -0
- data/lib/health-data-standards/models/insurance_provider.rb +2 -0
- data/lib/health-data-standards/models/order_information.rb +2 -0
- data/lib/health-data-standards/models/record.rb +6 -5
- data/lib/health-data-standards/models/svs/value_set.rb +1 -1
- data/lib/health-data-standards/railtie.rb +11 -0
- data/lib/health-data-standards/tasks/bundle.rake +107 -0
- data/lib/health-data-standards/util/code_system_helper.rb +9 -1
- data/lib/hqmf-generator/attribute.xml.erb +11 -0
- data/lib/hqmf-generator/characteristic_criteria.xml.erb +21 -0
- data/lib/hqmf-generator/code.xml.erb +13 -0
- data/lib/hqmf-generator/condition_criteria.xml.erb +22 -0
- data/lib/hqmf-generator/derivation.xml.erb +6 -0
- data/lib/hqmf-generator/description.xml.erb +1 -0
- data/lib/hqmf-generator/document.xml.erb +63 -0
- data/lib/hqmf-generator/effective_time.xml.erb +4 -0
- data/lib/hqmf-generator/encounter_criteria.xml.erb +21 -0
- data/lib/hqmf-generator/field.xml.erb +28 -0
- data/lib/hqmf-generator/hqmf-generator.rb +292 -0
- data/lib/hqmf-generator/observation_criteria.xml.erb +25 -0
- data/lib/hqmf-generator/population_criteria.xml.erb +23 -0
- data/lib/hqmf-generator/precondition.xml.erb +14 -0
- data/lib/hqmf-generator/procedure_criteria.xml.erb +22 -0
- data/lib/hqmf-generator/reason.xml.erb +3 -0
- data/lib/hqmf-generator/reference.xml.erb +3 -0
- data/lib/hqmf-generator/source.xml.erb +6 -0
- data/lib/hqmf-generator/specific_occurrence.xml.erb +7 -0
- data/lib/hqmf-generator/subset.xml.erb +8 -0
- data/lib/hqmf-generator/substance_criteria.xml.erb +26 -0
- data/lib/hqmf-generator/supply_criteria.xml.erb +26 -0
- data/lib/hqmf-generator/template_id.xml.erb +5 -0
- data/lib/hqmf-generator/temporal_relationship.xml.erb +6 -0
- data/lib/hqmf-generator/value.xml.erb +24 -0
- data/lib/hqmf-generator/variable_criteria.xml.erb +12 -0
- data/lib/hqmf-model/attribute.rb +35 -0
- data/lib/hqmf-model/data_criteria.json +1123 -0
- data/lib/hqmf-model/data_criteria.rb +344 -0
- data/lib/hqmf-model/document.rb +178 -0
- data/lib/hqmf-model/population_criteria.rb +96 -0
- data/lib/hqmf-model/precondition.rb +91 -0
- data/lib/hqmf-model/types.rb +319 -0
- data/lib/hqmf-model/utilities.rb +52 -0
- data/lib/hqmf-parser.rb +56 -0
- data/lib/hqmf-parser/1.0/attribute.rb +68 -0
- data/lib/hqmf-parser/1.0/comparison.rb +34 -0
- data/lib/hqmf-parser/1.0/data_criteria.rb +92 -0
- data/lib/hqmf-parser/1.0/data_criteria_oid_xpath.json +91 -0
- data/lib/hqmf-parser/1.0/document.rb +203 -0
- data/lib/hqmf-parser/1.0/expression.rb +58 -0
- data/lib/hqmf-parser/1.0/observation.rb +61 -0
- data/lib/hqmf-parser/1.0/population_criteria.rb +75 -0
- data/lib/hqmf-parser/1.0/precondition.rb +89 -0
- data/lib/hqmf-parser/1.0/range.rb +65 -0
- data/lib/hqmf-parser/1.0/restriction.rb +160 -0
- data/lib/hqmf-parser/1.0/utilities.rb +41 -0
- data/lib/hqmf-parser/2.0/data_criteria.rb +319 -0
- data/lib/hqmf-parser/2.0/document.rb +165 -0
- data/lib/hqmf-parser/2.0/population_criteria.rb +53 -0
- data/lib/hqmf-parser/2.0/precondition.rb +44 -0
- data/lib/hqmf-parser/2.0/types.rb +223 -0
- data/lib/hqmf-parser/2.0/utilities.rb +30 -0
- data/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb +252 -0
- data/lib/hqmf-parser/converter/pass1/document_converter.rb +185 -0
- data/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb +165 -0
- data/lib/hqmf-parser/converter/pass1/precondition_converter.rb +173 -0
- data/lib/hqmf-parser/converter/pass1/precondition_extractor.rb +188 -0
- data/lib/hqmf-parser/converter/pass1/simple_data_criteria.rb +26 -0
- data/lib/hqmf-parser/converter/pass1/simple_operator.rb +89 -0
- data/lib/hqmf-parser/converter/pass1/simple_population_criteria.rb +10 -0
- data/lib/hqmf-parser/converter/pass1/simple_precondition.rb +51 -0
- data/lib/hqmf-parser/converter/pass1/simple_restriction.rb +64 -0
- data/lib/hqmf-parser/converter/pass2/comparison_converter.rb +112 -0
- data/lib/hqmf-parser/converter/pass2/operator_converter.rb +102 -0
- data/lib/hqmf-parser/parser.rb +54 -0
- data/lib/hqmf-parser/value_sets/value_set_parser.rb +241 -0
- data/lib/util/counter.rb +20 -0
- data/templates/{_allergies.c32.erb → c32/_allergies.c32.erb} +0 -0
- data/templates/{_allergies_no_current.c32.erb → c32/_allergies_no_current.c32.erb} +0 -0
- data/templates/{_care_goals.c32.erb → c32/_care_goals.c32.erb} +0 -0
- data/templates/{_code_with_reference.c32.erb → c32/_code_with_reference.c32.erb} +0 -0
- data/templates/{_conditions.c32.erb → c32/_conditions.c32.erb} +0 -0
- data/templates/{_conditions_no_current.c32.erb → c32/_conditions_no_current.c32.erb} +0 -0
- data/templates/{_encounters.c32.erb → c32/_encounters.c32.erb} +0 -0
- data/templates/{_immunizations.c32.erb → c32/_immunizations.c32.erb} +0 -0
- data/templates/{_medical_equipment.c32.erb → c32/_medical_equipment.c32.erb} +0 -0
- data/templates/{_medications.c32.erb → c32/_medications.c32.erb} +0 -0
- data/templates/{_medications_no_current.c32.erb → c32/_medications_no_current.c32.erb} +0 -0
- data/templates/{_narrative_block.c32.erb → c32/_narrative_block.c32.erb} +0 -0
- data/templates/{_procedures.c32.erb → c32/_procedures.c32.erb} +0 -0
- data/templates/{_results.c32.erb → c32/_results.c32.erb} +0 -0
- data/templates/{_social_history.c32.erb → c32/_social_history.c32.erb} +0 -0
- data/templates/{_vital_signs.c32.erb → c32/_vital_signs.c32.erb} +0 -0
- data/templates/{show.c32.erb → c32/show.c32.erb} +0 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.22.4.85.cat1.erb +18 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.1.cat1.erb +14 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.101.cat1.erb +25 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.103.cat1.erb +12 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.105.cat1.erb +60 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.11.cat1.erb +41 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.12.cat1.erb +50 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.13.cat1.erb +37 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.14.cat1.erb +35 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.17.cat1.erb +22 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.18.cat1.erb +21 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.2.cat1.erb +28 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.20.cat1.erb +20 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.22.cat1.erb +21 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.23.cat1.erb +71 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.28.cat1.erb +20 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.3.cat1.erb +24 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.31.cat1.erb +20 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.32.cat1.erb +15 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.34.cat1.erb +58 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.37.cat1.erb +20 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.38.cat1.erb +16 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.4.cat1.erb +27 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.40.cat1.erb +17 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.41.cat1.erb +38 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.42.cat1.erb +38 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.43.cat1.erb +24 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.44.cat1.erb +24 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.45.cat1.erb +26 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.46.cat1.erb +30 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.47.cat1.erb +26 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.51.cat1.erb +13 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.54.cat1.erb +16 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.55.cat1.erb +10 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.57.cat1.erb +19 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.59.cat1.erb +17 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.62.cat1.erb +36 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.63.cat1.erb +23 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.64.cat1.erb +29 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.66.cat1.erb +34 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.69.cat1.erb +23 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.7.cat1.erb +30 -0
- data/templates/cat1/_2.16.840.1.113883.10.20.24.3.76.cat1.erb +32 -0
- data/templates/cat1/_measures.cat1.erb +66 -0
- data/templates/cat1/_medication_details.cat1.erb +9 -0
- data/templates/cat1/_ordinality.cat1.erb +4 -0
- data/templates/cat1/_patient_data.cat1.erb +14 -0
- data/templates/cat1/_reason.cat1.erb +16 -0
- data/templates/cat1/_record_target.cat1.erb +39 -0
- data/templates/cat1/_reporting_parameters.cat1.erb +24 -0
- data/templates/cat1/_result_value.cat1.erb +16 -0
- data/templates/cat1/show.cat1.erb +125 -0
- data/templates/{_address.gc32.erb → gc32/_address.gc32.erb} +1 -1
- data/templates/gc32/_advance_directive.gc32.erb +5 -0
- data/templates/gc32/_allergy.gc32.erb +12 -0
- data/templates/{_care_goal.gc32.erb → gc32/_care_goal.gc32.erb} +1 -1
- data/templates/gc32/_condition.gc32.erb +10 -0
- data/templates/gc32/_encounter.gc32.erb +28 -0
- data/templates/gc32/_entry.gc32.erb +3 -0
- data/templates/gc32/_entry_attributes.gc32.erb +10 -0
- data/templates/gc32/_immunization.gc32.erb +9 -0
- data/templates/gc32/_insurance_provider.gc32.erb +28 -0
- data/templates/gc32/_medical_equipment.gc32.erb +6 -0
- data/templates/gc32/_medication.gc32.erb +91 -0
- data/templates/{_name.gc32.erb → gc32/_name.gc32.erb} +0 -0
- data/templates/gc32/_organization.gc32.erb +10 -0
- data/templates/gc32/_person_attributes.gc32.erb +7 -0
- data/templates/gc32/_procedure.gc32.erb +9 -0
- data/templates/gc32/_provider.gc32.erb +9 -0
- data/templates/gc32/_result.gc32.erb +12 -0
- data/templates/gc32/_social_history.gc32.erb +6 -0
- data/templates/{_support.gc32.erb → gc32/_support.gc32.erb} +4 -3
- data/templates/gc32/_telecom.gc32.erb +1 -0
- data/templates/gc32/_vital_sign.gc32.erb +4 -0
- data/templates/{record.gc32.erb → gc32/record.gc32.erb} +26 -10
- data/templates/html/_entries_by_encounter.html.erb +2 -2
- data/templates/html/_entries_by_section.html.erb +1 -1
- data/templates/html/_entry.html.erb +16 -21
- data/templates/html/_header.html.erb +1 -1
- data/templates/html/_section.html.erb +1 -1
- data/templates/html/show.html.erb +23 -2
- data/templates/metadata.hdata.erb +3 -3
- metadata +282 -54
- data/lib/health-data-standards/import/c32/allergy_importer.rb +0 -47
- data/lib/health-data-standards/import/c32/medical_equipment_importer.rb +0 -45
- data/lib/health-data-standards/import/c32/procedure_importer.rb +0 -62
- data/lib/health-data-standards/import/c32/result_importer.rb +0 -56
- data/templates/_advance_directive.gc32.erb +0 -8
- data/templates/_allergy.gc32.erb +0 -23
- data/templates/_condition.gc32.erb +0 -9
- data/templates/_encounter.gc32.erb +0 -26
- data/templates/_entry.gc32.erb +0 -14
- data/templates/_immunization.gc32.erb +0 -11
- data/templates/_insurance_provider.gc32.erb +0 -0
- data/templates/_medical_equipment.gc32.erb +0 -7
- data/templates/_medication.gc32.erb +0 -72
- data/templates/_organization.gc32.erb +0 -10
- data/templates/_procedure.gc32.erb +0 -10
- data/templates/_provider.gc32.erb +0 -19
- data/templates/_result.gc32.erb +0 -16
- data/templates/_social_history.gc32.erb +0 -8
- data/templates/_telecom.gc32.erb +0 -1
- data/templates/_vital_sign.gc32.erb +0 -7
@@ -0,0 +1,21 @@
|
|
1
|
+
<entry typeCode="DRIV">
|
2
|
+
<encounterCriteria moodCode="EVN" classCode="ENC"<%= " 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_code(criteria) %>
|
8
|
+
<%= xml_for_description(criteria) %>
|
9
|
+
<%= xml_for_effective_time(criteria) %>
|
10
|
+
<%= xml_for_reason(criteria) %>
|
11
|
+
<definition>
|
12
|
+
<encounterReference moodCode="EVN" classCode="ENC">
|
13
|
+
<id root="2.16.840.1.113883.3.100.1" extension="<%= section_name(criteria) %>"/>
|
14
|
+
</encounterReference>
|
15
|
+
</definition>
|
16
|
+
<%= xml_for_temporal_references(criteria) %>
|
17
|
+
<%= xml_for_fields(criteria) %>
|
18
|
+
<%= xml_for_derivation(criteria) %>
|
19
|
+
<%= xml_for_subsets(criteria) %>
|
20
|
+
</encounterCriteria>
|
21
|
+
</entry>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<outboundRelationship typeCode="SUBJ">
|
2
|
+
<%- if details[:code] == 'SDLOC' -%>
|
3
|
+
<encounterCriteria classCode="ENC" moodCode="EVN">
|
4
|
+
<%- if details[:templateId] -%>
|
5
|
+
<templateId>
|
6
|
+
<item root="<%= details[:template_id] %>"/>
|
7
|
+
</templateId>
|
8
|
+
<%- end -%>
|
9
|
+
<participation typeCode="LOC">
|
10
|
+
<role classCode="SDLOC">
|
11
|
+
<%= xml_for_value(value, 'code') %>
|
12
|
+
</role>
|
13
|
+
</participation>
|
14
|
+
</encounterCriteria>
|
15
|
+
<%- else -%>
|
16
|
+
<observationCriteria classCode="OBS" moodCode="EVN">
|
17
|
+
<%- if details[:templateId] -%>
|
18
|
+
<templateId>
|
19
|
+
<item root="<%= details[:template_id] %>"/>
|
20
|
+
</templateId>
|
21
|
+
<%- end -%>
|
22
|
+
<code code="<%= details[:code] %>" codeSystem="<%= details[:code_system] %>" codeSystemName="<%= details[:code_system_name] %>">
|
23
|
+
<displayName value="<%= details[:title] %>"/>
|
24
|
+
</code>
|
25
|
+
<%= xml_for_value(value) %>
|
26
|
+
</observationCriteria>
|
27
|
+
<%- end -%>
|
28
|
+
</outboundRelationship>
|
@@ -0,0 +1,292 @@
|
|
1
|
+
module HQMF2
|
2
|
+
module Generator
|
3
|
+
|
4
|
+
def self.render_template(name, params)
|
5
|
+
template_path = File.expand_path(File.join('..', "#{name}.xml.erb"), __FILE__)
|
6
|
+
template_str = File.read(template_path)
|
7
|
+
template = ERB.new(template_str, nil, '-', "_templ#{HQMF::Counter.instance.next}")
|
8
|
+
context = ErbContext.new(params)
|
9
|
+
template.result(context.get_binding)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Class to serialize HQMF::Document as HQMF V2 XML
|
13
|
+
class ModelProcessor
|
14
|
+
# Convert the supplied model instance to XML
|
15
|
+
# @param [HQMF::Document] doc the model instance
|
16
|
+
# @return [String] the serialized XML as a String
|
17
|
+
def self.to_hqmf(doc)
|
18
|
+
HQMF2::Generator.render_template('document', {'doc' => doc})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Utility class used to supply a binding to Erb. Contains utility functions used
|
23
|
+
# by the erb templates that are used to generate the HQMF document.
|
24
|
+
class ErbContext < OpenStruct
|
25
|
+
|
26
|
+
def initialize(vars)
|
27
|
+
super(vars)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get a binding that contains all the instance variables
|
31
|
+
# @return [Binding]
|
32
|
+
def get_binding
|
33
|
+
binding
|
34
|
+
end
|
35
|
+
|
36
|
+
def xml_for_reference_id(id)
|
37
|
+
reference = HQMF::Reference.new(id)
|
38
|
+
xml_for_reference(reference)
|
39
|
+
end
|
40
|
+
|
41
|
+
def xml_for_reference(reference)
|
42
|
+
HQMF2::Generator.render_template('reference', {'doc' => doc, 'reference' => reference})
|
43
|
+
end
|
44
|
+
|
45
|
+
def xml_for_attribute(attribute)
|
46
|
+
HQMF2::Generator.render_template('attribute', {'attribute' => attribute})
|
47
|
+
end
|
48
|
+
|
49
|
+
def xml_for_fields(criteria)
|
50
|
+
fields = []
|
51
|
+
if criteria.field_values
|
52
|
+
criteria.field_values.each_pair do |key, value|
|
53
|
+
details = HQMF::DataCriteria::FIELDS[key]
|
54
|
+
details[:code_system_name] = HealthDataStandards::Util::CodeSystemHelper.code_system_for(details[:code_system])
|
55
|
+
fields << HQMF2::Generator.render_template('field', {'details' => details, 'value' => value})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
if criteria.specific_occurrence
|
59
|
+
fields << HQMF2::Generator.render_template('specific_occurrence', {'source_criteria_id' => criteria.source_data_criteria, 'type' => criteria.specific_occurrence_const, 'id' => criteria.specific_occurrence})
|
60
|
+
elsif criteria.source_data_criteria
|
61
|
+
fields << HQMF2::Generator.render_template('source', {'source_criteria_id' => criteria.source_data_criteria})
|
62
|
+
end
|
63
|
+
fields.join
|
64
|
+
end
|
65
|
+
|
66
|
+
def xml_for_value(value, element_name='value', include_type=true)
|
67
|
+
HQMF2::Generator.render_template('value', {'doc' => doc, 'value' => value, 'name' => element_name, 'include_type' => include_type})
|
68
|
+
end
|
69
|
+
|
70
|
+
def xml_for_code(criteria, element_name='code', include_type=true)
|
71
|
+
HQMF2::Generator.render_template('code', {'doc' => doc, 'criteria' => criteria, 'name' => element_name, 'include_type' => include_type})
|
72
|
+
end
|
73
|
+
|
74
|
+
def xml_for_derivation(data_criteria)
|
75
|
+
xml = ''
|
76
|
+
if data_criteria.derivation_operator
|
77
|
+
xml = HQMF2::Generator.render_template('derivation', {'doc' => doc, 'criteria' => data_criteria})
|
78
|
+
end
|
79
|
+
xml
|
80
|
+
end
|
81
|
+
|
82
|
+
def xml_for_effective_time(data_criteria)
|
83
|
+
xml = ''
|
84
|
+
if data_criteria.effective_time
|
85
|
+
xml = HQMF2::Generator.render_template('effective_time', {'doc' => doc, 'effective_time' => data_criteria.effective_time})
|
86
|
+
end
|
87
|
+
xml
|
88
|
+
end
|
89
|
+
|
90
|
+
def xml_for_reason(data_criteria)
|
91
|
+
xml = ''
|
92
|
+
if data_criteria.negation && data_criteria.negation_code_list_id
|
93
|
+
xml = HQMF2::Generator.render_template('reason', {'doc' => doc, 'code_list_id' => data_criteria.negation_code_list_id})
|
94
|
+
end
|
95
|
+
xml
|
96
|
+
end
|
97
|
+
|
98
|
+
def xml_for_template(data_criteria, is_source_data_criteria)
|
99
|
+
xml = ''
|
100
|
+
templates = []
|
101
|
+
# Add a template ID if one is defined for this data criteria
|
102
|
+
template_id = HQMF::DataCriteria.template_id_for_definition(data_criteria.definition, data_criteria.status, data_criteria.negation)
|
103
|
+
if template_id
|
104
|
+
templates << {:id => template_id, :title => HQMF::DataCriteria.title_for_template_id(template_id)}
|
105
|
+
end
|
106
|
+
# Add our own template id if this is a source data criteria from HQMF V1. Source
|
107
|
+
# data criteria are the 'raw' HQMF V1 data criteria before any restrictions are applied
|
108
|
+
# they are only used for negating specific occurrences
|
109
|
+
if is_source_data_criteria
|
110
|
+
templates << {:id => HQMF::DataCriteria::SOURCE_DATA_CRITERIA_TEMPLATE_ID, :title => HQMF::DataCriteria::SOURCE_DATA_CRITERIA_TEMPLATE_TITLE}
|
111
|
+
end
|
112
|
+
if templates.length > 0
|
113
|
+
xml = HQMF2::Generator.render_template('template_id', {'templates' => templates})
|
114
|
+
end
|
115
|
+
xml
|
116
|
+
end
|
117
|
+
|
118
|
+
def xml_for_description(data_criteria)
|
119
|
+
xml = ''
|
120
|
+
if data_criteria.description
|
121
|
+
xml = HQMF2::Generator.render_template('description', {'text' => data_criteria.description})
|
122
|
+
end
|
123
|
+
xml
|
124
|
+
end
|
125
|
+
|
126
|
+
def xml_for_subsets(data_criteria)
|
127
|
+
subsets_xml = []
|
128
|
+
if data_criteria.subset_operators
|
129
|
+
subsets_xml = data_criteria.subset_operators.collect do |operator|
|
130
|
+
HQMF2::Generator.render_template('subset', {'doc' => doc, 'subset' => operator, 'criteria' => data_criteria})
|
131
|
+
end
|
132
|
+
end
|
133
|
+
subsets_xml.join()
|
134
|
+
end
|
135
|
+
|
136
|
+
def xml_for_precondition(precondition)
|
137
|
+
HQMF2::Generator.render_template('precondition', {'doc' => doc, 'precondition' => precondition})
|
138
|
+
end
|
139
|
+
|
140
|
+
def xml_for_data_criteria(data_criteria, is_source_data_criteria)
|
141
|
+
HQMF2::Generator.render_template(data_criteria_template_name(data_criteria), {'doc' => doc, 'criteria' => data_criteria, 'is_source_data_criteria' => is_source_data_criteria})
|
142
|
+
end
|
143
|
+
|
144
|
+
def xml_for_population_criteria(population, criteria_id)
|
145
|
+
xml = ''
|
146
|
+
population_criteria = doc.population_criteria(population[criteria_id])
|
147
|
+
if population_criteria
|
148
|
+
xml = HQMF2::Generator.render_template('population_criteria', {'doc' => doc, 'population' => population, 'criteria_id' => criteria_id, 'population_criteria' => population_criteria})
|
149
|
+
end
|
150
|
+
xml
|
151
|
+
end
|
152
|
+
|
153
|
+
def xml_for_temporal_references(criteria)
|
154
|
+
refs = []
|
155
|
+
if criteria.temporal_references
|
156
|
+
refs = criteria.temporal_references.collect do |reference|
|
157
|
+
HQMF2::Generator.render_template('temporal_relationship', {'doc' => doc, 'relationship' => reference})
|
158
|
+
end
|
159
|
+
end
|
160
|
+
refs.join
|
161
|
+
end
|
162
|
+
|
163
|
+
def oid_for_name(code_system_name)
|
164
|
+
HealthDataStandards::Util::CodeSystemHelper.oid_for_code_system(code_system_name)
|
165
|
+
end
|
166
|
+
|
167
|
+
def reference_element_name(id)
|
168
|
+
referenced_criteria = doc.data_criteria(id)
|
169
|
+
element_name_prefix(referenced_criteria)
|
170
|
+
end
|
171
|
+
|
172
|
+
def reference_type_name(id)
|
173
|
+
referenced_criteria = doc.data_criteria(id)
|
174
|
+
type = nil
|
175
|
+
if referenced_criteria
|
176
|
+
type = referenced_criteria.type
|
177
|
+
elsif id=="MeasurePeriod"
|
178
|
+
type = :observation
|
179
|
+
end
|
180
|
+
if !type
|
181
|
+
raise "No data criteria with ID: #{id}"
|
182
|
+
end
|
183
|
+
case type
|
184
|
+
when :encounters
|
185
|
+
'ENC'
|
186
|
+
when :procedures
|
187
|
+
'PROC'
|
188
|
+
when :medications, :allMedications
|
189
|
+
'SBADM'
|
190
|
+
when :medication_supply
|
191
|
+
'SPLY'
|
192
|
+
else
|
193
|
+
'OBS'
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def code_for_characteristic(characteristic)
|
198
|
+
case characteristic
|
199
|
+
when :birthtime
|
200
|
+
'21112-8'
|
201
|
+
when :age
|
202
|
+
'424144002'
|
203
|
+
when :gender
|
204
|
+
'263495000'
|
205
|
+
when :languages
|
206
|
+
'102902016'
|
207
|
+
when :maritalStatus
|
208
|
+
'125680007'
|
209
|
+
when :race
|
210
|
+
'103579009'
|
211
|
+
else
|
212
|
+
raise "Unknown demographic code [#{characteristic}]"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def oid_for_characteristic(characteristic)
|
217
|
+
case characteristic
|
218
|
+
when :birthtime
|
219
|
+
'2.16.840.1.113883.6.1'
|
220
|
+
else
|
221
|
+
'2.16.840.1.113883.6.96'
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
def data_criteria_template_name(data_criteria)
|
226
|
+
case data_criteria.definition
|
227
|
+
when 'diagnosis', 'diagnosis_family_history'
|
228
|
+
'condition_criteria'
|
229
|
+
when 'encounter'
|
230
|
+
'encounter_criteria'
|
231
|
+
when 'procedure', 'risk_category_assessment', 'physical_exam', 'communication_from_patient_to_provider', 'communication_from_provider_to_provider', 'device', 'diagnostic_study', 'intervention'
|
232
|
+
if data_criteria.value.nil?
|
233
|
+
'procedure_criteria'
|
234
|
+
else
|
235
|
+
'observation_criteria'
|
236
|
+
end
|
237
|
+
when 'medication'
|
238
|
+
case data_criteria.status
|
239
|
+
when 'dispensed', 'ordered'
|
240
|
+
'supply_criteria'
|
241
|
+
else # active or administered
|
242
|
+
'substance_criteria'
|
243
|
+
end
|
244
|
+
when 'patient_characteristic', 'patient_characteristic_birthdate', 'patient_characteristic_clinical_trial_participant', 'patient_characteristic_expired', 'patient_characteristic_gender', 'patient_characteristic_age', 'patient_characteristic_languages', 'patient_characteristic_marital_status', 'patient_characteristic_race'
|
245
|
+
'characteristic_criteria'
|
246
|
+
when 'variable'
|
247
|
+
'variable_criteria'
|
248
|
+
else
|
249
|
+
'observation_criteria'
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def section_name(data_criteria)
|
254
|
+
data_criteria.definition.to_s
|
255
|
+
end
|
256
|
+
|
257
|
+
def element_name_prefix(data_criteria)
|
258
|
+
type = data_criteria ? data_criteria.type : :observation
|
259
|
+
case type
|
260
|
+
when :encounters
|
261
|
+
'encounter'
|
262
|
+
when :procedures
|
263
|
+
'procedure'
|
264
|
+
when :medications, :allMedications
|
265
|
+
'substanceAdministration'
|
266
|
+
when :medication_supply
|
267
|
+
'supply'
|
268
|
+
else
|
269
|
+
'observation'
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def population_element_prefix(population_criteria_code)
|
274
|
+
case population_criteria_code
|
275
|
+
when HQMF::PopulationCriteria::IPP
|
276
|
+
'patientPopulation'
|
277
|
+
when HQMF::PopulationCriteria::DENOM
|
278
|
+
'denominator'
|
279
|
+
when HQMF::PopulationCriteria::NUMER
|
280
|
+
'numerator'
|
281
|
+
when HQMF::PopulationCriteria::DENEXCEP
|
282
|
+
'denominatorException'
|
283
|
+
when HQMF::PopulationCriteria::DENEX
|
284
|
+
'denominatorExclusion'
|
285
|
+
else
|
286
|
+
raise "Unknown population criteria type #{population_criteria_code}"
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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_code(criteria) %>
|
8
|
+
<%= xml_for_description(criteria) %>
|
9
|
+
<%= "<statusCode code=\"#{criteria.status}\"/>" if criteria.status %>
|
10
|
+
<%= xml_for_effective_time(criteria) %>
|
11
|
+
<%= xml_for_reason(criteria) %>
|
12
|
+
<%- if criteria.value -%>
|
13
|
+
<%= xml_for_value(criteria.value) %>
|
14
|
+
<%- end -%>
|
15
|
+
<definition>
|
16
|
+
<observationReference moodCode="EVN" classCode="OBS">
|
17
|
+
<id root="2.16.840.1.113883.3.100.1" extension="<%= section_name(criteria) %>"/>
|
18
|
+
</observationReference>
|
19
|
+
</definition>
|
20
|
+
<%= xml_for_temporal_references(criteria) %>
|
21
|
+
<%= xml_for_fields(criteria) %>
|
22
|
+
<%= xml_for_derivation(criteria) %>
|
23
|
+
<%= xml_for_subsets(criteria) %>
|
24
|
+
</observationCriteria>
|
25
|
+
</entry>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<component typeCode="COMP">
|
2
|
+
<<%= population_element_prefix(criteria_id) %>Criteria classCode="OBS" moodCode="EVN">
|
3
|
+
<id root="c75181d0-73eb-11de-8a39-0800200c9a66"
|
4
|
+
extension="<%= population_criteria.hqmf_id %>"/>
|
5
|
+
<code codeSystem="2.16.840.1.113883.5.1063"
|
6
|
+
codeSystemName="HL7 Observation Value"
|
7
|
+
code="<%= population_criteria.type %>">
|
8
|
+
<displayName value="<%= population_criteria.title %>"/>
|
9
|
+
</code>
|
10
|
+
<isCriterionInd value="true"/>
|
11
|
+
<%- if population_criteria.preconditions.present? && population_criteria.preconditions.length > 0 -%>
|
12
|
+
<%- population_criteria.preconditions.each do |precondition| -%>
|
13
|
+
<%= xml_for_precondition(precondition) %>
|
14
|
+
<%- end -%>
|
15
|
+
<%- else -%>
|
16
|
+
<precondition typeCode="PRCN" nullFlavor="NA">
|
17
|
+
<allTrue>
|
18
|
+
<id/>
|
19
|
+
</allTrue>
|
20
|
+
</precondition>
|
21
|
+
<%- end -%>
|
22
|
+
</<%= population_element_prefix(criteria_id) %>Criteria>
|
23
|
+
</component>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<precondition typeCode="PRCN">
|
2
|
+
<%- if precondition.conjunction? -%>
|
3
|
+
<<%= precondition.conjunction_code_with_negation %>>
|
4
|
+
<id/>
|
5
|
+
<%- precondition.preconditions.each do |child| -%>
|
6
|
+
<%= xml_for_precondition(child) %>
|
7
|
+
<%- end -%>
|
8
|
+
</<%= precondition.conjunction_code_with_negation %>>
|
9
|
+
<%- else -%>
|
10
|
+
<<%= reference_element_name(precondition.reference.id) %>Reference moodCode="EVN" classCode="<%= reference_type_name(precondition.reference.id) %>">
|
11
|
+
<id root="2.16.840.1.113883.3.100.1" extension="<%= precondition.reference.id %>"/>
|
12
|
+
</<%= reference_element_name(precondition.reference.id) %>Reference>
|
13
|
+
<%- end -%>
|
14
|
+
</precondition>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<entry typeCode="DRIV">
|
2
|
+
<procedureCriteria moodCode="EVN" classCode="PROC"<%= " 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_code(criteria) %>
|
8
|
+
<%= xml_for_description(criteria) %>
|
9
|
+
<%= "<statusCode code=\"#{criteria.status}\"/>" if criteria.status %>
|
10
|
+
<%= xml_for_effective_time(criteria) %>
|
11
|
+
<%= xml_for_reason(criteria) %>
|
12
|
+
<definition>
|
13
|
+
<procedureReference moodCode="EVN" classCode="PROC">
|
14
|
+
<id root="2.16.840.1.113883.3.100.1" extension="<%= section_name(criteria) %>"/>
|
15
|
+
</procedureReference>
|
16
|
+
</definition>
|
17
|
+
<%= xml_for_temporal_references(criteria) %>
|
18
|
+
<%= xml_for_fields(criteria) %>
|
19
|
+
<%= xml_for_derivation(criteria) %>
|
20
|
+
<%= xml_for_subsets(criteria) %>
|
21
|
+
</procedureCriteria>
|
22
|
+
</entry>
|