Skip to contents

Creates the temporary table _enrollment_spans(person_id, start_date, end_date). Spans are clipped to [min_date, max_date] (default: today), dropped when empty, and merged when they overlap or touch, so each row is one continuous enrolment. Persons are matched on person_source_value.

Usage

load_enrollment_spans(
  con,
  source_dir,
  site_id = NULL,
  disambiguate_patids = FALSE,
  min_date = "1900-01-02",
  max_date = NULL,
  open_end = NULL
)

Arguments

con

Active DuckDB connection (mapping macros loaded, person populated).

source_dir

Directory of PCORnet source files.

site_id, disambiguate_patids

As in etl_pcornet().

min_date, max_date

Clip bounds; see build_observation_period().

open_end

Optional date given to spans with no end date instead of max_date; etl_pcornet() passes the data cutoff here under data_cutoff = "auto", so an ongoing enrolment is not extended to the build date while recorded end dates are kept.

Value

The number of merged spans (0, and no table, when the source has no ENROLLMENT file), invisibly.