Bug #849
openWalk-in registration allows a doctor with no schedule at that time; auto-assign can pick a doctor who is not working
0%
Description
Patients can be registered for consultation with a doctor who has no OPD schedule for that day or time. Registration never checks the doctor's schedule, so the patient lands in the queue of a doctor who is not working, with no warning to the front desk.
Steps to Reproduce:
- Check My Schedule for Dr. Sravan VS (General Medicine): on Thu 12 Nov 2026 the only OPD block is 10:00-11:00 (OPD 0/4).
- At about 15:30 the same day, register a walk-in patient (e.g. Lakshmi Ramanathan) for consultation, with this doctor or with the doctor left blank (auto-assign) in General Medicine.
- Open My Queue for the doctor.
Expected Result: Registration refuses, or warns and asks for a reason, when the chosen doctor has no OPD block covering the current time (or is on leave). Auto-assign only picks doctors who are scheduled now. Emergency registrations stay allowed.
Actual Result: The walk-in is registered without any warning. My Queue shows the patient (token OP7, Walk-in, Awaiting triage, waiting 2 min) in the doctor's queue, hours outside the only scheduled block.
Cause (found in code):
- VisitRegistrationService.RegisterWithQueueAsync (nuvita-opd): when a doctor is named it only calls EnsureDoctorAssignedToDepartmentAsync (HR department assignment). Nothing checks schedule, working hours or leave.
- Auto-assign: ResolveDoctorAsync picks the least-loaded doctor in the department from visit history (IDoctorRoutingService), else the first HR doctor. A doctor with no schedule today can be chosen.
- Slot assignment: SlotAssignmentService.FindNextEmptySlotAsync returns nothing when there is no free slot, and the code just skips assigning one (if (slotTime.HasValue)). The visit is registered anyway.
- Appointments are not affected (they book real slots).
Suggested fix (OPD, reaches Doctor Desktop on the next npm run sync:opd):
- Auto-assign only considers doctors with an OPD block covering the current time and not on leave; if none, say so instead of choosing one.
- For a named doctor with no block now: block, or warn and require a reason (policy decision for product), and show who is available.
- Always allow Emergency registration.
- Optional: show an "outside schedule" tag on such visits in My Queue.
- Regression tests: no schedule -> refused/warned; scheduled -> allowed; emergency -> allowed; auto-assign skips unscheduled doctors.
Related: #821 (schedule slot validation), #848 (queue visibility).
AV Updated by Alminta V. about 13 hours ago
- Assignee set to Fiza M.