Sending Files Through Redox

About Sending PDF, JPEG, & PNG Files

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.

To upload a file to Redox:

  • Post to https://blob.redoxengine.com/upload with your file attached as multipart/form-data . Check out the docs for your HTTP client library for how to send a file as multipart/form-data . Below are examples for curl and the NodeJS request library. (Note that most HTTP client libraries will set the content-type header for you when you attach a file. Setting content-type  explicitly in your code might prevent your library from setting the correct value.)
  • Include the ‘Authorization’: ‘Bearer <<access token>>’  header you received from the authentication API.
  • Each file is associated with the source whose access token you use in the Authorization header. It can only be referenced in subsequent API requests associated with that source.
  • For more information on the authentication process, please see the “Authenticating with Redox” section of our Create a Source Record help article.

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, you should use this method to upload the file to Redox.

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. A 403 Forbidden error will be returned if you try to upload files using a Free Account. 

Response

 

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

{
   "URI": "https://blob.redoxengine.com/"
}

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/123456789",
      "DocumentType": "Empty File",
      "DocumentID": "b169267c-10c9-4fe3-91ae-9ckf5703e90l", // external reference number unrelated to Redox File Upload
      "Provider": {...},
      "Authenticated": "False",
      "Authenticator": {...},
      "Availability": "Unavailable",
      "Notifications": [...]
   }
}

Results Message

{
   "Meta": {...}
   "Patient": {...}
   "Orders": [
      {...
         "Results": [
            {...
               "Value": "https://blob.redoxengine.com/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 = { 
  url: 'https://blob.redoxengine.com/upload',
  headers: { 
    'Authorization': 'Bearer <your access token>'
  },
  formData: { 
    // request sets the content-type header if a file is attached
    file: fs.createReadStream('test.pdf') 
  }
};

request.post(options, function (error, response, body) {
  if (error) {
    console.log(error);
  } else {
    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, just hit up the chat window in the bottom right of your screen.