class SimpleXml::SubTree

Represents a data criteria specification

Attributes

id[R]
name[R]
precondition[R]

Public Class Methods

new(entry, doc, negated=false) click to toggle source
# File lib/model/sub_tree.rb, line 8
def initialize(entry, doc, negated=false)
  @doc = doc
  @entry = entry

  @id = attr_val('@uuid')
  @name = attr_val('@displayName')

  children = children_of(@entry)
  raise "multiple children of subtree... not clear how to handle this" if children.length > 1
  @child = children.first
  @processed = false
end

Public Instance Methods

convert_to_data_criteria(operator='clause') click to toggle source
# File lib/model/sub_tree.rb, line 51
def convert_to_data_criteria(operator='clause')
  process
  DataCriteria.convert_precondition_to_criteria(@precondition, @doc, operator)
end
convert_to_variable() click to toggle source
# File lib/model/sub_tree.rb, line 33
def convert_to_variable
  # wrap a reference precondition with a parent
  @precondition = ParsedPrecondition.new(HQMF::Counter.instance.next, [@precondition], nil, SimpleXml::Precondition::UNION, false) if @precondition.reference

  # create the grouping data criteria for the variable
  criteria = convert_to_data_criteria('variable')
  criteria.instance_variable_set('@variable', true)
  criteria.instance_variable_set('@description', @entry.attributes['displayName'].value || attr_val('@displayName'))
  criteria.handle_specific_occurrence(attr_val('@instance')) if attr_val('@instance')

  # put variable in source data criteria
  @doc.register_source_data_criteria(criteria)

  # update the reference to the variable data criteria
  @precondition.preconditions = []
  @precondition.reference = Reference.new(criteria.id)
end
process() click to toggle source
# File lib/model/sub_tree.rb, line 21
def process
  return if @processed
  @precondition = Precondition.new(@child, @doc)
  @processed = true
  convert_to_variable if attr_val('@qdmVariable') == 'true'
end