Skip to contents

Writes every row dated on/after cutoff to a new DuckDB file (same CDM tables), optionally deleting them from the source, and verifies that kept + moved rows and checksums reconstruct the source. Mirror of omop_etl.temporal_split.split_by_date.

Usage

split_by_date(
  con,
  cutoff,
  out_db,
  tables = NULL,
  remove_from_source = FALSE,
  manifest = NULL
)

Arguments

con

Writable DuckDB DBI connection to the CDM (read-only is fine unless remove_from_source).

cutoff

Split date (inclusive start of the held-out period); a Date or "YYYY-MM-DD".

out_db

DuckDB file to create; refuses to overwrite. Also receives full copies of the undated tables person, provider, care_site, location, cdm_source so it is self-contained.

tables

Dated tables to split (character vector, or a named character vector table -> date column). Default: the CDM clinical tables present, from DEFAULT_SPLIT_DATE_COLUMNS.

remove_from_source

Delete the moved rows from the source afterwards.

manifest

Optional run_manifest(); per-table counts are added as steps.

Value

A list with cutoff and tables (per table source_before, kept, moved, checksums). A split that does not reconstruct the source raises an error.