Class: ConceptQL::Operators::StandardVocabularyOperator
- Inherits:
-
VocabularyOperator
- Object
- Operator
- VocabularyOperator
- ConceptQL::Operators::StandardVocabularyOperator
- Defined in:
- lib/conceptql/operators/standard_vocabulary_operator.rb
Overview
A StandardVocabularyOperator is a superclass for a operator that represents a criterion whose column stores information associated with a standard vocabulary.
If that seems confusing, then think of CPT or SNOMED criteria. That type of criterion takes a set of values that live in the OMOP concept table.
My coworker came up with a nice, generalized query that checks for matching concept_ids and matching source_code values. This class encapsulates that query.
Subclasses must provide the following methods:
-
table
-
The CDM table name where the criterion will fetch its rows
-
e.g. for CPT, this would be procedure_occurrence
-
-
concept_column
-
Name of the column in the table that stores a concept_id related to the criterion
-
e.g. for CPT, this would be procedure_concept_id
-
-
vocabulary_id
-
The vocabulary ID of the source vocabulary for the criterion
-
e.g. for CPT, a value of 4 (for CPT-4)
-
Direct Known Subclasses
Cpt, CptOrHcpcs, Drg, Hcpcs, Icd10Pcs, Icd9Procedure, Loinc, RevenueCode, Rxnorm, Snomed
Instance Attribute Summary
Attributes inherited from Operator
#arguments, #errors, #nodifier, #options, #upstreams, #values
Instance Method Summary collapse
Methods inherited from VocabularyOperator
Methods inherited from Operator
#annotate, #cast_column, #code_list, codes_should_match, #columns, #create_upstreams, #data_model, #database_type, default_query_columns, #domains, #dup_values, #dynamic_columns, #evaluate, inherited, #initialize, #inspect, #label, new, #operator_name, #optimized, query_columns, register, require_column, #required_columns, #scope, #select_it, #setup_select, #sql, #stream, #to_op, #unionable?, #upstreams_valid?, #valid?
Methods included from Metadatable
#allows_many_upstreams, #allows_one_upstream, #argument, #auto_label, #basic_type, #category, #derive_metadata_from_validations, #desc, #domains, #get_desc, #humanized_class_name, #inherited, #just_class_name, #no_desc, #option, #predominant_domains, #pref_name, #preferred_name, #reset_categories, #standard_description, #to_metadata, #validate_at_least_one_upstream_to_metadata, #validate_at_most_one_upstream_to_metadata, #validate_no_arguments_to_metadata, #validate_no_upstreams_to_metadata, #validate_one_upstream_to_metadata, #validate_required_options_to_metadata, #warn_about_missing_metadata
Constructor Details
This class inherits a constructor from ConceptQL::Operators::Operator
Instance Method Details
#conditions(db) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/conceptql/operators/standard_vocabulary_operator.rb', line 36 def conditions(db) if omopv4? {c__concept_code: arguments_fix(db), c__vocabulary_id: vocabulary_id} else conditions = { code_column => arguments_fix(db) } conditions[vocabulary_id_column] = vocabulary_id if vocabulary_id_column conditions end end |
#describe_code(db, code) ⇒ Object
46 47 48 |
# File 'lib/conceptql/operators/standard_vocabulary_operator.rb', line 46 def describe_code(db, code) db[:concept].filter(:vocabulary_id => vocabulary_id).filter(:concept_code => code).map(:concept_name)[0] end |
#query(db) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/conceptql/operators/standard_vocabulary_operator.rb', line 23 def query(db) ds = db.from(table_name) .where(conditions(db)) if omopv4? ds = ds.join(:concept___c, c__concept_id: table_concept_column) end ds end |
#query_cols ⇒ Object
32 33 34 |
# File 'lib/conceptql/operators/standard_vocabulary_operator.rb', line 32 def query_cols table_columns(table_name, :concept) end |