AWS Builder Center
How to Build a Clinic Appointment Waitlist on AWS

How to Build a Clinic Appointment Waitlist on AWS

Build a clinic appointment waitlist with AWS Lambda and DynamoDB. Offer cancelled slots to eligible patients, handle expiry, and prevent duplicate bookings.

Series: Healthcare (8 articles)

  1. …
  2. 4
    How to Build a Clinic Appointment Waitlist on AWS This article
A clinic appointment waitlist fills cancelled slots by matching each opening to an eligible patient, holding the slot for a limited time, and confirming the booking only when that patient accepts. On AWS, Lambda can apply the matching rules, DynamoDB can track the slot and offer, and EventBridge Scheduler can trigger an expiry check.
Imagine that a patient cancels a Thursday 3:00 p.m. appointment. Four people are on the waitlist, but only two can attend that afternoon. If the clinic messages all four, staff may end up handling several replies for the same opening. If it messages one person and waits indefinitely, the slot may go unused. A timed offer gives the clinic a way to handle both situations.

What should an appointment waitlist track?

  • Patient preferences such as clinic, appointment type, preferred time window, and minimum notice.
  • Slot status such as  OPEN ,  HELD , or  BOOKED .
  • Offer status such as  PENDING ,  ACCEPTED ,  DECLINED , or  EXPIRED .
  • Offer ownership and deadline so the portal can determine who can accept the slot and until when.
Store the clinic’s priority rules separately from the technical workflow. For routine scheduling, this example selects the earliest eligible entry. If a clinic gives certain appointments priority, apply its approved policy before sorting the remaining entries by wait time.

Hold the opening before sending the offer

When a cancellation frees a slot, a Lambda worker looks up eligible waitlist entries. It checks appointment type, location, notice period, and whether the patient is still waiting. It then uses a DynamoDB transaction to change the slot from  OPEN  to  HELD , create the offer, and save a pending notification job. The slot update succeeds only while the slot is still  OPEN .
Suppose the clinic chooses a 20-minute offer window.
Time
Event
What the system records
11:00 a.m.
Cancellation frees the Thursday slot
Slot becomes  OPEN 
11:01 a.m.
First eligible patient is selected
Slot becomes  HELD  for offer A, which expires at 11:21 a.m.
11:22 a.m.
The expiry worker checks offer A
If it is still pending, the worker expires the offer and releases the hold
11:23 a.m.
Next eligible patient is selected
A new hold is recorded under offer B
Send a generic message asking the patient to sign in to review the offer. The portal verifies that the offer belongs to the signed-in patient and displays the appointment details there. Keep the notification job separate from the booking state so a messaging outage can be investigated without losing track of the held slot.

Handle acceptance and expiry as competing operations

The patient might tap Accept just as the expiry worker runs. The acceptance path should require a pending offer, an unexpired deadline, and a slot still held by that offer. It then updates the offer and slot and creates the appointment in one transaction.
The expiry path checks the same offer identity and pending state, plus an elapsed deadline. If offer A expires and offer B takes the slot, a delayed retry for offer A must leave offer B’s hold intact. If the scheduler runs late, the acceptance endpoint still enforces the stored deadline.

What should you test before launch?

  • Two workers try to offer the same opening at once.
  • The patient accepts immediately before or after the deadline.
  • A notification fails while the slot is held.
  • A patient declines, and the next eligible entry gets an offer.
  • No eligible entries remain, and the slot returns to normal booking.
  • A patient already has another appointment that overlaps the opening.
Measure how many cancellations become offers, how many offers become bookings, and how long slots stay open. If most offers expire before patients respond, check notification delivery and the length of the offer window before changing the matching rules.

Series: Healthcare (8 articles)

  1. …
  2. 4
    How to Build a Clinic Appointment Waitlist on AWS This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article