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:

  1. Get or create a Patient. OrderIntents are associated with a Patient, so you need to provide a Patient.id. To get one, you can either sync all the Patients in the Clinic ahead of time to patients in your application, or create one when you create the OrderIntent.
  2. Create the OrderIntent. Then you create the OrderIntent using the Patient.id. You can also associated one or more LabTests with the OrderIntent. If you do, they'll be in the Order when the Practitioner visits the redirect_url. Either way, the practitioner can add or remove LabTests.
  3. Redirect to OrderIntent.checkout_url. Once you have the OrderIntent, redirect the practitioner to OrderIntent.checkout_url to finalize the Order. Once they've submitted the Order, they'll be returned to your application via a return_url you provide.
  4. 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.

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.

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.