Explore documentation

Waitlist Management

Managing waitlists when no slots are available

Set up the SDK server client to run the examples using esus. The REST examples use a session token. To run them with the SDK’s API key, send X-API-Key instead of Authorization.

Using the waitlist Status

Appointment has a dedicated waitlist status. When a patient requests a time and no slot is available, you can record an appointment with status: "waitlist" and no slot[].

Important limitation. waitlist can only be set at creation time (create does not validate transitions), and it has NO outgoing transition: the state machine only allows proposed → {pending, cancelled}, pending → {booked, cancelled}, booked → {arrived, cancelled, noshow} and arrived → {fulfilled, cancelled}. A PATCH/PUT that moves a waitlist appointment to any other status (including booked or cancelled) fails with HTTP 400.

A waitlist entry therefore cannot be “converted”: when a slot frees up, delete the waitlist entry and create a new appointment. See “Convert Waitlist to Booking” below.

Create a Waitlist Entry

REST
curl -X POST https://api.esus.health/fhir/Appointment \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "status": "waitlist",
    "serviceType": [{
      "coding": [{ "code": "124", "display": "General Practice" }]
    }],
    "participant": [{
      "actor": {
        "reference": "Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6"
      },
      "required": "required",
      "status": "needs-action"
    }],
    "reasonCode": [{
      "coding": [{
        "system": "http://snomed.info/sct",
        "code": "185349003",
        "display": "Encounter for check up"
      }]
    }],
    "description": "Waitlist — preferred morning appointments",
    "requestedPeriod": [{
      "start": "2026-04-21T08:00:00Z",
      "end": "2026-04-21T12:00:00Z"
    }],
    "priority": 5
  }'
SDK
const created = await esus.fhir.create("Appointment", {
  "status": "waitlist",
  "serviceType": [
    {
      "coding": [
        {
          "code": "124",
          "display": "General Practice"
        }
      ]
    }
  ],
  "participant": [
    {
      "actor": {
        "reference": "Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6"
      },
      "required": "required",
      "status": "needs-action"
    }
  ],
  "reasonCode": [
    {
      "coding": [
        {
          "system": "http://snomed.info/sct",
          "code": "185349003",
          "display": "Encounter for check up"
        }
      ]
    }
  ],
  "description": "Waitlist — preferred morning appointments",
  "requestedPeriod": [
    {
      "start": "2026-04-21T08:00:00Z",
      "end": "2026-04-21T12:00:00Z"
    }
  ],
  "priority": 5
});

The optional requestedPeriod[] captures the windows the patient is willing to attend. priority is a plain number that Esus stores without interpreting it: pick a convention (for example, higher = more urgent) and document it for your operators.

Fields other than status (description, requestedPeriod, priority…) can still be edited on a waitlist entry with a PATCH that doesn’t include status (or that re-sends "status": "waitlist").

Search the Waitlist

# Waitlisted appointments that include a given practitioner
curl "https://api.esus.health/fhir/Appointment?practitioner=a7b1c2d3-e4f5-6789-abcd-ef0123456789&status=waitlist" \
  -H "Authorization: Bearer YOUR_TOKEN"

# Or every waitlisted appointment for the organization
curl "https://api.esus.health/fhir/Appointment?status=waitlist&_sort=_lastUpdated" \
  -H "Authorization: Bearer YOUR_TOKEN"

_sort on Appointment only supports date, status and _lastUpdated; _sort=priority is silently ignored (results fall back to ordering by start). Sort by priority on the client side.

Convert Waitlist to Booking

When a slot frees up:

  1. Book the slot with $book (recommended), which creates a new Appointment as booked and flips the Slot to busy:
REST
curl -X POST https://api.esus.health/fhir/Appointment/\$book \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "slotId": "c1a2e3d4-5b6f-7890-abcd-ef1234567890",
    "participant": [
      { "actor": { "reference": "Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6" }, "required": "required", "status": "accepted" }
    ]
  }'
SDK
const { body } = await esus.fhir.operation("POST /fhir/Appointment/$book", {
  body: {
    "slotId": "c1a2e3d4-5b6f-7890-abcd-ef1234567890",
    "participant": [
      {
        "actor": {
          "reference": "Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6"
        },
        "required": "required",
        "status": "accepted"
      }
    ]
  },
});

If you need the patient’s confirmation before committing the slot, instead create the new appointment as pending with POST /fhir/Appointment and move it pending → booked once confirmed (remember manual create does not touch the Slot).

  1. Remove the waitlist entry with DELETE /fhir/Appointment/{id} (HTTP 204). Its previous versions stay readable via _history only while the resource exists, so if you need an audit trail of the waitlist, record it elsewhere (for example in a Communication, see below) before deleting.

Notifying Waitlisted Patients

Esus does not notify waitlisted patients. When a slot opens, the recommended pattern is:

  1. Find the top waitlisted appointment (search by status=waitlist, sort by priority client-side).
  2. Contact the patient through your messaging provider.
  3. Book the new appointment and delete the waitlist entry as described above.
  4. Record the outreach by creating a Communication (see “Appointment Reminders” for the shape).