class ConceptQL::QueryModifiers::DrugQueryModifier
Attributes
db[R]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/conceptql/query_modifiers/drug_query_modifier.rb, line 9 def initialize(*args) super @db = query.db end
Public Instance Methods
modified_query()
click to toggle source
# File lib/conceptql/query_modifiers/drug_query_modifier.rb, line 14 def modified_query return query unless domain == :drug_exposure query.from_self(alias: :de) .left_join(micro_table.as(:mt), mt__drug_concept_id: :de__drug_concept_id) .select_all(:de) .select_append(:mt__amount_value___drug_amount) .select_append(:mt__amount_unit___drug_amount_units) .select_append(:mt__drug_name___drug_name) .from_self end
Private Instance Methods
domain()
click to toggle source
# File lib/conceptql/query_modifiers/drug_query_modifier.rb, line 27 def domain op.try(:domain) rescue nil end
micro_table()
click to toggle source
# File lib/conceptql/query_modifiers/drug_query_modifier.rb, line 31 def micro_table # TODO: Does drug_strength only have RXNORM concept_ids? # TODO: What is vocabulary for units? Can we shrink concept table to just that vocab before joining? db.from(:drug_strength___ds) .join(:concept___dc, ds__drug_concept_id: :dc__concept_id) .select( :ds__drug_concept_id___drug_concept_id, :ds__amount_value___amount_value, :ds__amount_unit___amount_unit, :dc__concept_name___drug_name, ) end