Sha256: 0fe3c62c87d9d3b663482bf42b11f55bc4289e3b4c7c228fb817f16f7b0f0862

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

module HQMF
  class Parser
    
    HQMF_VERSION_1 = "1.0"
    HQMF_VERSION_2 = "2.0"
    
    def self.parse(hqmf_contents, version, codes = nil)
      
      HQMF::Counter.instance.reset()
      case version
        when HQMF_VERSION_1
          puts("\tCodes not passed in, cannot backfill properties like gender") unless codes
          HQMF::DocumentConverter.convert(HQMF1::Document.new(hqmf_contents).to_json, codes)
        when HQMF_VERSION_2
          HQMF2::Document.new(hqmf_contents).to_model
        else
          raise "Unsupported HQMF version specified: #{version}"
      end
    end
    
    def self.parse_id(hqmf_contents, version)
      case version
        when HQMF_VERSION_1
          doc = HQMF1::Document.parse(hqmf_contents)
          doc.at_xpath('//cda:id/@root').value.upcase
        when HQMF_VERSION_2
          doc = HQMF2::Document.parse(hqmf_contents)
          doc.at_xpath('cda:QualityMeasureDocument/cda:id/@extension', HQMF2::Document::NAMESPACES).value.upcase
        else
          raise "Unsupported HQMF version specified: #{version}"
      end
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hqmf-parser-1.1.0 lib/hqmf-parser/parser.rb