Class: HealthDataStandards::SVS::ValueSet
- Inherits:
-
Object
- Object
- HealthDataStandards::SVS::ValueSet
- Includes:
- Mongoid::Document
- Defined in:
- lib/health-data-standards/models/svs/value_set.rb
Class Method Summary collapse
- .denormalize_code_set_name(code_set_name) ⇒ Object
- .load_from_xml(doc) ⇒ Object
- .normalize_code_set_name(code_set_name) ⇒ Object
Instance Method Summary collapse
-
#code_set_map ⇒ Object
Provides an Array of Hashes.
Class Method Details
.denormalize_code_set_name(code_set_name) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 72 def self.denormalize_code_set_name(code_set_name) case code_set_name when'RxNorm' 'RXNORM' when'ICD-9-CM' 'ICD9CM' when'ICD-10-CM' 'ICD10CM' when'ICD-10-PCS' 'ICD10PCS' when'SNOMED-CT' 'SNOMEDCT' when'CDC Race' 'CDCREC' when'HL7 Healthcare Service Location' 'HSLOC' else code_set_name end end |
.load_from_xml(doc) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 36 def self.load_from_xml(doc) doc.root.add_namespace_definition("vs","urn:ihe:iti:svs:2008") vs_element = doc.at_xpath("/vs:RetrieveValueSetResponse/vs:ValueSet") if vs_element vs = ValueSet.new(oid: vs_element["ID"], display_name: vs_element["displayName"], version: vs_element["version"]) concepts = vs_element.xpath("//vs:Concept").collect do |con| Concept.new(code: con["code"], code_system_name: normalize_code_set_name(con["codeSystemName"]), code_system_version: con["code_system_version"], display_name: con["displayName"], code_system: con["codeSystem"]) end vs.concepts = concepts return vs end end |
.normalize_code_set_name(code_set_name) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 52 def self.normalize_code_set_name(code_set_name) case code_set_name when 'RXNORM' 'RxNorm' when 'ICD9CM' 'ICD-9-CM' when 'ICD10CM' 'ICD-10-CM' when 'ICD10PCS' 'ICD-10-PCS' when 'SNOMEDCT' 'SNOMED-CT' when 'CDCREC' 'CDC Race' when 'HSLOC' 'HL7 Healthcare Service Location' else code_set_name end end |
Instance Method Details
#code_set_map ⇒ Object
Provides an Array of Hashes. Each code system gets its own Hash The hash has a key of “set” for the code system name and “values” for the actual code list
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 23 def code_set_map codes = [] self.concepts.inject({}) do |memo, concept| memo[concept.code_system_name] ||= [] memo[concept.code_system_name] << concept.code memo end.each_pair do |code_set, code_list| codes << {"set" => code_set, "values" => code_list} end codes end |