class HealthDataStandards::Validate::QrdaQdmTemplateValidator

Constants

QRDA_CAT_1_R3_1_QDM_OIDS

Hash of templateIds/extensions specified in the Patient Data Section QDM for QRDA R3_1

QRDA_CAT_1_R3_QDM_OIDS

Hash of templateIds/extensions specified in the Patient Data Section QDM for QRDA R3

QRDA_CAT_1_R4_QDM_OIDS

Hash of templateIds/extensions specified in the Patient Data Section QDM for QRDA R4

QRDA_CAT_1_R5_QDM_OIDS

Hash of templateIds/extensions specified in the Patient Data Section QDM for QRDA R4

Public Class Methods

new(qrda_version) click to toggle source
# File lib/health-data-standards/validate/qrda_qdm_template_validator.rb, line 275
def initialize(qrda_version)
  @name = 'QRDA QDM Template Validator'
  @templateshash = case qrda_version
    when 'r3' then QRDA_CAT_1_R3_QDM_OIDS
    when 'r3_1' then QRDA_CAT_1_R3_1_QDM_OIDS
    when 'r4' then QRDA_CAT_1_R4_QDM_OIDS
    when 'r5' then QRDA_CAT_1_R5_QDM_OIDS
    end
end

Public Instance Methods

entry_value_for_qrda_version(entry, data={}) click to toggle source
# File lib/health-data-standards/validate/qrda_qdm_template_validator.rb, line 306
def entry_value_for_qrda_version(entry, data={})
  # an entry may have multiple templateIds
  tids = entry.xpath('./*/cda:templateId')
  # an entry only needs one valid templateId to be acceptable
  unless tids.map { |tid| @templateshash.has_key?(tid['root']) && @templateshash[tid['root']] == tid['extension'] }.include? true
    msg = "#{tids.map { |tid| "#{tid['root']}:#{tid['extension']}" }} are not valid Patient Data Section QDM entries for this QRDA Version"
    @errors << build_error(msg, entry.path, data[:file_name])
  end
end
extract_entries() click to toggle source

returns a list of the patient data entries

# File lib/health-data-standards/validate/qrda_qdm_template_validator.rb, line 317
def extract_entries
  @doc.xpath('//cda:component/cda:section[cda:templateId/@root="2.16.840.1.113883.10.20.24.2.1"]/cda:entry')
end
validate(file, data={}) click to toggle source

Validates that a QRDA Cat I file's Patient Data Section QDM (V3) contains entries that conform to the QDM approach to QRDA. In contrast to a QRDA Framework Patient Data Section that requires but does not specify the structured entries, the Patient Data Section QDM contained entry templates have specific requirements to align the quality measure data element type with its corresponding NQF QDM HQMF pattern, its referenced value set and potential QDM attributes. The result will be an Array of execution errors indicating use of templates that are not valid for the specified QRDA version

# File lib/health-data-standards/validate/qrda_qdm_template_validator.rb, line 292
def validate(file, data={})
  @errors = []
  # if validator does not support the qrda version specified, no checks are made
  unless @templateshash.nil?
    @doc = get_document(file)
    @doc.root.add_namespace_definition('cda', 'urn:hl7-org:v3')
    extract_entries.each do |entry|
      # each entry is evaluated separetly.
      entry_value_for_qrda_version(entry, data)
    end
  end
  @errors
end