Skip to content

Drug mapping enhancements + Dependabot fixes - #20

Merged
gkennos merged 2 commits into
mainfrom
drug_enhancements
Oct 11, 2026
Merged

gkennos merged 2 commits into
mainfrom
drug_enhancements

Conversation

@gkennos

@gkennos gkennos commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

Normalised search compares against a computed expression, so ordinary indexes on concept_name do not help.

Measured on a 1.7M-concept CDM:

Call Time
unconstrained 40s
domain='Drug' 25s
vocabulary_id='MedDRA' 0.4s

search_normalized now requires vocabulary_id or parent_ids (a domain filter is not selective enough) and raises INVALID_INPUT otherwise.

allow_unindexed_scan=True accepts the scan if it's really requires (exposed on MCP tool)

concept_candidate_bundle degrades instead of failing (the same way an absent full-text sidecar is handled)

Share one normalisation contract between Python and SQL

Adds NormalizationProfile (StrEnum: verbatim / aggressive / drug_name) and moves the SQL expression builder to base/sql.py as normalization_expression(), replacing the private _normalized_sql_expr in the vocab service. The three profiles were previously bare strings validated on only one of the two paths; an unknown profile is now rejected by both.

Expose a read-only MappingContext to plugins

Plugins can reuse the host's configured mapping and grounding services (candidate bundles, sync and async, concept context, grounding), instead of constructing a second omop-graph or vocabulary adapter from context.cdm_engine. All operations are query-only --> the underlying service objects are deliberately not exposed. The application wires one shared instance into every plugin.

Checklist

  • Applied exactly one label (breaking, feature, fix, dependencies, or chore)
  • Tests pass locally (uv run pytest -q)
  • Lint passes (uv run ruff check .)

@gkennos
gkennos merged commit 60e617d into main Oct 11, 2026
3 checks passed
@gkennos
gkennos deleted the drug_enhancements branch October 11, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant