Class: QRDA::Cat1::MedicationDischargeImporter

Inherits:
SectionImporter show all
Defined in:
lib/qrda-import/data-element-importers/medication_discharge_importer.rb

Instance Attribute Summary

Attributes inherited from SectionImporter

#check_for_usable, #code_xpath, #codes, #codes_modifiers, #status_xpath, #warnings

Instance Method Summary collapse

Methods inherited from SectionImporter

#create_entries, #usable_entry?

Constructor Details

#initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.105']")) ⇒ MedicationDischargeImporter

Returns a new instance of MedicationDischargeImporter.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/qrda-import/data-element-importers/medication_discharge_importer.rb', line 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.105']"))
  super(entry_finder)
  @id_xpath = './cda:entryRelationship/cda:substanceAdministration/cda:id'
  @code_xpath = "./cda:entryRelationship/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.16']/cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"
  @author_datetime_xpath = "./cda:entryRelationship/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.16']/cda:author[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.155']/cda:time"
  @refills_xpath = "./cda:entryRelationship/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.16']/cda:repeatNumber"
  @dosage_xpath = "./cda:entryRelationship/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.16']/cda:doseQuantity"
  @supply_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.99']/cda:quantity"
  @frequency_xpath = "./cda:entryRelationship/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.16']/cda:effectiveTime[@operator='A']/cda:period"
  @days_supplied_xpath = "./cda:entryRelationship/cda:supply[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.157']/cda:quantity"
  @route_xpath = "./cda:entryRelationship/cda:substanceAdministration[cda:templateId/@root = '2.16.840.1.113883.10.20.22.4.16']/cda:routeCode"

  @entry_class = QDM::MedicationDischarge
end

Instance Method Details

#create_entry(entry_element, nrh = NarrativeReferenceHandler.new) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/qrda-import/data-element-importers/medication_discharge_importer.rb', line 19

def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
  medication_discharge = super
  medication_discharge.refills = extract_refills(entry_element, @refills_xpath)
  medication_discharge.dosage = extract_scalar(entry_element, @dosage_xpath)
  medication_discharge.supply = extract_scalar(entry_element, @supply_xpath)
  medication_discharge.frequency = frequency_as_coded_value(entry_element, @frequency_xpath)
  medication_discharge.daysSupplied = extract_scalar(entry_element, @days_supplied_xpath)&.value
  medication_discharge.route = code_if_present(entry_element.at_xpath(@route_xpath))
  entity1 = extract_entity(entry_element, "./cda:participant[@typeCode='PRF']")
  medication_discharge.prescriber.concat(entity1) if entity1
  entity2 = extract_entity(entry_element, "./cda:participant[@typeCode='AUT']")
  medication_discharge.recorder.concat(entity2) if entity2
  medication_discharge
end