Class: HealthDataStandards::Import::CDA::SectionImporter

Inherits:
Object
  • Object
show all
Includes:
LocatableImportUtils, Util
Defined in:
lib/health-data-standards/import/cda/section_importer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LocatableImportUtils

#import_address, #import_telecom

Constructor Details

#initialize(entry_finder) ⇒ SectionImporter

Returns a new instance of SectionImporter.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/health-data-standards/import/cda/section_importer.rb', line 10

def initialize(entry_finder)
  @entry_finder = entry_finder
  @code_xpath = "./cda:code"
  @id_xpath = "./cda:id"
  @status_xpath = nil
  @priority_xpath = nil
  @description_xpath = "./cda:code/cda:originalText/cda:reference[@value] | ./cda:text/cda:reference[@value]"
  @check_for_usable = true
  @entry_class = Entry
  @value_xpath = 'cda:value'
end

Instance Attribute Details

#check_for_usableObject

Returns the value of attribute check_for_usable.



5
6
7
# File 'lib/health-data-standards/import/cda/section_importer.rb', line 5

def check_for_usable
  @check_for_usable
end

#code_xpathObject

Returns the value of attribute code_xpath.



5
6
7
# File 'lib/health-data-standards/import/cda/section_importer.rb', line 5

def code_xpath
  @code_xpath
end

#status_xpathObject

Returns the value of attribute status_xpath.



5
6
7
# File 'lib/health-data-standards/import/cda/section_importer.rb', line 5

def status_xpath
  @status_xpath
end

Instance Method Details

#create_entries(doc, nrh = NarrativeReferenceHandler.new) ⇒ Array

Traverses an HL7 CDA document passed in and creates an Array of Entry objects based on what it finds

Parameters:

  • doc (Nokogiri::XML::Document)

    It is expected that the root node of this document will have the “cda” namespace registered to “urn:hl7-org:v3” measure definition

Returns:

  • (Array)

    will be a list of Entry objects



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/health-data-standards/import/cda/section_importer.rb', line 28

def create_entries(doc, nrh = NarrativeReferenceHandler.new)
  entry_list = []
  entry_elements = @entry_finder.entries(doc)
  entry_elements.each do |entry_element|
    entry = create_entry(entry_element, nrh)
    if @check_for_usable
      entry_list << entry if entry.usable?
    else
      entry_list << entry
    end
  end
  entry_list
end

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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/health-data-standards/import/cda/section_importer.rb', line 42

def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
  entry = @entry_class.new
  extract_id(entry_element, entry)
  extract_codes(entry_element, entry)
  extract_dates(entry_element, entry)
  if @value_xpath
    extract_values(entry_element, entry)
  end
  extract_description(entry_element, entry, nrh)
  if @status_xpath
    extract_status(entry_element, entry)
  end
  entry
end