Real-world evidence studies, quality measures and many clinical AI projects begin with the same deceptively simple step: find the right patients. "Patients with type 2 diabetes starting metformin" sounds precise until you ask which codes, which first occurrence, how much prior history, and when someone stops counting. Different answers produce different results from the same data.
A cohort is not a code list
The Book of OHDSI defines a cohort as a set of persons who satisfy one or more inclusion criteria for a duration of time. It is explicit that a cohort is not a code set: it needs logic for how codes are used, such as first occurrence versus any occurrence, and a well-defined cohort specifies how a person enters and how they exit1.
A few properties follow: one person can belong to several cohorts, can belong to the same cohort in different periods, but not twice in the same period, and a cohort can be empty1. Cohorts are also defined independently and reused, so the same outcome cohort can serve many studies1.
The building blocks

Rule-based definitions combine four components1:
- Domain: where the data lives in the CDM, such as drug exposures or procedures.
- Concept set: a data-agnostic expression of standard concepts for the clinical idea, portable across databases.
- Domain-specific attributes: days' supply for a drug, a measurement value or range.
- Temporal logic: when one criterion must occur relative to another, for example within 365 days before the index event.
Assembled, they answer three questions: what event sets the index date, which inclusion criteria apply, and what ends cohort membership1. In OHDSI tools there are no separate exclusion criteria; "exclude prior hypertension" becomes "include people with zero occurrences of prior hypertension"1.

Definitions as code
Definitions built in ATLAS are stored as JSON and compiled to SQL for each database platform, and tools such as CohortGenerator run them in analysis pipelines2. That is what makes OHDSI network studies possible: the same definition, run unchanged at many sites.
For a data platform, I treat cohort definitions as versioned artefacts: stored in a repository, reviewed, tested against data quality checks as in OMOP data quality checks, and linked to every result produced with them.
If a result can't be traced to the exact cohort definition version that produced it, it isn't reproducible, however good the analysis was.
Where LLMs fit
Turning a clinical question into a cohort definition is skilled, slow work, which makes it a natural target for language models. Research is exploring this, including an MCP server that exposes the OHDSI WebAPI's cohort tools so a model can assemble definitions from natural language3. That design is the right shape: the model calls structured tools that produce standard definitions, rather than writing free-form SQL.
The risks are clinical, not technical. A plausible definition with the wrong concept set, a missing washout period or an exit rule that silently drops patients will run perfectly and produce wrong evidence. My rules:
- Generate into the standard format, never ad hoc SQL, so definitions can be reviewed in familiar tools.
- Require clinical review of concept sets and temporal logic before any use.
- Check against data: counts, attrition by criterion and patient profiles, before trusting results.
- Prefer reuse. Start from established, validated definitions where they exist, and let the model adapt rather than invent.
The tool-based approach also follows the governance patterns in MCP Apps and tool annotations: read-only tools for exploration, review before anything is saved or run.
How I can help
I design OMOP platforms and research pipelines where cohort definitions are versioned, tested and reproducible, and help teams apply AI to them safely. See healthcare data architecture, or analyse your challenge and bring the result to a call.
- 1
- 2
- 3MCP server exposing the OHDSI WebAPI cohort subsystem (CBMS 2026 slides)EasyChair Smart Slide
- 4The Book of OHDSIOHDSI