Skip to contents

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

Usage

compute_attrition(con, cohort_id, steps)

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.

Value

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