Class: HealthDataStandards::Import::CDA::NarrativeReferenceHandler

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

Instance Method Summary collapse

Constructor Details

#initializeNarrativeReferenceHandler

Returns a new instance of NarrativeReferenceHandler.



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

def initialize
  @id_map = {}
end

Instance Method Details

#build_id_map(doc) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/health-data-standards/import/cda/narrative_reference_handler.rb', line 9

def build_id_map(doc)
  path = "//*[@ID]"
  ids = doc.xpath(path)
  ids.each do |id|
    tag = id['ID']
    value = id.content
    @id_map[tag] = value
  end
end

#lookup_tag(tag) ⇒ String

Returns text description of tag.

Parameters:

Returns:

  • (String)

    text description of tag



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/health-data-standards/import/cda/narrative_reference_handler.rb', line 21

def lookup_tag(tag)
  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