fhir_count_resource {fhircrackr} | R Documentation |
Get Resources' Counts
Description
Downloads a count of resources matching the resource type and search parameters specified in resource
and parameters
.
This function makes use of the _summary=count
parameter of FHIR search and is therefore able to count resources on the server
without actually downloading them.
Usage
fhir_count_resource(
base_url,
resource,
parameters = NULL,
username = NULL,
password = NULL,
token = NULL,
add_headers = NULL
)
Arguments
base_url |
A character vector of length one specifying the base URL of the FHIR server, e.g. |
resource |
A character vector of length one or fhir_resource_type object with the resource type to be searched, e.g. |
parameters |
Optional. Either a length 1 character vector containing properly formatted FHIR search parameters, e.g.
|
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 |
add_headers |
A named character vector of custom headers to add to the HTTP request, e.g. |
Details
For more information on authentication options, please see the help page of fhir_search()
Value
An integer of length 1 containing the number of resources matching the type and search parameters specified in resource
and parameters
.
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({
#number of female Patient resources on the server
fhir_count_resource(
base_url = 'https://vonk.fire.ly/R4',
resource = "Patient",
parameters = c(gender = "female"))
}, silent = TRUE)