Skip to contents

Prior utilization is the strongest single family of readmission predictors. For every cohort row this counts the visits that precede the index admission: inpatient (IP), emergency (ED) and outpatient (OS) counts, cumulative length of stay, days since the last encounter and the number of prior 30-day readmissions. The look-back is strictly before the admission date, so nothing from the index stay (or anything later) can leak into the features. Mirror of omop_etl.utilization.extract_prior_utilization in Python.

Usage

extract_prior_utilization(
  con,
  cohort_table = "cohort",
  cohort_id = NULL,
  lookback_days = 365,
  anchor_date = "admission",
  visit_concept_groups = NULL,
  readmission_gap_days = 30,
  readmission_group = "ip",
  format = "df"
)

Arguments

con

DuckDB DBI connection with visit_occurrence and the cohort table.

cohort_table

Table or view with subject_id and cohort_start_date. If it also has visit_occurrence_id that visit is excluded explicitly.

cohort_id

Optional cohort_definition_id filter.

lookback_days

Window length in days (non-negative integer).

anchor_date

Only "admission" is supported: a window anchored at discharge would count the index stay.

visit_concept_groups

Named list group -> visit_concept_ids. Defaults to DEFAULT_VISIT_CONCEPT_GROUPS. A visit concept may belong to several groups.

readmission_gap_days

Gap for the prior-readmission count.

readmission_group

Group used for the prior-readmission count (must be a name of the groups).

format

"df" or "arrow".

Value

A data.frame (or Arrow Table).

Details

Output columns, one row per distinct (subject_id, cohort_start_date) ordered by both:

  • prior_<group>_count: visits of that group starting in [admission - lookback_days, admission)

  • prior_<group>_los_days: summed visit_end_date - visit_start_date of those visits (missing end = same day)

  • days_since_last_encounter: days from the end of the most recent visit of ANY type that started within the look-back to the admission (NA when there is none)

  • prior_readmit_<gap>d_count: prior readmission_group visits in the look-back that began within readmission_gap_days days after the discharge of an earlier visit of that group (any earlier date)