@extends('layouts.app') @section('title', $patient->full_name) @section('content')
{{-- ═══ LEFT COLUMN ════════════════════════════════════════════════════════ --}}
{{-- Profile card --}}
{{ strtoupper(substr($patient->first_name,0,1).substr($patient->last_name,0,1)) }}

{{ $patient->full_name }}

{{ $patient->mrn }}

{{ ucfirst($patient->status) }} @foreach($patient->alerts ?? [] as $alert) {{ $alert }} @endforeach
@if($patient->has_allergy_alerts)

⚠ ALLERGIES

{{ implode(', ', $patient->allergies) }}

@endif @if($patient->has_chronic_conditions)

Chronic Conditions

{{ implode(', ', $patient->chronic_conditions) }}

@endif {{-- Note: Outstanding balance is shown in the expanded widget on the right-hand column of this page. Kept out of the sidebar to avoid duplicating the same data in two places. --}}
Gender{{ $patient->gender }}
Age{{ $patient->age ?? '-' }}
DOB{{ $patient->date_of_birth?->format('d M Y') ?? '-' }}
Phone{{ $patient->phone ?? '-' }}
@if($patient->alt_phone)
Alt. Phone{{ $patient->alt_phone }}
@endif
ID Number{{ $patient->id_number ?? '-' }}
Blood Group{{ $patient->blood_group ?? '-' }}
@if($patient->email)
Email{{ $patient->email }}
@endif
County{{ $patient->county ?? '-' }}
@if($patient->occupation)
Occupation{{ $patient->occupation }}
@endif
{{-- Insurance --}} @if($patient->insurance_id)

Insurance

Company{{ $patient->insuranceCompany->name ?? '-' }}
Member No.{{ $patient->insurance_member_no ?? '-' }}
Scheme{{ $patient->insurance_scheme ?? '-' }}
@endif {{-- ═══ CONTACTS (Guardian / Caregiver / NOK / Guarantor) ═══ --}}

Contacts & Representatives

@if(auth()->user()->hasAnyRole('Receptionist','Triage Nurse','Clinician','Nurse','Hospital Admin','Super Admin')) @endif
@forelse($patient->contacts->sortBy('role') as $contact)
{{ $contact->role_label }} @if($contact->is_primary)PRIMARY@endif @if($contact->has_legal_authority)LEGAL AUTHORITY@endif

{{ $contact->name }}

@if($contact->relationship)

{{ ucfirst($contact->relationship) }}

@endif @if($contact->phone)

📞 {{ $contact->phone }}

@endif @if($contact->id_number)

ID: {{ $contact->id_number }}

@endif @if($contact->is_billing_guarantor)

Billing Guarantor @if($contact->credit_limit) · Limit: KES {{ number_format($contact->credit_limit) }}@endif

@endif
@if(auth()->user()->hasAnyRole('Receptionist','Triage Nurse','Hospital Admin','Super Admin'))
@csrf @method('DELETE')
@endif
@empty

No contacts recorded. Add guardian, caregiver, next of kin, or guarantor details.

@endforelse {{-- Legacy NOK fallback (shown when no structured contacts exist) --}} @if($patient->contacts->isEmpty() && ($patient->nok_name || $patient->nok_phone))

Legacy Next of Kin (not yet structured)

{{ $patient->nok_name }}

{{ $patient->nok_phone }} · {{ $patient->nok_relationship }}

Consider migrating to a structured contact using the Add button above.

@endif
{{-- Actions --}}
Edit Full History @if(auth()->user()->hasAnyRole('Super Admin', 'Hospital Admin')) {{-- Sick leave issuance is restricted to Super Admin / Hospital Admin. Other roles can VIEW past certificates via the list below, but only these admin tiers can issue a new one. --}} Issue Sick Leave @endif
{{-- ═══ RIGHT COLUMN | visits & activity ══════════════════════════════════ --}}
{{-- Patient Balance Summary (expanded — full right column is available) --}} @include('partials._patient-balance-summary', ['patient' => $patient, 'compact' => false]) @if($patient->appointments->count())

Upcoming Appointments

@foreach($patient->appointments->take(3) as $apt)

{{ $apt->appointment_date->format('D, d M Y') }} {{ $apt->appointment_time ? '@ '.$apt->appointment_time : '' }}

{{ $apt->type }} · {{ $apt->department->name ?? '' }}

{{ ucfirst($apt->status) }}
@endforeach
@endif {{-- Recent Visits --}}

Recent Visits

View All →
@forelse($patient->visits as $visit) @empty @endforelse
Date Visit # Type Doctor Invoice Status
{{ $visit->created_at->format('d M Y') }} {{ $visit->visit_number }} {{ str_replace('_', ' ', $visit->visit_type) }} {{ $visit->clinician->name ?? '-' }} @if($visit->invoice) KES {{ number_format($visit->invoice?->total_amount) }} @else - @endif {{ ucfirst(str_replace('_',' ',$visit->status)) }}
No visits recorded yet.
{{-- Sick Leave Certificates issued to this patient. Shown to ALL roles that can reach this profile, so non-admin clinical staff and Reception can find and reprint past certs. Only Admin sees the "Issue Sick Leave" button up top. --}} @php $sickLeaves = \App\Models\SickLeave::with(['attendingClinician', 'issuer']) ->where('patient_id', $patient->id) ->latest('issued_at') ->limit(10) ->get(); @endphp @if($sickLeaves->count())

Sick Leave Certificates

@if(auth()->user()->hasAnyRole('Super Admin', 'Hospital Admin')) + Issue New @endif
@foreach($sickLeaves as $sl) @endforeach
Issued Treatment Days Issued To Sign-off
{{ $sl->issued_at?->format('d M Y H:i') }} {{ $sl->treatment_date?->format('d M Y') }} {{ $sl->days }} @if($sl->isForGuardian()) Guardian {{ $sl->guardian_name }} @else Patient @endif {{ $sl->sign_off_name }} View · Print
@endif @if($patient->admissions->where('status', 'admitted')->count())

Currently Admitted

@foreach($patient->admissions->where('status', 'admitted') as $adm)

Ward: {{ $adm->ward->name ?? '' }} · Bed: {{ $adm->bed->bed_number ?? '' }}

Since: {{ $adm->admission_date->format('d M Y') }} ({{ $adm->length_of_stay }} day{{ $adm->length_of_stay == 1 ? '' : 's' }})

Reason: {{ $adm->reason }}

@endforeach
@endif
{{-- ═══ ADD CONTACT MODAL ═══════════════════════════════════════════════════ --}} @endsection @section('scripts') @endsection