lib/hqmf-parser/1.0/range.rb in health-data-standards-3.0.6 vs lib/hqmf-parser/1.0/range.rb in health-data-standards-3.1.0
- old
+ new
@@ -2,12 +2,24 @@
# Represents a bound within a HQMF pauseQuantity, has a value, a unit and an
# inclusive/exclusive indicator
class Value
include HQMF1::Utilities
- def initialize(entry)
+ def initialize(entry, inclusive=nil)
@entry = entry
+
+ if (inclusive.nil?)
+ case attr_val('./@inclusive')
+ when 'true'
+ @inclusive = true
+ else
+ @inclusive = false
+ end
+ else
+ @inclusive = inclusive
+ end
+
end
def value
attr_val('./@value')
end
@@ -15,16 +27,11 @@
def unit
attr_val('./@unit')
end
def inclusive?
- case attr_val('./@inclusive')
- when 'true'
- true
- else
- false
- end
+ @inclusive
end
def to_json
build_hash(self, [:value,:unit,:inclusive?])
end
@@ -38,10 +45,15 @@
def initialize(entry)
@entry = entry
if @entry
@low = optional_value('./cda:low')
@high = optional_value('./cda:high')
+ if (@low == nil && @high == nil)
+ @low = optional_value('.',true)
+ @high = optional_value('.',true)
+ puts "\tfound = relationship parsing temporal reference (bugfix)"
+ end
end
end
def to_json
json = {}
@@ -50,13 +62,13 @@
json
end
private
- def optional_value(xpath)
+ def optional_value(xpath, inclusive=nil)
value_def = @entry.at_xpath(xpath)
if value_def
- Value.new(value_def)
+ Value.new(value_def, inclusive)
else
nil
end
end
\ No newline at end of file