Class: HealthDataStandards::Import::C32::SectionImporter
- Inherits:
-
Object
- Object
- HealthDataStandards::Import::C32::SectionImporter
- Includes:
- Util
- Defined in:
- lib/health-data-standards/import/c32/section_importer.rb
Overview
Class that can be used to create an importer for a section of a HITSP C32 document. It usually operates by selecting all CDA entries in a section and then creates entries for them.
Direct Known Subclasses
AllergyImporter, CareGoalImporter, ConditionImporter, EncounterImporter, ImmunizationImporter, InsuranceProviderImporter, MedicalEquipmentImporter, MedicationImporter, OrganizationImporter, ProcedureImporter, ProviderImporter, ResultImporter
Instance Attribute Summary collapse
-
#check_for_usable ⇒ Object
Returns the value of attribute check_for_usable.
Instance Method Summary collapse
-
#create_entries(doc, id_map = {}) ⇒ Array
Traverses that HITSP C32 document passed in using XPath and creates an Array of Entry objects based on what it finds.
- #create_entry(entry_element, id_map = {}) ⇒ Object
-
#initialize(entry_xpath, code_xpath = "./cda:code", status_xpath = nil, priority_xpath = nil, description_xpath = "./cda:code/cda:originalText/cda:reference[@value] | ./cda:text/cda:reference[@value] ") ⇒ SectionImporter
constructor
Creates a new SectionImporter.
-
#lookup_tag(tag, id_map) ⇒ String
Text description of tag.
Constructor Details
#initialize(entry_xpath, code_xpath = "./cda:code", status_xpath = nil, priority_xpath = nil, description_xpath = "./cda:code/cda:originalText/cda:reference[@value] | ./cda:text/cda:reference[@value] ") ⇒ SectionImporter
Creates a new SectionImporter
18 19 20 21 22 23 24 25 |
# File 'lib/health-data-standards/import/c32/section_importer.rb', line 18 def initialize(entry_xpath, code_xpath="./cda:code", status_xpath=nil,priority_xpath=nil, description_xpath="./cda:code/cda:originalText/cda:reference[@value] | ./cda:text/cda:reference[@value] ") @entry_xpath = entry_xpath @code_xpath = code_xpath @status_xpath = status_xpath @priority_xpath = priority_xpath @description_xpath = description_xpath @check_for_usable = true # Pilot tools will set this to false end |
Instance Attribute Details
#check_for_usable ⇒ Object
Returns the value of attribute check_for_usable.
9 10 11 |
# File 'lib/health-data-standards/import/c32/section_importer.rb', line 9 def check_for_usable @check_for_usable end |
Instance Method Details
#create_entries(doc, id_map = {}) ⇒ Array
Traverses that HITSP C32 document passed in using XPath and creates an Array of Entry objects based on what it finds
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/health-data-standards/import/c32/section_importer.rb', line 48 def create_entries(doc,id_map = {}) entry_list = [] entry_elements = doc.xpath(@entry_xpath) entry_elements.each do |entry_element| entry = create_entry(entry_element, id_map) if @check_for_usable entry_list << entry if entry.usable? else entry_list << entry end end entry_list end |
#create_entry(entry_element, id_map = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/health-data-standards/import/c32/section_importer.rb', line 62 def create_entry(entry_element, id_map={}) entry = Entry.new extract_codes(entry_element, entry) extract_dates(entry_element, entry) extract_value(entry_element, entry) if @status_xpath extract_status(entry_element, entry) end if @description_xpath extract_description(entry_element, entry, id_map) end entry end |
#lookup_tag(tag, id_map) ⇒ String
Returns text description of tag.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/health-data-standards/import/c32/section_importer.rb', line 30 def lookup_tag(tag, id_map) value = id_map[tag] # Not sure why, but sometimes the reference is #<Reference> and the ID value is <Reference>, and # sometimes it is #<Reference>. We look for both. if !value and tag[0] == '#' tag = tag[1,tag.length] value = id_map[tag] end value end |