@php $patient = $patient ?? new \App\Models\Patient\Patient(); $profile = old('profile', [ 'occupation' => $patient->profile->occupation ?? '', 'marital_status' => $patient->profile->marital_status ?? '', 'preferred_language' => $patient->profile->preferred_language ?? '', 'blood_group' => $patient->profile->blood_group ?? '', 'notes' => $patient->profile->notes ?? '', ]); $medicalHistory = old('medical_history', [ 'allergies' => $patient->medicalHistory->allergies ?? '', 'chronic_diseases' => $patient->medicalHistory->chronic_diseases ?? '', 'current_medications' => $patient->medicalHistory->current_medications ?? '', 'medical_notes' => $patient->medicalHistory->medical_notes ?? '', 'dental_history' => $patient->medicalHistory->dental_history ?? '', 'important_alerts' => $patient->medicalHistory->important_alerts ?? '', ]); $contacts = old('emergency_contacts', $patient->emergencyContacts?->map(fn ($contact) => [ 'name' => $contact->name, 'relation' => $contact->relation, 'phone' => $contact->phone, 'notes' => $contact->notes, ])->values()->all() ?? []); if (empty($contacts)) { $contacts = array_fill(0, 2, ['name' => '', 'relation' => '', 'phone' => '', 'notes' => '']); } @endphp @if ($errors->any())