{{-- Specialty action buttons (desktop sticky + mobile sheet). --}} @php $btn = 'flex w-full items-center justify-center rounded-xl px-3 py-2.5 text-sm font-semibold transition'; $btnPrimary = $btn.' bg-indigo-600 text-white hover:bg-indigo-700'; $btnSecondary = $btn.' border border-slate-200 bg-white text-slate-800 hover:bg-slate-50'; $btnAccent = $btn.' border border-indigo-200 bg-indigo-50 text-indigo-900 hover:bg-indigo-100'; $onWorkspace = ($section ?? '') === 'workspace'; $appointment = $workspaceVisit?->appointment; $openConsultation = $appointment?->consultation; $ticketCalled = $appointment && $appointment->queue_ticket_status === 'called'; $canCallNext = $canCallNext ?? ($canManageSpecialty ?? false); $canConsult = $canConsult ?? false; $canAdvanceStage = $canAdvanceStage ?? $canConsult; $canStartConsultationFlag = $canStartConsultation ?? $canConsult; $canBookAppointments = $canBookAppointments ?? false; $canViewPatients = $canViewPatients ?? true; $canViewAppointments = $canViewAppointments ?? true; $appointmentReadyToStart = $appointment && in_array($appointment->status, [ \App\Models\Appointment::STATUS_WAITING, \App\Models\Appointment::STATUS_CHECKED_IN, ], true); $consultationInProgress = $appointment && ( $appointment->status === \App\Models\Appointment::STATUS_IN_CONSULTATION || ($openConsultation && $openConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED) ); $canCompleteConsultation = $canConsult && $consultationInProgress && $openConsultation && $openConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED; $chartTab = collect($workspaceTabs ?? []) ->keys() ->first(fn ($key) => ! in_array($key, ['overview', 'timeline', 'plan', 'treat', 'notes', 'imaging', 'orders', 'billing', 'documents', 'perio', 'lab', 'recalls', 'vitals', 'disposition', 'observation', 'issue', 'transfusion', 'inventory'], true)) ?: match ($moduleKey) { 'emergency' => 'triage', 'blood_bank' => 'requests', default => 'odontogram', }; $stageRoute = match ($moduleKey) { 'dentistry' => 'care.specialty.dentistry.stage', 'emergency' => 'care.specialty.emergency.stage', 'blood_bank' => 'care.specialty.blood-bank.stage', default => null, }; $stageFlow = match ($moduleKey) { 'emergency' => ($emergencyStageFlow ?? [ 'arrival' => ['next' => 'treatment', 'label' => 'Move to treatment'], 'resus' => ['next' => 'treatment', 'label' => 'Move to treatment bay'], 'treatment' => ['next' => 'observation', 'label' => 'Move to observation'], 'observation' => ['next' => 'disposition', 'label' => 'Ready for disposition'], ]), 'blood_bank' => ($bloodBankStageFlow ?? [ 'request' => ['next' => 'crossmatch', 'label' => 'Start cross-match'], 'crossmatch' => ['next' => 'issue', 'label' => 'Ready to issue'], 'issue' => ['next' => 'transfusion', 'label' => 'Start transfusion'], 'transfusion' => ['next' => 'completed', 'label' => 'Complete visit'], ]), 'dentistry' => [ 'waiting' => ['next' => 'chair', 'label' => 'Seat at chair'], 'chair' => ['next' => 'procedure', 'label' => 'Start procedure'], 'procedure' => ['next' => 'recovery', 'label' => 'Move to recovery'], 'recovery' => ['next' => 'completed', 'label' => 'Complete visit'], ], default => [], }; $defaultStartStage = match ($moduleKey) { 'emergency' => 'arrival', 'blood_bank' => 'request', 'dentistry' => 'chair', default => null, }; $defaultStartLabel = match ($moduleKey) { 'emergency' => 'Start triage', 'blood_bank' => 'Start request', 'dentistry' => 'Seat at chair', default => 'Start', }; $currentStage = $workspaceVisit?->specialty_stage; @endphp @if ($onWorkspace && $canCallNext) @include('care.partials.queue-ops', [ 'queueIntegration' => $queueIntegration ?? null, 'queueCallNextRoute' => 'care.specialty.call-next', 'queueCallNextParams' => ['module' => $moduleKey], 'branchId' => $branchId ?? null, 'currentAppointmentId' => $appointment?->id, 'variant' => 'button', ]) @endif @if ($canConsult && $ticketCalled && $appointment)
@endif @if ($workspaceVisit) @if ($canAdvanceStage && $stageRoute && $currentStage && isset($stageFlow[$currentStage]) && ($stageFlow[$currentStage]['next'] ?? null) !== $currentStage) @elseif ($canAdvanceStage && $stageRoute && ! $currentStage && $defaultStartStage) @endif @if ($canCompleteConsultation) @endif @if ($consultationInProgress) Open chart @elseif ($canStartConsultationFlag && $appointmentReadyToStart) @endif @if (($canReferSpecialty ?? false) && ! ($canManageSpecialty ?? true) && $workspaceVisit->patient) @endif @if ($canViewPatients && $workspaceVisit->patient) Patient chart @endif @if ($canViewAppointments && $workspaceVisit->appointment) Appointment @endif @endif @if (! empty($canAccessPatientQueue)) Back to queue @else Specialty home @endif @if ($canBookAppointments) Register / book @endif