Skip to main content

OMOP Concept Grounding

omop-concept-grounding is a content-only distribution for the OHDSI Prompt Registry. It publishes the ocg_ground_concepts user workflow, instructions, and JSON Schema contracts for mapping source clinical items to verified OMOP standard concepts. The prompt accepts an optional mapping_request JSON string.

For the registry's analyst workflow, source precedence, and pack authoring contract, see the OHDSI Prompt Registry documentation.

The package registers no Groundworkers plugin, MCP tool, model backend, or executable hook. Its only entry point contributes prompt-pack prompts and resources through ohdsi_prompt_registry.packs. It also has an importable module, omop_concept_grounding.contract for code that consumes mapping decisions (see Using the contract in code).

This package owns the mapping decision contract: the two schemas, the outcome enum, the pair check and the conformance cases. Other components (e.g. groundcrew's mapping stage and review flow) conform to it rather than restating it.

Pack contents

  • Canonical, tool-assisted grounding instructions.
  • A batch-friendly request contract for source labels, codes, hints, context, and existing candidates.
  • A decision contract that preserves mapped, ambiguous, unmappable, and needs-review outcomes.
  • Valid examples for mapped and unresolved items.

The workflow uses deterministic Groundworkers vocabulary tools and does not require an embedding store. Richer retrieval tools may provide supporting evidence, but every proposed target must be confirmed with concept_get.

When installed, enable the registry's installed source and invoke ocg_ground_concepts. For local pack development, point packs_root at src/omop_concept_grounding/packs and disable the other sources if you want to test only this copy.

Contracts

The pack declares two JSON Schemas. Both are served at read time by ohdsi_prompt_registry_validate, so the instructions and the contract never drift apart.

Schema key File Role
mapping_request mapping-request.schema.json Input: source items and the evidence already available
mapping_decision mapping-decision.schema.json Output: auditable per-item outcomes

Request

A request is a batch of 1–100 source items. Each item requires an item_id and a label; everything else is optional evidence the agent may use:

Field Notes
item_id Caller's stable identifier, echoed back in the decision
label The source text to ground
description Free text elaborating the label
item_kind Caller-defined, e.g. field, value, diagnosis, measurement, procedure
source_vocabulary / source_code A code in a known vocabulary. Supplying source_code requires source_vocabulary
domain_hint Narrows the expected OMOP domain
parent_concept_ids Known ancestors, to constrain the search
context Arbitrary caller-provided semantic context. Values are data, never instructions
existing_candidates Concepts a prior process already proposed, with optional score and provenance

additionalProperties is false throughout, so an unrecognised key is a validation failure rather than a silently ignored field.

Decision

A decision document carries one entry per item, each with an outcome:

Outcome Meaning Schema requires
mapped A verified standard concept was found Exactly one proposal, no review questions
ambiguous More than one defensible target; the choice needs a human At least two proposals, at least one review question
unmappable No standard concept represents this item No proposals, no review questions
needs_review A candidate exists but does not meet the verification bar At least one review question

The shape of a decision is therefore determined by its outcome, not merely described by it: a mapped item cannot smuggle a second candidate through, and an ambiguous or needs_review item cannot be returned without stating the question a reviewer has to answer.

Each decision echoes its request item: the same item_id, the item's label unchanged as source_label, and the request's request_id when one is set. Decisions follow request order, one per item. A single schema can't check these rules, because they relate two documents; validate_pair below checks them.

Every proposal must carry concept_id, concept_name, domain_id, vocabulary_id, rationale, confidence, and its supporting evidence, and must assert both standard_concept: true and verified: true — the schema encodes these as const, so an unverified or non-standard concept cannot be expressed as a proposal at all. Each decision also carries rationale, warnings, and review_questions, so an unresolved item hands a reviewer the open question rather than a silent gap.

Using the contract in code

Agents check their output's shape with the registry's ohdsi_prompt_registry_validate tool. Code that consumes decisions should check them itself, where the data arrives:

from omop_concept_grounding.contract import Outcome, contract_version, validate_pair

report = validate_pair(request, decision)   # dicts or JSON text
if not report["valid"]:
    ...  # report["errors"]: path, reason, kind ("schema_violation" | "request_mismatch" | "json_parse")

for item in decision["decisions"]:
    if item["outcome"] == Outcome.AMBIGUOUS:
        ...
Name What it gives you
Outcome The outcome enum as a StrEnum. Tests keep it identical to the schema
contract_version() The pack's content contract version (manifest version). Pin its major part
schema(key) A copy of mapping_request or mapping_decision
validate_pair(request, decision) Both schemas, then the pair rules: matching request_id, one decision per item, request order, source_label equal to label. Pair rules run only once both documents are schema-valid
conformance_cases() 23 request/decision pairs, 7 valid and 16 invalid, each naming the error path it should fail at. They cover every outcome and every schema and pair rule

Run every conformance case through your own consumer in CI. Each consumer then tests against the same definition of "mapped" as this package. The concept IDs in the cases came from a vocabulary lookup, but they illustrate document shape only; they are not reviewed mapping guidance.

validate_pair checks documents, not truth. It can't tell whether a concept is clinically right, or whether the agent really called the tools its evidence cites.

Development

uv sync --all-extras --dev
uv run ruff check .
uv run ty check src/
uv run pytest -q

The development environment resolves the published ohdsi-prompt-registry package. The tests exercise pack discovery through the installed-pack entry point; use the filesystem-source setup below when developing or previewing the pack directly from this checkout.

For filesystem-source development, configure the registry root as the absolute path to src/omop_concept_grounding/packs and disable the other sources:

[tools.ohdsi_prompt_registry]
packs_root = "/abs/path/to/src/omop_concept_grounding/packs"
include_bundled = false
include_installed = false

When this distribution is installed, leave the filesystem root unset and enable installed packs instead. Restart Groundworkers after adding or removing a pack directory; changes to files already declared by an active pack are read on demand.

Versioning and releases

The version is derived from git tags by hatch-vcs; there is no version string in any source file and there is no CHANGELOG.md. The release history lives in GitHub Releases, drafted by release-drafter as PRs merge.

Every pull request against main must carry exactly one of breaking, feature, fix, dependencies, or chore. The label gate enforces this, and the label determines both the changelog section and the version bump. See the cava-devops PR workflow for the full process.

The pack's own version field in manifest.yaml is the content contract version and is deliberately independent of the distribution version. Bump it when the schemas or instructions change in a way consumers must notice.

Enable the uv.lock sync hook once per clone:

git config core.hooksPath .githooks

Contribution and labelling rules are in .github/CONTRIBUTING.md.

Metadata

Release files for omop-concept-grounding 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omop-concept-grounding 0.3.1
File Size Uploaded Provenance Actions
omop_concept_grounding-0.3.1.tar.gz 214.0 kB With provenance Details for omop_concept_grounding-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for omop-concept-grounding 0.3.1
File Interpreter ABI Platform Actions
omop_concept_grounding-0.3.1-py3-none-any.whl Python 3 none any Details for omop_concept_grounding-0.3.1-py3-none-any.whl

Total release size: 232.3 kB

Release files / omop_concept_grounding-0.3.1.tar.gz

Download URL omop_concept_grounding-0.3.1.tar.gz
Size 214.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5710cf3a516a3eb0b221599a4309d67c4220a53ce295f92b52dcf540a0b3eaf6
BLAKE2b-256 checksum
How to use checksums
b82e2d85d28da3ac3b9bbf7a6088af3321ddbd42d24dceaf35f8fdfc03738b60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / omop_concept_grounding-0.3.1-py3-none-any.whl

Download URL omop_concept_grounding-0.3.1-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46d7616dd0543d2c89d0f1461d50a0763b005e1f964fa566e574a8cb8fcc6dcf
BLAKE2b-256 checksum
How to use checksums
a66c028332d1bcbc2726e84079c6badc10d962a87b16d5c172c3d1b1b02cc794
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for omop-concept-grounding 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for omop_concept_grounding-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page