Query Filtering¶
omop_alchemy.cdm.query provides ConceptFilter, a shared, reusable way to
filter CDM concept-table queries by domain, vocabulary, concept ID, and
standard/active status, with an optional row-count limit.
It exists so that packages consuming OMOP Alchemy (e.g. omop-emb, omop-graph)
don't each need to reimplement the same filtering logic against their own copy
of Concept's column names — since this package owns the Concept model
directly, the filter can reference real columns rather than duck-typing against
an opaquely-imported table.
from sqlalchemy import select
from omop_alchemy.cdm.model.vocabulary import Concept
from omop_alchemy.cdm.query import ConceptFilter
concept_filter = ConceptFilter(
domains=("Condition", "Drug"),
require_standard=True,
)
query = concept_filter.apply(select(Concept))
All fields are optional and combinable.
Search constraints for plain CDM concept-table queries.
All fields are optional. Unset fields impose no constraint.
Attributes:
| Name | Type | Description |
|---|---|---|
concept_ids |
(tuple[int, ...], optional)
|
Restrict results to this set of concept IDs. |
domains |
(tuple[str, ...], optional)
|
Restrict results to concepts in these OMOP domains. |
vocabularies |
(tuple[str, ...], optional)
|
Restrict results to concepts from these vocabularies. |
require_standard |
bool
|
When |
include_classification |
bool
|
Only meaningful with |
require_active |
bool
|
When |
limit |
(int, optional)
|
Maximum number of rows to return. If not set, all matching rows are returned. |