Class: HQMF2::Value

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/hqmf-parser/2.0/types.rb

Overview

Represents a bound within a HQMF pauseQuantity, has a value, a unit and an inclusive/exclusive indicator

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, attr_val, #to_xml

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(entry, default_type = 'PQ', force_inclusive = false) ⇒ Value

Returns a new instance of Value.



23
24
25
26
27
28
29
# File 'lib/hqmf-parser/2.0/types.rb', line 23

def initialize(entry, default_type='PQ', force_inclusive=false)
  @entry = entry
  @type = attr_val('./@xsi:type') || default_type
  @unit = attr_val('./@unit')
  @value = attr_val('./@value')
  @force_inclusive = force_inclusive
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



21
22
23
# File 'lib/hqmf-parser/2.0/types.rb', line 21

def type
  @type
end

#unitObject (readonly)

Returns the value of attribute unit.



21
22
23
# File 'lib/hqmf-parser/2.0/types.rb', line 21

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



21
22
23
# File 'lib/hqmf-parser/2.0/types.rb', line 21

def value
  @value
end

Instance Method Details

#derived?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
# File 'lib/hqmf-parser/2.0/types.rb', line 35

def derived?
  case attr_val('./@nullFlavor')
  when 'DER'
    true
  else
    false
  end
end

#expressionObject



44
45
46
47
48
49
50
# File 'lib/hqmf-parser/2.0/types.rb', line 44

def expression
  if !derived?
    nil
  else
    attr_val('./cda:expression/@value')
  end
end

#inclusive?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/hqmf-parser/2.0/types.rb', line 31

def inclusive?
  attr_val("../@#{@entry.name}Closed") == 'true' || @force_inclusive
end

#to_modelObject



52
53
54
# File 'lib/hqmf-parser/2.0/types.rb', line 52

def to_model
  HQMF::Value.new(type,unit,value,inclusive?,derived?,expression)
end