Class: SimpleXml::Value
- Inherits:
-
Object
- Object
- SimpleXml::Value
- Includes:
- Utilities
- Defined in:
- lib/model/types.rb
Overview
Represents a bound within a HQMF pauseQuantity, has a value, a unit and an inclusive/exclusive indicator
Constant Summary collapse
- TIME_UNIT_TRANSLATION =
{ years: 'a', months: 'mo', weeks: 'wk', days: 'd', hours: 'h', minutes: 'min', seconds: 's'}
- OTHER_UNIT_TRANSLATION =
{ 'mmHg' => 'mm[Hg]', 'per mm3' => '/mm3', 'copies/mL' => '[copies]/mL', 'bpm' => '{H.B}/min'}
Constants included from Utilities
Utilities::MEASURE_ATTRIBUTES_MAP
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #derived? ⇒ Boolean
- #expression ⇒ Object
- #inclusive? ⇒ Boolean
-
#initialize(quantity, unit, inclusive, type = 'PQ') ⇒ Value
constructor
A new instance of Value.
- #to_model ⇒ Object
- #translate_unit(unit) ⇒ Object
Methods included from Utilities
#attr_val, attr_val, build_value, #children_of, #comments_on, #create_age_timing, #create_birthdate_criteria
Constructor Details
#initialize(quantity, unit, inclusive, type = 'PQ') ⇒ Value
Returns a new instance of Value.
26 27 28 29 30 31 |
# File 'lib/model/types.rb', line 26 def initialize(quantity, unit, inclusive, type='PQ') @type = type @value = quantity @inclusive = inclusive @unit = translate_unit(unit) end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
24 25 26 |
# File 'lib/model/types.rb', line 24 def type @type end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
24 25 26 |
# File 'lib/model/types.rb', line 24 def unit @unit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
24 25 26 |
# File 'lib/model/types.rb', line 24 def value @value end |
Instance Method Details
#derived? ⇒ Boolean
33 34 35 |
# File 'lib/model/types.rb', line 33 def derived? false end |
#expression ⇒ Object
41 42 43 |
# File 'lib/model/types.rb', line 41 def expression nil end |
#inclusive? ⇒ Boolean
37 38 39 |
# File 'lib/model/types.rb', line 37 def inclusive? @inclusive end |
#to_model ⇒ Object
45 46 47 |
# File 'lib/model/types.rb', line 45 def to_model HQMF::Value.new(type,unit,value,inclusive?,derived?,expression) end |
#translate_unit(unit) ⇒ Object
49 50 51 52 53 |
# File 'lib/model/types.rb', line 49 def translate_unit(unit) unit = (TIME_UNIT_TRANSLATION[unit.downcase.to_sym] || unit) if unit unit = (OTHER_UNIT_TRANSLATION[unit] || unit) if unit unit end |