Class: HealthDataStandards::Import::CDA::AllergyImporter

Inherits:
SectionImporter show all
Defined in:
lib/health-data-standards/import/cda/allergy_importer.rb

Instance Attribute Summary

Attributes inherited from SectionImporter

#check_for_usable, #code_xpath, #status_xpath

Instance Method Summary collapse

Methods inherited from SectionImporter

#create_entries

Methods included from LocatableImportUtils

#import_address, #import_telecom

Constructor Details

#initialize(entry_finder = EntryFinder.new("//cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.1.18']")) ⇒ AllergyImporter

Returns a new instance of AllergyImporter.



6
7
8
9
10
11
12
13
14
15
# File 'lib/health-data-standards/import/cda/allergy_importer.rb', line 6

def initialize(entry_finder=EntryFinder.new("//cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.1.18']"))
  @entry_finder = entry_finder
  @code_xpath = "./cda:participant/cda:participantRole/cda:playingEntity/cda:code"
  @description_xpath = "./cda:code/cda:originalText/cda:reference[@value] | ./cda:text/cda:reference[@value]"
  @type_xpath = "./cda:code"
  @reaction_xpath = "./cda:entryRelationship[@typeCode='MFST']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.1.54']/cda:value"
  @severity_xpath = "./cda:entryRelationship[@typeCode='SUBJ']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.1.55']/cda:value"
  @status_xpath   = "./cda:entryRelationship[@typeCode='REFR']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.1.39']/cda:value"
  @entry_class = Allergy
end

Instance Method Details

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



17
18
19
20
21
22
23
24
25
# File 'lib/health-data-standards/import/cda/allergy_importer.rb', line 17

def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
  allergy = super
  extract_reason_or_negation(entry_element, allergy)
  allergy.type = extract_code(entry_element, @type_xpath)
  allergy.reaction = extract_code(entry_element, @reaction_xpath)
  allergy.severity = extract_code(entry_element, @severity_xpath)

  allergy
end