logo

Introduction

Last month, we announced the release of the Rnssp R package which facilitates access to the ESSENCE system via a secure and simple interface. Rnssp provides methods that streamline the data pull and simplify R code previously required by users to pull data via the APIs using the keyring library. In this tutorial, we specifically show how to pull data from the ESSENCE system using Rnssp.

The Rnssp package is yet to be released on CRAN and can be installed from its Github repository. You may download the latest pre-packaged version 0.0.2 (Rnssp_0.0.2.tar.gz) and manually install it.

To install the development version of the Rnssp package from Github, run the following code in your R console:

# install the Rnssp package
devtools::install_github("cdcgov/Rnssp")

Alternatively, the package can also be installed using the remotes package:

# install the Rnssp package
remotes::install_github("cdcgov/Rnssp")

The ESSENCE APIs

An application programming interface, or API, is a structured and consistent way for one machine to exchange information with another machine. ESSENCE has APIs that allow you to programmatically access and further manipulate your data from outside the system. You may select the CSV format to export data, and in some instances JSON is also supported. More information about the APIs can be found in ESSENCE under “More”, then “User Guide”, and then API Documentation. You may write API URL syntax on your own after reading the documentation, or you can let ESSENCE create the API URL by clicking the “API URL” button on an ESSENCE page after completing a query. Currently, the ESSENCE system offers using the following ESSENCE APIs:

  1. Time series data table,
  2. Time series png image,
  3. Table builder results,
  4. Data details (line level),
  5. Summary stats
  6. Alert list detection table
  7. Time series data table with stratified, historical alerts (from ESSENCE2)

Creating an NSSP user profile

We start by loading the Rnssp package.

# Loading useful R packages...
library(Rnssp)

To pull data from ESSENCE, you will need to authenticate to the system with your user credentials. For this reason, you will have to create an NSSP user profile. Rnssp provides a Credentials class, which is an abstraction of the user’s NSSP profile. By creating an instance of the Credentials class, you will be prompted to enter your Access and Management Center (AMC) username and password.

Run the following code to create a user profile:

# Creating an ESSENCE user profile
myProfile <- Credentials$new(
  username = askme("Enter your username: "), 
  password = askme()
)

# save profile object to file for future use
# save(myProfile, "myProfile.rda") # saveRDS(myProfile, "myProfile.rds")
# Load profile object
# load("myProfile.rda") # myProfile <- readRDS("myProfile.rds")

The above code needs to be executed only once. Upon execution, it prompts the user to provide their username and password. Although, the username and password can be directly provided in plain text, we highly recommend the use of the askme() function to interactively enter the user NSSP credentials (as shown above).

Alternatively, the myProfile object can be saved on file as an .RData (.rda) or .rds file and loaded to automate Rmarkdown reports generation.

Be assured that your password is highly protected and completely insulated from being accessible in plain text. In fact, both password and username are fully encrypted, even the encrypted texts are not available for display as shown (below) when the myProfile object is inspected.

# Inspecting the myProfile object
myProfile
#> <NSSPCredentials>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     get_api_data: function (url, fromCSV = FALSE, ...) 
#>     get_api_response: function (url) 
#>     get_api_tsgraph: function (url) 
#>     initialize: function (username, password) 
#>   Private:
#>     ..__: NSSPContainer, R6
#>     ..password: NSSPContainer, R6
#>     ..username: NSSPContainer, R6
# Alternatively, you may look at the structure of the myProfile object
str(myProfile) # or `structure(myProfile)`
#> Classes 'NSSPCredentials', 'R6' <NSSPCredentials>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     get_api_data: function (url, fromCSV = FALSE, ...) 
#>     get_api_response: function (url) 
#>     get_api_tsgraph: function (url) 
#>     initialize: function (username, password) 
#>   Private:
#>     ..__: NSSPContainer, R6
#>     ..password: NSSPContainer, R6
#>     ..username: NSSPContainer, R6

The created myProfile object comes with the $get_api_response(), the $get_api_data(), and the $get_api_tsgraph() methods with various parameters to pull ESSENCE data. For full documentation on all the methods available, execute the help(Credentials) or ?Credentials command in the R console.

In the following sections, we show how to pull data from ESSENCE using the seven ESSENCE APIs.

1 Time Series Data Table

# URL from ESSENCE JSON Time Series Data Table API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/timeSeries?endDate=9Feb2021&medicalGrouping=injury&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=probrepswitch&startDate=11Nov2020&timeResolution=daily&medicalGroupingSystem=essencesyndromes&userId=455&aqtTarget=TimeSeries"

# pull time series data
api_data_ts <- myProfile$get_api_data(url)

class(api_data_ts)
#> [1] "list"
names(api_data_ts)
#> [1] "title"          "timeSeriesData"
glimpse(api_data_ts$timeSeriesData)
#> Rows: 91
#> Columns: 8
#> $ date     <chr> "2020-11-11", "2020-11-12", "2020-11-13", "2020-11-14", "202…
#> $ count    <dbl> 40197, 38835, 38925, 37457, 35079, 40420, 37811, 37307, 3735…
#> $ expected <chr> "40720", "40718.107", "40702.25", "40627.536", "40552.286", …
#> $ levels   <chr> "0.226", "0.73", "0.913", "0.991", "1", "0.615", "0.952", "0…
#> $ colorID  <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
#> $ color    <chr> "blue", "blue", "blue", "blue", "blue", "blue", "blue", "blu…
#> $ altText  <chr> "Data: Date: 11Nov20, Level: 0.226, Count: 40197, Expected: …
#> $ details  <chr> "/nssp_essence/api/dataDetails?medicalGrouping=injury&percen…

Alternatively, the example below could be performed via the $get_api_response() method (as shown below), but with extra steps:

# URL from ESSENCE JSON Time Series Data Table API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/timeSeries?endDate=9Feb2021&medicalGrouping=injury&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=probrepswitch&startDate=11Nov2020&timeResolution=daily&medicalGroupingSystem=essencesyndromes&userId=455&aqtTarget=TimeSeries"

# pull time series data
api_response <- myProfile$get_api_response(url) 

api_response_content <- httr::content(api_response, as = "text")
api_data_ts2 <- jsonlite::fromJSON(api_response_content)

class(api_data_ts2)
#> [1] "list"
names(api_data_ts2$timeSeriesData)
#> [1] "date"     "count"    "expected" "levels"   "colorID"  "color"    "altText" 
#> [8] "details"

glimpse(api_data_ts2$timeSeriesData)
#> Rows: 91
#> Columns: 8
#> $ date     <chr> "2020-11-11", "2020-11-12", "2020-11-13", "2020-11-14", "202…
#> $ count    <dbl> 40197, 38835, 38925, 37457, 35079, 40420, 37811, 37307, 3735…
#> $ expected <chr> "40720", "40718.107", "40702.25", "40627.536", "40552.286", …
#> $ levels   <chr> "0.226", "0.73", "0.913", "0.991", "1", "0.615", "0.952", "0…
#> $ colorID  <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
#> $ color    <chr> "blue", "blue", "blue", "blue", "blue", "blue", "blue", "blu…
#> $ altText  <chr> "Data: Date: 11Nov20, Level: 0.226, Count: 40197, Expected: …
#> $ details  <chr> "/nssp_essence/api/dataDetails?medicalGrouping=injury&percen…

Although we present the alternate code above, the following sections will only demonstrate the direct approach using the $get_api_data() method. The alternate code can nevertheless be easily adapted to the other types of ESSENCE API data pulls.

2 Time Series Graph from ESSENCE

The example below shows how to retrieve the Time Series Graph from ESSENCE and insert it in the RMarkdown report.

# URL from ESSENCE Time Series Graph from ESSENCE API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/timeSeries/graph?endDate=9Feb2021&medicalGrouping=injury&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=probrepswitch&startDate=11Nov2020&timeResolution=daily&medicalGroupingSystem=essencesyndromes&userId=455&aqtTarget=TimeSeries&graphTitle=National%20-%20Injury%20Syndrome%20Daily%20Counts&xAxisLabel=Date&yAxisLabel=Count"

# Data pull from ESSENCE
api_data_graph <- myProfile$get_api_tsgraph(url)

# Inspecting api_data_graph object
class(api_data_graph)
#> [1] "list"
names(api_data_graph)
#> [1] "api_response" "tsgraph"

# Inserting graph in the report
knitr::include_graphics(api_data_graph$tsgraph)

3 Table Builder Results

The CSV option of the Table Builder Results API pulls in data in the tabular format seen on ESSENCE. The JSON option on the other hand, pulls in the data in a long, pivoted format. In the following subsections, we demonstrate how to pull the Table Builder results data with both options.

3.1 CSV option

# URL from CSV ESSENCE Table Builder results API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/tableBuilder/csv?endDate=31Dec2020&ccddCategory=cdc%20opioid%20overdose%20v3&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=nodetectordetector&startDate=1Oct2020&ageNCHS=11-14&ageNCHS=15-24&ageNCHS=25-34&ageNCHS=35-44&ageNCHS=45-54&ageNCHS=55-64&ageNCHS=65-74&ageNCHS=75-84&ageNCHS=85-1000&ageNCHS=unknown&timeResolution=monthly&hasBeenE=1&medicalGroupingSystem=essencesyndromes&userId=455&aqtTarget=TableBuilder&rowFields=timeResolution&rowFields=geographyhospitaldhhsregion&columnField=ageNCHS"

# Data Pull from ESSENCE
api_data_tb_csv <- myProfile$get_api_data(url, fromCSV = TRUE)

# Inspecting api_data_graph object
class(api_data_tb_csv) 
#> [1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame"

glimpse(api_data_tb_csv)
#> Rows: 33
#> Columns: 12
#> $ timeResolution              <chr> "2020-10", "2020-10", "2020-10", "2020-10…
#> $ geographyhospitaldhhsregion <chr> "OTHER_REGION", "Region 1", "Region 10", …
#> $ `11-14`                     <dbl> 0, 1, 2, 0, 3, 6, 7, 1, 1, 2, 5, 0, 0, 4,…
#> $ `15-24`                     <dbl> 0, 129, 118, 133, 246, 602, 347, 158, 46,…
#> $ `25-34`                     <dbl> 0, 478, 277, 426, 803, 1921, 1153, 326, 8…
#> $ `35-44`                     <dbl> 0, 408, 163, 316, 661, 1567, 822, 273, 46…
#> $ `45-54`                     <dbl> 0, 327, 125, 287, 491, 910, 669, 150, 33,…
#> $ `55-64`                     <dbl> 0, 261, 168, 264, 465, 895, 679, 149, 36,…
#> $ `65-74`                     <dbl> 0, 70, 145, 87, 193, 441, 294, 66, 15, 55…
#> $ `75-84`                     <dbl> 0, 25, 45, 13, 39, 211, 52, 32, 11, 24, 5…
#> $ `85+`                       <dbl> 0, 39, 18, 11, 51, 82, 35, 9, 4, 6, 14, 0…
#> $ Unknown                     <dbl> 0, 4, 10, 6, 6, 37, 19, 4, 3, 1, 3, 0, 8,…

3.2 JSON option

# URL from JSON ESSENCE Table Builder results API
url <- "https://essence2.syndromicsurveillance.org/nssp_essence/api/tableBuilder?endDate=31Dec2020&ccddCategory=cdc%20opioid%20overdose%20v3&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=nodetectordetector&startDate=1Oct2020&ageNCHS=11-14&ageNCHS=15-24&ageNCHS=25-34&ageNCHS=35-44&ageNCHS=45-54&ageNCHS=55-64&ageNCHS=65-74&ageNCHS=75-84&ageNCHS=85-1000&ageNCHS=unknown&timeResolution=monthly&hasBeenE=1&medicalGroupingSystem=essencesyndromes&userId=2362&aqtTarget=TableBuilder&rowFields=timeResolution&rowFields=geographyhospitaldhhsregion&columnField=ageNCHS"

# Data Pull from ESSENCE
api_data_tb_json <- myProfile$get_api_data(url)

class(api_data_tb_json)
#> [1] "data.frame"
names(api_data_tb_json)
#> [1] "timeResolution"              "geographyhospitaldhhsregion"
#> [3] "ageNCHS"                     "count"

glimpse(api_data_tb_json)
#> Rows: 330
#> Columns: 4
#> $ timeResolution              <chr> "2020-10", "2020-10", "2020-10", "2020-10…
#> $ geographyhospitaldhhsregion <chr> "OTHER_REGION", "OTHER_REGION", "OTHER_RE…
#> $ ageNCHS                     <chr> "11-14", "15-24", "25-34", "35-44", "45-5…
#> $ count                       <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 129, 478…

4 Data Details (line level)

Similarly to the Table builder Results API, the Data Details (line level) provides CSV and JSON data outputs.

4.1 CSV option

# URL from CSV ESSENCE Data Details (line level) API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/dataDetails/csv?medicalGrouping=injury&geography=region%20i&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=probrepswitch&timeResolution=daily&medicalGroupingSystem=essencesyndromes&userId=455&aqtTarget=TimeSeries&startDate=31Jan2021&endDate=31Jan2021"

# Data Pull from ESSENCE
api_data_dd_csv <- myProfile$get_api_data(url, fromCSV = TRUE)

class(api_data_dd_csv)  
#> [1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame"

glimpse(api_data_dd_csv)
#> Rows: 2,049
#> Columns: 19
#> $ Date                  <chr> "01/31/2021", "01/31/2021", "01/31/2021", "01/3…
#> $ Category_flat         <chr> ";Injury;", ";Injury;", ";Injury;", ";Injury;",…
#> $ SubCategory_flat      <chr> ";Electrocution;", ";Fall;", ";BiteOrSting;", "…
#> $ Patient_Class         <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "E…
#> $ HospitalDHHSRegion    <chr> "Region I", "Region I", "Region I", "Region I",…
#> $ dhhsregion            <chr> "Region I", "Region I", "Region I", "OTHER_REGI…
#> $ AgeGroup              <chr> "Unknown", "Unknown", "Unknown", "Unknown", "00…
#> $ Sex                   <chr> "F", "F", "F", "M", "M", "F", "M", "M", "F", "F…
#> $ DispositionCategory   <chr> "DISCHARGED", "DISCHARGED", "none", "DISCHARGED…
#> $ AdmissionTypeCategory <chr> "E", "E", "NR", "NR", "NR", "NR", "NR", "NR", "…
#> $ HasBeenE              <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ HasBeenI              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ HasBeenO              <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ DDAvailable           <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ DDInformative         <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ CCAvailable           <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ CCInformative         <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ FirstDateTimeAdded    <dttm> 2021-01-31 23:12:22, 2021-01-31 23:12:22, 2021…
#> $ HasBeenAdmitted       <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…

4.2 JSON option

# URL from JSON ESSENCE Data Details (line level) API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/dataDetails?endDate=31Jan2021&medicalGrouping=injury&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=probrepswitch&startDate=31Jan2021&timeResolution=daily&medicalGroupingSystem=essencesyndromes&userId=455&aqtTarget=DataDetails"

# Data Pull from ESSENCE
api_data_dd_json <- myProfile$get_api_data(url)

class(api_data_dd_json)
#> [1] "list"
names(api_data_dd_json)
#> [1] "dataDetails"

glimpse(api_data_dd_json$dataDetails)
#> Rows: 31,933
#> Columns: 19
#> $ Date                  <chr> "01/31/2021", "01/31/2021", "01/31/2021", "01/3…
#> $ Category_flat         <chr> ";Injury;", ";Injury;", ";Injury;", ";Injury;",…
#> $ SubCategory_flat      <chr> ";Fall;", ";CutOrPierce;", ";SuicideOrSelfInfli…
#> $ Patient_Class         <chr> "I", "E", "E", "E", "E", "E", "E", "E", "E", "E…
#> $ HospitalDHHSRegion    <chr> "Region V", "Region V", "Region V", "Region V",…
#> $ dhhsregion            <chr> "Region V", "Region V", "Region V", "Region V",…
#> $ AgeGroup              <chr> "Unknown", "Unknown", "Unknown", "Unknown", "Un…
#> $ Sex                   <chr> "F", "M", "F", "M", "M", "F", "M", "M", "M", "F…
#> $ DispositionCategory   <chr> "TRANSFERRED", "DISCHARGED", "DISCHARGED", "DIS…
#> $ AdmissionTypeCategory <chr> "NR", "NR", "NR", "NR", "NR", "NR", "NR", "NR",…
#> $ HasBeenE              <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
#> $ HasBeenI              <chr> "1", "0", "0", "0", "0", "0", "0", "0", "0", "0…
#> $ HasBeenO              <chr> "0", "0", "0", "0", "0", "0", "0", "0", "0", "0…
#> $ DDAvailable           <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
#> $ DDInformative         <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
#> $ CCAvailable           <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
#> $ CCInformative         <chr> "1", "1", "1", "1", "1", "1", "1", "1", "1", "1…
#> $ FirstDateTimeAdded    <chr> "2021-02-01 06:13:51.63", "2021-02-01 06:13:51.…
#> $ HasBeenAdmitted       <chr> "1", "0", "0", "0", "0", "0", "0", "0", "0", "0…

The Summary Stats ESSENCE API counts regions (or, “counties” in ESSENCE) and facilities in a query by whatever time resolution is defined (daily, weekly, monthly, quarterly, or yearly). Note that the Summary Stats API is only available on full details data sources (the only data sources that expose this level of information). This API is particularly useful for understanding the number of hospitals with results in a query.

5 Summary Stats

# URL from JSON ESSENCE Summary Stats API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/summaryData?endDate=31Jan2021&medicalGrouping=injury&geography=region%20i&percentParam=noPercent&geographySystem=hospitaldhhsregion&datasource=va_hosp&detector=probrepswitch&startDate=29Jan2021&timeResolution=daily&medicalGroupingSystem=essencesyndromes&userId=455&aqtTarget=TimeSeries"

# Data Pull from ESSENCE
api_data_ss <- myProfile$get_api_data(url)

class(api_data_ss)
#> [1] "list"
names(api_data_ss)
#> [1] "summaryData"

glimpse(api_data_ss$summaryData)
#> Rows: 3
#> Columns: 5
#> $ date          <chr> "29Jan21", "30Jan21", "31Jan21"
#> $ HospitalState <dbl> 6, 6, 6
#> $ State         <dbl> 16, 18, 19
#> $ Region        <dbl> 91, 93, 97
#> $ Hospital      <dbl> 204, 203, 200

6 Alert List Detection Table

Since the Alert List API provides programmatic access to the Alert List table on the ESSENCE user interface by patient region or by hospital regions, we provide two use cases of data pull in the following subsections:

6.1 Alert List Detection Table by Patient Region

# URL from JSON ESSENCE Alert List Detection Table API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/alerts/regionSyndromeAlerts?end_date=31Jan2021&start_date=29Jan2021"

# Data Pull from ESSENCE
api_data_alr <- myProfile$get_api_data(url)

class(api_data_alr)
#> [1] "list"
names(api_data_alr)
#> [1] "regionSyndromeAlerts"

glimpse(api_data_alr$regionSyndromeAlerts)
#> Rows: 14,474
#> Columns: 12
#> $ date                <chr> "2021-01-31", "2021-01-31", "2021-01-30", "2021-0…
#> $ datasource          <chr> "va_er", "va_er", "va_er", "va_er", "va_er", "va_…
#> $ age                 <chr> "all", "all", "all", "all", "all", "00-04", "05-1…
#> $ sex                 <chr> "all", "all", "all", "all", "all", "all", "all", …
#> $ detector            <chr> "probrepswitch", "probrepswitch", "probrepswitch"…
#> $ level               <dbl> 0.0496388110, 0.0425316906, 0.0371335163, 0.00878…
#> $ count               <int> 8, 7, 8, 13, 8, 1, 1, 3, 1, 1, 3, 1, 2, 2, 4, 1, …
#> $ expected            <dbl> 4.0714286, 2.9642857, 3.9285714, 5.7857143, 3.035…
#> $ region              <chr> "KY_Daviess", "AL_Pickens", "AL_Pickens", "AL_Pic…
#> $ syndrome            <chr> "Bot_Like", "Neuro", "Injury", "GI", "Neuro", "In…
#> $ timeResolution      <chr> "daily", "daily", "daily", "daily", "daily", "dai…
#> $ `observed/expected` <dbl> 1.964912, 2.361446, 2.036364, 2.246914, 2.635294,…

6.2 Alert List Detection Table by Hospital Region

# URL from JSON ESSENCE Alert List Detection Table API
url <- "https://essence.syndromicsurveillance.org/nssp_essence/api/alerts/hospitalSyndromeAlerts?end_date=30Jun2021&start_date=28Jun2021"

# Data Pull from ESSENCE
api_data_alh <- myProfile$get_api_data(url) %>%
  pluck("hospitalSyndromeAlerts")

class(api_data_alh)
#> [1] "data.frame"
names(api_data_alh)
#>  [1] "date"             "datasource"       "age"              "sex"             
#>  [5] "detector"         "level"            "count"            "expected"        
#>  [9] "hospitalName"     "regionOfHospital" "syndrome"         "hospital"        
#> [13] "timeResolution"

glimpse(api_data_alh %>% select(-hospitalName, -regionOfHospital))
#> Rows: 44,440
#> Columns: 11
#> $ date           <chr> "2021-06-29", "2021-06-29", "2021-06-30", "2021-06-29"…
#> $ datasource     <chr> "va_hosp", "va_hosp", "va_hosp", "va_hosp", "va_hosp",…
#> $ age            <chr> "05-17", "65-1000", "65-1000", "45-64", "65-1000", "al…
#> $ sex            <chr> "all", "all", "all", "all", "all", "all", "all", "all"…
#> $ detector       <chr> "probrepswitch", "probrepswitch", "probrepswitch", "pr…
#> $ level          <dbl> 0.0444196783, 0.0120779855, 0.0327493054, 0.0385253878…
#> $ count          <int> 1, 3, 2, 1, 3, 2, 2, 4, 2, 1, 1, 1, 2, 2, 2, 8, 1, 1, …
#> $ expected       <dbl> 0.35714286, 0.57142857, 0.39285714, 0.14285714, 0.7142…
#> $ syndrome       <chr> "Resp", "Resp", "Neuro", "Injury", "GI", "Shk_coma", "…
#> $ hospital       <chr> "28935", "28942", "28958", "28963", "28963", "28925", …
#> $ timeResolution <chr> "daily", "daily", "daily", "daily", "daily", "daily", …

7 Time series data table with stratified, historical alerts (from ESSENCE2)

This functionality as of July 23, 2021 is available from ESSENCE2.

# URL from JSON ESSENCE Time series data table with stratified, historical alerts API
url <- "https://essence2.syndromicsurveillance.org/nssp_essence/api/timeSeries?endDate=9Feb2021&ccddCategory=cdc%20pneumonia%20ccdd%20v1&ccddCategory=cdc%20coronavirus-dd%20v1&ccddCategory=cli%20cc%20with%20cli%20dd%20and%20coronavirus%20dd%20v2&percentParam=ccddCategory&geographySystem=hospitaldhhsregion&datasource=va_hospdreg&detector=probrepswitch&startDate=11Nov2020&timeResolution=daily&hasBeenE=1&medicalGroupingSystem=essencesyndromes&userId=2362&aqtTarget=TimeSeries&stratVal=ccddCategory&multiStratVal=geography&graphOnly=true&numSeries=3&graphOptions=multipleSmall&seriesPerYear=false&nonZeroComposite=false&removeZeroSeries=true&startMonth=January&stratVal=ccddCategory&multiStratVal=geography&graphOnly=true&numSeries=3&graphOptions=multipleSmall&seriesPerYear=false&startMonth=January&nonZeroComposite=false"

# Data Pull from ESSENCE
api_data_tssh <- myProfile$get_api_data(url)

class(api_data_tssh)
#> [1] "list"
names(api_data_tssh)
#> [1] "timeSeriesData"

glimpse(api_data_tssh$timeSeriesData)
#> Rows: 2,730
#> Columns: 21
#> $ date                       <chr> "2020-11-11", "2020-11-12", "2020-11-13", …
#> $ count                      <dbl> 1.713316, 1.828619, 1.752491, 1.775573, 2.…
#> $ expected                   <chr> "1.484", "1.493", "1.791", "1.732", "1.805…
#> $ levels                     <chr> "0.217", "0.177", "0.526", "0.471", "0.313…
#> $ colorID                    <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
#> $ color                      <chr> "blue", "blue", "blue", "blue", "blue", "b…
#> $ altText                    <chr> "Data: Date: 11Nov20, Level: 0.217, Count:…
#> $ details                    <chr> "/nssp_essence/servlet/DataDetailsServlet?…
#> $ graphType                  <chr> "percent", "percent", "percent", "percent"…
#> $ dataCount                  <dbl> 303, 309, 292, 272, 305, 385, 360, 313, 30…
#> $ expected_dataCount         <dbl> 239.0000, 307.4345, 301.8204, 278.2955, 29…
#> $ levels_dataCount           <dbl> 0.001311789, 0.467663208, 0.690271447, 0.6…
#> $ colorID_dataCount          <int> 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, …
#> $ color_dataCount            <chr> "red", "blue", "blue", "blue", "blue", "re…
#> $ allCount                   <dbl> 17685, 16898, 16662, 15319, 14556, 17987, …
#> $ lineLabel                  <chr> "CDC Pneumonia CCDD v1 - Region 1", "CDC P…
#> $ title                      <chr> "CDC Pneumonia CCDD v1 - Region 1", "CDC P…
#> $ ccddCategory_id            <chr> "CDC Pneumonia CCDD v1", "CDC Pneumonia CC…
#> $ ccddCategory_display       <chr> "CDC Pneumonia CCDD v1", "CDC Pneumonia CC…
#> $ hospitaldhhsregion_id      <chr> "Region I", "Region I", "Region I", "Regio…
#> $ hospitaldhhsregion_display <chr> "Region 1", "Region 1", "Region 1", "Regio…