Learn R Programming

healthyR (version 0.1.4)

ts_census_los_daily_tbl: Time Series - Census and LOS by Day

Description

Sometimes it is important to know what the census was on any given day, or what the average length of stay is on given day, including for those patients that are not yet discharged. This can be easily achieved. This wil return one record for every account so the data will still need to be summarised.

This function can take a little bit of time to run while the join comparison runs.

Usage

ts_census_los_daily_tbl(
  .data,
  .keep_nulls_only = FALSE,
  .start_date_col,
  .end_date_col,
  .by_time = "day"
)

Arguments

.data

The data you want to pass to the function

.keep_nulls_only

A boolean that will keep only those records that have a NULL end date, meaning the patient is still admitted. The default is FALSE which brings back all records.

.start_date_col

The column containing the start date for the record

.end_date_col

The column containing the end date for the record.

.by_time

How you want the data presented, defaults to day and should remain that way unless you need more granular data.

Value

A tibble object

Details

  • Requires a dataset that has at least a start date column and an end date column

  • Takes a single boolean parameter

Examples

Run this code
# NOT RUN {
library(healthyR)
library(healthyR.data)
library(dplyr)

df <- healthyR_data

df_tbl <- df %>%
  filter(ip_op_flag == "I") %>%
  select(visit_start_date_time, visit_end_date_time) %>%
  timetk::filter_by_time(.date_var = visit_start_date_time, .start_date = "2020")

ts_census_los_daily_tbl(
   .data              = df_tbl
   , .keep_nulls_only = FALSE
   , .start_date_col  = visit_start_date_time
   , .end_date_col    = visit_end_date_time
)

# }

Run the code above in your browser using DataLab