class HQMF2::DataCriteriaBaseExtractions

Contains extraction methods which are self-contained (rely only on the xml and an xpath, no other instance variables)

Constants

CONJUNCTION_CODE_TO_DERIVATION_OP

Public Class Methods

new(entry) click to toggle source
# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 11
def initialize(entry)
  @entry = entry
end

Public Instance Methods

all_subset_operators() click to toggle source

Extracts all subset operators contained in the entry xml

# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 56
def all_subset_operators
  @entry.xpath('./*/cda:excerpt', HQMF2::Document::NAMESPACES).collect do |subset_operator|
    SubsetOperator.new(subset_operator)
  end
end
extract_child_criteria() click to toggle source

Generate a list of child criterias

# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 22
def extract_child_criteria
  @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:criteriaReference/cda:id",
               HQMF2::Document::NAMESPACES).collect do |ref|
    Reference.new(ref).id
  end.compact
end
extract_derivation_operator() click to toggle source

Extracts the derivation operator to be used by the data criteria, and fails out if it finds more than one (should not be valid)

# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 31
def extract_derivation_operator
  codes = @entry.xpath("./*/cda:outboundRelationship[@typeCode='COMP']/cda:conjunctionCode/@code",
                       HQMF2::Document::NAMESPACES)
  codes.inject(nil) do |d_op, code|
    if d_op && d_op != CONJUNCTION_CODE_TO_DERIVATION_OP[code.value]
      fail 'More than one derivation operator in data criteria'
    end
    CONJUNCTION_CODE_TO_DERIVATION_OP[code.value]
  end
end
extract_local_variable_name() click to toggle source

Extract the local variable name (held in the value of the localVariableName element)

# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 16
def extract_local_variable_name
  lvn = @entry.at_xpath('./cda:localVariableName')
  lvn['value'] if lvn
end
extract_negation() click to toggle source

Extract the negation (and the negation_code_list_id if appropriate)

# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 69
def extract_negation
  negation = (attr_val('./*/@actionNegationInd').to_s.downcase == 'true')
  negation_code_list_id = nil
  if negation
    res = @entry.at_xpath('./*/cda:outboundRelationship/*/cda:code[@code="410666004"]/../cda:value/@valueSet',
                          HQMF2::Document::NAMESPACES)
    negation_code_list_id = res.value if res
  end
  [negation, negation_code_list_id]
end
extract_subset_operators() click to toggle source

Filters all the subset operators to only include the ones of type 'UNION' and 'XPRODUCT'

# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 49
def extract_subset_operators
  all_subset_operators.select do |operator|
    operator.type != 'UNION' && operator.type != 'XPRODUCT'
  end
end
extract_template_ids() click to toggle source
# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 62
def extract_template_ids
  @entry.xpath('./*/cda:templateId/cda:item', HQMF2::Document::NAMESPACES).collect do |template_def|
    HQMF2::Utilities.attr_val(template_def, '@root')
  end
end
extract_temporal_references() click to toggle source
# File lib/hqmf-parser/2.0/data_criteria_helpers/dc_base_extract.rb, line 42
def extract_temporal_references
  @entry.xpath('./*/cda:temporallyRelatedInformation', HQMF2::Document::NAMESPACES).collect do |temporal_reference|
    TemporalReference.new(temporal_reference)
  end
end