library(knitr) library(ccdm) knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of ccdm is to facilitate the use of the Core Clinical Data Model (Core CDM) and other data sources
in the Cloud Data Warehouse (CDW).
To install ccdm, the package remotes is required, and can be installed with install.packages("remotes").
If you are able to access GitHub.com, you can then install cddm on RStudio from GitHub with:
remotes::install_github("RollieParrish/ccdm")
Network security settings may prevent remotes::install_github() from accessing GitHub.com. If this is the case, ccdm can be installed by downloading the Package Archive and running the following code (replacing the section marked <>, including the arrows themselves):
remotes::install_local("<FILEPATH OF ccdm.*.tar.gz FILE>")
include_graphics("RStudio_install.png")
This package assumes that:
First, set up the connection to the CDW.
library(dplyr, warn.conflicts = FALSE) library(ccdm) conn <- connect_cdw()
The ccdm_tbl() function is use to create pointers to Core CDM tables. The conn connection defined above must be passed as the first parameter, followed by the name of a table. If a name is not specified, then a list of available tables will be displayed.
ccdm_tbl(conn)
Next we need to set up a pointer to a remote tables in Core CDM. HOSPITAL_ENCOUNTERS is the primary table and will probably used for most analytics projects.
Note: data has been de-identified and truncated to just a few columns in the examples below
hosp_enc <- ccdm_tbl(conn, "HOSPITAL_ENCOUNTERS") hosp_enc
hosp_enc <- ccdm_tbl(conn, "HOSPITAL_ENCOUNTERS") %>% filter(ARRIVAL_DT == "2020-02-22") %>% filter(FACILITY_CD == "PSHMC") %>% filter(!is.na(AGE)) %>% filter(!is.na(ARRIVAL_DTS)) %>% select(PAT_ENC_CSN_ID, AGE, SEX, FACILITY_CD, ACCOUNT_CLASS, ARRIVAL_DTS) %>% head() %>% collect() %>% mutate( PAT_ENC_CSN_ID = gsub("150[0-9]{6}", "150xxx", PAT_ENC_CSN_ID), ARRIVAL_DTS = gsub("2020.*22", "yyyy-mm-dd", ARRIVAL_DTS)) %>% arrange(PAT_ENC_CSN_ID) hosp_enc %>% kable()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.