Class: HQMF::Parser::V1Parser

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

Overview

HQMF v1 Parser for measures that use QDM for measure logic

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.valid?(xml_contents) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
94
# File 'lib/hqmf-parser/parser.rb', line 91

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

Instance Method Details

#parse(xml_contents, codes = nil) ⇒ Object



67
68
69
70
# File 'lib/hqmf-parser/parser.rb', line 67

def parse(xml_contents, codes=nil)
  HQMF::Counter.instance.reset()
  HQMF::DocumentConverter.convert(HQMF1::Document.new(xml_contents).to_json, codes)
end

#parse_fields(xml_contents) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/hqmf-parser/parser.rb', line 76

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

#versionObject



72
73
74
# File 'lib/hqmf-parser/parser.rb', line 72

def version
  HQMF_VERSION_1
end