Class: SimpleXml::SubTree

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/model/sub_tree.rb

Overview

Represents a data criteria specification

Constant Summary

Constants included from Utilities

Utilities::MEASURE_ATTRIBUTES_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, attr_val, build_value, #children_of, #comments_on, #create_age_timing, #create_birthdate_criteria

Constructor Details

#initialize(entry, doc, negated = false) ⇒ SubTree

Returns a new instance of SubTree.



8
9
10
11
12
13
14
15
16
17
18
19
# 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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/model/sub_tree.rb', line 6

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/model/sub_tree.rb', line 6

def name
  @name
end

#preconditionObject (readonly)

Returns the value of attribute precondition.



6
7
8
# File 'lib/model/sub_tree.rb', line 6

def precondition
  @precondition
end

Instance Method Details

#convert_to_data_criteria(operator = 'clause') ⇒ Object



51
52
53
54
# 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_variableObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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

#processObject



21
22
23
24
25
26
# 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