Class: HQMF::Util::HQMFTemplateHelper
- Inherits:
-
Object
- Object
- HQMF::Util::HQMFTemplateHelper
- Defined in:
- lib/util/hqmf_template_helper.rb
Overview
General helpers for working with codes and code systems
Class Method Summary collapse
- .definition_for_template_id(template_id, version = "r1") ⇒ Object
-
.get_all_hqmf_oids(definition, status) ⇒ Object
Returns a list of all hqmf_oids (regardless of version) for the combination of definition and status.
- .template_id_by_definition_and_status(definition, status, negation, version) ⇒ Object
- .template_id_map(version) ⇒ Object
Class Method Details
.definition_for_template_id(template_id, version = "r1") ⇒ Object
6 7 8 |
# File 'lib/util/hqmf_template_helper.rb', line 6 def self.definition_for_template_id(template_id, version = "r1") template_id_map(version)[template_id] end |
.get_all_hqmf_oids(definition, status) ⇒ Object
Returns a list of all hqmf_oids (regardless of version) for the combination of definition and status
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/util/hqmf_template_helper.rb', line 39 def self.get_all_hqmf_oids(definition, status) status ||= "" version_negation_combinations = [{ version: 'r1', negation: false }, { version: 'r1', negation: true }, { version: 'r2', negation: false }, { version: 'r2cql', negation: false }] hqmf_oids = version_negation_combinations.collect do |obj| template_id_by_definition_and_status(definition, status, obj[:negation], obj[:version]) end hqmf_oids end |
.template_id_by_definition_and_status(definition, status, negation, version) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/util/hqmf_template_helper.rb', line 21 def self.template_id_by_definition_and_status(definition, status, negation, version) 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/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.('../hqmf_template_oid_map.json', __FILE__))), 'r2' => JSON.parse(File.read(File.('../hqmfr2_template_oid_map.json', __FILE__))), 'r2cql' => JSON.parse(File.read(File.('../hqmfr2cql_template_oid_map.json', __FILE__))) } end @id_map[version] end |