View source: R/sample_resources.R
| fhir_count_resource | R Documentation | 
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.
fhir_count_resource(
  base_url,
  resource,
  parameters = NULL,
  username = NULL,
  password = NULL,
  token = NULL,
  add_headers = NULL
)
| 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.  | 
For more information on authentication options, please see the help page of fhir_search()
An integer of length 1 containing the number of resources matching the type and search parameters specified in resource and parameters.
#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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.