Skip to contents

Applies sequential filtering criteria step-by-step and computes patient retention metrics.

Usage

compute_attrition(con, cohort_id, steps, count_stays = FALSE)

Arguments

con

Active DuckDB DBI connection.

cohort_id

Integer cohort ID being evaluated.

steps

A list of named steps, each containing step_name (character) and step_query (character SQL). Each query after step 1 can query _step_current to filter down from the previous step.

count_stays

If TRUE and the steps return visit_occurrence_id, adds stays_retained and stays_dropped (used by define_study_cohort(one_per_patient = FALSE)).

Value

A data.frame with columns: step_number, step_name, subjects_retained, subjects_dropped, percent_retained.