-
Notifications
You must be signed in to change notification settings - Fork 3
/
ts_census_los_daily_tbl.Rd
77 lines (66 loc) · 2.4 KB
/
ts_census_los_daily_tbl.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ts-census-los-tbl.R
\name{ts_census_los_daily_tbl}
\alias{ts_census_los_daily_tbl}
\title{Time Series - Census and LOS by Day}
\usage{
ts_census_los_daily_tbl(
.data,
.keep_nulls_only = FALSE,
.start_date_col,
.end_date_col,
.by_time = "day"
)
}
\arguments{
\item{.data}{The data you want to pass to the function}
\item{.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.}
\item{.start_date_col}{The column containing the start date for the record}
\item{.end_date_col}{The column containing the end date for the record.}
\item{.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
}
\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 will return one
record for every account so the data will still need to be summarized. If there
are multiple entries per day then those records will show up and you will
therefore have multiple entries in the column \code{date} in the resulting \code{tibble}.
If you want to aggregate from there you should be able to do so easily.
If you have a record where the \code{.start_date_col} is filled in but the corresponding
\code{end_date} is null then the end date will be set equal to \code{Sys.Date()}
If a record has a \code{start_date} that is \code{NA} then it will be discarded.
\strong{This function can take a little bit of time to run while the join comparison runs.}
}
\details{
\itemize{
\item Requires a dataset that has at least a start date column and an end date
column
\item Takes a single boolean parameter
}
}
\examples{
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
)
}
\author{
Steven P. Sanderson II, MPH
}