feat: Centralised filtering API of OMOP Queries#4
Open
nicoloesch wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Query Filtering Framework for OMOP_Alchemy
Summary
Introduces a composable, extensible query filtering system (
ConceptFilterandBaseConceptFilter)that eliminates code duplication and provides a unified interface for OMOP concept filtering.
Problem
Both
omop-embandomop-graphindependently implement identical filtering classes to filter Concept table queries by domain, vocabulary, concept ID, and standardization status:omop-emb:EmbeddingConceptFilteromop-graph:SearchConstraintConceptThis duplication creates maintenance burden and inhibits circular-import-free sharing of this common pattern.
Solution
New module:
omop_alchemy.cdm.queryBaseConceptFilter: Abstract protocol enforcing consistentapply(query: Select) -> SelectinterfaceConceptFilter: Frozen dataclass implementing unified concept filteringconcept_ids,domains,vocabularies,require_standardBenefits
Single Source of Truth — Eliminates ~70 lines of duplicated code
No Circular Imports — Shared library is stable and can be imported by all projects
Extensible Protocol —
BaseConceptFilterenables future filter types (measurements, relationships, temporal, etc.)Backward Compatible — Downstream projects can re-export as aliases for gradual migration
Migration Opportunities
omop-emb: Replace
EmbeddingConceptFilterwithfrom omop_alchemy.cdm.query import ConceptFilteromop-graph: Replace
SearchConstraintConceptwithfrom omop_alchemy.cdm.query import ConceptFilterSee
docs/api/query-filtering.mdfor full API documentation and extension guide.Changes
omop_alchemy/cdm/query/filters.pywithBaseConceptFilterprotocol andConceptFilterimplementationomop_alchemy/cdm/query/__init__.pywith public exportsomop_alchemy/cdm/__init__.pyto re-export filtersdocs/api/query-filtering.mdwith usage, composition, and extensibility guide