get_hospital_metadata: Get metadata on all hospitals covered by the "tempos" API

Description Usage Arguments Value Examples

View source: R/get_hospital_metadata.R

Description

This function provides a wrapper to the 'api.php/institution' endpoint from the following domain: http://tempos.min-saude.pt. Crucial for extracting the wait times, see get_wait_times has it contains the "hospital id"s as well as logical variables for the data available per website

Usage

1
2
get_hospital_metadata(output_format = c("json", "data_frame"),
  request_headers = "")

Arguments

output_format

Character which 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

Value

json string or tibble containing the relevant metadata.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
library(esperaR)
library(jsonlite)

## pull the metadata as a json file
hospital_meta_json <- get_hospital_metadata(output_format = "json")

prettify(hospital_meta_json)

## Adding a user-agent header to the get request and returning a tibble
hospital_meta_df <- get_hospital_metadata(output_format = "data_frame", request_headers = list("User-Agent" = "Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"))


## End(Not run)

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