lib/hqmf-parser/parser.rb in health-data-standards-3.7.0 vs lib/hqmf-parser/parser.rb in health-data-standards-4.0.0
- old
+ new
@@ -2,20 +2,21 @@
class Parser
HQMF_VERSION_1 = "1.0"
HQMF_VERSION_2 = "2.0"
+ # HQMF v2 Parser for measures that use QDM for measure logic
class V2Parser
def initialize
end
def parse(xml_contents, codes=nil)
HQMF::Counter.instance.reset()
HQMF2::Document.new(xml_contents).to_model
end
- def parse_fileds(xml_contents)
+ 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
@@ -37,9 +38,31 @@
!doc.at_xpath("/cda:QualityMeasureDocument/cda:typeId[@root='2.16.840.1.113883.1.3' and @extension='POQM_HD000001UV02']").nil?
end
end
+ # HQMF v2 Parser for measures that use CQL for measure logic
+ class V2CQLParser < V2Parser
+
+ def parse(xml_contents, codes=nil)
+ HQMF::Counter.instance.reset()
+ HQMF2CQL::Document.new(xml_contents).to_model
+ end
+
+ def self.valid?(xml_contents)
+ doc = HQMF2::Document.parse(xml_contents)
+ hqmf2 = !doc.at_xpath("/cda:QualityMeasureDocument/cda:typeId[@root='2.16.840.1.113883.1.3' and @extension='POQM_HD000001UV02']").nil?
+ cql = !doc.at_xpath("/cda:QualityMeasureDocument/cda:relatedDocument/cda:expressionDocument/cda:text[@mediaType='application/cql']").nil?
+ if !cql
+ # The media type changed for MAT version 5.3
+ cql = !doc.at_xpath("/cda:QualityMeasureDocument/cda:relatedDocument/cda:expressionDocument/cda:text[@mediaType='text/cql']").nil?
+ end
+ hqmf2 && cql
+ end
+
+ end
+
+ # HQMF v1 Parser for measures that use QDM for measure logic
class V1Parser
def parse(xml_contents, codes=nil)
HQMF::Counter.instance.reset()
HQMF::DocumentConverter.convert(HQMF1::Document.new(xml_contents).to_json, codes)