lib/conceptql/graph_nodifier.rb in conceptql-0.0.3 vs lib/conceptql/graph_nodifier.rb in conceptql-0.0.4
- old
+ new
@@ -9,10 +9,11 @@
TYPES = {
# Conditions
condition: :condition_occurrence,
primary_diagnosis: :condition_occurrence,
icd9: :condition_occurrence,
+ icd10: :condition_occurrence,
condition_type: :condition_occurrence,
# Procedures
procedure: :procedure_occurrence,
cpt: :procedure_occurrence,
@@ -22,10 +23,11 @@
procedure_cost: :procedure_cost,
# Visits
visit_occurrence: :visit_occurrence,
place_of_service: :visit_occurrence,
+ place_of_service_code: :visit_occurrence,
# Person
person: :person,
gender: :person,
race: :person,
@@ -39,11 +41,14 @@
# Observation
loinc: :observation,
# Drug
drug_exposure: :drug_exposure,
+ rxnorm: :drug_exposure,
drug_cost: :drug_cost,
+ drug_type_concept_id: :drug_exposure,
+ drug_type_concept: :drug_exposure,
# Date Nodes
date_range: :date,
# Miscelaneous nodes
@@ -118,14 +123,65 @@
def arguments
options.values
end
end
+ class DefineNode < DotNode
+ def initialize(*args)
+ @gn = args.pop
+ super(*args)
+ end
+
+ def types
+ @gn.types[namify(arguments.first)] = super
+ end
+
+ def shape
+ :cds
+ end
+ end
+
+ class FromNode < DotNode
+ def initialize(*args)
+ @gn = args.pop
+ super(*args)
+ end
+
+ def types
+ @gn.types[namify(arguments.first)]
+ end
+
+ def shape
+ :cds
+ end
+ end
+
+ class VsacNode < DotNode
+ def initialize(name, values, types)
+ @types = types
+ super(name, values)
+ end
+
+ def types
+ [ @types ].flatten.compact.map(&:to_sym)
+ end
+ end
+
BINARY_OPERATOR_TYPES = %w(before after meets met_by started_by starts contains during overlaps overlapped_by finished_by finishes coincides except person_filter less_than less_than_or_equal equal not_equal greater_than greater_than_or_equal filter).map { |temp| [temp, "not_#{temp}"] }.flatten.map(&:to_sym)
+ def types
+ @types ||= {}
+ end
def create(type, values)
if BINARY_OPERATOR_TYPES.include?(type)
return BinaryOperatorNode.new(type, values)
+ elsif type == :define
+ return DefineNode.new(type, values, self)
+ elsif type == :from
+ return FromNode.new(type, values, self)
+ elsif type == :vsac
+ types = values.pop
+ return VsacNode.new(type, values, types)
end
DotNode.new(type, values)
end
end
end