Skip to contents

Calculate the total length of stay between start_date and end_date. If the end_date is missing then use the dummy discharge date.

Usage

calculate_stay(year, start_date, end_date, sc_qtr = NULL)

Arguments

year

The financial year in '1920' format

start_date

The admission/start date variable. e.g. record_keydate1

end_date

The discharge/end date variable. e.g. record_keydate2

sc_qtr

The latest submitted quarter. e.g. sc_latest_submission

Value

a tibble with additional variable stay. If there is no end date use dummy discharge to calculate the total length of stay. If there is no end date but sc_qtr is supplied then set this to the end of the quarter. If quarter end_date < start_date and sc_qtr is supplied then set this to the end of the next quarter.