{{-- 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())
Follow-up visits @forelse ($fuVisits as $fv) @php $fvText = \Carbon\Carbon::parse($fv->date)->format('d M, Y') . ($fv->dr ? ' · Dr ' . $fv->dr->name : '') . ($fv->entry_status === 'Entered' ? ' · seen' : ''); @endphp @if ($fuOpen) {{ $fvText }} @else {{ $fvText }} @endif @empty none yet @endforelse @if ($fuCanBook) @endif
@if ($fuCanBook) @include('patient_mangement.appointment.follow_up_js') @endif @endif