@extends('layouts.app') @section('title', $patient->full_name) @php // Whitelist the fields the edit modal needs. Avoids leaking eager-loaded // relations (appointments, prescriptions…) into the page payload. $patientFormData = $patient->only([ 'id', 'first_name', 'last_name', 'gender', 'date_of_birth', 'national_id', 'nationality', 'phone', 'alternative_phone', 'email', 'city', 'address', 'marital_status', 'occupation', 'blood_type', 'allergies', 'chronic_diseases', 'current_medications', 'family_history', 'insurance_provider', 'insurance_number', 'insurance_expires_at', 'emergency_contact_name', 'emergency_contact_phone', 'emergency_contact_relation', 'photo', 'notes', ]); $apptStatusMeta = [ 'scheduled' => ['label' => 'مجدول', 'color' => 'blue'], 'confirmed' => ['label' => 'مؤكد', 'color' => 'azure'], 'checked_in' => ['label' => 'حضر', 'color' => 'cyan'], 'completed' => ['label' => 'مكتمل', 'color' => 'green'], 'cancelled' => ['label' => 'ملغي', 'color' => 'red'], 'no_show' => ['label' => 'لم يحضر', 'color' => 'orange'], ]; $labStatusMeta = [ 'requested' => ['label' => 'مطلوب', 'color' => 'blue'], 'in_progress' => ['label' => 'قيد التنفيذ', 'color' => 'yellow'], 'completed' => ['label' => 'مكتمل', 'color' => 'green'], 'cancelled' => ['label' => 'ملغي', 'color' => 'red'], ]; @endphp @section('content')
@if($patient->photo) {{ $patient->full_name }} @else {{ mb_substr($patient->first_name, 0, 1) }}{{ mb_substr($patient->last_name, 0, 1) }} @endif
ملف المريض · {{ $patient->file_number }}
{{ $patient->full_name }}
{{ $patient->gender === 'female' ? 'أنثى' : 'ذكر' }} @php $__isSaudi = ($patient->nationality ?? 'saudi') === 'saudi'; @endphp {{ $__isSaudi ? 'سعودي' : 'غير سعودي' }} @if($patient->age !== null) {{ $patient->age }} سنة @endif @if($patient->blood_type) {{ $patient->blood_type }} @endif @if($patient->phone) {{ $patient->phone }} @endif
@can('patients.update') @endcan
@if($patient->allergies) @endif
{{-- ============ Overview ============ --}}
الهاتف
{{ $patient->phone ?: '—' }}
هاتف بديل
{{ $patient->alternative_phone ?: '—' }}
البريد
{{ $patient->email ?: '—' }}
العنوان
{{ trim(($patient->address ?: '').($patient->city ? ', '.$patient->city : ''), ', ') ?: '—' }}
الرقم القومي
{{ $patient->national_id ?: '—' }}
الجنسية
@if(($patient->nationality ?? 'saudi') === 'saudi') سعودي @else غير سعودي ضريبة 15% تُطبَّق تلقائياً @endif
المهنة
{{ $patient->occupation ?: '—' }}
التأمين
{{ $patient->insurance_provider ? $patient->insurance_provider.' ('.$patient->insurance_number.')' : '—' }}
@if($patient->notes)

ملاحظات

{{ $patient->notes }}

@endif
{{-- ============ Appointments ============ --}}
@can('appointments.create')
@endcan @forelse($patient->appointments as $a) @php $meta = $apptStatusMeta[$a->status] ?? ['label' => $a->status, 'color' => 'secondary']; @endphp
{{ $a->appointment_date->format('Y-m-d') }} · {{ substr($a->start_time, 0, 5) }} – {{ substr($a->end_time, 0, 5) }}
{{ optional($a->doctor)->name }} · {{ $a->reason ?: $a->type }}
{{ $meta['label'] }}
@can('appointments.update') @endcan @can('appointments.delete') @endcan
@empty @endforelse
{{-- ============ Medical records ============ --}}
@can('medical_records.create')
@endcan @forelse($patient->medicalRecords as $r)
{{ $r->visit_date->format('Y-m-d') }} · د. {{ optional($r->doctor)->name }}
{{ $r->chief_complaint }}
@if($r->diagnosis)
{{ $r->diagnosis }}
@endif
@can('medical_records.update') @endcan @can('medical_records.delete') @endcan
@empty @endforelse
{{-- ============ Prescriptions ============ --}}
@can('prescriptions.create')
@endcan @forelse($patient->prescriptions as $p)
{{ $p->prescription_number }} · {{ $p->issued_at->format('Y-m-d') }} @if($p->doctor)
د. {{ $p->doctor->name }}
@endif
@can('prescriptions.update') @endcan @can('prescriptions.delete') @endcan
@empty @endforelse
{{-- ============ Lab tests ============ --}}
@can('lab_tests.create') @feature('lab_tests')
@endfeature @endcan @forelse($patient->labTests as $l) @php $meta = $labStatusMeta[$l->status] ?? ['label' => $l->status, 'color' => 'secondary']; @endphp
{{ $l->test_name }} {{ $meta['label'] }}
{{ optional($l->test_date)->format('Y-m-d') ?: '—' }} @if($l->lab_name) · {{ $l->lab_name }}@endif
@if($l->file_path) @endif @can('lab_tests.update') @endcan @can('lab_tests.delete') @endcan
@empty @endforelse
{{-- ============ Invoices ============ --}}
@can('invoices.create') @feature('invoices')
@endfeature @endcan @forelse($patient->invoices as $inv)
{{ $inv->invoice_number }} · {{ $inv->issue_date->format('Y-m-d') }}
المبلغ: {{ number_format($inv->total, 2) }} · المتبقي: {{ number_format($inv->balance, 2) }}
{{ $inv->status }}
@can('invoices.update') @endcan @can('invoices.delete') @endcan
@empty @endforelse

جهة الاتصال للطوارئ

@if($patient->emergency_contact_name)
{{ $patient->emergency_contact_name }}
{{ $patient->emergency_contact_phone }}
{{ $patient->emergency_contact_relation }}
@else

لم تُحدَّد.

@endif

الأمراض المزمنة

{{ $patient->chronic_diseases ?: 'لا يوجد.' }}

الأدوية الحالية

{{ $patient->current_medications ?: 'لا يوجد.' }}

@include('patients._form-modal') @can('appointments.create') @include('appointments._form-modal', ['doctors' => $doctors]) @endcan @include('patients._resource-modals', ['doctors' => $doctors]) @endsection @push('scripts') @endpush