Class: ConceptQL::Operators::SourceVocabularyOperator
- Defined in:
- lib/conceptql/operators/source_vocabulary_operator.rb
Overview
A SourceVocabularyOperator is a superclass for a operator that represents a criterion whose column stores information associated with a source vocabulary.
If that seems confusing, then think of ICD-9 or NDC criteria. That type of criterion takes a set of values that are mapped via the source_to_concept_map table into a standard vocabulary.
This kind of criterion can have some interesting issues when we are searching for rows that match. Let’s take ICD-9 286.53 for example. That code maps to concept_id 0, so if we try to pull all conditions that match just the concept_id of 0 we’ll pull all condtions that have no match in the SNOMED standard vocabulary. That’s not what we want! So we need to search the condition_source_value field for matches on this code instead.
But there’s another, more complicated problem. Say we’re looking for ICD-9 289.81. OMOP maps this to concept_id 432585. OMOP also maps 20 other conditions, 6 of which are other ICD-9 codes, to this same concept_id. So if we look for ICD-9s that have a non-zero condition_condept_id, we might pull up conditions that match on concept_id, but aren’t the same exact code as the one we’re looking for.
My coworker came up with a nice, gneralized 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 ICD-9, this would be condition_occurrence
-
-
concept_column
-
Name of the column in the table that stores a concept_id related to the criterion
-
e.g. for ICD-9, this would be condition_concept_id
-
-
source_column
-
Name of the column in the table that stores the “raw” value related to the criterion
-
e.g. for ICD-9, this would be condition_source_value
-
-
vocabulary_id
-
The vocabulary ID of the source vocabulary for the criterion
-
e.g. for ICD-9, a value of 2 (for ICD-9-CM)
-
Direct Known Subclasses
Icd10, Icd9, Medcode, MedcodeProcedure, Ndc, ObservationByEnttype, Prodcode
Constant Summary
Constants inherited from Operator
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
32 33 34 35 36 |
# File 'lib/conceptql/operators/source_vocabulary_operator.rb', line 32 def query(db) db.from(table_name) .join(:vocabulary__source_to_concept_map___scm, scm__target_concept_id: table_concept_column) .where(Sequel.expr(scm__source_code: values, scm__source_vocabulary_id: vocabulary_id).&(Sequel.expr(scm__source_code: table_source_column))) end |
#type ⇒ Object
38 39 40 |
# File 'lib/conceptql/operators/source_vocabulary_operator.rb', line 38 def type table end |