Skip to contents

This function requests a growth chart from groeidiagrammen.nl. The function can upload a JSON file with BDS-format to the server, parse its contents into a tibble with a person attribute, and draw the plot. The user may skip uploading, and use a previously stored location on the server.

Usage

request_chart(
  txt = NULL,
  loc = NULL,
  host = "https://groeidiagrammen.nl",
  chartcode = NULL,
  selector = NULL,
  curve_interpolation = TRUE
)

Arguments

txt

A JSON string, URL or file with the data in JSON format. The input data adhere to specification BDS JGZ 3.2.5, and are converted to JSON according to schema.

loc

Alternative to txt. Location where input data is uploaded and converted to internal server format.

host

The host to which to upload

chartcode

The code of the requested growth chart. If not specified, the server will automatically plot child height for the most recent age period.

selector

Either "chartcode", "data" or "derive". See james::draw_chart() docs for more detail.

curve_interpolation

Logical. Smooth growth curve along centiles?

Value

An object of class httr::response()

Details

One of txt or resp need to be specified. If both are given, a non-NULL txt takes precedence over resp.

See also

Examples

if (FALSE) {
# examples with direct uploads
url <- "https://groeidiagrammen.nl/ocpu/library/james/testdata/client3.json"
fn <- system.file("testdata", "client3.json", package = "jamesclient")
host <- "http://localhost"

js1 <- readLines(fn)
js2 <- jsonlite::toJSON(jsonlite::fromJSON(fn), auto_unbox = TRUE)

# request default chart (PMAHN27)
resp1 <- request_chart(url, host = host)
# browseURL(get_url(resp1, "svglite"))

# request 30 weeks chart ((PMAHN30)
resp2 <- request_chart(url, host = host, chartcode = "PMAHN30")
resp3 <- request_chart(fn, host = host, chartcode = "PMAHN30")
resp4 <- request_chart(js1, host = host, chartcode = "PMAHN30")
resp5 <- request_chart(js2, host = host, chartcode = "PMAHN30")

# in two steps: first upload then request chart
resp6 <- upload_txt(fn, host = host)
loc <- get_url(resp6, "loc")
resp7 <- request_chart(loc = loc, host = host, chartcode = "PMAHN30")
}