Class: QRDA::Cat1::EncounterPerformedImporter

Inherits:
SectionImporter show all
Defined in:
lib/qrda-import/data-element-importers/encounter_performed_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:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.23']")) ⇒ EncounterPerformedImporter

Returns a new instance of EncounterPerformedImporter.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/qrda-import/data-element-importers/encounter_performed_importer.rb', line 4

def initialize(entry_finder = QRDA::Cat1::EntryFinder.new("./cda:entry/cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.23']"))
  super(entry_finder)
  @id_xpath = './cda:id'
  @code_xpath = "./cda:code"
  @relevant_period_xpath = "./cda:effectiveTime"
  @author_datetime_xpath = "./cda:author[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.155']/cda:time"
  @admission_source_xpath = "./cda:participant/cda:participantRole[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.151']/cda:code"
  @discharge_disposition_xpath = "./sdtc:dischargeDispositionCode"
  @facility_locations_xpath = "./cda:participant[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.100']"
  @clazz_xpath = "./cda:entryRelationship/cda:act[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.171']/cda:code"
  @diagnosis_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.168']"
  @related_to_xpath = "./sdtc:inFulfillmentOf1/sdtc:actReference"
  @entry_class = QDM::EncounterPerformed
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
33
34
35
# File 'lib/qrda-import/data-element-importers/encounter_performed_importer.rb', line 19

def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
  encounter_performed = super
  encounter_performed.admissionSource = code_if_present(entry_element.at_xpath(@admission_source_xpath))
  encounter_performed.dischargeDisposition = code_if_present(entry_element.at_xpath(@discharge_disposition_xpath))
  encounter_performed.facilityLocations = extract_facility_locations(entry_element)
  encounter_performed.clazz = code_if_present(entry_element.at_xpath(@clazz_xpath))
  encounter_performed.diagnoses = extract_diagnoses(entry_element)
  if encounter_performed&.relevantPeriod&.low && encounter_performed&.relevantPeriod&.high
    los = encounter_performed.relevantPeriod.high.to_date - encounter_performed.relevantPeriod.low.to_date
    encounter_performed.lengthOfStay = QDM::Quantity.new(los.to_i, 'd')
  end
  entity = extract_entity(entry_element, "./cda:participant[@typeCode='PRF']")
  encounter_performed.participant.concat(entity) if entity
  extract_modifier_code(encounter_performed, entry_element)
  encounter_performed.relatedTo = extract_related_to(entry_element)
  encounter_performed
end