15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/hqmf-parser/converter/pass2/comparison_converter.rb', line 15
def walk_up_tree(preconditions)
preconditions.each do |precondition|
if (has_child_comparison(precondition))
walk_up_tree(precondition.preconditions)
end
if (precondition.comparison? && !precondition.processed)
new_data_criteria = nil
if precondition.reference and precondition.reference.id != HQMF::Document::MEASURE_PERIOD_ID
data_criteria = @data_criteria_converter.v2_data_criteria_by_id[precondition.reference.id]
new_data_criteria = @data_criteria_converter.duplicate_data_criteria(data_criteria, precondition.id)
precondition.reference.id = new_data_criteria.id
end
if precondition.has_preconditions?
restrictions = precondition.restrictions
restrictions.sort! {|left, right| (right.operator.summary? and !left.operator.summary?) ? 1 : 0 }
restrictions.each do |restriction|
operator = restriction.operator
if (precondition.reference and (new_data_criteria == nil or new_data_criteria.id != precondition.reference.id))
new_data_criteria = @data_criteria_converter.v2_data_criteria_by_id[precondition.reference.id]
end
if (operator.temporal?)
HQMF::OperatorConverter.apply_temporal(new_data_criteria, precondition, restriction, @data_criteria_converter)
elsif(operator.summary?)
HQMF::OperatorConverter.apply_summary(new_data_criteria, precondition, restriction, @data_criteria_converter)
else
case operator.type
when 'REFR'
if operator.field.downcase == 'status'
new_data_criteria.status ||= operator.value.code
elsif operator.field.downcase == 'result value' or operator.field.downcase == 'result'
puts "\tREFR result value is nil: #{new_data_criteria.title}" if (operator.value.nil?)
new_data_criteria.value = operator.value
else
new_data_criteria.field_values ||= {}
new_data_criteria.field_values[operator.field_value_key] = operator.value
end
restriction.converted=true
when 'RSON'
new_data_criteria.negation_code_list_id = operator.value.code_list_id
new_data_criteria.negation=true
restriction.converted=true
when 'SUBJ'
new_data_criteria.field_values ||= {}
new_data_criteria.field_values[operator.field_value_key] = operator.value
restriction.converted=true
else
puts "\tOperator is unknown: #{operator.type}"
restriction.converted=true
end
end
end
precondition.delete_converted_restrictions!
precondition.processed = true
end
end
end
end
|