Skip to the content.

Bulk Data Client

If you want to use this in JS/TS projects, aor if you would like to contribute to this projects see the API Docs

Usage examples

Note: these example are using an open server. Protected server examples would work the same but you need to set your clientId, privateKey and tokenEndpoint in the configuration file. The fhirUrl option can also set in the config file to keep the examples shorter.

Patient-level export

node . -f https://bulk-data.smarthealthit.org/fhir

System-level export

node . --global

Group-level export

node . -g myGroupId

Passing export parameters Group-level export

node . --_since 2010-03 --_type Patient, Observations

Patient-level export with debugging information printed to the console

export NODE_DEBUG=app-request; node . -f https://builk-data.smarthealthit.org/fhir 

For more options see the CLI parameters and configuration options below.

Installation

Prerequisites: Git and NodeJS 15+

  1. Clone the repository
    git clone https://github.com/smart-on-fhir/bulk-data-client.git
    
  2. Go into the project directory
    cd bulk-data-client
    
  3. Make sure you are using NodeJS 15+. If you use nvm run:
    nvm use
    
  4. Install dependencies
    npm i
    

Configuration

A configuration file will have to be created for every server you want to connect to. The way to do that is:

  1. Copy the default config file and give it new name:
    cp config/defaults.js config/my-config-1.js
    
  2. Edit your configuration open your newly created configuration file, read the description in the comments for every option and set whatever you need. Feel free to remove unneeded options! See below for details.

The configuration works by loading the default values from config/defaults.js, then merging that with your custom config (overriding the defaults), and finally merging with any CLI parameters (a subset of the config options can be passed as CLI parameters).

Configuration File Options

The Bulk Data Client uses js configuration files, but you can think of them as JSON configuration objects. The only reason to use JS is to allow for comments and type hinting. Below are all the options that can be set in a configuration file.

Environment Variables

There are two environment that can be passed to the client to modify it’s behavior.

Example of running in non-interactive mode:

AUTO_RETRY_TRANSIENT_ERRORS=1 SHOW_ERRORS=1 node . --config myConfigFile.js --reporter text

CLI Parameters

Note that you can pass a --help parameter to see this listed in your terminal

short long description
-f --fhir-url FHIR server base URL. Must be set either as parameter or in the configuration file.
-F --_outputFormat The output format you expect.
-s --_since Only include resources modified after this date
-t --_type Zero or more resource types to download. If omitted downloads everything.
-e --_elements Zero or more FHIR elements to include in the downloaded resources
-p --patient Zero or more patient IDs to be included. Implies --post
-i --includeAssociatedData String of comma delimited values. When provided, server with support for the parameter and requested values SHALL return a pre-defined set of metadata associated with the request.
-q --_typeFilter Experimental _typeFilter parameter passed as is to the server
  --global Global (system-level) export
  --post Use POST kick-off requests
-g --group Group ID - only include resources that belong to this group. Ignored if –global is set
  --lenient Sets a “Prefer: handling=lenient” request header to tell the server to ignore unsupported parameters
-d --destination Download destination. See config/defaults.js for examples
  --config Relative path to config file
  --reporter Reporter to use to render the output. “cli” renders fancy progress bars and tables. “text” is better for log files. Defaults to “cli”
-c --custom Custom parameters to be passed to the kick-off endpoint. Example: -c a=1 b=c
  --status If a status request fails for some reason the client will exit. However, if the status endpoint is printed in the output, you can retry by passing it as --status option here

Features