Class: ConceptQL::Operators::Gender

Inherits:
Operator
  • Object
show all
Defined in:
lib/conceptql/operators/gender.rb

Constant Summary

Constants inherited from Operator

Operator::COLUMNS

Instance Attribute Summary

Attributes inherited from Operator

#arguments, #options, #upstreams, #values

Instance Method Summary collapse

Methods inherited from Operator

#columns, #evaluate, #initialize, #label, #select_it, #set_values, #sql, #stream, #types

Methods included from Metadatable

#allows_many_upstreams, #allows_one_upstream, #argument, #category, #desc, #humanized_class_name, #inherited, #just_class_name, #option, #predominant_types, #preferred_name, #reset_categories, #to_metadata, #types

Constructor Details

This class inherits a constructor from ConceptQL::Operators::Operator

Instance Method Details

#query(db) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/conceptql/operators/gender.rb', line 10

def query(db)
  gender_concept_ids = values.map do |value|
    case value.to_s
    when /^m/i
      8507
    when /^f/i
      8532
    else
      value.to_i
    end
  end

  db.from(:person)
    .where(gender_concept_id: gender_concept_ids)
end