Send a file via Redox FHIR API

If you haven’t already, check out our high-level summary and best practices for sending a file to an integrated system. The details below get into the specific “how-to” but it’s best to have a general idea before getting started. 

Embedding a file

With the Redox FHIR® API, you can use the DocumentReference resource with the $write operation to send a file to your integrated system. 

  1. Encode the file as a base64 encoded string.
  2. Populate the entry.resource.content.attachment fields to include the encoded file in your request: 
    • In the contentType field, enter a valid MIME typeLearn more about MIME types for files.
    • In the data field, insert the base64 encoded string for the file. 
    • (Optional) In the title field, enter the name of the file.
      1
      "content": [
      2
      {
      3
      "attachment": {
      4
      "contentType": "application/pdf"
      5
      "data": "XG82ZSC0aHUgd3F5IHlvdSBsaYU="
      6
      "title": "Order Request"
      7
      }
      8
      }
      9
      ]
  3. Populate any other fields you require for the $write operation. Learn more about the available fields in the DocumentReference resource.
  4. Send the request to your connection’s EHR system.

Uploading and referencing a file

For larger files, you must first upload them to Redox. Then, you can refer to the file in your requests.

  1. Locate the file you want to upload.
  2. Send your file to the Redox upload endpoint. Note that the [Environment] portion should be replaced by Development, Staging, or Production respectively:
    1
    curl --location
    2
    --request POST 'https://api.redoxengine.com/fhir/R4/redox/[Environment]/Binary' \
    3
    --header 'Authorization: Bearer [TOKEN]' \
    4
    --data-binary 'file.pdf'
    The endpoint above uses the same authentication as a typical FHIR® API request. Learn how to authenticate and initiate a request
  3. If the upload is successful, you receive a 201 Created status with the URL reference in the Location header of the response:
    1
    {
    2
    "location": "https://blob.redoxengine.com/123456789"
    3
    }
  4. Populate the required entry.resource.content.attachment fields to reference the previously uploaded file in your request: 
    • In the url field, enter the URL from the previous step
    • In the contentType field, enter a valid MIME typeLearn more about MIME types for files.
    • (Optional) In the title field, enter the name of the file.
    1
    "content": [
    2
    {
    3
    "attachment": {
    4
    "url": "https://blob.redoxengine.com/123456789"
    5
    "contentType": "application/pdf"
    6
    "title": "Order Request"
    7
    }
    8
    }
    9
    ]
  5. Populate any other fields you require for the $write operation. Learn more about the available fields in the DocumentReference resource.
  6. Send the request to your connection’s EHR system.
  7. To check if the file uploaded successfully, log in to the Redox dashboard and check the log for the request. The uploaded file displays under the Process tab of the log.