fhir_get_resource_ids: Get Resources' IDs

View source: R/sample_resources.R

fhir_get_resource_idsR Documentation

Get Resources' IDs

Description

Download the resource (aka logical) IDs of all resources matching the FHIR search request build from the resource type and search parameters specified in resource and parameters. This function does not download the entire resources, but only extracts their IDs using the ⁠_elements⁠ parameter of FHIR Search.

Usage

fhir_get_resource_ids(
  base_url,
  resource,
  parameters = NULL,
  username = NULL,
  password = NULL,
  token = NULL,
  add_headers = NULL,
  verbose = 0
)

Arguments

base_url

A character vector of length one specifying the base URL of the FHIR server, e.g. "http://hapi.fhir.org/baseR4".

resource

A character vector of length one or fhir_resource_type object with the resource type to be searched, e.g. "Patient".

parameters

Optional. Either a length 1 character vector containing properly formatted FHIR search parameters, e.g. "gender=male&_summary=count" or a named list or named character vector e.g. list(gender="male", "_summary"="count") or c(gender="male", "_summary"="count"). Note that parameter names beginning with ⁠_⁠ have to be put in quotation marks!

username

A character vector of length one containing the username for basic authentication.

password

A character vector of length one containing the password for basic authentication.

token

A character vector of length one or object of class httr::Token, for bearer token authentication (e.g. OAuth2). See fhir_authenticate() for how to create this.

add_headers

A named character vector of custom headers to add to the HTTP request, e.g. c(myHeader = "somevalue") or c(firstHeader = "value1", secondHeader = "value2").

verbose

An integer of length 1 containing the level of verbosity. Defaults to 0.

Details

For more information on authentication options, please see the help page of fhir_search()

Value

A character vector containing the resource (aka logical) IDs of all requested resources.

See Also

fhir_search(), fhir_get_resources_by_ids()

Examples



#the try({}, silent = TRUE) statement is only there to catch errors when the server is down
#you can skip it when the server is reachable

try({

fhir_get_resource_ids(
  base_url   = 'https://vonk.fire.ly/R4',
  resource   = "Patient",
  parameters = "gender=female", verbose=1)

  }, silent = TRUE)

  

TPeschel/fhiR documentation built on April 14, 2024, 7:31 a.m.