Class: SimpleXml::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/model/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, code_list_id, title) ⇒ Attribute

Returns a new instance of Attribute.



229
230
231
232
233
# File 'lib/model/types.rb', line 229

def initialize(id, code_list_id, title)
  @id = id
  @code_list_id = code_list_id
  @title = title
end

Instance Attribute Details

#code_list_idObject (readonly)

Returns the value of attribute code_list_id.



227
228
229
# File 'lib/model/types.rb', line 227

def code_list_id
  @code_list_id
end

#idObject (readonly)

Returns the value of attribute id.



227
228
229
# File 'lib/model/types.rb', line 227

def id
  @id
end

#titleObject (readonly)

Returns the value of attribute title.



227
228
229
# File 'lib/model/types.rb', line 227

def title
  @title
end

Class Method Details

.translate_attribute(attribute, doc) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/model/types.rb', line 235

def self.translate_attribute(attribute, doc)
  mode = attribute.at_xpath('@mode').value
  case mode
  when 'Value Set'
    attribute_entry = doc.attribute_map[attribute.at_xpath('@qdmUUID').value]
    Coded.new(attribute_entry.code_list_id,attribute_entry.title)
  when 'Check if Present'
    AnyValue.new
  else
    if attribute.at_xpath('@attrDate')
      date = attribute.at_xpath('@attrDate').value
      unit = attribute.at_xpath('@unit').try(:value) # should this be the comparison granularity?
      Utilities.build_value(mode, date, unit, 'IVL_TS')
    else
      quantity = attribute.at_xpath('@comparisonValue').value
      unit = attribute.at_xpath('@unit').try(:value)
      Utilities.build_value(mode, quantity, unit)
    end
  end
end