Class: HQMF2::Value
- Inherits:
-
Object
- Object
- HQMF2::Value
- 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
-
#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
-
#inclusive_basic_values? ⇒ Boolean
Check is the basic values should be marked as inclusive, currently only checks for greater than case.
-
#inclusive_length_of_stay? ⇒ Boolean
Check whether the length of stay should be inclusive.
-
#inclusive_subsets? ⇒ Boolean
Check if subset values should be marked as inclusive.
-
#inclusive_temporal_ref? ⇒ Boolean
Check whether the temporal reference should be marked as inclusive.
-
#initialize(entry, default_type = 'PQ', force_inclusive = false, _parent = nil) ⇒ Value
constructor
A new instance of Value.
-
#to_model ⇒ Object
Generates this classes hqmf-model equivalent.
Methods included from Utilities
#attr_val, attr_val, #strip_tokens, #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, _parent = nil) ⇒ Value
Returns a new instance of Value.
24 25 26 27 28 29 30 31 32 33 |
# 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 |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/hqmf-parser/2.0/types.rb', line 22 def type @type end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
22 23 24 |
# File 'lib/hqmf-parser/2.0/types.rb', line 22 def unit @unit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
22 23 24 |
# File 'lib/hqmf-parser/2.0/types.rb', line 22 def value @value end |
Instance Method Details
#derived? ⇒ Boolean
88 89 90 91 92 93 94 95 |
# File 'lib/hqmf-parser/2.0/types.rb', line 88 def derived? case attr_val('./@nullFlavor') when 'DER' true else false end end |
#expression ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/hqmf-parser/2.0/types.rb', line 97 def expression if !derived? nil else attr_val('./cda:expression/@value') end end |
#inclusive? ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 |
# 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? ⇒ Boolean
Check is the basic values should be marked as inclusive, currently only checks for greater than case
71 72 73 74 75 76 77 |
# 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? ⇒ Boolean
Check whether the length of stay should be inclusive.
59 60 61 62 63 64 65 66 67 68 |
# 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? ⇒ Boolean
Check if subset values should be marked as inclusive. Currently only handles greater than
80 81 82 83 84 85 86 |
# 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? ⇒ Boolean
Check whether the temporal reference should be marked as inclusive
47 48 49 50 51 52 53 54 55 56 |
# 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 |