Setup
connector=, you get a Database. Domains are attributes: db.diagnosis, db.procedure, db.medication, db.enrollment, …
EventFrame — finding events
An EventFrame is a lazy list of clinical events (one row ≈ one code on one date for one patient). You chain verbs; nothing hits the database until.to_df().
Typical index-date chain
EventFrame verbs
Gap semantics
gap_days=30 means: look at ordered distinct dates and require some neighboring pair to be ≥30 days apart.
Cohort — defining a study population
A Cohort starts from an entry EventFrame (people + index date), then requires or excludes criteria. Each step is a set operation onpatient_id. .attrition() counts how many people remain after each step.
Cohort building blocks
Built-in criteria
Windows are always
(days_before, days_after) relative to the cohort entry index date. Example: window=(-365, 0) = the year ending on the index day.
Table / Column — custom predicates
Inspect anything
Legacy API
query_event / filter_event still import but warn. Their gap rule is span, not consecutive days — see Migration.