Class: HealthDataStandards::Util::HQMFTemplateHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/health-data-standards/util/hqmf_template_helper.rb

Overview

General helpers for working with codes and code systems

Class Method Summary collapse

Class Method Details

.definition_for_template_id(template_id, version = "r1") ⇒ Object



6
7
8
# File 'lib/health-data-standards/util/hqmf_template_helper.rb', line 6

def self.definition_for_template_id(template_id, version="r1")
  template_id_map(version)[template_id]
end

.template_id_by_definition_and_status(definition, status, negation = false, version = "r1") ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/health-data-standards/util/hqmf_template_helper.rb', line 21

def self.template_id_by_definition_and_status(definition, status, negation=false, version="r1")
  case version
  when "r1"
    kv_pair = template_id_map(version).find {|k, v| v['definition'] == definition &&
                                           v['status'] == status &&
                                           v['negation'] == negation}
  when "r2", "r2cql"
    kv_pair = template_id_map(version).find {|k, v| v['definition'] == definition &&
                                           v['status'] == status}
  end
  if kv_pair
    kv_pair.first
  else
    nil
  end
end

.template_id_map(version) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/health-data-standards/util/hqmf_template_helper.rb', line 10

def self.template_id_map(version)
  if @id_map.blank?
    @id_map = {
      'r1' => JSON.parse(File.read(File.expand_path('../hqmf_template_oid_map.json', __FILE__))),
      'r2' => JSON.parse(File.read(File.expand_path('../hqmfr2_template_oid_map.json', __FILE__))),
      'r2cql' => JSON.parse(File.read(File.expand_path('../hqmfr2cql_template_oid_map.json', __FILE__)))
    }
  end
  @id_map[version]
end