Downloads all FHIR bundles of a FHIR search request from a FHIR server.
fhir_search(
request,
username = NULL,
password = NULL,
max_bundles = Inf,
verbose = 1,
max_attempts = 5,
delay_between_attempts = 10,
log_errors = 0,
save_to_disc = FALSE,
directory = paste0("FHIR_bundles_", gsub("-| |:", "", Sys.time()))
)A string containing the full FHIR search request.
A string containing the username for basic authentication. Defaults to NULL, meaning no authentication.
A string containing the password for basic authentication. Defaults to NULL, meaning no authentication.
Maximal number of bundles to get. Defaults to Inf meaning all available bundles are downloaded.
An Integer Scalar. If 0, nothings is printed, if 1, only finishing message is printed, if > 1, downloading progress will be printed. Defaults to 2.
A numeric scalar. The maximal number of attempts to send a request, defaults to 5.
A numeric scalar specifying the delay in seconds between two attempts. Defaults to 10.
Takes values 0, 1 or 2. Controls the logging of errors. 1 and 2 will write a file to the current working directory.
0: no logging of errors,
1: tabulate http response and write to csv-file
2: write http response as to xml-file
A logical scalar. If TRUE the bundles are saved as numerated xml-files into the directory specified
in the argument directory and not returned as a bundle list in the R session. This is useful when a lot of
bundles are to be downloaded and keeping them all in one R session might overburden working memory. When download
is complete, the bundles can be loaded into R using fhir_load. Defaults to FALSE, i.e. bundles are
returned as a list within the R session.
The directory the bundles are saved to when save_to_disc is TRUE. Defaults to creating a
time-stamped directory into the current working directory.
A list of bundles in xml format when save_to_disc = FALSE (the default), else NULL.
# NOT RUN {
bundles <- fhir_search("https://hapi.fhir.org/baseR4/Medication?", max_bundles=3)
# }
Run the code above in your browser using DataLab