cqm-parsers 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +29 -0
- data/README.md +21 -0
- data/Rakefile +19 -0
- data/lib/ext/code.rb +10 -0
- data/lib/ext/data_element.rb +24 -0
- data/lib/hqmf-model/attribute.rb +63 -0
- data/lib/hqmf-model/data_criteria.rb +467 -0
- data/lib/hqmf-model/document.rb +253 -0
- data/lib/hqmf-model/population_criteria.rb +102 -0
- data/lib/hqmf-model/precondition.rb +94 -0
- data/lib/hqmf-model/types.rb +457 -0
- data/lib/hqmf-model/utilities.rb +52 -0
- data/lib/hqmf-parser.rb +116 -0
- data/lib/hqmf-parser/1.0/attribute.rb +121 -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/document.rb +195 -0
- data/lib/hqmf-parser/1.0/expression.rb +60 -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 +90 -0
- data/lib/hqmf-parser/1.0/range.rb +76 -0
- data/lib/hqmf-parser/1.0/restriction.rb +162 -0
- data/lib/hqmf-parser/1.0/utilities.rb +55 -0
- data/lib/hqmf-parser/2.0/data_criteria.rb +372 -0
- data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb +80 -0
- data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb +201 -0
- data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_post_processing.rb +85 -0
- data/lib/hqmf-parser/2.0/data_criteria_helpers/dc_specific_occurrences_and_source_data_criteria_extract.rb +117 -0
- data/lib/hqmf-parser/2.0/document.rb +304 -0
- data/lib/hqmf-parser/2.0/document_helpers/doc_population_helper.rb +173 -0
- data/lib/hqmf-parser/2.0/document_helpers/doc_utilities.rb +131 -0
- data/lib/hqmf-parser/2.0/field_value_helper.rb +251 -0
- data/lib/hqmf-parser/2.0/population_criteria.rb +134 -0
- data/lib/hqmf-parser/2.0/precondition.rb +73 -0
- data/lib/hqmf-parser/2.0/source_data_criteria_helper.rb +112 -0
- data/lib/hqmf-parser/2.0/types.rb +448 -0
- data/lib/hqmf-parser/2.0/utilities.rb +45 -0
- data/lib/hqmf-parser/2.0/value_set_helper.rb +104 -0
- data/lib/hqmf-parser/converter/pass1/data_criteria_converter.rb +257 -0
- data/lib/hqmf-parser/converter/pass1/document_converter.rb +133 -0
- data/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb +185 -0
- data/lib/hqmf-parser/converter/pass1/precondition_converter.rb +173 -0
- data/lib/hqmf-parser/converter/pass1/precondition_extractor.rb +201 -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/cql/data_criteria.rb +57 -0
- data/lib/hqmf-parser/cql/data_criteria_helpers/dc_definition_from_template_or_type_extract.rb +79 -0
- data/lib/hqmf-parser/cql/data_criteria_helpers/dc_post_processing.rb +43 -0
- data/lib/hqmf-parser/cql/document.rb +78 -0
- data/lib/hqmf-parser/cql/document_helpers/doc_population_helper.rb +124 -0
- data/lib/hqmf-parser/cql/value_set_helper.rb +103 -0
- data/lib/hqmf-parser/parser.rb +100 -0
- data/lib/qrda-export/catI-r5/qrda1_r5.rb +125 -0
- data/lib/qrda-export/helper/cat_1_view_helper.rb +142 -0
- data/lib/qrda-export/helper/code_system_helper.rb +77 -0
- data/lib/qrda-export/helper/date_helper.rb +81 -0
- data/lib/qrda-import/base-importers/demographics_importer.rb +47 -0
- data/lib/qrda-import/base-importers/medication_importer.rb +22 -0
- data/lib/qrda-import/base-importers/section_importer.rb +196 -0
- data/lib/qrda-import/cda_identifier.rb +19 -0
- data/lib/qrda-import/data-element-importers/adverse_event_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/allergy_intolerance_importer.rb +21 -0
- data/lib/qrda-import/data-element-importers/assessment_performed_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/communication_from_patient_to_provider_importer.rb +18 -0
- data/lib/qrda-import/data-element-importers/communication_from_provider_to_patient_importer.rb +18 -0
- data/lib/qrda-import/data-element-importers/communication_from_provider_to_provider_importer.rb +20 -0
- data/lib/qrda-import/data-element-importers/device_applied_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/device_order_importer.rb +18 -0
- data/lib/qrda-import/data-element-importers/diagnosis_importer.rb +23 -0
- data/lib/qrda-import/data-element-importers/diagnostic_study_order_importer.rb +20 -0
- data/lib/qrda-import/data-element-importers/diagnostic_study_performed_importer.rb +30 -0
- data/lib/qrda-import/data-element-importers/encounter_order_importer.rb +20 -0
- data/lib/qrda-import/data-element-importers/encounter_performed_importer.rb +41 -0
- data/lib/qrda-import/data-element-importers/immunization_administered_importer.rb +18 -0
- data/lib/qrda-import/data-element-importers/intervention_order_importer.rb +18 -0
- data/lib/qrda-import/data-element-importers/intervention_performed_importer.rb +22 -0
- data/lib/qrda-import/data-element-importers/laboratory_test_order_importer.rb +20 -0
- data/lib/qrda-import/data-element-importers/laboratory_test_performed_importer.rb +28 -0
- data/lib/qrda-import/data-element-importers/medication_active_importer.rb +17 -0
- data/lib/qrda-import/data-element-importers/medication_administered_importer.rb +17 -0
- data/lib/qrda-import/data-element-importers/medication_discharge_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/medication_dispensed_importer.rb +19 -0
- data/lib/qrda-import/data-element-importers/medication_order_importer.rb +16 -0
- data/lib/qrda-import/data-element-importers/patient_characteristic_expired.rb +21 -0
- data/lib/qrda-import/data-element-importers/physical_exam_performed_importer.rb +26 -0
- data/lib/qrda-import/data-element-importers/procedure_order_importer.rb +26 -0
- data/lib/qrda-import/data-element-importers/procedure_performed_importer.rb +34 -0
- data/lib/qrda-import/data-element-importers/substance_administered_importer.rb +16 -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 +105 -0
- data/lib/util/code_system_helper.rb +76 -0
- data/lib/util/counter.rb +20 -0
- data/lib/util/hqmf_template_helper.rb +39 -0
- metadata +340 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
module DemographicsImporter
|
4
|
+
def get_demographics(patient, doc)
|
5
|
+
# effective_date = doc.at_xpath('/cda:ClinicalDocument/cda:effectiveTime')['value']
|
6
|
+
# patient.effective_time = HL7Helper.timestamp_to_integer(effective_date)
|
7
|
+
patient_role_element = doc.at_xpath('/cda:ClinicalDocument/cda:recordTarget/cda:patientRole')
|
8
|
+
patient_element = patient_role_element.at_xpath('./cda:patient')
|
9
|
+
# patient.title = patient_element.at_xpath('cda:name/cda:title').try(:text)
|
10
|
+
patient.givenNames = [patient_element.at_xpath('cda:name/cda:given').text]
|
11
|
+
patient.familyName = patient_element.at_xpath('cda:name/cda:family').text
|
12
|
+
patient.birthDatetime = Time.parse(patient_element.at_xpath('cda:birthTime')['value']).utc
|
13
|
+
pcbd = QDM::PatientCharacteristicBirthdate.new
|
14
|
+
pcbd.birthDatetime = patient.birthDatetime
|
15
|
+
pcbd.dataElementCodes = [{ code: '21112-8', codeSystem: 'LOINC' }]
|
16
|
+
patient.dataElements << pcbd
|
17
|
+
|
18
|
+
pcs = QDM::PatientCharacteristicSex.new
|
19
|
+
gender_code = patient_element.at_xpath('cda:administrativeGenderCode')['code']
|
20
|
+
pcs.dataElementCodes = [{ code: gender_code, codeSystem: 'AdministrativeGender' }]
|
21
|
+
patient.dataElements << pcs
|
22
|
+
|
23
|
+
# TODO: Investigate what of this HDS import codes needs to be addressed in this qrda parser.
|
24
|
+
# gender_node = patient_element.at_xpath('cda:administrativeGenderCode')
|
25
|
+
# patient.gender = gender_node['code']
|
26
|
+
# id_node = patient_role_element.at_xpath('./cda:id')
|
27
|
+
# patient.medical_record_number = id_node['extension']
|
28
|
+
|
29
|
+
# parse race, ethnicity, and spoken language
|
30
|
+
# race_node = patient_element.at_xpath('cda:raceCode')
|
31
|
+
# patient.race = { 'code' => race_node['code'], 'codeSystem' => 'CDC Race' } if race_node
|
32
|
+
# ethnicity_node = patient_element.at_xpath('cda:ethnicGroupCode')
|
33
|
+
# patient.ethnicity = {'code' => ethnicity_node['code'], 'codeSystem' => 'CDC Race'} if ethnicity_node
|
34
|
+
# marital_status_node = patient_element.at_xpath("./cda:maritalStatusCode")
|
35
|
+
# patient.marital_status = {code: marital_status_node['code'], code_set: "HL7 Marital Status"} if marital_status_node
|
36
|
+
# ra_node = patient_element.at_xpath("./cda:religiousAffiliationCode")
|
37
|
+
# patient.religious_affiliation = {code: ra_node['code'], code_set: "Religious Affiliation"} if ra_node
|
38
|
+
# languages = patient_element.search('languageCommunication').map {|lc| lc.at_xpath('cda:languageCode')['code'] }
|
39
|
+
# patient.languages = languages unless languages.empty?
|
40
|
+
|
41
|
+
# patient.addresses = patient_role_element.xpath("./cda:addr").map { |addr| import_address(addr) }
|
42
|
+
# patient.telecoms = patient_role_element.xpath("./cda:telecom").map { |tele| import_telecom(tele) }
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class MedicationImporter < SectionImporter
|
4
|
+
|
5
|
+
def initialize(entry_finder = nil)
|
6
|
+
super(entry_finder)
|
7
|
+
@code_xpath = "./cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"
|
8
|
+
@relevant_period_xpath = "./cda:effectiveTime"
|
9
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
10
|
+
@dosage_xpath = "./cda:doseQuantity"
|
11
|
+
@route_xpath = "./cda:routeCode"
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
15
|
+
medication = super
|
16
|
+
medication.dosage = extract_scalar(entry_element, @dosage_xpath)
|
17
|
+
medication.route = code_if_present(entry_element.at_xpath(@route_xpath))
|
18
|
+
medication
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class SectionImporter
|
4
|
+
attr_accessor :check_for_usable, :status_xpath, :code_xpath
|
5
|
+
|
6
|
+
def initialize(entry_finder)
|
7
|
+
@entry_finder = entry_finder
|
8
|
+
@code_xpath = "./cda:code"
|
9
|
+
@entry_id_map = {}
|
10
|
+
@check_for_usable = true
|
11
|
+
@entry_class = QDM::DataElement
|
12
|
+
end
|
13
|
+
|
14
|
+
# Traverses an HL7 CDA document passed in and creates an Array of Entry
|
15
|
+
# objects based on what it finds
|
16
|
+
# @param [Nokogiri::XML::Document] doc It is expected that the root node of this document
|
17
|
+
# will have the "cda" namespace registered to "urn:hl7-org:v3"
|
18
|
+
# measure definition
|
19
|
+
# @return [Array] will be a list of Entry objects
|
20
|
+
def create_entries(doc, nrh = NarrativeReferenceHandler.new)
|
21
|
+
entry_list = []
|
22
|
+
@entry_id_map = {}
|
23
|
+
entry_elements = @entry_finder.entries(doc)
|
24
|
+
entry_elements.each do |entry_element|
|
25
|
+
entry = create_entry(entry_element, nrh)
|
26
|
+
if @check_for_usable
|
27
|
+
entry_list << entry if usable_entry?(entry)
|
28
|
+
else
|
29
|
+
entry_list << entry
|
30
|
+
end
|
31
|
+
end
|
32
|
+
[entry_list, @entry_id_map]
|
33
|
+
end
|
34
|
+
|
35
|
+
def usable_entry?(entry)
|
36
|
+
entry.dataElementCodes.present?
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_entry(entry_element, _nrh = NarrativeReferenceHandler.new)
|
40
|
+
entry = @entry_class.new
|
41
|
+
@entry_id_map[extract_id(entry_element, "./cda:id")] ||= []
|
42
|
+
@entry_id_map[extract_id(entry_element, "./cda:id")] << entry.id
|
43
|
+
entry.dataElementCodes = extract_codes(entry_element, @code_xpath)
|
44
|
+
extract_dates(entry_element, entry)
|
45
|
+
if @result_xpath
|
46
|
+
entry.result = extract_result_values(entry_element)
|
47
|
+
end
|
48
|
+
extract_reason_or_negation(entry_element, entry)
|
49
|
+
entry
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def extract_id(parent_element, id_xpath)
|
55
|
+
id_element = parent_element.at_xpath(id_xpath)
|
56
|
+
return unless id_element
|
57
|
+
identifier = CDAIdentifier.new
|
58
|
+
identifier.root = id_element['root']
|
59
|
+
identifier.extension = id_element['extension']
|
60
|
+
identifier
|
61
|
+
end
|
62
|
+
|
63
|
+
def extract_codes(coded_element, code_xpath)
|
64
|
+
code_list = []
|
65
|
+
code_elements = coded_element.xpath(code_xpath)
|
66
|
+
code_elements.each do |code_element|
|
67
|
+
code_list << code_if_present(code_element)
|
68
|
+
translations = code_element.xpath('cda:translation')
|
69
|
+
translations.each do |translation|
|
70
|
+
code_list << code_if_present(translation)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
code_list.compact
|
74
|
+
end
|
75
|
+
|
76
|
+
def code_if_present(code_element)
|
77
|
+
return unless code_element && code_element['codeSystem'] && code_element['code']
|
78
|
+
QDM::Code.new(code_element['code'], HQMF::Util::CodeSystemHelper.code_system_for(code_element['codeSystem']))
|
79
|
+
end
|
80
|
+
|
81
|
+
def extract_dates(parent_element, entry)
|
82
|
+
entry.authorDatetime = extract_time(parent_element, @author_datetime_xpath) if @author_datetime_xpath
|
83
|
+
entry.relevantPeriod = extract_interval(parent_element, @relevant_period_xpath) if @relevant_period_xpath
|
84
|
+
entry.prevalencePeriod = extract_interval(parent_element, @prevalence_period_xpath) if @prevalence_period_xpath
|
85
|
+
end
|
86
|
+
|
87
|
+
def extract_interval(parent_element, interval_xpath)
|
88
|
+
if parent_element.at_xpath("#{interval_xpath}/@value")
|
89
|
+
low_time = DateTime.parse(parent_element.at_xpath(interval_xpath)['value'])
|
90
|
+
high_time = DateTime.parse(parent_element.at_xpath(interval_xpath)['value'])
|
91
|
+
end
|
92
|
+
if parent_element.at_xpath("#{interval_xpath}/cda:low")
|
93
|
+
low_time = DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:low")['value'])
|
94
|
+
end
|
95
|
+
if parent_element.at_xpath("#{interval_xpath}/cda:high")
|
96
|
+
high_time = if parent_element.at_xpath("#{interval_xpath}/cda:high")['value']
|
97
|
+
DateTime.parse(parent_element.at_xpath("#{interval_xpath}/cda:high")['value'])
|
98
|
+
else
|
99
|
+
DateTime.new(9999,1,1)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
if parent_element.at_xpath("#{interval_xpath}/cda:center")
|
103
|
+
low_time = Time.parse(parent_element.at_xpath("#{interval_xpath}/cda:center")['value'])
|
104
|
+
high_time = Time.parse(parent_element.at_xpath("#{interval_xpath}/cda:center")['value'])
|
105
|
+
end
|
106
|
+
QDM::Interval.new(low_time, high_time).shift_dates(0)
|
107
|
+
end
|
108
|
+
|
109
|
+
def extract_time(parent_element, datetime_xpath)
|
110
|
+
DateTime.parse(parent_element.at_xpath(datetime_xpath)['value']) if parent_element.at_xpath("#{datetime_xpath}/@value")
|
111
|
+
end
|
112
|
+
|
113
|
+
def extract_result_values(parent_element)
|
114
|
+
result = []
|
115
|
+
parent_element.xpath(@result_xpath).each do |elem|
|
116
|
+
result << extract_result_value(elem)
|
117
|
+
end
|
118
|
+
result.size > 1 ? result : result.first
|
119
|
+
end
|
120
|
+
|
121
|
+
def extract_result_value(value_element)
|
122
|
+
return unless value_element && !value_element['nullFlavor']
|
123
|
+
value = value_element['value']
|
124
|
+
if value.present?
|
125
|
+
return value.strip.to_i if (value_element['unit'] == "1" || value_element['unit'].nil?)
|
126
|
+
return QDM::Quantity.new(value.strip.to_i, value_element['unit'])
|
127
|
+
elsif value_element['code'].present?
|
128
|
+
return code_if_present(value_element)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# extracts the reason or negation data. if an element is negated and the code has a null flavor, a random code is assigned for calculation
|
133
|
+
# coded_parent_element is the 'parent' element when the coded is nested (e.g., medication order)
|
134
|
+
def extract_reason_or_negation(parent_element, entry, coded_parent_element = nil)
|
135
|
+
coded_parent_element ||= parent_element
|
136
|
+
reason_element = parent_element.at_xpath("./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value | ./cda:entryRelationship[@typeCode='RSON']/cda:act[cda:templateId/@root='2.16.840.1.113883.10.20.1.27']/cda:code")
|
137
|
+
negation_indicator = parent_element['negationInd']
|
138
|
+
if reason_element
|
139
|
+
if negation_indicator.eql?('true')
|
140
|
+
entry.negationRationale = code_if_present(reason_element)
|
141
|
+
else
|
142
|
+
entry.reason = code_if_present(reason_element)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
extract_negated_code(coded_parent_element, entry)
|
146
|
+
end
|
147
|
+
|
148
|
+
def extract_negated_code(coded_parent_element, entry)
|
149
|
+
code_elements = coded_parent_element.xpath(@code_xpath)
|
150
|
+
code_elements.each do |code_element|
|
151
|
+
if code_element['nullFlavor'] == 'NA' && code_element['sdtc:valueSet']
|
152
|
+
entry.dataElementCodes = [{ code: code_element['sdtc:valueSet'], codeSystem: 'NA_VALUESET' }]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def extract_scalar(parent_element, scalar_xpath)
|
158
|
+
scalar_element = parent_element.at_xpath(scalar_xpath)
|
159
|
+
return unless scalar_element
|
160
|
+
QDM::Quantity.new(scalar_element['value'].to_i, scalar_element['unit'])
|
161
|
+
end
|
162
|
+
|
163
|
+
def extract_components(parent_element)
|
164
|
+
component_elements = parent_element.xpath(@components_xpath)
|
165
|
+
components = []
|
166
|
+
component_elements&.each do |component_element|
|
167
|
+
component = QDM::Component.new
|
168
|
+
component.code = code_if_present(component_element.at_xpath('./cda:code'))
|
169
|
+
component.result = extract_result_value(component_element.at_xpath('./cda:value'))
|
170
|
+
components << component
|
171
|
+
end
|
172
|
+
components
|
173
|
+
end
|
174
|
+
|
175
|
+
def extract_facility(parent_element, entry)
|
176
|
+
facility_element = parent_element.at_xpath(@facility_xpath)
|
177
|
+
return unless facility_element
|
178
|
+
facility = QDM::FacilityLocation.new
|
179
|
+
participant_element = facility_element.at_xpath("./cda:participantRole[@classCode='SDLOC']/cda:code")
|
180
|
+
facility.code = code_if_present(participant_element)
|
181
|
+
facility.locationPeriod = extract_interval(facility_element, './cda:time')
|
182
|
+
entry.facilityLocations = [facility]
|
183
|
+
end
|
184
|
+
|
185
|
+
def extract_related_to(parent_element)
|
186
|
+
related_to_elements = parent_element.xpath(@related_to_xpath)
|
187
|
+
related_ids = []
|
188
|
+
related_to_elements.each do |related_to_element|
|
189
|
+
related_ids << extract_id(related_to_element, './sdtc:id')
|
190
|
+
end
|
191
|
+
related_ids
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'mongoid'
|
2
|
+
|
3
|
+
class CDAIdentifier
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Attributes::Dynamic
|
6
|
+
|
7
|
+
field :root, type: String
|
8
|
+
field :extension, type: String
|
9
|
+
embedded_in :cda_identifiable, polymorphic: true
|
10
|
+
|
11
|
+
def ==(other)
|
12
|
+
return unless other.respond_to?(:root) && other.respond_to?(:extension)
|
13
|
+
root == other.root && extension == other.extension
|
14
|
+
end
|
15
|
+
|
16
|
+
def hash
|
17
|
+
"#{root}#{extension}".hash
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class AdverseEventImporter < 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.146']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = './cda:entryRelationship/cda:observation/cda:value'
|
7
|
+
@author_datetime_xpath = './cda:author/cda:time'
|
8
|
+
@relevant_period_xpath = './cda:effectiveTime'
|
9
|
+
@severity_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.8']/cda:value"
|
10
|
+
@facility_xpath = "./cda:participant[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.100']"
|
11
|
+
@entry_class = QDM::AdverseEvent
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
15
|
+
adverse_event = super
|
16
|
+
adverse_event.severity = code_if_present(entry_element.at_xpath(@severity_xpath))
|
17
|
+
extract_facility(entry_element, adverse_event)
|
18
|
+
adverse_event
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class AllergyIntoleranceImporter < 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.147']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = './cda:participant/cda:participantRole/cda:playingEntity/cda:code'
|
7
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
8
|
+
@prevalence_period_xpath = "./cda:effectiveTime"
|
9
|
+
@severity_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.8']/cda:value"
|
10
|
+
@entry_class = QDM::AllergyIntolerance
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
14
|
+
allergy_intolerance = super
|
15
|
+
allergy_intolerance.severity = code_if_present(entry_element.at_xpath(@severity_xpath))
|
16
|
+
allergy_intolerance
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class AssessmentPerformedImporter < 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.144']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = './cda:code'
|
7
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
8
|
+
@result_xpath = "./cda:value | ./cda:entryRelationship[@typeCode='REFR']/cda:observation/cda:value"
|
9
|
+
@method_xpath = './cda:methodCode'
|
10
|
+
@components_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.149']"
|
11
|
+
@entry_class = QDM::AssessmentPerformed
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
15
|
+
assessment_performed = super
|
16
|
+
assessment_performed.method = code_if_present(entry_element.at_xpath(@method_xpath))
|
17
|
+
assessment_performed.components = extract_components(entry_element)
|
18
|
+
assessment_performed
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/qrda-import/data-element-importers/communication_from_patient_to_provider_importer.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class CommunicationFromPatientToProviderImporter < 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.2']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = './cda:code'
|
7
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
8
|
+
@entry_class = QDM::CommunicationFromPatientToProvider
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
12
|
+
communication_from_patient_to_provider = super
|
13
|
+
communication_from_patient_to_provider
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/qrda-import/data-element-importers/communication_from_provider_to_patient_importer.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class CommunicationFromProviderToPatientImporter < 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.3']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = './cda:code'
|
7
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
8
|
+
@entry_class = QDM::CommunicationFromProviderToPatient
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
12
|
+
communication_from_provider_to_patient = super
|
13
|
+
communication_from_provider_to_patient
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/qrda-import/data-element-importers/communication_from_provider_to_provider_importer.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class CommunicationFromProviderToProviderImporter < 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.4']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = './cda:code'
|
7
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
8
|
+
@related_to_xpath = "./sdtc:inFulfillmentOf1/sdtc:actReference"
|
9
|
+
@entry_class = QDM::CommunicationFromProviderToProvider
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
13
|
+
communication_from_provider_to_provider = super
|
14
|
+
communication_from_provider_to_provider.relatedTo = extract_related_to(entry_element)
|
15
|
+
communication_from_provider_to_provider
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class DeviceAppliedImporter < SectionImporter
|
4
|
+
def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:procedure[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.7']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = './cda:participant/cda:participantRole/cda:playingDevice/cda:code'
|
7
|
+
@author_datetime_xpath = "./cda:author/cda:time"
|
8
|
+
@relevant_period_xpath = "./cda:effectiveTime"
|
9
|
+
@anatomical_location_site_xpath = "./cda:targetSiteCode"
|
10
|
+
@anatomical_approach_site_xpath = "./cda:approachSiteCode"
|
11
|
+
@entry_class = QDM::DeviceApplied
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
15
|
+
device_applied = super
|
16
|
+
device_applied.anatomicalLocationSite = code_if_present(entry_element.at_xpath(@anatomical_location_site_xpath))
|
17
|
+
device_applied.anatomicalApproachSite = code_if_present(entry_element.at_xpath(@anatomical_approach_site_xpath))
|
18
|
+
device_applied
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module QRDA
|
2
|
+
module Cat1
|
3
|
+
class DeviceOrderImporter < 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.130']"))
|
5
|
+
super(entry_finder)
|
6
|
+
@code_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.9']/cda:participant/cda:participantRole/cda:playingDevice/cda:code"
|
7
|
+
@author_datetime_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.9']/cda:author/cda:time"
|
8
|
+
@entry_class = QDM::DeviceOrder
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
|
12
|
+
device_order = super
|
13
|
+
device_order
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|