# Case #2: Appointments can be booked on past dates with no error

**CASE CLOSED** · Clinic Records · opened 2026-11-13 11:27 · report 20261113-112727

## The report

> hi. my receptionist booked mrs aisha for 3 march 2025 by accident (we meant 2027) and the system just saved it?? no warning nothing. it should not let us book in the past right. we are sunrise clinic

**What the user most likely did:** A Sunrise Clinic receptionist booked an appointment for patient Aisha on 3 March 2025, a date in the past, and the app saved it without any warning or error.

**What should happen:** The app should refuse to book an appointment on a past date. It should show an error such as 'appointment date cannot be in the past' and not save the booking.

## What Kane did, in a real browser

1. I went to http://127.0.0.1:8001/login.
2. I typed the test email into Email.
3. I typed the test password into Password.
4. I clicked Log in with email and password.
5. I waited to see what the page did.
6. I clicked Appointments link in navigation.
7. I clicked + Book appointment link to open new appointment booking page.
8. I picked Aisha Rahman in Patient.
9. I typed 2025-03-03 into Date.
10. I typed 10:00 into Time.
11. I clicked Book appointment.
12. I looked closely: The appointment was not saved.
13. I checked: The app shows an error saying the date is in the past and the appointment was not saved.

## Verdict

**Confirmed.** The browser agent logged in, booked Aisha Rahman for 3 March 2025 at 10:00, and the app saved it without any warning. The appointment then showed on her patient page, so the app does accept bookings in the past, just as the clinic reported.

## The repair

The app was saving bookings on any valid date, including dates that had already passed, so the 3 March 2025 booking went through with no warning. I added a check in `validate_appointment` (`app.py:247`) that turns down dates before today. The booking form now stays open with "The appointment date cannot be in the past. The appointment was not saved." and nothing is saved.

I tried to run a quick check of the new validation, but that command needed an approval that wasn't given, so I haven't run it yet. Kane's re-run will be the first real test.

```diff
diff --git a/clinic/app.py b/clinic/app.py
index 46b0718..269425d 100644
--- a/clinic/app.py
+++ b/clinic/app.py
@@ -244,7 +244,8 @@ def validate_patient(full_name: str, date_of_birth: str) -> list[str]:
 def validate_appointment(appt_date: str, appt_time: str) -> list[str]:
     errors = []
     try:
-        date.fromisoformat(appt_date)
+        if date.fromisoformat(appt_date) < date.today():
+            errors.append("The appointment date cannot be in the past. The appointment was not saved.")
     except ValueError:
         errors.append("Please choose a valid date.")
     try:
```

**Kane went back and repeated the same steps:** passed. Logged in and opened the new appointment booking page.
Selected Aisha and entered March 3, 2025 at 10:00, then submitted the appointment request.
The appointment was not saved because the page reported: “The appointment date cannot be in the past.”

**Kept on file as a regression test:** `bug-20261113-112727`

## Bug ticket

### Appointments can be booked on past dates with no error

**Steps**
1. Log in to the clinic app as a Sunrise Clinic user
2. Go to Appointments and click '+ Book appointment'
3. Select patient 'Aisha Rahman'
4. Set the date to 2025-03-03 and the time to 10:00
5. Click 'Book appointment'

**Expected:** The booking is refused, the user stays on the form, and an error such as 'Appointment date cannot be in the past' is shown. Nothing is saved.

**Actual:** The form is accepted and the user is redirected (POST /appointments/new returns 303). The patient page then shows a saved appointment on 03 Mar 2025 · 10:00, and no error or warning appears.

Reproduced by Kane CLI (Bug Whisperer report 20261113-112727).

---
Proved by Kane CLI: 2 run(s), about 233 s, 67.8 credits. Generated by Bug Whisperer on 2026-12-03 23:21.
