knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 8, fig.height = 4.5, fig.align = 'center', out.width = '95%', dpi = 100 )
LICHospitalR: A toolkit for working with hospital data in R
In this vignette I will discuss how to obtain data on excess readmit rates from DSS.
First to get started, load in the LICHospitalR
library package into your R session:
library(LICHospitalR)
Once the package is loaded in, you can then start getting data from DSS and analyzing it. The first piece of code that you will use in order to get data from DSS is the function ts_readmit_excess_query()
. This function relies on a connection to DSS using the db_connect()
function that makes an odbc()
call out to DSS. This requires that the end user be able to make such a connection from their local desktop machine. This is typically done by having a connection file on your machine. You would normally find a connection file in the sample path here: C:\Users\bh_number_here\Documents\My Data Sources
. If you are having difficulties please file a help-desk ticket with Information Services.
Now lets see an example of getting the data, we will then glimpse()
the data in order to see what fields are returned and what their types are. This will require us to load the dplyr
library as well.
suppressPackageStartupMessages(library(dplyr)) ts_readmit_excess_query() %>% glimpse()
You will notice that this required nothing but a simple function call brings back the data starting from April 1st, 2016 as this is the date that the start of APR-DRG data is available for this purpose. The data also comes back properly formatted for further use.
Now lets take a look at this data summarised by time. We can do this by using the ts_readmit_excess_tbl()
table function.
By Month:
ts_readmit_excess_query() %>% ts_readmit_excess_tbl(.date_col = dsch_date, .by_time = "month")
By Week:
ts_readmit_excess_query() %>% ts_readmit_excess_tbl(.date_col = dsch_date, .by_time = "week")
We see that we can with ease change the time period with the ts_readmit_excess_tbl
by simply choosing things like year, month, or week for the .by_time
parameter.
Now lets simply plot the excess value.
suppressPackageStartupMessages(library(healthyR)) ts_readmit_excess_query() %>% ts_readmit_excess_tbl(.date_col = dsch_date, .by_time = "month") %>% ts_plt(.date_col = date_col, .value_col = value, .interactive = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.