Rupa Checkout
Learn how to create new Orders using Rupa Checkout.
With Rupa Checkout, you can create Orders
for Practitioners directly from your application. You do this using OrderIntents
. Think of OrderIntents
as a cart on a traditional e-commerce site. You create an OrderIntent
using a Patient.id
, an optional list of LabTest.ids
, then to turn it into an Order
, you direct your Practitioner
to the OrderIntent.checkout_url
, which allows the Practitioner
to finalise and submit the Order
.
Overview
Let's run through how it works. Here are the steps:
- Get or create a
Patient
.OrderIntents
are associated with aPatient
, so you need to provide aPatient.id
. To get one, you can either sync all thePatients
in theClinic
ahead of time to patients in your application, or create one when you create theOrderIntent
. - Create the
OrderIntent
. Then you create theOrderIntent
using thePatient.id
. You can also associated one or moreLabTests
with theOrderIntent
. If you do, they'll be in theOrder
when thePractitioner
visits theredirect_url
. Either way, the practitioner can add or removeLabTests
. - Redirect to
OrderIntent.checkout_url
. Once you have theOrderIntent
, redirect the practitioner toOrderIntent.checkout_url
to finalize theOrder
. Once they've submitted the Order, they'll be returned to your application via areturn_url
you provide. - Listen for Order Events. To keep your application up-to-date with the Order, you'll want to listen for the appropriate events via your webhook.
1. Get or create a Patient
You can choose to either sync a list of existing Patients in the Clinic to matching patients in your application, or you create one when you create the OrderIntent.
Syncing Patients
To sync existing patients, use the Patients endpoint.
GET /patients 1.1
Host: api.rupahealth.com
Authorization: Bearer ACCESS_TOKEN
Content-Type: "application/vnd.api+json"
The Patient object has attributes for first_name
, last_name
, birthday
, and email
, which you can use to sync with patients in your application. You can listen for the patient.created
and patient.updated
events to keep your application up-to-date.
Improve Patient matching
To help solve matching issues like incorrect date of birth or slight differences in names, your application should allow a practitioner to modify the order to which the Rupa Order
is associated in your application.
Create a Patient
To create a patient, use the Create Patient endpoint. At a minimum you'll need to provide the first_name
, last_name
, and email
attributes.
Patient de-duplication
If a Patient already exists with the same first_name
, last_name
, and email
, Rupa will return the existing Patient.
POST /patients 1.1
Host: api.rupahealth.com
Authorization: Bearer ACCESS_TOKEN
Content-Type: "application/vnd.api+json"
{
"data": {
"type": "patient",
"attributes": {
"first_name": "Katherine",
"last_name": "Johnson",
"email": "[email protected]",
}
}
}
2. Create an OrderIntent
Call the Create OrderIntent endpoint with the Patient.id
and an optional list of LabTests
. You can get a list of available LabTests use the LabTests endpoint. You can keep them in sync using the labtest.created
and labtest.updated
events.
You also need to provide a return_url
, which is the URL Rupa will redirect the practitioner to once they've completed the Order.
POST /order_intents 1.1
Host: api.rupahealth.com
Authorization: Bearer ACCESS_TOKEN
{
"data": {
"type": "order_intent",
"attributes": {
"return_url": "example.com"
},
"relationships": {
"patient": {
"data": {
"type": "patient",
"id": "pat_aaa111"
}
},
"lab_tests": {
"data": [
{
"type": "lab_test",
"id": "labts_abc111"
}
]
}
}
}
}
3. Redirect to OrderIntent.checkout_url
Redirect the practitioner to the order_intent.attributes.checkout_url
so they can finalize the Order
. Once they've submitted the Order, they'll be returned to the return_url
you provided. You can open checkout_url
in a new tab, a window, an iframe; however you want.
When redirected, the URL will have an ?order
parameter with the ID of the created order.
4. Listen for Order Events
After the Order has been submitted, it'll move through various stages as its processed. To be notified of these status changes, listen for order.updated
and order.new_result
events. See Webhooks to learn more.