@extends('layouts.app') @section('title', 'Appointments') @section('content') {{-- Appointments index — May 24 2026 revision. Changes vs prior version: • Stats cards bar removed (the counts were never actioned). • Rows are now colour-coded by how close the appointment is: – red → due today or already overdue and still scheduled (the receptionist must check the patient in) – yellow → due in 1–3 days (heads-up to confirm with the patient) Completed / checked-in / cancelled / no-show rows are NOT coloured, because the urgency only matters for live scheduled bookings. • A red banner appears above the table whenever there are any due rows on the current page, prompting the receptionist to action them. The banner only counts appointments visible on the current page, which mirrors what the user actually sees. • Department filter dropdown now uses the standard partial so it picks up the canonical department list automatically. --}} @php // Pre-compute the urgency bucket for each row once so the // table loop stays readable. Only scheduled rows are // ever flagged — everything else is "normal". $today = \Carbon\Carbon::today(); $urgencyOf = function ($apt) use ($today) { if ($apt->status !== 'scheduled') { return 'normal'; } // appointment_date is already cast to Carbon by the model $diffDays = $today->diffInDays($apt->appointment_date, false); // false = signed result. <= 0 means the appointment is // today or in the past. if ($diffDays <= 0) return 'due'; // red if ($diffDays >= 1 && $diffDays <= 3) return 'soon'; // yellow return 'normal'; }; // The "N appointment(s) due — please check the patient in" banner // that used to sit here was removed 25 May 2026. The red row tint // + bold red "Check In" button on each due row already carry the // same signal without the duplicated banner header. $urgencyOf is // still used below to drive the row coloring. @endphp
@if(request()->hasAny(['search','date','status','department'])) Clear @endif
Book Appointment
@forelse($appointments as $apt) @php $urgency = $urgencyOf($apt); @endphp {{-- Row colour classes. We use bg-*-50 (very pale) with a left border accent so the table still reads as a table, not a wall of colour. The normal hover state is preserved for clickable feel. --}} @empty @endforelse
Date & Time Patient Type Department Clinician Status Actions

{{ $apt->appointment_date->format('d M Y') }}

{{-- Explicit inline font-size beats the global "table .text-xs { ... !important }" rule in layouts/app.blade.php. The time + Due/In-N-days line is metadata under the date and reads better one step smaller than its surrounding 13px row text. --}} {{ $apt->appointment_time ?? 'Any time' }} @if($urgency === 'due') · Due @elseif($urgency === 'soon') @php $d = (int) $today->diffInDays($apt->appointment_date, false); @endphp · In {{ $d }} day{{ $d === 1 ? '' : 's' }} @endif

{{ $apt->patient->full_name ?? '' }}

{{ $apt->patient->mrn ?? '' }} · {{ $apt->patient->phone ?? '' }}

{{ str_replace('_',' ',$apt->type) }} {{ $apt->department->name ?? '-' }} {{ $apt->clinician->name ?? 'Any' }} @php $sc = ['scheduled'=>'badge-info','checked_in'=>'badge-success','completed'=>'badge-success','no_show'=>'badge-danger','cancelled'=>'badge-gray']; @endphp {{ ucfirst(str_replace('_',' ',$apt->status)) }}
@if($apt->status === 'scheduled')
@csrf {{-- For due appointments emphasise the Check In button with a solid red fill so the receptionist can't miss it. --}}
@csrf
@csrf @method('DELETE')
@endif
@if($apt->status === 'scheduled') @endif
No appointments found.
@if($appointments->hasPages())
{{ $appointments->links() }}
@endif
@endsection