$export

FHIR Bulk Data Export

The FHIR Bulk Data Export feature allows to export FHIR resources in ndjson format.

Aidbox supports patient-level and group-level export. When the export request is submitted the server returns URL to check the export status. When export is finished, status endpoint returns URLs to download resources.

Only one export process can be run at the same time. If you try to submit an export request while there is active export, you get 429 Too Many Requests error.

Setup storage

Aidbox can export data to GCP or AWS cloud. Export results will be in <datetime>_<uuid> folder on the bucket.

GCP

Create bucket and service account that has read and write access to the bucket.

Create GcpServiceAccount resource in Aidbox. Example:

private-key: |
  -----BEGIN PRIVATE KEY-----
  your-key-here
  -----END PRIVATE KEY-----
service-account-email: service-account@email
id: gcp-service-account
resourceType: GcpServiceAccount

Set the following environment variables:

  • BOX_FHIR_BULK_STORAGE_PROVIDER: gcp — backend for export

  • BOX_FHIR_BULK_STORAGE_GCP_SERVICE_ACCOUNT — id of the GcpServiceAccount resource

  • BOX_FHIR_BULK_STORAGE_GCP_BUCKET — bucket name

Azure

Create Azure storage account and storage container.

Create AzureAccount resource in Aidbox.

resourceType: AzureAccount
id: azureaccount                  # your storage account id
key: 7x..LA                       # your storage account key

Create AzureContainer resource in Aidbox.

resourceType: AzureContainer
id: smartboxexporttestcontainer
account:
  resourceType: AzureAccount
  id: azureaccount
storage: azureaccount             # your storage account
container: azureaccountcontainer  # your account container

Set the following environment variables:

  • BOX_FHIR_BULK_STORAGE_PROVIDER: azure — backend for export

  • BOX_FHIR_BULK_STORAGE_AZURE_CONTAINER: smartboxexporttestcontainer — id of the AzureContainer resource

AWS

Create S3 bucket and IAM user that has read and write access to the bucket.

Create AwsAccount resource in Aidbox. Example:

region: us-east-1
access-key-id: your-key-id
secret-access-key: key
id: aws-account
resourceType: AwsAccount

Set the following environment variables:

  • BOX_FHIR_BULK_STORAGE_PROVIDER: aws — backend for export

  • BOX_FHIR_BULK_STORAGE_AWS_ACCOUNT — id of the AwsAccount resource

  • BOX_FHIR_BULK_STORAGE_AWS_BUCKET — bucket name

Parameters

Parameter
Description

_outputFormat

Specifies format in which the server generates files. The following formats are supported:

  • application/fhir+ndjson.ndjson files will be saved

  • application/fhir+ndjson+gzip.ndjson.gz files will be saved

_type

Includes only the specified types. This list is comma-separated.

_since

Includes only resources changed after the specified time.

patient

Export data that belongs only to listed patient. Format: comma-separated list of patient ids. Available only for patient-level export.

Patient-level export

Patient-level export exports all Patient resources and resources associated with them. This association is defined by FHIR Compartments.

To start export make a request to /fhir/Patient/$export:

Rest console

GET /fhir/Patient/$export
Accept: application/fhir+json
Prefer: respond-async

Make a request to the export status endpoint to check the status:

Rest console

GET /fhir/$export-status/<id>

Delete request on the export status endpoint cancels export.

Rest console

DELETE /fhir/$export-status/<id>

Group-level export

Group-level export exports all Patient resources that belong to the specified group and resources associated with them. Characteristics of the group are not exported. This association is defined by FHIR Compartments.

To start export make a request to /fhir/Group/<group-id>/$export:

Rest console

GET /fhir/Group/<group-id>/$export
Accept: application/fhir+json
Prefer: respond-async

Make a request to the export status endpoint to check the status:

Rest console

GET /fhir/$export-status/<id>

Delete request on the export status endpoint cancels export.

Rest console

DELETE /fhir/$export-status/<id>

System-level export

System-level export exports data from a FHIR server, whether or not it is associated with a patient. You may restrict the resources returned using the _type parameter.

GET /fhir/$export
Accept: application/fhir+json
Prefer: respond-async

A delete request on the export status endpoint cancels export.

Rest console

DELETE /fhir/$export-status/<id>

Troubleshooting guide

$export operation expects you set up external storage, Aidbox exports data into. In most cases, issues with $exoprt are the consequences of incorrect Adbox configuration. To exclude this, run the following rpc:

POST /rpc
Content-Type: text/yaml

method: aidbox.bulk/storage-healthcheck

Normally, you should see something like this in the response body:

result:
  message: ok
  storage:
    type: gcp
    bucket: my_bucket
    account:
      id: gcp-acc
      resourceType: GcpServiceAccount

This means that integration between Aidbox and your storage setup is correct.

Other responses you might see:

Storage-type not specified

The storage-type not specified error means that BOX_FHIR_BULK_STORAGE_PROVIDER environment variable wasn't set up. Valid values are aws , azure and gcp.

Unsupported storage-type

The unsupported storage-type error means that BOX_FHIR_BULK_STORAGE_PROVIDER environment variable has an invalid value. Valid values are aws , azure and gcp.

bulk-storage account not specified

This error means account is not specified

  • BOX_FHIR_BULK_STORAGE_GCP_SERVICE_ACCOUNT for GCP

  • BOX_FHIR_BULK_STORAGE_AWS_ACCOUNT for AWS

Account not found

This means there is no account for AWS or GCP

Create AWSAccount or GCPServiceAccount, depending on your config.

Bucket is not specified

This error means that the bucket is not specified.

Specify BOX_FHIR_BULK_STORAGE_GCP_BUCKET for GCP.

Specify BOX_FHIR_BULK_STORAGE_AWS_BUCKET for AWS.

Last updated

Was this helpful?