Class: HQMF::Parser::V2Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/hqmf-parser/parser.rb

Overview

HQMF v2 Parser for measures that use QDM for measure logic

Direct Known Subclasses

V2CQLParser

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeV2Parser

Returns a new instance of V2Parser.



9
10
# File 'lib/hqmf-parser/parser.rb', line 9

def initialize
end

Class Method Details

.valid?(xml_contents) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/hqmf-parser/parser.rb', line 36

def self.valid?(xml_contents)
   doc = HQMF2::Document.parse(xml_contents)
  !doc.at_xpath("/cda:QualityMeasureDocument/cda:typeId[@root='2.16.840.1.113883.1.3' and @extension='POQM_HD000001UV02']").nil?
end

Instance Method Details

#parse(xml_contents, codes = nil) ⇒ Object



12
13
14
15
# File 'lib/hqmf-parser/parser.rb', line 12

def parse(xml_contents, codes=nil)
  HQMF::Counter.instance.reset()
  HQMF2::Document.new(xml_contents).to_model
end

#parse_fields(xml_contents) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hqmf-parser/parser.rb', line 17

def parse_fields(xml_contents)
  result = {}
  doc = HQMF2::Document.parse(xml_contents)
  type = doc.at_xpath('/cda:QualityMeasureDocument/cda:code/@code').value
  if type == '57024-2'
    id = doc.at_xpath('cda:QualityMeasureDocument/cda:id/@extension', HQMF2::Document::NAMESPACES).value.upcase
    set_id = doc.at_xpath('cda:QualityMeasureDocument/cda:setId/@extension').value.upcase
    version_number = doc.at_xpath('cda:QualityMeasureDocument/cda:versionNumber/@value').value.to_i
    title = doc.at_xpath('cda:QualityMeasureDocument/cda:title/@value').inner_text
    description = doc.at_xpath('cda:QualityMeasureDocument/cda:text/@value').inner_text
    result=  {'id' => id, 'set_id' => set_id, 'version' => version_number, 'title' => title, 'description' => description}
  end
  result
end

#versionObject



32
33
34
# File 'lib/hqmf-parser/parser.rb', line 32

def version
  HQMF_VERSION_2
end