{{-- Single patient-flow card for queue-board stages. Expected: $appointment, $stage (waiting|called|in_care|done), $canConsult, $queueIntegration, $startRouteName, $openInCareUrl (callable) Open (view workspace / form) is available whenever a destination URL exists — not gated by canConsult. Start / Call again remain consult-manage only. Layout: stacked — badges on top, patient info in the middle, actions in a footer row — so narrow board columns never squeeze text under buttons. --}} @php $stage = $stage ?? 'waiting'; $ticketStatus = $appointment->queue_ticket_status ?? null; $isCalled = in_array($ticketStatus, ['called', 'serving'], true); $openUrl = isset($openInCareUrl) ? $openInCareUrl($appointment) : null; $canConsult = $canConsult ?? false; $canRecall = ! empty($queueIntegration['enabled']) && $appointment->queue_ticket_uuid && $isCalled && $canConsult; $showStart = $canConsult && ($stage === 'waiting' || $stage === 'called'); $hasActions = $openUrl || $canRecall || $showStart; @endphp
(bool) $openUrl, 'border-indigo-200 bg-indigo-50/70 ring-1 ring-indigo-100' => $stage === 'called' || ($stage === 'waiting' && $isCalled), 'border-emerald-200 bg-emerald-50/60' => $stage === 'in_care', 'border-slate-200 bg-white' => $stage === 'waiting' && ! $isCalled, 'border-slate-100 bg-white opacity-80' => $stage === 'done', ]) >
@if (! empty($queueIntegration['enabled']) && $appointment->queue_ticket_number) @include('care.partials.queue-ticket', [ 'ticketNumber' => $appointment->queue_ticket_number, 'ticketStatus' => $ticketStatus, 'destination' => $appointment->queue_destination, 'staffDisplayName' => $appointment->queue_staff_display_name, 'showAssignment' => $stage !== 'in_care' && $stage !== 'done', 'prominent' => false, ]) @elseif (! empty($queueIntegration['enabled']) && ($appointment->queue_routing_status ?? '') === 'unresolved') Unassigned @elseif ($appointment->queue_position) {{ $appointment->queue_position }} @endif

{{ $appointment->patient?->fullName() ?? 'Patient' }}

@if ($stage === 'in_care' || $stage === 'done') {{ $appointment->practitioner?->name ?? 'Unassigned' }} @if ($appointment->patient?->patient_number) · {{ $appointment->patient->patient_number }} @endif @else {{ $appointment->patient?->patient_number ?? '—' }} @if ($appointment->reason) · {{ $appointment->reason }} @endif @endif

@if ($hasActions)
@if ($showStart)
@csrf
@endif @if ($openUrl) $stage === 'in_care', 'bg-indigo-600 font-semibold text-white hover:bg-indigo-700' => ! $showStart && $stage !== 'in_care' && $stage !== 'done', 'border border-slate-200 font-medium text-slate-600 hover:bg-slate-50' => $stage === 'done' || ($showStart && $stage !== 'in_care'), ])>Open @endif @if ($canRecall)
@csrf
@endif
@endif