Class: ConceptQL::Nodes::Node
- Inherits:
-
Object
- Object
- ConceptQL::Nodes::Node
show all
- Defined in:
- lib/conceptql/nodes/node.rb
Direct Known Subclasses
GraphNodifier::DotNode, BinaryOperatorNode, CastingNode, Concept, ConditionType, DateRange, Define, DrugTypeConcept, From, Gender, Occurrence, PassThru, PlaceOfServiceCode, Race, Recall, SourceVocabularyNode, StandardVocabularyNode, TimeWindow, Visit
Constant Summary
collapse
- COLUMNS =
[
:person_id,
:criterion_id,
:criterion_type,
:start_date,
:end_date,
:value_as_numeric,
:value_as_string,
:value_as_concept_id
]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Node
Returns a new instance of Node.
18
19
20
21
22
23
24
25
|
# File 'lib/conceptql/nodes/node.rb', line 18
def initialize(*args)
args.flatten!
if args.last.is_a?(Hash)
@options = args.pop.symbolize_keys
end
@options ||= {}
@values = args.flatten
end
|
Instance Attribute Details
#tree=(value) ⇒ Object
17
18
19
|
# File 'lib/conceptql/nodes/node.rb', line 17
def tree=(value)
@tree = value
end
|
#values ⇒ Object
Returns the value of attribute values.
16
17
18
|
# File 'lib/conceptql/nodes/node.rb', line 16
def values
@values
end
|
Instance Method Details
#arguments ⇒ Object
52
53
54
|
# File 'lib/conceptql/nodes/node.rb', line 52
def arguments
@arguments ||= values.reject { |v| v.is_a?(Node) }
end
|
#children ⇒ Object
44
45
46
|
# File 'lib/conceptql/nodes/node.rb', line 44
def children
@children ||= values.select { |v| v.is_a?(Node) }
end
|
#columns(query, local_type = nil) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/conceptql/nodes/node.rb', line 56
def columns(query, local_type = nil)
criterion_type = :criterion_type
if local_type
criterion_type = Sequel.cast_string(local_type.to_s).as(:criterion_type)
end
columns = [:person_id,
type_id(local_type),
criterion_type]
columns += date_columns(query, local_type)
columns += value_columns(query)
end
|
#evaluate(db) ⇒ Object
27
28
29
|
# File 'lib/conceptql/nodes/node.rb', line 27
def evaluate(db)
select_it(query(db))
end
|
#select_it(query, specific_type = nil) ⇒ Object
35
36
37
38
|
# File 'lib/conceptql/nodes/node.rb', line 35
def select_it(query, specific_type = nil)
specific_type = type if specific_type.nil? && respond_to?(:type)
query.select(*columns(query, specific_type))
end
|
#sql(db) ⇒ Object
31
32
33
|
# File 'lib/conceptql/nodes/node.rb', line 31
def sql(db)
evaluate(db).sql
end
|
#stream ⇒ Object
48
49
50
|
# File 'lib/conceptql/nodes/node.rb', line 48
def stream
@stream ||= children.first
end
|
#types ⇒ Object
40
41
42
|
# File 'lib/conceptql/nodes/node.rb', line 40
def types
@types ||= determine_types
end
|