Class: ConceptQL::Nodes::SourceVocabularyNode
- Defined in:
- lib/conceptql/nodes/source_vocabulary_node.rb
Overview
A SourceVocabularyNode is a superclass for a node 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)
-
Constant Summary
Constants inherited from Node
Instance Attribute Summary
Attributes inherited from Node
Instance Method Summary collapse
Methods inherited from Node
#arguments, #children, #columns, #date_columns, #evaluate, #initialize, #select_it, #stream
Constructor Details
This class inherits a constructor from ConceptQL::Nodes::Node
Instance Method Details
#query(db) ⇒ Object
29 30 31 32 33 |
# File 'lib/conceptql/nodes/source_vocabulary_node.rb', line 29 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 |
#types ⇒ Object
35 36 37 |
# File 'lib/conceptql/nodes/source_vocabulary_node.rb', line 35 def types [table] end |