lib/conceptql/operators/from_seer_visits.rb in conceptql-0.2.0 vs lib/conceptql/operators/from_seer_visits.rb in conceptql-0.3.0

- old
+ new

@@ -1,20 +1,26 @@ require_relative 'operator' module ConceptQL module Operators class FromSeerVisits < Operator - def type + register __FILE__ + + no_desc + query_columns :observation + validate_one_upstream + + def domain :observation end + def query(db) visit_ids = stream.evaluate(db) .from_self - .where(criterion_type: 'visit_occurrence') + .where(criterion_domain: 'visit_occurrence') query = db[:observation].where(visit_occurrence_id: visit_ids.select(:criterion_id)) - arguments.inject(query) do |q, key| - q.where(observation_source_value: key.to_s.upcase) - end + query = query.where(observation_source_value: arguments.map{|key| key.to_s.upcase}) unless arguments.empty? + query end end end end