This feature is in closed beta.Interested in this feature? Get in touch with your Customer Success Manager.
Order Transactions and Initial Orders
An order transaction is created whenever a newinitial order is created and a link is established between the two entities.
-
initialorders are orders that are not derived from another order. This is denoted in the order’soriginfield. -
Order transactions have a
statusfield, which can either beactive,completedorcancelledactive- one or more orders belonging to the order transaction is in progresscompleted- all expected lab work for this transaction is completed and no further updates are expectedcancelled- the initial order has been cancelled (and there’s no redraw order), or both the initial and redraw orders have been cancelled
- An order can only ever belong to one order transaction
Order Transactions and Redraw Orders
If aninitial order is eligible for a redraw, rather than transitioning the low-level status of the order to completed, the order status is set to redraw_available.
- At this point, a new order is created, with
originset toredrawand it is linked to the same order transaction as theinitialorder
Webhooks
- A
labtest.order.updatedwebhook will be sent for theinitialorder when it transitions to theredraw_availablestatus - Additionally,
labtest.order.createdandlabtest.order.updatedwebhooks will be sent for theredraworder, when it is created and transitions to therequisition_createdstatus upon the requisition being processed - The
labtest.order.createdandlabtest.order.updatedwebhook payloads will include origin and order transaction details (including a list of orders that belong to the transaction, ordered by ascending date of order creation) - see the example payload on the webhooks page for more details - Ordering of webhooks delivery is not guaranteed and should not be relied upon
Monitoring updates and completion
- The results for the
initialorder will be available via the results API when theredraw_availableevent is received. No further updates for this order should be expected. - The
redraworder will move through the usual order lifecycle and will emit its own webhooks so that updates can be tracked. - A patient can only go through one redraw per order transaction. This means that a
redraworder will never transition to aredraw_availablestate. - When results for the
redraworder have been received and processed, theredraworder status will transition tocompleted, regardless of whether there are still missing results. The order transaction status will also be marked ascompleted.
API Endpoints
The following endpoints are available to retrieve order transaction information and combined results for all orders within a transaction:GET /v3/order_transaction/{order_transaction_id}- Get an order transaction’s details and list of ordersGET /v3/order_transaction/{order_transaction_id}/result- Get combined results for an order transaction in JSON formatGET /v3/order_transaction/{order_transaction_id}/result/pdf- Get combined results for an order transaction in PDF format
GET /v3/orders- Get a list of filtered orders (including the ability to filter by order transaction ID)GET /v3/order/{order_id}- Get an individual orderGET /v3/order/{order_id}/result- Get an individual order’s results
Key things to note
- The order transaction should be used as the primary way to reason about all related orders. A workflow for monitoring redraws could be as follows:
- Save the order transaction ID associated with an order at the point of its creation
- When processing order webhooks, if an initial order is in a
redraw_availablestate, check the order transaction details in the payload to retrieve the order ID for the new redraw order - Monitor webhooks for the redraw order to get the latest updates
- Once the redraw order is completed, use the order transaction endpoint to retrieve combined results
Integrating with Order Transactions
We recommend that you store both theorder_id and order_transaction_id when placing an order in Junction. This way, if you receive a webhook for an order that you have not seen in your system, you will be able to link it to the initial order via the order_transaction_id.
From there, you can always use the order_transaction_id directly to obtain results, ensuring you always get the complete set of results for a particular order transaction.