Data analysis in healthcare is often about large volumes of data. The current FHIR API works excellent for retrieving small amounts of data, but for retrieving larger volumes of data it can be inefficient. The main reason for this is the fact that the current FHIR API only supports synchronous calls and returns paged results. Exactly this problem is tackled in the FHIR Bulk Data API proposal. The FHIR Bulk Data API makes asynchronous calls possible and returns the results as new line delimited JSON (ndjson).
The newest version of R on FHIR implements the specifications of the FHIR Bulk Data API proposal. It is now possible to fetch bulk data from all patients, a cohort of patients, or all available data on a FHIR Bulk Data server with R on FHIR and start analyzing it with all tools R has to offer. You can copy paste the example below in your R console and run it to see how easily it works. See the documentation for more features and examples, including authorization. Feel free to join the development of R on FHIR on GitHub.
install.packages("RonFHIR") library(RonFHIR) # Initialize a fhirBulkClient object bulkclient <- fhirBulkClient$new("https://bulk-data.smarthealthit.org/eyJlcnIiOiIiLCJwYWdlIjoxMDAwMCwiZHVyIjoxMCwidGx0IjoxNSwibSI6MX0/fhir/") # Request the server to prepare the bulk data of patient cohort number 1 (27 patients) bulkclient$groupExport(1) # Check the progress of the request bulkclient$getBulkStatus()$progress # When it is at 100%, you can download the files # (retry on a later moment if the progress is not at 100% yet) # R on FHIR downloads all the files for you and parses it into a list patient_cohort_1 <- bulkclient$downloadBulk(1) # View how the data is structured and start analyzing! View(patient_cohort_1)
Navigating through bulk data of a patient cohort fetched and parsed with R on FHIR.