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, From, Gender, Occurrence, PassThru, PlaceOfServiceCode, Race, SourceVocabularyNode, StandardVocabularyNode, TimeWindow, Visit
Constant Summary
collapse
- KNOWN_TYPES =
i(
condition_occurrence
death
drug_cost
drug_exposure
observation
payer_plan_period
procedure_cost
procedure_occurrence
visit_occurrence
)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ 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
#values ⇒ Object
Returns the value of attribute values.
17
18
19
|
# File 'lib/conceptql/nodes/node.rb', line 17
def values
@values
end
|
Instance Method Details
#arguments ⇒ Object
47
48
49
|
# File 'lib/conceptql/nodes/node.rb', line 47
def arguments
@arguments ||= values.reject { |v| v.is_a?(Node) }
end
|
#children ⇒ Object
39
40
41
|
# File 'lib/conceptql/nodes/node.rb', line 39
def children
@children ||= values.select { |v| v.is_a?(Node) }
end
|
#columns(select_types = types) ⇒ Object
51
52
53
54
55
|
# File 'lib/conceptql/nodes/node.rb', line 51
def columns(select_types = types)
[:person_id___person_id] + KNOWN_TYPES.map do |known_type|
select_types.include?(known_type) ? "#{known_type}_id___#{known_type}_id".to_sym : Sequel.expr(nil).cast(:bigint).as("#{known_type}_id".to_sym)
end + date_columns
end
|
#date_columns ⇒ Object
57
58
59
|
# File 'lib/conceptql/nodes/node.rb', line 57
def date_columns
[:start_date, :end_date]
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, select_types = types) ⇒ Object
31
32
33
|
# File 'lib/conceptql/nodes/node.rb', line 31
def select_it(query, select_types=types)
query.select(*columns(select_types))
end
|
#stream ⇒ Object
43
44
45
|
# File 'lib/conceptql/nodes/node.rb', line 43
def stream
@stream ||= children.first
end
|
#types ⇒ Object
35
36
37
|
# File 'lib/conceptql/nodes/node.rb', line 35
def types
@types ||= children.map(&:types).flatten.uniq
end
|