Book an Appointment with a Practitioner

Overview

Building on the previous guide where we retrieved a practitioner's availabilities (open slots), this guide will run you through booking an appointment for your patient.

Since we are in test mode, we return simulated data and won't book a real appointment. However, this guide should give you a sense of how to use our API to book appointments.

Booking an appointment

Before booking an appointment for your patient, you must create a Patient object that stores the basic information we need about them while booking appointments.

The POST /patients endpoint lets you quickly create a patient. Let's assume we've previously created an object for this patient. We can retrieve their Railway-provided patient id using their identifying information like name and date of birth.

curl --request GET \
     --url 'https://api.closurehealth.com/patients?dob=1994-12-22&name=Trisha%20Pandit' \
     --header 'Accept: application/json' \
     --header 'Authorization: Basic Y2hfc2tfdGVzdF9xdWlja3N0YXJ0Og==' \
     --header 'Closure-API-Version: 2022-04-01'

If you inputted the correct query parameters, you will get back the patient in the response.

[
  {
    "id": "pt_sxKCbaoVdBXHBGWywcBETm",
    "first_name": "Trisha",
    ...,
    "dob": "1994-12-22",
    ...,
    "insurance": {
      "id": "ins_8rdzjCQtD1VLg9aLRwARNF",
      ...,
    },
    ...
  }
]

Great, now that we have the patient, we can book an appointment for her.

In the previous guide, we found Dr. Sanon's availabilities (open slots).

[
  {
    "start_at": "2022-05-20T16:45:00.000Z",
    "duration": 30
  },
  {
    "start_at": "2022-05-20T17:00:00.000Z",
    "duration": 30
  },
  {
    "start_at": "2022-05-20T17:15:00.000Z",
    "duration": 30
  }
]

Let's say your patient wants to book an appointment on the second slot 2022-05-20T17:00:00.000Z.

Before booking an appointment, let's first confirm Dr. Sanon accepts our patient's insurance (ins_8rdzjCQtD1VLg9aLRwARNF). Remember that the accepted insurances are defined on the Schedule object. Send a request to GET /schedules/sch_u5oQnnMdSbyb83xgqgkUgX to view the accepted insurances and confirm it includes our patient's insurance.

Now, we can finally book an appointment with the following request.

curl --request POST \
     --url https://api.closurehealth.com/appointments \
     --header 'Accept: application/json' \
     --header 'Authorization: Basic Y2hfc2tfdGVzdF9xdWlja3N0YXJ0Og==' \
     --header 'Closure-API-Version: 2022-04-01' \
     --header 'Content-Type: application/json' \
     --data '
{
     "schedule_id": "sch_u5oQnnMdSbyb83xgqgkUgX",
     "patient_id": "pt_sxKCbaoVdBXHBGWywcBETm",
     "start_at": "2022-05-20T17:00:00.000Z",
     "duration": 30
}
'

Wrapping up

Congratulations, you successfully booked an appointment for your patient!

Now, you can continue to poke around the API in test mode, explore our other development guides, and start to integrate our APIs into your production environment. When you're ready to go live, send us a note at [email protected] and we'll get you set up!