Fix Call next when Care waiters lack Queue tickets.
Deploy Ladill Care / deploy (push) Successful in 1m35s

Demo/pre-integration waiting lists showed patients but Call next hit an empty Queue and flashed a red error. Backfill missing tickets on Call next and queue load, and treat empty Call next as info.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 16:53:52 +00:00
co-authored by Cursor
parent 015a4cc7fe
commit c5151ad476
11 changed files with 393 additions and 23 deletions
@@ -9,6 +9,8 @@ use App\Services\Care\AppointmentPatientNotifier;
use App\Services\Care\AuditLogger;
use App\Services\Care\CareFeatures;
use App\Services\Care\CarePermissions;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueContexts;
use App\Services\Care\CareQueueProvisioner;
use App\Services\Care\PlanService;
use App\Services\Billing\PlatformEmailClient;
@@ -155,7 +157,22 @@ class SettingsController extends Controller
if ($wantsQueue && $queue->configured()) {
try {
$provisioner->provisionOrganization($organization->fresh());
$organization = $organization->fresh();
$provisioner->provisionOrganization($organization);
// Backfill tickets for patients already waiting when Queue was just linked.
$bridge = app(CareQueueBridge::class);
$branches = Branch::owned($owner)
->where('organization_id', $organization->id)
->where('is_active', true)
->pluck('id');
foreach ($branches as $branchId) {
foreach (array_keys(CareQueueContexts::departments()) as $context) {
if ($context === CareQueueContexts::RECEPTION) {
continue;
}
$bridge->syncMissingTickets($organization, $context, (int) $branchId, 50);
}
}
} catch (\Throwable) {
// Best-effort; role pages will lazy-ensure on next use.
}