{{-- On a discharged admission / emergency visit: "Book follow-up" (a free visit linked to this stay) and the follow-up visits already booked from it. Include with ['fuKind' => 'admission'|'emergency', 'fuStay' => the model, 'fuNo' => its number, 'fuPatient' => patient name]. --}} @php $fuDischarged = $fuStay->status === 'Discharged'; $fuCanBook = $fuDischarged && auth()->user()->can('appointment-follow-up'); $fuVisits = \App\Models\Appointment::where('follow_up_of_' . $fuKind, $fuStay->id) ->with('dr:id,name')->orderBy('date')->get(['id', 'date', 'doctor_id', 'payment_status', 'entry_status']); $fuLabel = ($fuKind === 'admission' ? 'admission #' : 'emergency #') . $fuNo; $fuOpen = auth()->user()->can('appointment-profile'); @endphp @if ($fuCanBook || $fuVisits->isNotEmpty())