Queries are two-way, synchronous requests for data where one system initiates a query (REQUEST) and the other responds with relevant data (RESPOND). The source system that requests data waits for a response from the destination system.
Think of a query like a phone call. When you ask a question, you stay on the line and wait for a direct response. This is different from an asynchronous notification, which is more like sending a text message—you send it and then continue with your day, waiting for a response to arrive later. Learn about handling notifications.
When handling queries, it’s important to understand two different response scenarios:
- Response from Redox (after you REQUEST): This contains a two-part response with the delivery status and your query results.
- Response to Redox (when you RESPOND): This is the answer you give with results to your connection’s query. Your response tells Redox whether you successfully processed the query.
When you initiate a query, you receive a response with two parts:
- HTTP status code from Redox
- query results from the destination system
There are three types of synchronous responses:
- success response
- partial error response
- error response
Best case scenario: Redox successfully processes and delivers your query to the intended destination, and the destination successfully accepts the request and returns results.
If so, you receive a 200 OK status from Redox. The response body contains the requested data from the destination system. The fields and values present are specific to the data model or FHIR® resource you sent.
Keep in mind that not having query results doesn’t mean your query failed. You could receive a success response with no query results. You might need to modify the request if there aren’t any matching results.
Occasionally, Redox successfully processes and delivers your request, but an error occurs within the destination system, so it fails to accept the query.
If this happens, you still receive a 200 OK status from Redox, but the body of the response contains an array populated with error data:
Data | Notes |
---|---|
Meta.Errors[] array | This array is present for Redox Data Model API responses. It contains the details for any errors. At a minimum, a Text field from Redox provides the error message details. |
Issues[] array | This array is present for Redox FHIR® API responses. It contains the details for any errors. |
DestinationStatusCode | If present in one of the above arrays, this field comes from the destination system. It contains the failure status code as defined by the destination system. |
Details | If present in one of the above arrays, this field comes from the destination system. It contains information about the error as defined by the destination system. |
Sometimes your query fails within Redox, which means we fail to process and deliver it to the intended destination.
If the error occurs within Redox, you may receive a 4XX or 5XX HTTP status. Review HTTP errors.
When you receive a synchronous query from your connection, we wait for you to send back a response with the results of their request. Then, we return it to your connection in the format indicated in their request.
When you successfully receive a query from your connection, you should send back a 200 OK status with a response type that matches the query request.
Here’s an example: Your connection’s EHR system triggers an alert when a provider wants to order a new medication for a patient, but the provider wants to review the patient’s data before deciding on a specific medication. The EHR system sends a ClinicalDecisionsSupport request for more data. Your system successfully processes the request and aggregates results with the relevant data. You respond to Redox with a 200 OK status and the ClinicalDecisionsSupport.Response data model.
Keep in mind that not having query results doesn’t mean the query failed. You could return a success response with no query results. Your connection might need to modify the request if there aren’t any matching results.
There are two scenarios for failed deliveries to your system:
- query times out
- system error
If we don’t hear back from you after a couple of minutes, the query times out. We let the source system (i.e., your connection who initiated the query) know that their query wasn’t received. The source system can retry sending if they want.
If an error occurs and your system isn’t able to successfully receive the query, you should respond with a 4XX or 5XX HTTP status code and a response body with any relevant details:
Data | Notes |
---|---|
Meta.Errors[] array | This array can be added to Redox Data Model API responses. It should contain details about any errors in your system. At a minimum, a Text field should provide the error message details. |
Issues[] array | This array can be added to Redox FHIR® API responses. It should contain details about any errors in your system. |
DestinationStatusCode | Provide the failure status code as defined by your system. |
Details | Provide the error as defined by your system. |
We send the failed status code and the response with the errors back to your connection.