Redox

Sending Files Through Redox

Posted March 30, 2017
By Julia Zehel

The Redox API is capable of exchanging patient data with EHRs in a variety of message formats. In order to facilitate the transmission of large files like PDFs, Images, Audio Files, and other media, a separate Redox API endpoint is available for file uploading.

Doing so is rather straightforward: to upload a file to Redox, you can post a message to https://blob.redoxengine.com/upload, with 'content-type': 'multipart/form-data'. In addtion, include Authorization: Bearer <<Your access token>> received from the login api. Each file is associated to the source you use in the Authorization header, and can only be used in subsequent API requests by that source. For more information on the authentication process, please see the “Authenticating with Redox” section of our Getting Started documentation.

Check out some code snippets below to help you get started.

The break point in which you would use the file upload endpoint vs. directly sending data to the API as a base64 encoded string or plain text string is currently 200KB. If you expect that the contents of your messages may occasionally exceed 200KB, we suggest working with the Redox Customer Success team to determine the best path forward.

There is currently a 10MB file size limit for all files uploaded to Redox. Attempting to load any larger files will return a 413 error response.

Please note: This functionality is only available with a Pre-Production or Production account.

Response

If your upload is successful, you’ll get a 201 response with this structure:

{
   "URI": "https://blob.redoxengine.com/blob/<file ID>"
}

When posting subsequent requests to Redox, include the File URL to reference your uploaded document within the message. Here are two examples where the blob URI is included in the message body.

Media Message

{
   "Meta": {...},
   "Patient": {...},
   "Visit": {...},
   "Media": {
      "FileType": "PDF",
      "FileName": "SamplePDF",
      "FileContents": "https://blob.redoxengine.com/blob/123456789",
      "DocumentType": "Empty File",
      "DocumentID": "b169267c-10c9-4fe3-91ae-9ckf5703e90l", // ext ref number
      "Provider": {...},
      "Authenticated": "False",
      "Authenticator": {...},
      "Availability": "Unavailable",
      "Notifications": [...]
   }
}

Results Message

{
   "Meta": {...}
   "Patient": {...}
   "Orders": [
      {...
         "Results": [
            {...
               "Value": "https://blob.redoxengine.com/blob/123456789",
               "ValueType": "Encapsulated Data",
               "FileType": "PDF",
            }
         ]
      }
   ],
   "Visit": {...}
}

Example Requests

Here is an example in Node.js:

var fs = require("fs");
var request = require("request");

var options = { method: 'POST',
  url: 'https://blob.redoxengine.com/upload',
  headers: 
   { authorization: 'Bearer <<ACCESS TOKEN>>',
     'content-type': 'multipart/form-data; boundary=---011000010111000001101001' },
  formData: 
   { file: 
      { value: 'fs.createReadStream("<file contents>")',
        options: { filename: { '0': {} }, contentType: null } } } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

An example in curl:

curl https://blob.redoxengine.com/upload \
  -H "Authorization: Bearer <<ACCESS TOKEN>>" -X POST \
  -F file=@file.pdf

There you have it. If you have any questions about this topic or would like anything explained further, please get in touch at hello@redoxengine.com. We’d be happy to talk with you.