ClinicArchitectClinicArchitect
Логін
← Блог
·Scheduling

How to Prevent Double Booking in a Clinic Appointment System

Why two receptionists can still book the same doctor at the same time in most systems, and the database-level fix that makes it impossible.

Double booking in a clinic is two appointments for the same doctor in overlapping time. The reliable way to prevent it is to make the overlap check and the save a single protected step: take a lock on the doctor and the appointment's start time, check for overlaps, insert, then release the lock. An overlap check without that lock still allows double bookings when two people save at the same moment.

Why does double booking still happen with an overlap check?

Most scheduling tools do check for overlaps, but they check and then save as two separate steps. If two staff members press save within the same fraction of a second, both checks run before either appointment exists, both see an empty slot, and both appointments are written. This is called a race condition, and it is most common at busy front desks, when a coordinator books from a phone while reception books from the web, or when an online form and staff book the same slot.

TimeReceptionist AReceptionist B
10:00:00.100Checks Dr. X at 14:00 — free
10:00:00.120Checks Dr. X at 14:00 — free
10:00:00.150Saves appointment
10:00:00.170Saves appointment — now double-booked

What are the ways to prevent double booking?

ApproachStops simultaneous saves?Trade-off
Interface warning onlyNoTwo browsers each see the slot as free
Overlap check, then saveNoRace window between check and write
Unique constraint on exact start timePartlyMisses overlaps that start at different minutes
Lock held across check and saveYesSecond request is rejected; the user picks another slot
Single booking owner (one person books)YesBecomes a bottleneck and fails when that person is away

How ClinicArchitect prevents it

ClinicArchitect takes a PostgreSQL advisory lock keyed on the doctor and the appointment's start minute before it runs the overlap check. The lock is held while the check and the insert run and is released afterwards. A second request for the same doctor and minute cannot interleave with the first, so two simultaneous saves for the same doctor and time produce one appointment and one clear rejection instead of two overlapping appointments. The mechanism is described on the security and data handling page.

Front-desk habits that reduce conflicts further

  1. Book in one shared system — not in a calendar app plus a spreadsheet plus messaging.
  2. Limit who can create and edit appointments with role permissions.
  3. Send appointment-created and appointment-updated notifications to the roles that own the schedule.
  4. Record the doctor on every appointment, so the conflict check has something to key on.
  5. When a booking is rejected, re-open the calendar instead of retrying the same slot.

What to ask a scheduling software vendor

  • Is the overlap check enforced on the server, or only in the interface?
  • What happens if two users save the same doctor and time in the same second?
  • Is the conflict detected across web and mobile, not only within one device?
  • Can you restrict who may create, edit or cancel appointments?

Часті запитання

What is the most common cause of double booking in clinics?

Two people saving the same slot at nearly the same moment. Each sees the slot as free because the other appointment has not been saved yet. A check that is not protected by a lock cannot stop it.

Is a warning in the calendar enough to prevent double booking?

No. A warning is shown in one person's browser; it cannot see an appointment another person is saving at the same instant. Prevention has to happen on the server when the appointment is written.

Does ClinicArchitect prevent double booking between web and mobile?

Yes. The check runs on the server with a database lock on doctor and start minute, so it applies to every booking regardless of which device created it.