Fix queue handoff so tickets keep their number across services.
Deploy Ladill Queue / deploy (push) Successful in 40s
Deploy Ladill Queue / deploy (push) Successful in 40s
Handoff now frees the counter, ends the service session, and requeues the same ticket for the next department — critical for hospital flows like doctor → lab. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -87,7 +87,7 @@ class ConsoleApiController extends Controller
|
||||
'call_next' => $this->handleCallNext($counter, $validated['queue_uuid'] ?? '', $actor),
|
||||
'available' => tap($counter)->update(['status' => 'available']),
|
||||
'offline' => tap($counter)->update(['status' => 'offline']),
|
||||
default => $this->handleTicketAction($validated, $actor),
|
||||
default => $this->handleTicketAction($validated, $counter, $actor),
|
||||
};
|
||||
|
||||
if ($result instanceof Ticket) {
|
||||
@@ -105,7 +105,7 @@ class ConsoleApiController extends Controller
|
||||
return $this->engine->callNext($queue, $counter, $actor);
|
||||
}
|
||||
|
||||
protected function handleTicketAction(array $validated, string $actor): Ticket|Counter|null
|
||||
protected function handleTicketAction(array $validated, Counter $counter, string $actor): Ticket|Counter|null
|
||||
{
|
||||
$ticketUuid = $validated['ticket_uuid'] ?? '';
|
||||
abort_if($ticketUuid === '', 422, 'ticket_uuid is required for this action.');
|
||||
@@ -119,14 +119,28 @@ class ConsoleApiController extends Controller
|
||||
'skip' => $this->engine->skip($ticket, $actor),
|
||||
'complete' => $this->engine->completeTicket($ticket, $actor),
|
||||
'no_show' => $this->engine->markNoShow($ticket, $actor),
|
||||
'transfer' => $this->engine->transfer(
|
||||
'transfer' => $this->handleTransfer(
|
||||
$ticket,
|
||||
ServiceQueue::where('uuid', $validated['to_queue_uuid'] ?? '')->firstOrFail(),
|
||||
null,
|
||||
$counter,
|
||||
$validated['to_queue_uuid'] ?? '',
|
||||
$validated['reason'] ?? null,
|
||||
$actor,
|
||||
),
|
||||
default => abort(422, 'Unknown action.'),
|
||||
};
|
||||
}
|
||||
|
||||
protected function handleTransfer(
|
||||
Ticket $ticket,
|
||||
Counter $counter,
|
||||
string $toQueueUuid,
|
||||
?string $reason,
|
||||
string $actor,
|
||||
): Ticket {
|
||||
abort_if($toQueueUuid === '', 422, 'to_queue_uuid is required for transfer.');
|
||||
|
||||
$toQueue = ServiceQueue::where('uuid', $toQueueUuid)->firstOrFail();
|
||||
|
||||
return $this->engine->transfer($ticket, $toQueue, $counter, $reason, $actor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user