get_wait_times: Get wait times for emergencies, consultations, and surgeries...

Description Usage Arguments Value Examples

View source: R/get_wait_times.R

Description

This function provides a wrapper to the API endpoints for getting the live wait times for emergencies, consultations, and surgeries at the following domain: http://tempos.min-saude.pt. get_wait_times_all runs this function on all existing ids.

Usage

1
2
3
get_wait_times(hospital_id = NULL, output_format = c("json",
  "data_frame"), request_headers = NULL, data_type = c("emergency",
  "consultation", "surgery"))

Arguments

hospital_id

Integer containing the hospital id, get it through get_hospital_metadata under the collumn id

output_format

defines the format of the final output resulting form the API call. Two options: (1) output_format = "data_frame" returns a tibble object; (2) output_format = "json" returns the data as a json file

request_headers

named character vector with the HTTP headers to be added to GET via add_headers. Defaults to NULL

data_type

Character string determining the type of data to request. Can be either (1) "emergency", (2) "consultation", or "surgery"

Value

json string or tibble containing the relevant metadata. The relevant wait times for "emergency" are in both seconds as integer or ymd_hms. For "consultation" or "surgery" they unit of analysis is day as integer. All datasets also contain a variable measuring wait times by the number of people waiting.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(jsonlite)
library(esperaR)

## Not run: 
library(ggplot2)
## extract emergency data as a data frame
wait_dta <- get_wait_times(hospital_id = 333,
                          output_format = "data_frame",
                          request_headers = NULL
                          data_type = "emergency")

wait_dta %>%
 ggplot(aes(triage_type, wait_time_secs)) +
 geom_boxplot()

## End(Not run)

josemreis/esperaR documentation built on March 31, 2020, 1:50 a.m.