Platform
Patient Queue
Managing patient flow with the queue API
The Patient Queue API manages patient flow inside a facility: check-in, waiting list, calling the next patient, consultation tracking, and no-shows. Endpoints live under /queue (not under /fhir) and return plain JSON, not FHIR resources.
Access: API keys need the Queue.read scope for GET routes and Queue.create for POST routes (every action below is a POST).
Set up the SDK client as esus. Replace the example IDs with IDs from your test organization.
Check In a Patient
curl -X POST https://api.esus.health/queue/check-in \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{
"patientId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"priority": 0,
"note": "Follow-up consultation"
}'
const entry = await esus.queue.checkIn({
"patientId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"priority": 0,
"note": "Follow-up consultation"
});
Body fields: patientId (required), and optionally appointmentId, locationId, practitionerId, priority (number), and note. patientId, locationId, and practitionerId must exist in your organization, otherwise the API returns 400.
Response: 201 Created
{
"id": "c1a2e3d4-5b6f-7890-abcd-ef1234567890",
"organizationId": "11112222-3333-4444-5555-666677778888",
"patientId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"appointmentId": null,
"locationId": null,
"practitionerId": null,
"status": "waiting",
"priority": 0,
"queueNumber": 3,
"checkedInAt": "2024-01-15T09:00:00.000Z",
"calledAt": null,
"startedAt": null,
"completedAt": null,
"note": "Follow-up consultation",
"createdAt": "2024-01-15T09:00:00.000Z",
"updatedAt": "2024-01-15T09:00:00.000Z"
}
Priority and queue number
priority defaults to 0. A higher value is called first; within the same priority, the earliest check-in goes first. queueNumber is assigned automatically: it counts up from 1 each day, per locationId (or across the organization when no location is given).
Get the Waiting List
Returns an array of entries in waiting status, ordered by priority and then check-in time. Optional query filters: locationId, practitionerId.
curl "https://api.esus.health/queue/waiting?locationId=bb22cc33-dd44-ee55-ff66-778899001122" \
-H "Authorization: Bearer TOKEN"
const entries = await esus.queue.waiting({
locationId: "bb22cc33-dd44-ee55-ff66-778899001122",
});
Each item has the same shape as the check-in response.
Call the Next Patient
Takes the first entry of the waiting list (same ordering), sets it to called, stamps calledAt, and returns it. The request needs a JSON object body; its fields narrow the pick:
curl -X POST https://api.esus.health/queue/call-next \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{ "locationId": "bb22cc33-dd44-ee55-ff66-778899001122" }'
const entry = await esus.queue.callNext({
locationId: "bb22cc33-dd44-ee55-ff66-778899001122",
});
Body fields (both optional): locationId, practitionerId. To consider every waiting entry, send {}: a request without a body is rejected with 422. If you pass practitionerId, only entries assigned to that practitioner are considered, and the practitioner is recorded on the called entry. When nobody is waiting, the API returns 404 ("No patients waiting in queue").
Consultation Lifecycle
Each call returns the updated entry.
# called → in-progress (sets startedAt)
curl -X POST https://api.esus.health/queue/ENTRY_ID/start \
-H "Authorization: Bearer TOKEN"
# in-progress → completed (sets completedAt)
curl -X POST https://api.esus.health/queue/ENTRY_ID/complete \
-H "Authorization: Bearer TOKEN"
# waiting or called → no-show (sets completedAt)
curl -X POST https://api.esus.health/queue/ENTRY_ID/no-show \
-H "Authorization: Bearer TOKEN"
await esus.queue.start(entryId);
await esus.queue.complete(entryId);
// Alternative for a patient who did not show up.
await esus.queue.noShow(absentEntryId);
Transitions are enforced. Calling one from the wrong status returns 400, for example "Cannot start consultation from status 'waiting'. Entry must be in 'called' status.". An unknown id returns 404.
Queue Status Values
| Status | Meaning | Reached via |
|---|---|---|
waiting | Checked in, waiting to be called | POST /queue/check-in |
called | Called to the consulting room | POST /queue/call-next |
in-progress | Consultation in progress | POST /queue/:id/start |
completed | Consultation finished | POST /queue/:id/complete |
no-show | Did not show up | POST /queue/:id/no-show |
Queue Board
Returns entries grouped by status, useful for a reception or waiting-room screen. Optional query filter: locationId.
curl https://api.esus.health/queue/board \
-H "Authorization: Bearer TOKEN"
const board = await esus.queue.board();
{
"waiting": [],
"called": [],
"inProgress": [],
"completed": []
}
no-show entries are not included. The groups are not limited to today, so completed includes earlier days too.
Queue Statistics
Returns today’s entries grouped by status, as an array of { status, count, avgWaitMinutes }. Optional query filter: locationId.
curl https://api.esus.health/queue/stats \
-H "Authorization: Bearer TOKEN"
const stats = await esus.queue.stats();
[
{ "status": "waiting", "count": 4, "avgWaitMinutes": 12.5 },
{ "status": "completed", "count": 35, "avgWaitMinutes": 18.2 }
]
avgWaitMinutes is the average time from check-in until the patient was called. For entries that have not been called yet, the current time is used instead. Only statuses with at least one entry today appear.
Linking to a FHIR Appointment
The queue does not update appointments for you. To keep the scheduling record consistent, update the Appointment yourself and pass its id on check-in:
# 1. Mark the appointment as arrived
curl -X PATCH https://api.esus.health/fhir/Appointment/f6a7b8c9-d0e1-2345-f678-9012345bcdef \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/fhir+json" \
-d '{ "status": "arrived" }'
# 2. Check the patient into the queue
curl -X POST https://api.esus.health/queue/check-in \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-d '{
"patientId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"appointmentId": "f6a7b8c9-d0e1-2345-f678-9012345bcdef"
}'
const { etag } = await esus.fhir.read("Appointment", appointmentId);
if (!etag) throw new Error("Missing Appointment ETag");
await esus.fhir.patch("Appointment", appointmentId, { status: "arrived" }, etag);
await esus.queue.checkIn({ patientId, appointmentId });