Class: XDS::AffinityDomainConfig
- Inherits:
-
Object
- Object
- XDS::AffinityDomainConfig
- Defined in:
- lib/xds/affinity_domain_config.rb
Constant Summary collapse
- CODE_TYPE_NAME_TO_CODED_ATTRIBUTE =
{ 'classCode' => :class_code, 'confidentialityCode' => :confidentiality_code, 'formatCode' => :format_code, 'healthcareFacilityTypeCode' => :healthcare_facility_type_code, 'practiceSettingCode' => :practice_setting_code, 'typeCode' => :type_code }
Instance Method Summary collapse
- #coded_attribute(attribute_type, code) ⇒ Object
-
#initialize(config_file) ⇒ AffinityDomainConfig
constructor
A new instance of AffinityDomainConfig.
- #select_options(attribute_type) ⇒ Object
Constructor Details
#initialize(config_file) ⇒ AffinityDomainConfig
Returns a new instance of AffinityDomainConfig.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/xds/affinity_domain_config.rb', line 12 def initialize(config_file) config_doc = REXML::Document.new(File.new(config_file, 'r')) @code_types = {} config_doc.root.elements.each('CodeType') do |code_type| code_type_name = code_type.attributes['name'] if CODE_TYPE_NAME_TO_CODED_ATTRIBUTE[code_type_name] attribute_type = CODE_TYPE_NAME_TO_CODED_ATTRIBUTE[code_type_name] @code_types[attribute_type] = [] unless @code_types[attribute_type] code_type.elements.each('Code') do |code| code_value = code.attributes['code'] display_name = code.attributes['display'] coding_scheme = code.attributes['codingScheme'] @code_types[attribute_type] << CodedAttribute.new(attribute_type, code_value, display_name, coding_scheme) end end end end |
Instance Method Details
#coded_attribute(attribute_type, code) ⇒ Object
30 31 32 33 34 |
# File 'lib/xds/affinity_domain_config.rb', line 30 def coded_attribute(attribute_type, code) if @code_types[attribute_type] @code_types[attribute_type].find() {|ca| ca.code.eql?(code)} end end |
#select_options(attribute_type) ⇒ Object
36 37 38 39 40 |
# File 'lib/xds/affinity_domain_config.rb', line 36 def (attribute_type) if @code_types[attribute_type] @code_types[attribute_type].map {|ca| [ca.display_name, ca.code]} end end |