Class: HealthDataStandards::Import::CDA::MedicationImporter

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

Overview

TODO: Coded Product Name, Free Text Product Name, Coded Brand Name and Free Text Brand name need to be pulled out separatelty

This would mean overriding extract_codes

TODO: Patient Instructions needs to be implemented. Will likely be a reference to the narrative section TODO: Couldn’t find an example medication reaction. Isn’t clear to me how it should be implemented from the specs, so

reaction is not implemented.

TODO: Couldn’t find an example dose indicator. Isn’t clear to me how it should be implemented from the specs, so

dose indicator is not implemented.

TODO: Fill Status is not implemented. Couldn’t figure out which entryRelationship it should be nested in

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:section[cda:templateId/@root='2.16.840.1.113883.3.88.11.83.112']/cda:entry/cda:substanceAdministration")) ⇒ MedicationImporter

Returns a new instance of MedicationImporter.



14
15
16
17
18
19
20
21
22
23
# File 'lib/health-data-standards/import/cda/medication_importer.rb', line 14

def initialize(entry_finder=EntryFinder.new("//cda:section[cda:templateId/@root='2.16.840.1.113883.3.88.11.83.112']/cda:entry/cda:substanceAdministration"))
  super(entry_finder)
  @code_xpath = "./cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code"
  @description_xpath = "./cda:consumable/cda:manufacturedProduct/cda:manufacturedMaterial/cda:code/cda:originalText/cda:reference[@value]"
  @type_of_med_xpath = "./cda:entryRelationship[@typeCode='SUBJ']/cda:observation[cda:templateId/@root='2.16.840.1.113883.3.88.11.83.8.1']/cda:code"
  @indication_xpath = "./cda:entryRelationship[@typeCode='RSON']/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.1.28']/cda:code"
  @vehicle_xpath = "cda:participant/cda:participantRole[cda:code/@code='412307009' and cda:code/@codeSystem='2.16.840.1.113883.6.96']/cda:playingEntity/cda:code"
  @fill_number_xpath = "./cda:entryRelationship[@typeCode='COMP']/cda:sequenceNumber/@value"
  @entry_class = Medication
end

Instance Method Details

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



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/health-data-standards/import/cda/medication_importer.rb', line 25

def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
  medication = super

  extract_administration_timing(entry_element, medication)

  medication.route = extract_code(entry_element, "./cda:routeCode")
  medication.dose = extract_scalar(entry_element, "./cda:doseQuantity")
  medication.anatomical_approach = extract_code(entry_element, "./cda:approachSiteCode", 'SNOMED-CT')
  
  extract_dose_restriction(entry_element, medication)

  medication.product_form = extract_code(entry_element, "./cda:administrationUnitCode", 'NCI Thesaurus')
  medication.delivery_method = extract_code(entry_element, "./cda:code", 'SNOMED-CT')
  medication.type_of_medication = extract_code(entry_element, @type_of_med_xpath, 'SNOMED-CT') if @type_of_med_xpath
  medication.indication = extract_code(entry_element, @indication_xpath, 'SNOMED-CT')
  medication.vehicle = extract_code(entry_element, @vehicle_xpath, 'SNOMED-CT')

  medication.allowed_administrations = extract_scalar(entry_element, "./cda:repeatNumber").value unless extract_scalar(entry_element, "./cda:repeatNumber").nil?

  extract_order_information(entry_element, medication)

  extract_fulfillment_history(entry_element, medication)
  extract_reason_or_negation(entry_element, medication)

  medication
end