class ConceptQL::Operators::DateRange
Represents a operator that will create a date_range for every person in the database
Accepts two params: start and end formateed as 'YYYY-MM-DD' or 'START' or 'END' 'START' represents the first date of data in the data source, 'END' represents the last date of data in the data source,
Public Instance Methods
domains(db)
click to toggle source
# File lib/conceptql/operators/date_range.rb, line 35 def domains(db) [:person] end
query(db)
click to toggle source
# File lib/conceptql/operators/date_range.rb, line 27 def query(db) db.from(:person) .select_append(Sequel.cast_string('person').as(:criterion_domain)) .select_append(Sequel.expr(:person_id).as(:criterion_id)) .select_append(Sequel.as(cast_date(db, start_date(db)), :start_date), Sequel.as(cast_date(db, end_date(db)), :end_date)).from_self end
query_cols()
click to toggle source
# File lib/conceptql/operators/date_range.rb, line 23 def query_cols table_columns(:person) + [:criterion_domain, :criterion_id, :start_date, :end_date] end
Private Instance Methods
date_from(db, str)
click to toggle source
TODO: Select the earliest and latest dates of observation from the proper CDM table to represent the start and end of data
# File lib/conceptql/operators/date_range.rb, line 51 def date_from(db, str) return db.from(:observation_period).get { min(:observation_period_start_date) } if str.upcase == 'START' return db.from(:observation_period).get { max(:observation_period_end_date) } if str.upcase == 'END' return str end
end_date(db)
click to toggle source
# File lib/conceptql/operators/date_range.rb, line 45 def end_date(db) date_from(db, options[:end]) end
start_date(db)
click to toggle source
# File lib/conceptql/operators/date_range.rb, line 41 def start_date(db) date_from(db, options[:start]) end