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.
See also
Other date functions:
compute_mid_year_age(),
convert_date_to_numeric(),
convert_numeric_to_date(),
end_fy(),
end_fy_quarter(),
end_next_fy_quarter(),
fy_interval(),
is_date_in_fyyear(),
last_date_month(),
midpoint_fy(),
next_fy(),
start_fy(),
start_fy_quarter(),
start_next_fy_quarter()