Class: HQMF::Coded
- Inherits:
-
Object
- Object
- HQMF::Coded
- Defined in:
- lib/tpg/ext/coded.rb
Class Method Summary collapse
-
.select_code(oid, value_sets) ⇒ Object
Select the relevant value set that matches the given OID and generate a hash that can be stored on a Record.
-
.select_codes(oid, value_sets) ⇒ Object
Select the relevant value set that matches the given OID and generate a hash that can be stored on a Record.
-
.select_value_sets(oid, value_sets) ⇒ Object
Filter through a list of value sets and choose only the ones marked with a given OID.
Class Method Details
.select_code(oid, value_sets) ⇒ Object
Select the relevant value set that matches the given OID and generate a hash that can be stored on a Record. The hash will be of this format: { “codeSystem” => “code_set_identified”, “code” => code }
36 37 38 39 40 41 42 43 44 |
# File 'lib/tpg/ext/coded.rb', line 36 def self.select_code(oid, value_sets) codes = select_codes(oid, value_sets) code_system = codes.keys()[0] return nil if code_system.nil? { 'code_system' => code_system, 'code' => codes[code_system][0] } end |
.select_codes(oid, value_sets) ⇒ Object
Select the relevant value set that matches the given OID and generate a hash that can be stored on a Record. The hash will be of this format: { “code_set_identified” => [code] }
9 10 11 12 13 14 15 16 |
# File 'lib/tpg/ext/coded.rb', line 9 def self.select_codes(oid, value_sets) value_sets = HQMF::Coded.select_value_sets(oid, value_sets) code_sets = {} value_sets["concepts"].each do |concept| code_sets[concept["code_system_name"]] ||= [concept["code"]] end code_sets end |
.select_value_sets(oid, value_sets) ⇒ Object
Filter through a list of value sets and choose only the ones marked with a given OID.
23 24 25 26 27 28 |
# File 'lib/tpg/ext/coded.rb', line 23 def self.select_value_sets(oid, value_sets) # Pick the value set for this DataCriteria. If it can't be found, it is an error from the value set source. We'll add the entry without codes for now. index = value_sets.index{|value_set| value_set["oid"] == oid} value_sets = index.nil? ? { "concepts" => [] } : value_sets[index] value_sets end |