class HQMF2::Value

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

Attributes

type[R]
unit[R]
value[R]

Public Class Methods

new(entry, default_type = 'PQ', force_inclusive = false, _parent = nil) click to toggle source
# File lib/hqmf-parser/2.0/types.rb, line 24
def initialize(entry, default_type = 'PQ', force_inclusive = false, _parent = nil)
  @entry = entry
  @type = attr_val('./@xsi:type') || default_type
  @unit = attr_val('./@unit')
  @value = attr_val('./@value')
  @force_inclusive = force_inclusive

  # FIXME: Remove below when lengthOfStayQuantity unit is fixed
  @unit = 'd' if @unit == 'days'
end

Public Instance Methods

derived?() click to toggle source
# File lib/hqmf-parser/2.0/types.rb, line 88
def derived?
  case attr_val('./@nullFlavor')
  when 'DER'
    true
  else
    false
  end
end
expression() click to toggle source
# File lib/hqmf-parser/2.0/types.rb, line 97
def expression
  if !derived?
    nil
  else
    attr_val('./cda:expression/@value')
  end
end
inclusive?() click to toggle source
# File lib/hqmf-parser/2.0/types.rb, line 35
def inclusive?
  # If the high and low value are at any time the same, then it must be an inclusive value.
  equivalent = attr_val('../cda:low/@value') == attr_val('../cda:high/@value')

  # If and inclusivity value is set for any specific value, then mark the value as inclusive.
  # IDEA: This could be limited in future iterations by including the parent type (temporal reference, subset code,
  # etc.)
  inclusive_temporal_ref? || inclusive_length_of_stay? || inclusive_basic_values? || inclusive_subsets? ||
    equivalent || @force_inclusive
end
inclusive_basic_values?() click to toggle source

Check is the basic values should be marked as inclusive, currently only checks for greater than case

# File lib/hqmf-parser/2.0/types.rb, line 71
def inclusive_basic_values?
  # Basic values - EP65, EP9, and more
  attr_val('../cda:high/@nullFlavor') == 'PINF' &&
    attr_val('../cda:low/@value') &&
    attr_val('../@lowClosed') != 'false' &&
    attr_val('../@xsi:type') == 'IVL_PQ'
end
inclusive_length_of_stay?() click to toggle source

Check whether the length of stay should be inclusive.

# File lib/hqmf-parser/2.0/types.rb, line 59
def inclusive_length_of_stay?
  # lengthOfStay - EH111, EH108
  less_than_equal_los = attr_val('../cda:low/@nullFlavor') == 'NINF' &&
                        attr_val('../@highClosed') != 'false'

  greater_than_equal_los = attr_val('../cda:high/@nullFlavor') == 'PINF' &&
                           attr_val('../@lowClosed') != 'false'
  # Both less and greater require that the type is PQ
  (less_than_equal_los || greater_than_equal_los) && attr_val('@xsi:type') == 'PQ'
end
inclusive_subsets?() click to toggle source

Check if subset values should be marked as inclusive. Currently only handles greater than

# File lib/hqmf-parser/2.0/types.rb, line 80
def inclusive_subsets?
  # subset - EP128, EH108
  attr_val('../cda:low/@value') != '0' &&
    !attr_val('../cda:high/@value') &&
    attr_val('../@lowClosed') != 'false' &&
    !attr_val('../../../../../qdm:subsetCode/@code').nil?
end
inclusive_temporal_ref?() click to toggle source

Check whether the temporal reference should be marked as inclusive

# File lib/hqmf-parser/2.0/types.rb, line 47
def inclusive_temporal_ref?
  # FIXME: NINF is used instead of 0 sometimes...? (not in the IG)
  # FIXME: Given nullFlavor, but IG uses it and nullValue everywhere...
  less_than_equal_tr = attr_val('../@highClosed') == 'true' &&
                       (attr_val('../cda:low/@value') == '0' || attr_val('../cda:low/@nullFlavor') == 'NINF')
  greater_than_equal_tr = attr_val('../cda:high/@nullFlavor') == 'PINF' &&
                          attr_val('../cda:low/@value')
  # Both less and greater require lowClosed to be set to true
  (less_than_equal_tr || greater_than_equal_tr) && attr_val('../@lowClosed') == 'true'
end
to_model() click to toggle source

Generates this classes hqmf-model equivalent

# File lib/hqmf-parser/2.0/types.rb, line 106
def to_model
  HQMF::Value.new(type, unit, value, inclusive?, derived?, expression)
end