Fix Call next when doctor desk is missing from cached points.
Deploy Ladill Care / deploy (push) Successful in 48s
Deploy Ladill Care / deploy (push) Successful in 48s
Assigned doctors could see board waiters while Call next returned empty because ensure() early-returned without provisioning a newly linked desk. Re-provision on point miss, recover stale tickets, and align empty messaging with visible waiters. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -125,7 +125,12 @@ class QueueController extends Controller
|
||||
|
||||
$waitingCountQuery = Appointment::owned($owner)
|
||||
->where('organization_id', $organization->id)
|
||||
->whereIn('status', [Appointment::STATUS_WAITING, Appointment::STATUS_CHECKED_IN]);
|
||||
->whereIn('status', [Appointment::STATUS_WAITING, Appointment::STATUS_CHECKED_IN])
|
||||
->where(function ($q) {
|
||||
$q->whereNull('queue_ticket_status')
|
||||
->orWhere('queue_ticket_status', '')
|
||||
->orWhereNotIn('queue_ticket_status', ['called', 'serving']);
|
||||
});
|
||||
if ($lockToPractitioner) {
|
||||
$waitingCountQuery->whereIn('practitioner_id', $practitionerScope ?: [0]);
|
||||
if ($branchId > 0) {
|
||||
@@ -142,6 +147,14 @@ class QueueController extends Controller
|
||||
$waitingCountQuery->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
// Hero Waiting must match the Waiting column (same list the doctor acts on).
|
||||
$waitingHero = $queue->reject(
|
||||
fn ($a) => in_array($a->queue_ticket_status ?? '', ['called', 'serving'], true)
|
||||
)->count();
|
||||
if ($queue->count() >= $boardLimit) {
|
||||
$waitingHero = max($waitingHero, $waitingCountQuery->count());
|
||||
}
|
||||
|
||||
$inCareCountQuery = Appointment::owned($owner)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('status', Appointment::STATUS_IN_CONSULTATION);
|
||||
@@ -172,7 +185,7 @@ class QueueController extends Controller
|
||||
->get();
|
||||
|
||||
$heroStats = [
|
||||
'waiting' => $waitingCountQuery->count(),
|
||||
'waiting' => $waitingHero,
|
||||
'in_consultation' => $inCareCountQuery->count(),
|
||||
'today' => $todayQuery->count(),
|
||||
];
|
||||
@@ -258,6 +271,25 @@ class QueueController extends Controller
|
||||
? 'consultation'
|
||||
: $context;
|
||||
|
||||
$waitingVisible = Appointment::owned($owner)
|
||||
->where('organization_id', $organization->id)
|
||||
->where('branch_id', $branchId)
|
||||
->whereIn('status', [Appointment::STATUS_WAITING, Appointment::STATUS_CHECKED_IN])
|
||||
->when($practitionerId, fn ($q) => $q->where('practitioner_id', $practitionerId))
|
||||
->where(function ($q) {
|
||||
$q->whereNull('queue_ticket_status')
|
||||
->orWhere('queue_ticket_status', '')
|
||||
->orWhereNotIn('queue_ticket_status', ['called', 'serving']);
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($waitingVisible > 0) {
|
||||
return back()->with(
|
||||
'info',
|
||||
"{$waitingVisible} waiting but none are callable at your {$label} desk right now (payment hold or specialty mismatch)."
|
||||
);
|
||||
}
|
||||
|
||||
return back()->with('info', "No patients waiting at your {$label} service point.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user