Count the number of patients by interval

Counts the number of patients in each location, by the specified interval,
for the duration of the patient admission. Results can be returned as a
grand totals, grouped totals, or individual patient level per interval.

Arguments

Optional unique character vector to identify specific patient
location or responsible clinician at each interval, or at time of a change in
location / responsible clinician during the interval.

time_unit

Character string to denote time intervals to count by e.g.
"1 hour", "15 mins".

time_adjust_period

Optional argument which allows
the user to obtain a snapshot at a specific time of day by making slight
adjustments to the specified interval.
Possible values are "start_sec","start_min","end_sec", or "end_min".
For example, you may specify hourly intervals, but adjust these
to 1 minute past the hour with "start_min", or several seconds before the
end with "end_sec".

time_adjust_value

Optional. An integer to adjust the startor end of
each period in minutes or seconds, depending on the chosen
time_adjust_period (if specified).

results

A character string specifying the granularity of the results.

'patient' returns one row per patient, group_var and interval. The results
can be input to external tools for further analysis or visualisation.

'group' provides an overall grouped count of patients by the specified time
interval.

'total' returns the grand total of patients by each unique time interval.

uniques

Logical. Specifies how to deal with patients who move during
an interval, and subsequently have two or more records per interval.
Set "uniques" to TRUE to get a distinct count of patients per interval.
To be clear, TRUE will count patients only once per interval.

Setting "uniques" to FALSE will count each patient entry per interval.
If a patient moves during an interval then at least two rows will be returned
for tha patient for that particular interval.
This is useful if you want to count occupied beds, or track moves or
transfers between departments.

In general, if you use a grouping variable, set "uniques" to FALSE.

Value

data.table showing the patient identifier, the specified group
variable , and the count by the relevant unit of time.
Also included are the start and end of the interval, plus the date and
base hour for convenient interactive filtering of the results.