Sha256: d0b39334c57a7c57045eda2588f3923ffc7673c1fb7e7a3fe07b91ff889adcc3
Contents?: true
Size: 1.92 KB
Versions: 12
Compression:
Stored size: 1.92 KB
Contents
module HealthDataStandards module SVS class ValueSet include Mongoid::Document field :oid, type: String field :display_name, type: String field :version, type: String index({oid: 1}) index({display_name: 1}) embeds_many :concepts index "concepts.code" => 1 index "concepts.code_system" => 1 index "concepts.code_system_name" => 1 index "concepts.display_name" => 1 index "bundle_id" => 1 scope :by_oid, ->(oid){where(:oid => oid)} # 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 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 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| code_system_name = HealthDataStandards::Util::CodeSystemHelper::CODE_SYSTEMS[con["codeSystem"]] || con["codeSystemName"] Concept.new(code: con["code"], code_system_name: code_system_name, code_system_version: con["code_system_version"], display_name: con["displayName"], code_system: con["codeSystem"]) end vs.concepts = concepts return vs end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems