Class: QRDA::Cat1::CommunicationPerformedImporter

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

Returns a new instance of CommunicationPerformedImporter.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/qrda-import/data-element-importers/communication_performed_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.156']"))
  super(entry_finder)
  @id_xpath = './cda:id'
  @code_xpath = "./cda:entryRelationship[@typeCode='REFR']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.88']/cda:value"
  @author_datetime_xpath = "./cda:author[cda:templateId/@root='2.16.840.1.113883.10.20.24.3.155']/cda:time"
  @sent_datetime_xpath = "./cda:effectiveTime/cda:low"
  @received_datetime_xpath = "./cda:effectiveTime/cda:high"
  @related_to_xpath = "./sdtc:inFulfillmentOf1/sdtc:actReference"
  @category_xpath = './cda:code'
  @medium_xpath = "./cda:participant[@typeCode='VIA']/cda:participantRole/cda:code"
  @entry_class = QDM::CommunicationPerformed
end

Instance Method Details

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



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/qrda-import/data-element-importers/communication_performed_importer.rb', line 17

def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
  communication_performed = super
  communication_performed.category = code_if_present(entry_element.at_xpath(@category_xpath))
  communication_performed.medium = code_if_present(entry_element.at_xpath(@medium_xpath))
  communication_performed.sentDatetime = extract_time(entry_element, @sent_datetime_xpath)
  communication_performed.receivedDatetime = extract_time(entry_element, @received_datetime_xpath)
  entity1 = extract_entity(entry_element, "./cda:participant[@typeCode='AUT']")
  communication_performed.sender.concat(entity1) if entity1
  entity2 = extract_entity(entry_element, "./cda:participant[@typeCode='IRCP']")
  communication_performed.recipient.concat(entity2) if entity2
  communication_performed.relatedTo = extract_related_to(entry_element)
  communication_performed
end