Skip to contents

For databases built before max_date = "auto" was used, whose periods end on the build date. Periods ending after cutoff are shortened to it; periods starting after it are deleted.

Usage

cap_observation_period(con, cutoff, dry_run = FALSE, by_end_date = FALSE)

Arguments

con

Active DuckDB connection.

cutoff

Data cutoff, a date like "2026-09-30". Unlike max_date = "auto" at build time, which caps only open-ended enrollment spans and keeps recorded end dates, this shortens every period ending after cutoff, recorded ends included; "auto" also picks its cutoff heuristically (latest event before today), while here the cutoff is the one you pass.

dry_run

If TRUE, only count what would change.

by_end_date

If TRUE with dry_run = TRUE, also return by_end_date, a data frame of the end dates (at most 20, most common first) of the periods that would be shortened, for planning a cap. Empty after a real run.

Value

A list with shortened and deleted counts (and by_end_date when requested).