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
- .extract_categories(vs_element) ⇒ Object
- .extract_concepts(vs_element) ⇒ Object
- .load_from_xml(doc) ⇒ Object
Instance Method Summary collapse
-
#code_set_map ⇒ Object
Provides an Array of Hashes.
Class Method Details
.extract_categories(vs_element) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 59 def self.extract_categories(vs_element) category_hash = Hash.new {|h,k| h[k]=[]} groups_with_categories = vs_element.xpath("//vs:Group/@ID[../@displayName='CATEGORY']") groups_with_categories.each do |group_number| measure = vs_element.xpath("//vs:Group[@displayName='CMS eMeasure ID' and @ID='#{group_number}']/vs:Keyword").text categories_for_group = vs_element.xpath("//vs:Group[@displayName='CATEGORY' and @ID='#{group_number}']/vs:Keyword") categories_for_group.each do |category| category_hash[measure] << category.text end end category_hash.size > 0 ? category_hash : nil end |
.extract_concepts(vs_element) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 49 def self.extract_concepts(vs_element) 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["codeSystemVersion"], display_name: con["displayName"], code_system: con["codeSystem"]) end end |
.load_from_xml(doc) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 38 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|/vs:RetrieveMultipleValueSetsResponse/vs:DescribedValueSet") if vs_element vs = ValueSet.new(oid: vs_element["ID"], display_name: vs_element["displayName"], version: vs_element["version"]) vs.concepts = extract_concepts(vs_element) vs.categories = extract_categories(vs_element) return vs 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
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/health-data-standards/models/svs/value_set.rb', line 25 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 |