cqm-reports 1.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +33 -0
- data/README.md +27 -0
- data/Rakefile +16 -0
- data/lib/cqm_report.rb +77 -0
- data/lib/ext/code.rb +11 -0
- data/lib/ext/data_element.rb +24 -0
- data/lib/html-export/qdm-patient/_header_css.mustache +61 -0
- data/lib/html-export/qdm-patient/_javascript.mustache +52 -0
- data/lib/html-export/qdm-patient/data_element/_data_element.mustache +4 -0
- data/lib/html-export/qdm-patient/data_element/_data_element_codes.mustache +9 -0
- data/lib/html-export/qdm-patient/data_element/_data_element_other_fields.mustache +106 -0
- data/lib/html-export/qdm-patient/data_element/_data_element_times.mustache +44 -0
- data/lib/html-export/qdm-patient/qdm_patient.mustache +73 -0
- data/lib/html-export/qdm-patient/qdm_patient.rb +47 -0
- data/lib/qrda-export/catI-r5/_code.mustache +1 -0
- data/lib/qrda-export/catI-r5/_codes.mustache +10 -0
- data/lib/qrda-export/catI-r5/_header.mustache +28 -0
- data/lib/qrda-export/catI-r5/_measure_section.mustache +59 -0
- data/lib/qrda-export/catI-r5/_reporting_period.mustache +23 -0
- data/lib/qrda-export/catI-r5/qrda1_r5.mustache +209 -0
- data/lib/qrda-export/catI-r5/qrda1_r5.rb +220 -0
- data/lib/qrda-export/catI-r5/qrda_header/_author.mustache +26 -0
- data/lib/qrda-export/catI-r5/qrda_header/_custodian.mustache +43 -0
- data/lib/qrda-export/catI-r5/qrda_header/_documentation_of_service_event.mustache +88 -0
- data/lib/qrda-export/catI-r5/qrda_header/_information_recipient.mustache +7 -0
- data/lib/qrda-export/catI-r5/qrda_header/_legal_authenticator.mustache +25 -0
- data/lib/qrda-export/catI-r5/qrda_header/_participant.mustache +7 -0
- data/lib/qrda-export/catI-r5/qrda_header/_record_target.mustache +44 -0
- data/lib/qrda-export/catI-r5/qrda_templates/adverse_event.mustache +40 -0
- data/lib/qrda-export/catI-r5/qrda_templates/allergy_intolerance.mustache +42 -0
- data/lib/qrda-export/catI-r5/qrda_templates/assessment_order.mustache +25 -0
- data/lib/qrda-export/catI-r5/qrda_templates/assessment_performed.mustache +38 -0
- data/lib/qrda-export/catI-r5/qrda_templates/assessment_recommended.mustache +25 -0
- data/lib/qrda-export/catI-r5/qrda_templates/communication_performed.mustache +62 -0
- data/lib/qrda-export/catI-r5/qrda_templates/device_applied.mustache +41 -0
- data/lib/qrda-export/catI-r5/qrda_templates/device_order.mustache +38 -0
- data/lib/qrda-export/catI-r5/qrda_templates/device_recommended.mustache +37 -0
- data/lib/qrda-export/catI-r5/qrda_templates/diagnosis.mustache +55 -0
- data/lib/qrda-export/catI-r5/qrda_templates/diagnostic_study_order.mustache +25 -0
- data/lib/qrda-export/catI-r5/qrda_templates/diagnostic_study_performed.mustache +50 -0
- data/lib/qrda-export/catI-r5/qrda_templates/diagnostic_study_recommended.mustache +21 -0
- data/lib/qrda-export/catI-r5/qrda_templates/encounter_order.mustache +35 -0
- data/lib/qrda-export/catI-r5/qrda_templates/encounter_performed.mustache +52 -0
- data/lib/qrda-export/catI-r5/qrda_templates/encounter_recommended.mustache +37 -0
- data/lib/qrda-export/catI-r5/qrda_templates/family_history.mustache +37 -0
- data/lib/qrda-export/catI-r5/qrda_templates/immunization_administered.mustache +35 -0
- data/lib/qrda-export/catI-r5/qrda_templates/immunization_order.mustache +46 -0
- data/lib/qrda-export/catI-r5/qrda_templates/intervention_order.mustache +24 -0
- data/lib/qrda-export/catI-r5/qrda_templates/intervention_performed.mustache +36 -0
- data/lib/qrda-export/catI-r5/qrda_templates/intervention_recommended.mustache +25 -0
- data/lib/qrda-export/catI-r5/qrda_templates/laboratory_test_order.mustache +24 -0
- data/lib/qrda-export/catI-r5/qrda_templates/laboratory_test_performed.mustache +42 -0
- data/lib/qrda-export/catI-r5/qrda_templates/laboratory_test_recommended.mustache +25 -0
- data/lib/qrda-export/catI-r5/qrda_templates/medication_active.mustache +32 -0
- data/lib/qrda-export/catI-r5/qrda_templates/medication_administered.mustache +39 -0
- data/lib/qrda-export/catI-r5/qrda_templates/medication_discharge.mustache +63 -0
- data/lib/qrda-export/catI-r5/qrda_templates/medication_dispensed.mustache +70 -0
- data/lib/qrda-export/catI-r5/qrda_templates/medication_order.mustache +64 -0
- data/lib/qrda-export/catI-r5/qrda_templates/patient_care_experience.mustache +14 -0
- data/lib/qrda-export/catI-r5/qrda_templates/patient_characteristic_clinical_trial_participant.mustache +18 -0
- data/lib/qrda-export/catI-r5/qrda_templates/patient_characteristic_expired.mustache +32 -0
- data/lib/qrda-export/catI-r5/qrda_templates/patient_characteristic_payer.mustache +14 -0
- data/lib/qrda-export/catI-r5/qrda_templates/physical_exam_order.mustache +30 -0
- data/lib/qrda-export/catI-r5/qrda_templates/physical_exam_performed.mustache +45 -0
- data/lib/qrda-export/catI-r5/qrda_templates/physical_exam_recommended.mustache +30 -0
- data/lib/qrda-export/catI-r5/qrda_templates/procedure_order.mustache +32 -0
- data/lib/qrda-export/catI-r5/qrda_templates/procedure_performed.mustache +64 -0
- data/lib/qrda-export/catI-r5/qrda_templates/procedure_recommended.mustache +34 -0
- data/lib/qrda-export/catI-r5/qrda_templates/provider_care_experience.mustache +15 -0
- data/lib/qrda-export/catI-r5/qrda_templates/provider_characteristic.mustache +15 -0
- data/lib/qrda-export/catI-r5/qrda_templates/substance_recommended.mustache +35 -0
- data/lib/qrda-export/catI-r5/qrda_templates/symptom.mustache +48 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_admission_source.mustache +6 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_anatomical_location_site.mustache +1 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_author.mustache +29 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_author_participation.mustache +8 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_component.mustache +13 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_data_element_codes_as_values.mustache +10 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_days_supplied.mustache +6 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_encounter_diagnosis.mustache +21 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_facility_location.mustache +24 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_immunization_details.mustache +14 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_medication_details.mustache +36 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_medication_supply_request.mustache +17 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_method.mustache +1 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_ordinality.mustache +1 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_principal_diagnosis.mustache +8 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_reaction_observation.mustache +9 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_reason.mustache +12 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_related_to.mustache +6 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_results.mustache +24 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_severity.mustache +8 -0
- data/lib/qrda-export/catI-r5/qrda_templates/template_partials/_status.mustache +8 -0
- data/lib/qrda-export/catIII-r2-1/_continuous_variable_value.mustache +17 -0
- data/lib/qrda-export/catIII-r2-1/_header.mustache +25 -0
- data/lib/qrda-export/catIII-r2-1/_measure_data.mustache +41 -0
- data/lib/qrda-export/catIII-r2-1/_measure_section.mustache +74 -0
- data/lib/qrda-export/catIII-r2-1/_reporting_period.mustache +23 -0
- data/lib/qrda-export/catIII-r2-1/_stratification.mustache +29 -0
- data/lib/qrda-export/catIII-r2-1/_supplemental_data.mustache +28 -0
- data/lib/qrda-export/catIII-r2-1/qrda3_r21.mustache +11 -0
- data/lib/qrda-export/catIII-r2-1/qrda3_r21.rb +127 -0
- data/lib/qrda-export/catIII-r2-1/qrda_header/_author.mustache +25 -0
- data/lib/qrda-export/catIII-r2-1/qrda_header/_custodian.mustache +17 -0
- data/lib/qrda-export/catIII-r2-1/qrda_header/_documentation_of_service_event.mustache +88 -0
- data/lib/qrda-export/catIII-r2-1/qrda_header/_legal_authenticator.mustache +25 -0
- data/lib/qrda-export/helper/aggregate_object_helper.rb +154 -0
- data/lib/qrda-export/helper/cat1_view_helper.rb +81 -0
- data/lib/qrda-export/helper/date_helper.rb +108 -0
- data/lib/qrda-export/helper/frequency_helper.rb +83 -0
- data/lib/qrda-export/helper/patient_view_helper.rb +46 -0
- data/lib/qrda-export/helper/view_helper.rb +28 -0
- data/lib/qrda-import/base-importers/demographics_importer.rb +38 -0
- data/lib/qrda-import/base-importers/section_importer.rb +237 -0
- data/lib/qrda-import/cda_identifier.rb +20 -0
- data/lib/qrda-import/data-element-importers/adverse_event_importer.rb +26 -0
- data/lib/qrda-import/data-element-importers/allergy_intolerance_importer.rb +24 -0
- data/lib/qrda-import/data-element-importers/assessment_order_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/assessment_performed_importer.rb +24 -0
- data/lib/qrda-import/data-element-importers/assessment_recommended_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/communication_performed_importer.rb +30 -0
- data/lib/qrda-import/data-element-importers/device_applied_importer.rb +22 -0
- data/lib/qrda-import/data-element-importers/device_order_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/device_recommended_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/diagnosis_importer.rb +24 -0
- data/lib/qrda-import/data-element-importers/diagnostic_study_order_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/diagnostic_study_performed_importer.rb +32 -0
- data/lib/qrda-import/data-element-importers/diagnostic_study_recommended_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/encounter_order_importer.rb +21 -0
- data/lib/qrda-import/data-element-importers/encounter_performed_importer.rb +46 -0
- data/lib/qrda-import/data-element-importers/encounter_recommended_importer.rb +21 -0
- data/lib/qrda-import/data-element-importers/family_history_importer.rb +21 -0
- data/lib/qrda-import/data-element-importers/immunization_administered_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/immunization_order_importer.rb +27 -0
- data/lib/qrda-import/data-element-importers/intervention_order_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/intervention_performed_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/intervention_recommended_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/laboratory_test_order_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/laboratory_test_performed_importer.rb +29 -0
- data/lib/qrda-import/data-element-importers/laboratory_test_recommended_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/medication_active_importer.rb +25 -0
- data/lib/qrda-import/data-element-importers/medication_administered_importer.rb +26 -0
- data/lib/qrda-import/data-element-importers/medication_discharge_importer.rb +32 -0
- data/lib/qrda-import/data-element-importers/medication_dispensed_importer.rb +37 -0
- data/lib/qrda-import/data-element-importers/medication_order_importer.rb +36 -0
- data/lib/qrda-import/data-element-importers/patient_care_experience_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/patient_characteristic_clinical_trial_participant_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/patient_characteristic_expired_importer.rb +22 -0
- data/lib/qrda-import/data-element-importers/patient_characteristic_payer_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/physical_exam_order_importer.rb +21 -0
- data/lib/qrda-import/data-element-importers/physical_exam_performed_importer.rb +27 -0
- data/lib/qrda-import/data-element-importers/physical_exam_recommended_importer.rb +21 -0
- data/lib/qrda-import/data-element-importers/procedure_order_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/procedure_performed_importer.rb +33 -0
- data/lib/qrda-import/data-element-importers/procedure_recommended_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/provider_care_experience_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/provider_characteristic_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/substance_administered_importer.rb +27 -0
- data/lib/qrda-import/data-element-importers/substance_order_importer.rb +29 -0
- data/lib/qrda-import/data-element-importers/substance_recommended_importer.rb +27 -0
- data/lib/qrda-import/data-element-importers/symptom_importer.rb +21 -0
- data/lib/qrda-import/entry_finder.rb +20 -0
- data/lib/qrda-import/entry_package.rb +16 -0
- data/lib/qrda-import/narrative_reference_handler.rb +33 -0
- data/lib/qrda-import/patient_importer.rb +128 -0
- data/lib/util/code_system_helper.rb +77 -0
- data/lib/util/hqmf_template_helper.rb +52 -0
- data/lib/util/hqmf_template_oid_map.json +654 -0
- data/lib/util/hqmfr2_template_oid_map.json +378 -0
- data/lib/util/hqmfr2cql_template_oid_map.json +390 -0
- data/lib/util/qrda_template_helper.rb +20 -0
- data/lib/util/qrdar5_1_template_oid_map.json +406 -0
- data/lib/util/qrdar5_template_oid_map.json +406 -0
- metadata +344 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class ProviderCareExperienceImporter < SectionImporter
|
4
|
+
def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.67']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@id_xpath = './cda:id'
|
7
|
+
@code_xpath = "./cda:value"
|
8
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
9
|
+
@entry_class = QDM::ProviderCareExperience
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
13
|
+
provider_care_experience = super
|
14
|
+
provider_care_experience
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class ProviderCharacteristicImporter < SectionImporter
|
4
|
+
def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.114']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@id_xpath = './cda:id'
|
7
|
+
@code_xpath = "./cda:value"
|
8
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
9
|
+
@entry_class = QDM::ProviderCharacteristic
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
13
|
+
provider_characteristic = super
|
14
|
+
provider_characteristic
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class SubstanceAdministeredImporter < SectionImporter
|
4
|
+
def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.42']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@entry_does_not_have_reason = true
|
7
|
+
@id_xpath = './cda:id'
|
8
|
+
@code_xpath = "./cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"
|
9
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
10
|
+
@relevant_period_xpath = "./cda:effectiveTime"
|
11
|
+
@dosage_xpath = "./cda:doseQuantity"
|
12
|
+
@frequency_xpath = "./cda:effectiveTime[@operator='A']/cda:period"
|
13
|
+
@route_xpath = "./cda:routeCode"
|
14
|
+
@entry_class = QDM::SubstanceAdministered
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
18
|
+
substance_administered = super
|
19
|
+
substance_administered.dosage = extract_scalar(entry_element, @dosage_xpath)
|
20
|
+
substance_administered.frequency = frequency_as_coded_value(entry_element, @frequency_xpath)
|
21
|
+
substance_administered.route = code_if_present(entry_element.at_xpath(@route_xpath))
|
22
|
+
substance_administered
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class SubstanceOrderImporter < SectionImporter
|
4
|
+
def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.47']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@id_xpath = './cda:id'
|
7
|
+
@code_xpath = "./cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"
|
8
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
9
|
+
@dosage_xpath = "./cda:doseQuantity"
|
10
|
+
@supply_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.99']/cda:quantity"
|
11
|
+
@frequency_xpath = "./cda:effectiveTime[@operator='A']/cda:period"
|
12
|
+
@refills_xpath = "./cda:repeatNumber"
|
13
|
+
@route_xpath = "./cda:routeCode"
|
14
|
+
@entry_class = QDM::SubstanceOrder
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
18
|
+
substance_order = super
|
19
|
+
substance_order.dosage = extract_scalar(entry_element, @dosage_xpath)
|
20
|
+
substance_order.supply = extract_scalar(entry_element, @supply_xpath)
|
21
|
+
substance_order.frequency = frequency_as_coded_value(entry_element, @frequency_xpath)
|
22
|
+
substance_order.refills = extract_scalar(entry_element, @refills_xpath)&.value
|
23
|
+
substance_order.route = code_if_present(entry_element.at_xpath(@route_xpath))
|
24
|
+
substance_order
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class SubstanceRecommendedImporter < SectionImporter
|
4
|
+
def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.75']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@id_xpath = './cda:id'
|
7
|
+
@code_xpath = "./cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"
|
8
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
9
|
+
@dosage_xpath = "./cda:doseQuantity"
|
10
|
+
@frequency_xpath = "./cda:effectiveTime[@operator='A']/cda:period"
|
11
|
+
@refills_xpath = "./cda:repeatNumber"
|
12
|
+
@route_xpath = "./cda:routeCode"
|
13
|
+
@entry_class = QDM::SubstanceRecommended
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
17
|
+
substance_recommended = super
|
18
|
+
substance_recommended.dosage = extract_scalar(entry_element, @dosage_xpath)
|
19
|
+
substance_recommended.frequency = frequency_as_coded_value(entry_element, @frequency_xpath)
|
20
|
+
substance_recommended.refills = extract_scalar(entry_element, @refills_xpath)&.value
|
21
|
+
substance_recommended.route = code_if_present(entry_element.at_xpath(@route_xpath))
|
22
|
+
substance_recommended
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class SymptomImporter < SectionImporter
|
4
|
+
def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.138']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@id_xpath = './cda:entryRelationship/cda:observation/cda:id'
|
7
|
+
@code_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.136']/cda:value"
|
8
|
+
@prevalence_period_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.136']/cda:effectiveTime"
|
9
|
+
@severity_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.136']/cda:entryRelationship/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.22.4.8']/cda:value"
|
10
|
+
@entry_class = QDM::Symptom
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
14
|
+
symptom = super
|
15
|
+
symptom.severity = code_if_present(entry_element.at_xpath(@severity_xpath))
|
16
|
+
symptom
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class EntryFinder
|
4
|
+
def initialize(entry_xpath)
|
5
|
+
@entry_xpath = entry_xpath
|
6
|
+
end
|
7
|
+
|
8
|
+
def entries(doc)
|
9
|
+
entry_elements = doc.xpath(@entry_xpath)
|
10
|
+
if block_given?
|
11
|
+
entry_elements.each do |entry_element|
|
12
|
+
yield entry_element
|
13
|
+
end
|
14
|
+
else
|
15
|
+
entry_elements
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class NarrativeReferenceHandler
|
4
|
+
def initialize
|
5
|
+
@id_map = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def build_id_map(doc)
|
9
|
+
path = "//*[@ID]"
|
10
|
+
ids = doc.xpath(path)
|
11
|
+
ids.each do |id|
|
12
|
+
tag = id['ID']
|
13
|
+
value = id.content
|
14
|
+
@id_map[tag] = value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param [String] tag
|
19
|
+
# @return [String] text description of tag
|
20
|
+
def lookup_tag(tag)
|
21
|
+
value = @id_map[tag]
|
22
|
+
# Not sure why, but sometimes the reference is #<Reference> and the ID value is <Reference>, and
|
23
|
+
# sometimes it is #<Reference>. We look for both.
|
24
|
+
if !value and tag[0] == '#'
|
25
|
+
tag = tag[1,tag.length]
|
26
|
+
value = @id_map[tag]
|
27
|
+
end
|
28
|
+
|
29
|
+
value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
# This class is the central location for taking a QRDA Cat 1 XML document and converting it
|
4
|
+
# into the processed form we store in MongoDB. The class does this by running each measure
|
5
|
+
# independently on the XML document
|
6
|
+
#
|
7
|
+
# This class is a Singleton. It should be accessed by calling PatientImporter.instance
|
8
|
+
class PatientImporter
|
9
|
+
include Singleton
|
10
|
+
include DemographicsImporter
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
# This differs from other HDS patient importers in that sections can have multiple importers
|
14
|
+
@data_element_importers = []
|
15
|
+
@data_element_importers << generate_importer(AdverseEventImporter)
|
16
|
+
@data_element_importers << generate_importer(AllergyIntoleranceImporter)
|
17
|
+
@data_element_importers << generate_importer(AssessmentOrderImporter)
|
18
|
+
@data_element_importers << generate_importer(AssessmentPerformedImporter)
|
19
|
+
@data_element_importers << generate_importer(AssessmentRecommendedImporter)
|
20
|
+
@data_element_importers << generate_importer(CommunicationPerformedImporter)
|
21
|
+
@data_element_importers << generate_importer(DeviceAppliedImporter)
|
22
|
+
@data_element_importers << generate_importer(DeviceOrderImporter)
|
23
|
+
@data_element_importers << generate_importer(DeviceRecommendedImporter)
|
24
|
+
@data_element_importers << generate_importer(DiagnosisImporter)
|
25
|
+
@data_element_importers << generate_importer(DiagnosticStudyOrderImporter)
|
26
|
+
@data_element_importers << generate_importer(DiagnosticStudyPerformedImporter)
|
27
|
+
@data_element_importers << generate_importer(DiagnosticStudyRecommendedImporter)
|
28
|
+
@data_element_importers << generate_importer(EncounterOrderImporter)
|
29
|
+
@data_element_importers << generate_importer(EncounterPerformedImporter)
|
30
|
+
@data_element_importers << generate_importer(EncounterRecommendedImporter)
|
31
|
+
@data_element_importers << generate_importer(FamilyHistoryImporter)
|
32
|
+
@data_element_importers << generate_importer(ImmunizationAdministeredImporter)
|
33
|
+
@data_element_importers << generate_importer(ImmunizationOrderImporter)
|
34
|
+
@data_element_importers << generate_importer(InterventionOrderImporter)
|
35
|
+
@data_element_importers << generate_importer(InterventionPerformedImporter)
|
36
|
+
@data_element_importers << generate_importer(InterventionRecommendedImporter)
|
37
|
+
@data_element_importers << generate_importer(LaboratoryTestOrderImporter)
|
38
|
+
@data_element_importers << generate_importer(LaboratoryTestPerformedImporter)
|
39
|
+
@data_element_importers << generate_importer(LaboratoryTestRecommendedImporter)
|
40
|
+
@data_element_importers << generate_importer(MedicationActiveImporter)
|
41
|
+
@data_element_importers << generate_importer(MedicationAdministeredImporter)
|
42
|
+
@data_element_importers << generate_importer(MedicationDischargeImporter)
|
43
|
+
@data_element_importers << generate_importer(MedicationDispensedImporter)
|
44
|
+
@data_element_importers << generate_importer(MedicationOrderImporter)
|
45
|
+
@data_element_importers << generate_importer(PatientCareExperienceImporter)
|
46
|
+
@data_element_importers << generate_importer(PatientCharacteristicClinicalTrialParticipantImporter)
|
47
|
+
@data_element_importers << generate_importer(PatientCharacteristicExpiredImporter)
|
48
|
+
@data_element_importers << generate_importer(PatientCharacteristicPayerImporter)
|
49
|
+
@data_element_importers << generate_importer(PhysicalExamOrderImporter)
|
50
|
+
@data_element_importers << generate_importer(PhysicalExamPerformedImporter)
|
51
|
+
@data_element_importers << generate_importer(PhysicalExamRecommendedImporter)
|
52
|
+
@data_element_importers << generate_importer(ProcedureOrderImporter)
|
53
|
+
@data_element_importers << generate_importer(ProcedurePerformedImporter)
|
54
|
+
@data_element_importers << generate_importer(ProcedureRecommendedImporter)
|
55
|
+
@data_element_importers << generate_importer(ProviderCareExperienceImporter)
|
56
|
+
@data_element_importers << generate_importer(ProviderCharacteristicImporter)
|
57
|
+
@data_element_importers << generate_importer(SubstanceAdministeredImporter)
|
58
|
+
@data_element_importers << generate_importer(SubstanceOrderImporter)
|
59
|
+
@data_element_importers << generate_importer(SubstanceRecommendedImporter)
|
60
|
+
@data_element_importers << generate_importer(SymptomImporter)
|
61
|
+
end
|
62
|
+
|
63
|
+
def parse_cat1(doc)
|
64
|
+
patient = CQM::Patient.new
|
65
|
+
entry_id_map = {}
|
66
|
+
import_data_elements(patient, doc, entry_id_map)
|
67
|
+
normalize_references(patient, entry_id_map)
|
68
|
+
get_demographics(patient, doc)
|
69
|
+
patient
|
70
|
+
end
|
71
|
+
|
72
|
+
def import_data_elements(patient, doc, entry_id_map)
|
73
|
+
context = doc.xpath("/cda:ClinicalDocument/cda:component/cda:structuredBody/cda:component/cda:section[cda:templateId/@root = '2.16.840.1.113883.10.20.24.2.1']")
|
74
|
+
nrh = NarrativeReferenceHandler.new
|
75
|
+
nrh.build_id_map(doc)
|
76
|
+
@data_element_importers.each do |entry_package|
|
77
|
+
data_elements, id_map = entry_package.package_entries(context, nrh)
|
78
|
+
new_data_elements = []
|
79
|
+
|
80
|
+
id_map.each_value do |elem_ids|
|
81
|
+
|
82
|
+
elem_id = elem_ids.first
|
83
|
+
data_element = data_elements.find { |de| de.id == elem_id }
|
84
|
+
|
85
|
+
elem_ids[1,elem_ids.length].each do |merge_id|
|
86
|
+
merge_element = data_elements.find { |de| de.id == merge_id }
|
87
|
+
data_element.merge!(merge_element)
|
88
|
+
end
|
89
|
+
|
90
|
+
new_data_elements << data_element
|
91
|
+
end
|
92
|
+
|
93
|
+
patient.qdmPatient.dataElements << new_data_elements
|
94
|
+
entry_id_map.merge!(id_map)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_patient_expired(record, doc)
|
99
|
+
entry_elements = doc.xpath("/cda:ClinicalDocument/cda:component/cda:structuredBody/cda:component/cda:section[cda:templateId/@root = '2.16.840.1.113883.10.20.24.2.1']/cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.54']")
|
100
|
+
return unless entry_elements.empty?
|
101
|
+
|
102
|
+
record.expired = true
|
103
|
+
record.deathdate = DateTime.parse(entry_elements.at_xpath("./cda:effectiveTime/cda:low")['value']).to_i
|
104
|
+
end
|
105
|
+
|
106
|
+
def normalize_references(patient, entry_id_map)
|
107
|
+
patient.qdmPatient.dataElements.each do |data_element|
|
108
|
+
next unless data_element.respond_to?(:relatedTo) && data_element.relatedTo
|
109
|
+
|
110
|
+
relations_to_add = []
|
111
|
+
data_element.relatedTo.each do |related_to|
|
112
|
+
relations_to_add << entry_id_map[related_to.value]
|
113
|
+
end
|
114
|
+
data_element.relatedTo.destroy
|
115
|
+
relations_to_add.each do |relation_to_add|
|
116
|
+
data_element.relatedTo << relation_to_add
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def generate_importer(importer_class)
|
124
|
+
EntryPackage.new(importer_class.new)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module HQMF
|
2
|
+
module Util
|
3
|
+
# General helpers for working with codes and code systems
|
4
|
+
class CodeSystemHelper
|
5
|
+
CODE_SYSTEMS = {
|
6
|
+
'2.16.840.1.113883.6.1' => 'LOINC',
|
7
|
+
'2.16.840.1.113883.6.96' => 'SNOMEDCT',
|
8
|
+
'2.16.840.1.113883.6.12' => 'CPT',
|
9
|
+
#'2.16.840.1.113883.3.88.12.80.32' => 'CPT', # Encounter Type from C32, a subset of CPT
|
10
|
+
'2.16.840.1.113883.6.88' => 'RXNORM',
|
11
|
+
'2.16.840.1.113883.6.103' => 'ICD9CM',
|
12
|
+
'2.16.840.1.113883.6.104' => 'ICD9CM',
|
13
|
+
'2.16.840.1.113883.6.4' => 'ICD10PCS',
|
14
|
+
'2.16.840.1.113883.6.90' => 'ICD10CM',
|
15
|
+
'2.16.840.1.113883.6.14' => 'HCP',
|
16
|
+
'2.16.840.1.113883.6.285' => 'HCPCS',
|
17
|
+
'2.16.840.1.113883.5.2' => "HL7 Marital Status",
|
18
|
+
'2.16.840.1.113883.12.292' => 'CVX',
|
19
|
+
'2.16.840.1.113883.5.83' => 'HITSP C80 Observation Status',
|
20
|
+
'2.16.840.1.113883.3.26.1.1' => 'NCI Thesaurus',
|
21
|
+
'2.16.840.1.113883.3.88.12.80.20' => 'FDA',
|
22
|
+
"2.16.840.1.113883.4.9" => "UNII",
|
23
|
+
"2.16.840.1.113883.6.69" => "NDC",
|
24
|
+
'2.16.840.1.113883.5.14' => 'HL7 ActStatus',
|
25
|
+
'2.16.840.1.113883.6.259' => 'HL7 Healthcare Service Location',
|
26
|
+
'2.16.840.1.113883.12.112' => 'DischargeDisposition',
|
27
|
+
'2.16.840.1.113883.5.4' => 'HL7 Act Code',
|
28
|
+
'2.16.840.1.113883.1.11.18877' => 'HL7 Relationship Code',
|
29
|
+
'2.16.840.1.113883.6.238' => 'CDCREC',
|
30
|
+
'2.16.840.1.113883.6.177' => 'NLM MeSH',
|
31
|
+
'2.16.840.1.113883.5.1076' => "Religious Affiliation",
|
32
|
+
'2.16.840.1.113883.1.11.19717' => "HL7 ActNoImmunicationReason",
|
33
|
+
'2.16.840.1.113883.3.88.12.80.33' => "NUBC",
|
34
|
+
'2.16.840.1.113883.1.11.78' => "HL7 Observation Interpretation",
|
35
|
+
'2.16.840.1.113883.3.221.5' => "Source of Payment Typology",
|
36
|
+
'2.16.840.1.113883.6.13' => 'CDT',
|
37
|
+
'2.16.840.1.113883.18.2' => 'AdministrativeSex',
|
38
|
+
'2.16.840.1.113883.5.1' => 'AdministrativeGender'
|
39
|
+
}
|
40
|
+
|
41
|
+
CODE_SYSTEM_ALIASES = {
|
42
|
+
'FDA SPL' => 'NCI Thesaurus',
|
43
|
+
'HSLOC' => 'HL7 Healthcare Service Location',
|
44
|
+
'SOP' => "Source of Payment Typology"
|
45
|
+
}
|
46
|
+
|
47
|
+
# Some old OID are still around in data, this hash maps retired OID values to
|
48
|
+
# the new value
|
49
|
+
OID_ALIASES = {
|
50
|
+
'2.16.840.1.113883.6.59' => '2.16.840.1.113883.12.292' # CVX
|
51
|
+
}
|
52
|
+
|
53
|
+
# Returns the name of a code system given an oid
|
54
|
+
# @param [String] oid of a code system
|
55
|
+
# @return [String] the name of the code system as described in the measure definition JSON
|
56
|
+
def self.code_system_for(oid)
|
57
|
+
oid = OID_ALIASES[oid] if OID_ALIASES[oid]
|
58
|
+
CODE_SYSTEMS[oid] || "Unknown"
|
59
|
+
end
|
60
|
+
|
61
|
+
# Returns the oid for a code system given a codesystem name
|
62
|
+
# @param [String] the name of the code system
|
63
|
+
# @return [String] the oid of the code system
|
64
|
+
def self.oid_for_code_system(code_system)
|
65
|
+
code_system = CODE_SYSTEM_ALIASES[code_system] if CODE_SYSTEM_ALIASES[code_system]
|
66
|
+
CODE_SYSTEMS.invert[code_system]
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns the whole map of OIDs to code systems
|
70
|
+
# @terurn [Hash] oids as keys, code system names as values
|
71
|
+
def self.code_systems
|
72
|
+
CODE_SYSTEMS
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module HQMF
|
2
|
+
module Util
|
3
|
+
# General helpers for working with codes and code systems
|
4
|
+
class HQMFTemplateHelper
|
5
|
+
|
6
|
+
def self.definition_for_template_id(template_id, version="r1")
|
7
|
+
template_id_map(version)[template_id]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.template_id_map(version)
|
11
|
+
if @id_map.blank?
|
12
|
+
@id_map = {
|
13
|
+
'r1' => JSON.parse(File.read(File.expand_path('../hqmf_template_oid_map.json', __FILE__))),
|
14
|
+
'r2' => JSON.parse(File.read(File.expand_path('../hqmfr2_template_oid_map.json', __FILE__))),
|
15
|
+
'r2cql' => JSON.parse(File.read(File.expand_path('../hqmfr2cql_template_oid_map.json', __FILE__)))
|
16
|
+
}
|
17
|
+
end
|
18
|
+
@id_map[version]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.template_id_by_definition_and_status(definition, status, negation=false, version="r1")
|
22
|
+
case version
|
23
|
+
when "r1"
|
24
|
+
kv_pair = template_id_map(version).find {|k, v| v['definition'] == definition &&
|
25
|
+
v['status'] == status &&
|
26
|
+
v['negation'] == negation}
|
27
|
+
when "r2", "r2cql"
|
28
|
+
kv_pair = template_id_map(version).find {|k, v| v['definition'] == definition &&
|
29
|
+
v['status'] == status}
|
30
|
+
end
|
31
|
+
if kv_pair
|
32
|
+
kv_pair.first
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns a list of all hqmf_oids (regardless of version) for the combination of definition and status
|
39
|
+
def self.get_all_hqmf_oids(definition, status)
|
40
|
+
status ||= ""
|
41
|
+
version_negation_combinations = [{ version: 'r1', negation: false },
|
42
|
+
{ version: 'r1', negation: true },
|
43
|
+
{ version: 'r2', negation: false },
|
44
|
+
{ version: 'r2cql', negation: false }]
|
45
|
+
hqmf_oids = version_negation_combinations.collect do |obj|
|
46
|
+
template_id_by_definition_and_status(definition, status, obj[:negation], obj[:version])
|
47
|
+
end
|
48
|
+
hqmf_oids
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|