estimate_hcru: estimate_hcru

View source: R/estimate_hcru.R

estimate_hcruR Documentation

estimate_hcru

Description

This function calculates estimates of healthcare resource utilization (HCRU) from electronic health record data across various care settings (e.g., IP, OP, ED/ER). It provides descriptive summaries of patient counts, encounters, costs, length of stay, and readmission rates for pre- and post-index periods.

Usage

estimate_hcru(
  data,
  cohort_col = "cohort",
  patient_id_col = "patient_id",
  admit_col = "admission_date",
  discharge_col = "discharge_date",
  index_col = "index_date",
  visit_col = "visit_date",
  encounter_id_col = "encounter_id",
  setting_col = "care_setting",
  cost_col = "cost_usd",
  readmission_col = "readmission",
  time_window_col = "period",
  los_col = "length_of_stay",
  custom_var_list = NULL,
  pre_days = 180,
  post_days = 365,
  readmission_days_rule = 30,
  group_var_main = "cohort",
  group_var_by = "care_setting",
  test = NULL,
  timeline = "Pre",
  gt_output = TRUE
)

Arguments

data

A dataframe specifying the health care details.

cohort_col

A character specifying the name of the cohort column.

patient_id_col

A character specifying the name of the patient identifier column.

admit_col

A character specifying the name of the date of admission column.

discharge_col

A character specifying the name of the date of discharge column.

index_col

A character specifying the name of the index date or diagnosis column.

visit_col

A character specifying the name of the date of visit/claim column.

encounter_id_col

A character specifying the name of the encounter/claim column.

setting_col

A character specifying the name of the HCRU setting column e.g. IP, ED, OP, etc.

cost_col

A character specifying the name of cost column.

readmission_col

A character specifying the name of readmission column.

time_window_col

A character specifying the name of time window column.

los_col

A character specifying the name of length of stay column.

custom_var_list

A character vector providing the list of additional columns.

pre_days

Number of days before index (default 180 days).

post_days

Number of days after index (default 365 days).

readmission_days_rule

Rule for how many days can be permissible to define readmission criteria in AP setting (default 30 days).

group_var_main

A character specifying the name of the main grouping column.

group_var_by

A character specifying the name of the secondary grouping column.

test

An optional named list of statistical tests (e.g., list(age = "wilcox.test")).

timeline

A character specifying the timeline window (default "Pre").

gt_output

Logical; if TRUE, also returns output formatted using gtsummary (default is TRUE).

Value

A list containing one or two summary data frames:

Summary by settings using dplyr

A descriptive summary of HCRU metrics by cohort, setting, and time window.

Summary by settings using gtsummary (optional)

Formatted summary statistics using gtsummary, if gt_output = TRUE.

Examples


df <- hcru_sample_data[sample(nrow(hcru_sample_data), 10), ]
estimate_hcru(data = df)


hcruR documentation built on Sept. 2, 2025, 1:09 a.m.