Class: ConceptQL::Operators::StandardVocabularyOperator

Inherits:
Operator
  • Object
show all
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, 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 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, Hcpcs, Icd9Procedure, Loinc, Rxnorm, Snomed, SnomedCondition

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



24
25
26
27
28
# File 'lib/conceptql/operators/standard_vocabulary_operator.rb', line 24

def query(db)
  db.from(table_name)
    .join(:vocabulary__concept___c, c__concept_id: table_concept_column)
    .where(c__concept_code: values, c__vocabulary_id: vocabulary_id)
end

#typeObject



30
31
32
# File 'lib/conceptql/operators/standard_vocabulary_operator.rb', line 30

def type
  table
end