class HQMF2::SubsetOperator
Represents a subset of a specific group (the first in the group, the sum of the group, etc.)
Constants
- LAST_SUBSETS
- ORDER_SUBSETS
- QDM_TYPE_MAP
- TIME_SUBSETS
Attributes
type[R]
value[R]
Public Class Methods
new(entry)
click to toggle source
# File lib/hqmf-parser/2.0/types.rb, line 267 def initialize(entry) @entry = entry sequence_number = attr_val('./cda:sequenceNumber/@value') qdm_subset_code = attr_val('./qdm:subsetCode/@code') subset_code = attr_val('./cda:subsetCode/@code') if sequence_number @type = ORDER_SUBSETS[sequence_number.to_i - 1] else @type = translate_type(subset_code, qdm_subset_code) end value_def = handle_value_definition @value = HQMF2::Range.new(value_def, 'IVL_PQ') if value_def && !@value end
Public Instance Methods
handle_value_definition()
click to toggle source
Return the value definition (what to calculate it on) associated with this subset. Other values, such as type and value, may be modified depending on this value.
# File lib/hqmf-parser/2.0/types.rb, line 285 def handle_value_definition value_def = @entry.at_xpath('./*/cda:repeatNumber', HQMF2::Document::NAMESPACES) unless value_def # TODO: HQMF needs better differentiation between SUM & COUNT... # currently using presence of repeatNumber... @type = 'SUM' if @type == 'COUNT' value_def = @entry.at_xpath('./*/cda:value', HQMF2::Document::NAMESPACES) end # TODO: Resolve extracting values embedded in criteria within outboundRel's if @type == 'SUM' value_def = @entry.at_xpath('./*/*/*/cda:value', HQMF2::Document::NAMESPACES) end if value_def value_type = value_def.at_xpath('./@xsi:type', HQMF2::Document::NAMESPACES) @value = HQMF2::AnyValue.new if String.try_convert(value_type) == 'ANY' end value_def end
to_model()
click to toggle source
Generates this classes hqmf-model equivalent
# File lib/hqmf-parser/2.0/types.rb, line 318 def to_model vm = value ? value.to_model : nil HQMF::SubsetOperator.new(type, vm) end
translate_type(subset_code, qdm_subset_code)
click to toggle source
Take a qdm type code to map it to a subset operator, or failing at finding that, return the given subset code.
# File lib/hqmf-parser/2.0/types.rb, line 308 def translate_type(subset_code, qdm_subset_code) combined = "#{qdm_subset_code}:#{subset_code}" if QDM_TYPE_MAP[combined] QDM_TYPE_MAP[combined] else subset_code end end