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,96 @@
|
|
1
|
+
module HQMF
|
2
|
+
# Represents an HQMF population criteria, also supports all the same methods as
|
3
|
+
# HQMF::Precondition
|
4
|
+
class PopulationCriteria
|
5
|
+
|
6
|
+
include HQMF::Conversion::Utilities
|
7
|
+
|
8
|
+
attr_reader :preconditions, :id, :type, :title, :hqmf_id
|
9
|
+
attr_accessor :aggregator
|
10
|
+
|
11
|
+
IPP = 'IPP'
|
12
|
+
DENOM = 'DENOM'
|
13
|
+
NUMER = 'NUMER'
|
14
|
+
DENEXCEP = 'DENEXCEP'
|
15
|
+
DENEX = 'DENEX'
|
16
|
+
MSRPOPL = 'MSRPOPL'
|
17
|
+
OBSERV = 'OBSERV'
|
18
|
+
|
19
|
+
ALL_POPULATION_CODES = [IPP, DENOM, NUMER, DENEXCEP, DENEX, MSRPOPL, OBSERV]
|
20
|
+
|
21
|
+
# Create a new population criteria
|
22
|
+
# @param [String] id
|
23
|
+
# @param [String] hqmf_id
|
24
|
+
# @param [Array#Precondition] preconditions
|
25
|
+
# @param [String] title (optional)
|
26
|
+
def initialize(id, hqmf_id, type, preconditions, title='', aggregator=nil)
|
27
|
+
@id = id
|
28
|
+
@hqmf_id = hqmf_id
|
29
|
+
@preconditions = preconditions
|
30
|
+
@type = type
|
31
|
+
@title = title
|
32
|
+
@aggregator = aggregator
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create a new population criteria from a JSON hash keyed off symbols
|
36
|
+
def self.from_json(id, json)
|
37
|
+
preconditions = json["preconditions"].map do |precondition|
|
38
|
+
HQMF::Precondition.from_json(precondition)
|
39
|
+
end if json['preconditions']
|
40
|
+
type = json["type"]
|
41
|
+
title = json['title']
|
42
|
+
hqmf_id = json['hqmf_id']
|
43
|
+
aggregator = json['aggregator']
|
44
|
+
|
45
|
+
HQMF::PopulationCriteria.new(id, hqmf_id, type, preconditions, title, aggregator)
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_json
|
49
|
+
{self.id.to_sym => base_json}
|
50
|
+
end
|
51
|
+
|
52
|
+
def base_json
|
53
|
+
x = nil
|
54
|
+
json = build_hash(self, [:conjunction?, :type, :title, :hqmf_id, :aggregator])
|
55
|
+
json[:preconditions] = x if x = json_array(@preconditions)
|
56
|
+
json
|
57
|
+
end
|
58
|
+
|
59
|
+
# Return true of this precondition represents a conjunction with nested preconditions
|
60
|
+
# or false of this precondition is a reference to a data criteria
|
61
|
+
# if it is an observation population criteria, then it is not a conjunction, it is instead doing a calculation
|
62
|
+
def conjunction?
|
63
|
+
type != HQMF::PopulationCriteria::OBSERV
|
64
|
+
end
|
65
|
+
|
66
|
+
# Get the conjunction code, e.g. allTrue, atLeastOneTrue
|
67
|
+
# @return [String] conjunction code
|
68
|
+
def conjunction_code
|
69
|
+
|
70
|
+
case @type
|
71
|
+
when IPP, DENOM, NUMER, MSRPOPL
|
72
|
+
HQMF::Precondition::ALL_TRUE
|
73
|
+
when DENEXCEP, DENEX
|
74
|
+
HQMF::Precondition::AT_LEAST_ONE_TRUE
|
75
|
+
else
|
76
|
+
raise "Unknown population type [#{@type}]"
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
# Can't have negation on population so this is the same as conjunction_code
|
82
|
+
def conjunction_code_with_negation
|
83
|
+
conjunction_code
|
84
|
+
end
|
85
|
+
|
86
|
+
def referenced_data_criteria
|
87
|
+
data_criteria_ids = []
|
88
|
+
@preconditions.each do |precondition|
|
89
|
+
data_criteria_ids.concat(precondition.referenced_data_criteria)
|
90
|
+
end if @preconditions
|
91
|
+
data_criteria_ids
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module HQMF
|
2
|
+
|
3
|
+
class Precondition
|
4
|
+
|
5
|
+
include HQMF::Conversion::Utilities
|
6
|
+
|
7
|
+
AT_LEAST_ONE_TRUE = 'atLeastOneTrue'
|
8
|
+
AT_LEAST_ONE_FALSE = 'atLeastOneFalse'
|
9
|
+
ALL_TRUE = 'allTrue'
|
10
|
+
ALL_FALSE = 'allFalse'
|
11
|
+
NEGATIONS = {
|
12
|
+
AT_LEAST_ONE_TRUE => ALL_FALSE,
|
13
|
+
ALL_FALSE => AT_LEAST_ONE_TRUE,
|
14
|
+
ALL_TRUE => AT_LEAST_ONE_FALSE,
|
15
|
+
AT_LEAST_ONE_FALSE => ALL_TRUE
|
16
|
+
}
|
17
|
+
INVERSIONS = {
|
18
|
+
AT_LEAST_ONE_TRUE => ALL_TRUE,
|
19
|
+
ALL_FALSE => AT_LEAST_ONE_FALSE,
|
20
|
+
ALL_TRUE => AT_LEAST_ONE_TRUE,
|
21
|
+
AT_LEAST_ONE_FALSE => ALL_FALSE
|
22
|
+
}
|
23
|
+
|
24
|
+
attr_reader :id, :preconditions, :reference, :conjunction_code
|
25
|
+
attr_accessor :negation
|
26
|
+
|
27
|
+
# Create a new population criteria
|
28
|
+
# @param [Array#Precondition] preconditions
|
29
|
+
# @param [Reference] reference
|
30
|
+
# @param [String] conjunction_code
|
31
|
+
def initialize(id, preconditions, reference, conjunction_code, negation)
|
32
|
+
@preconditions = preconditions || []
|
33
|
+
@reference = reference
|
34
|
+
@conjunction_code = conjunction_code
|
35
|
+
@negation = negation
|
36
|
+
@id = id
|
37
|
+
end
|
38
|
+
|
39
|
+
def conjunction_code_with_negation
|
40
|
+
if negation
|
41
|
+
NEGATIONS[conjunction_code]
|
42
|
+
else
|
43
|
+
conjunction_code
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Create a new population criteria from a JSON hash keyed off symbols
|
48
|
+
def self.from_json(json)
|
49
|
+
preconditions = []
|
50
|
+
id = json["id"] if json["id"]
|
51
|
+
preconditions = json["preconditions"].map {|precondition| HQMF::Precondition.from_json(precondition)} if json["preconditions"]
|
52
|
+
reference = Reference.new(json["reference"]) if json["reference"]
|
53
|
+
conjunction_code = json["conjunction_code"] if json["conjunction_code"]
|
54
|
+
negation = json["negation"] if json["negation"]
|
55
|
+
|
56
|
+
HQMF::Precondition.new(id, preconditions, reference, conjunction_code, negation)
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_json
|
60
|
+
x = nil
|
61
|
+
json = {}
|
62
|
+
json[:id] = self.id
|
63
|
+
json[:reference] = self.reference.id if self.reference
|
64
|
+
json[:preconditions] = x if x = json_array(@preconditions)
|
65
|
+
json[:conjunction_code] = self.conjunction_code if self.conjunction_code
|
66
|
+
json[:negation] = self.negation if self.negation
|
67
|
+
json
|
68
|
+
end
|
69
|
+
|
70
|
+
# Return true of this precondition represents a conjunction with nested preconditions
|
71
|
+
# or false of this precondition is a reference to a data criteria
|
72
|
+
def conjunction?
|
73
|
+
@preconditions.length>0
|
74
|
+
end
|
75
|
+
|
76
|
+
def referenced_data_criteria
|
77
|
+
data_criteria_ids = []
|
78
|
+
if @preconditions.empty?
|
79
|
+
data_criteria_ids << self.reference.id
|
80
|
+
else
|
81
|
+
@preconditions.each do |precondition|
|
82
|
+
data_criteria_ids.concat(precondition.referenced_data_criteria)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
data_criteria_ids
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,319 @@
|
|
1
|
+
module HQMF
|
2
|
+
|
3
|
+
# Used to represent 'any value' in criteria that require a value be present but
|
4
|
+
# don't specify any restrictions on that value
|
5
|
+
class AnyValue
|
6
|
+
include HQMF::Conversion::Utilities
|
7
|
+
attr_reader :type
|
8
|
+
|
9
|
+
def initialize(type='ANYNonNull')
|
10
|
+
@type = type
|
11
|
+
end
|
12
|
+
|
13
|
+
def derived?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.from_json(json)
|
18
|
+
type = json["type"] || 'ANYNonNull'
|
19
|
+
HQMF::AnyValue.new(type)
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json
|
23
|
+
hash = build_hash(self, [:type])
|
24
|
+
hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Represents a bound within a HQMF pauseQuantity, has a value, a unit and an
|
29
|
+
# inclusive/exclusive indicator
|
30
|
+
class Value
|
31
|
+
include HQMF::Conversion::Utilities
|
32
|
+
attr_reader :unit,:expression
|
33
|
+
attr_accessor :type, :value, :inclusive
|
34
|
+
|
35
|
+
# Create a new HQMF::Value
|
36
|
+
# @param [String] type
|
37
|
+
# @param [String] unit
|
38
|
+
# @param [String] value
|
39
|
+
# @param [Boolean] inclusive
|
40
|
+
# @param [Boolean] derived
|
41
|
+
# @param [String] expression
|
42
|
+
def initialize(type,unit,value,inclusive,derived,expression)
|
43
|
+
@type = type || 'PQ'
|
44
|
+
@unit = unit
|
45
|
+
@value = value
|
46
|
+
@inclusive = inclusive == nil ? true : inclusive
|
47
|
+
@derived = derived || false
|
48
|
+
@expression = expression
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.from_json(json)
|
52
|
+
type = json["type"] if json["type"]
|
53
|
+
unit = json["unit"] if json["unit"]
|
54
|
+
value = json["value"] if json["value"]
|
55
|
+
inclusive = json["inclusive?"] unless json["inclusive?"].nil?
|
56
|
+
derived = json["derived?"] unless json["derived?"].nil?
|
57
|
+
expression = json["expression"] if json["expression"]
|
58
|
+
|
59
|
+
HQMF::Value.new(type,unit,value,inclusive,derived,expression)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def inclusive?
|
64
|
+
@inclusive
|
65
|
+
end
|
66
|
+
|
67
|
+
def derived?
|
68
|
+
@derived
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_json
|
72
|
+
build_hash(self, [:type,:unit,:value,:inclusive?,:derived?,:expression])
|
73
|
+
end
|
74
|
+
|
75
|
+
def stringify
|
76
|
+
"#{inclusive? ? '=' : ''}#{value}#{unit ? ' '+unit : ''}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def ==(other)
|
80
|
+
check_equality(self,other)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
# Represents a HQMF physical quantity which can have low and high bounds
|
86
|
+
class Range
|
87
|
+
include HQMF::Conversion::Utilities
|
88
|
+
attr_accessor :type, :low, :high, :width
|
89
|
+
|
90
|
+
# Create a new HQMF::Value
|
91
|
+
# @param [String] type
|
92
|
+
# @param [Value] low
|
93
|
+
# @param [Value] high
|
94
|
+
# @param [Value] width
|
95
|
+
def initialize(type,low,high,width)
|
96
|
+
@type = type || 'IVL_PQ'
|
97
|
+
@low = low
|
98
|
+
@high = high
|
99
|
+
@width = width
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.from_json(json)
|
103
|
+
type = json["type"] if json["type"]
|
104
|
+
low = HQMF::Value.from_json(json["low"]) if json["low"]
|
105
|
+
high = HQMF::Value.from_json(json["high"]) if json["high"]
|
106
|
+
width = HQMF::Value.from_json(json["width"]) if json["width"]
|
107
|
+
|
108
|
+
HQMF::Range.new(type,low,high,width)
|
109
|
+
end
|
110
|
+
|
111
|
+
def to_json
|
112
|
+
json = build_hash(self, [:type])
|
113
|
+
json[:low] = self.low.to_json if self.low
|
114
|
+
json[:high] = self.high.to_json if self.high
|
115
|
+
json[:width] = self.width.to_json if self.width
|
116
|
+
json
|
117
|
+
end
|
118
|
+
|
119
|
+
def stringify
|
120
|
+
operator = ""
|
121
|
+
if (@high && @low)
|
122
|
+
if (@high.value == @low.value and @high.inclusive? and low.inclusive?)
|
123
|
+
"#{@low.stringify}"
|
124
|
+
else
|
125
|
+
">#{@low.stringify} and <#{@high.stringify}}"
|
126
|
+
end
|
127
|
+
elsif (@high)
|
128
|
+
"<#{@high.stringify}"
|
129
|
+
elsif (@low)
|
130
|
+
">#{@low.stringify}"
|
131
|
+
else
|
132
|
+
raise "cannot convert range to string"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def ==(other)
|
137
|
+
check_equality(self,other)
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
# Represents a HQMF effective time which is a specialization of a interval
|
144
|
+
class EffectiveTime < Range
|
145
|
+
def initialize(low,high,width)
|
146
|
+
super('IVL_TS', low, high, width)
|
147
|
+
end
|
148
|
+
|
149
|
+
def type
|
150
|
+
'IVL_TS'
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
# Represents a HQMF CD value which has a code and codeSystem
|
156
|
+
class Coded
|
157
|
+
include HQMF::Conversion::Utilities
|
158
|
+
attr_reader :type, :system, :code, :code_list_id, :title
|
159
|
+
|
160
|
+
# Create a new HQMF::Coded
|
161
|
+
# @param [String] type
|
162
|
+
# @param [String] system
|
163
|
+
# @param [String] code
|
164
|
+
# @param [String] code_list_id
|
165
|
+
def initialize(type,system,code,code_list_id=nil,title=nil)
|
166
|
+
@type = type
|
167
|
+
@system = system
|
168
|
+
@code = code
|
169
|
+
@code_list_id = code_list_id
|
170
|
+
@title = title
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.for_code_list(code_list_id,title=nil)
|
174
|
+
HQMF::Coded.new('CD',nil,nil,code_list_id,title)
|
175
|
+
end
|
176
|
+
|
177
|
+
def self.for_single_code(system,code,title=nil)
|
178
|
+
HQMF::Coded.new('CD',system,code,nil,title)
|
179
|
+
end
|
180
|
+
|
181
|
+
def self.from_json(json)
|
182
|
+
type = json["type"] if json["type"]
|
183
|
+
system = json["system"] if json["system"]
|
184
|
+
code = json["code"] if json["code"]
|
185
|
+
code_list_id = json["code_list_id"] if json["code_list_id"]
|
186
|
+
title = json["title"] if json["title"]
|
187
|
+
|
188
|
+
HQMF::Coded.new(type,system,code,code_list_id,title)
|
189
|
+
end
|
190
|
+
|
191
|
+
def to_json
|
192
|
+
build_hash(self, [:type,:system,:code,:code_list_id,:title])
|
193
|
+
end
|
194
|
+
|
195
|
+
def value
|
196
|
+
code
|
197
|
+
end
|
198
|
+
|
199
|
+
def derived?
|
200
|
+
false
|
201
|
+
end
|
202
|
+
|
203
|
+
def unit
|
204
|
+
nil
|
205
|
+
end
|
206
|
+
|
207
|
+
def ==(other)
|
208
|
+
check_equality(self,other)
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
class TemporalReference
|
214
|
+
include HQMF::Conversion::Utilities
|
215
|
+
|
216
|
+
TYPES = ['DURING','SBS','SAS','SBE','SAE','EBS','EAS','EBE','EAE','SDU','EDU','ECW','SCW','CONCURRENT']
|
217
|
+
INVERSION = {'SBS' => 'SAS','EAE' => 'EBE','SAS' => 'SBS','EBE' => 'EAE','SBE' => 'EAS','EAS' => 'SBE','SAE' => 'EBS','EBS' => 'SAE'}
|
218
|
+
|
219
|
+
attr_reader :type, :reference, :range
|
220
|
+
|
221
|
+
# @param [String] type
|
222
|
+
# @param [Reference] reference
|
223
|
+
# @param [Range] range
|
224
|
+
def initialize(type, reference, range)
|
225
|
+
@type = type
|
226
|
+
@reference = reference
|
227
|
+
if (range.is_a? HQMF::Value)
|
228
|
+
@range = HQMF::Range.new('IVL_PQ', range, range, nil)
|
229
|
+
else
|
230
|
+
@range = range
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def self.from_json(json)
|
235
|
+
type = json["type"] if json["type"]
|
236
|
+
reference = HQMF::Reference.new(json["reference"]) if json["reference"]
|
237
|
+
range = HQMF::Range.from_json(json["range"]) if json["range"]
|
238
|
+
|
239
|
+
HQMF::TemporalReference.new(type,reference,range)
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
def to_json
|
244
|
+
x = nil
|
245
|
+
json = build_hash(self, [:type])
|
246
|
+
json[:reference] = @reference.to_json if @reference
|
247
|
+
json[:range] = @range.to_json if @range
|
248
|
+
json
|
249
|
+
end
|
250
|
+
|
251
|
+
def ==(other)
|
252
|
+
check_equality(self,other)
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
class SubsetOperator
|
258
|
+
include HQMF::Conversion::Utilities
|
259
|
+
|
260
|
+
TYPES = ['COUNT', 'FIRST', 'SECOND', 'THIRD', 'FOURTH', 'FIFTH', 'RECENT', 'LAST', 'MIN', 'MAX', 'DATEDIFF', 'TIMEDIFF', 'MEDIAN', 'MEAN']
|
261
|
+
|
262
|
+
attr_accessor :type, :value
|
263
|
+
# @param [String] type
|
264
|
+
# @param [Value] value
|
265
|
+
def initialize(type,value)
|
266
|
+
@type = type
|
267
|
+
if (value.is_a? HQMF::Value)
|
268
|
+
value.inclusive = true
|
269
|
+
@value = HQMF::Range.new('IVL_PQ',value,value,nil)
|
270
|
+
else
|
271
|
+
@value = value
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
def self.from_json(json)
|
276
|
+
type = json["type"] if json["type"]
|
277
|
+
|
278
|
+
value = HQMF::DataCriteria.convert_value(json["value"]) if json["value"]
|
279
|
+
|
280
|
+
HQMF::SubsetOperator.new(type,value)
|
281
|
+
end
|
282
|
+
|
283
|
+
|
284
|
+
def to_json
|
285
|
+
x = nil
|
286
|
+
json = build_hash(self, [:type])
|
287
|
+
json[:value] = @value.to_json if @value
|
288
|
+
json
|
289
|
+
end
|
290
|
+
|
291
|
+
def ==(other)
|
292
|
+
check_equality(self,other)
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
|
298
|
+
# Represents a HQMF reference from a precondition to a data criteria
|
299
|
+
class Reference
|
300
|
+
include HQMF::Conversion::Utilities
|
301
|
+
attr_accessor :id
|
302
|
+
|
303
|
+
# Create a new HQMF::Reference
|
304
|
+
# @param [String] id
|
305
|
+
def initialize(id)
|
306
|
+
@id = id
|
307
|
+
end
|
308
|
+
|
309
|
+
def to_json
|
310
|
+
@id
|
311
|
+
end
|
312
|
+
|
313
|
+
def ==(other)
|
314
|
+
check_equality(self,other)
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
318
|
+
|
319
|
+
end
|