@php $doctorName = $doctor['full_name'] ?? 'Doctor'; $displayDoctorName = str_starts_with($doctorName, 'Dr.') ? $doctorName : 'Dr. ' . $doctorName; $roomName = $room['room_name'] ?? 'Dental Room 1'; $name = $patient['full_name'] ?? 'Unknown Patient'; $initial = strtoupper(substr($name, 0, 1)); $patientId = $patient['upsi_id'] ?? '-'; $role = ucfirst($patient['role'] ?? 'Patient'); $faculty = $patient['faculty'] ?? '-'; $dobText = !empty($patient['date_of_birth']) ? date('d M Y', strtotime($patient['date_of_birth'])) : '-'; $bloodType = $patient['blood_type'] ?? '-'; $allergies = $patient['allergies'] ?? 'None recorded'; $queueNo = $queue['queue_number'] ?? '-'; $total = (float)($allocation['total_amount'] ?? (($patient['role'] ?? '') === 'staff' ? 250 : 100)); $balance = (float)($allocation['balance_amount'] ?? $total); $used = max($total - $balance, 0); $percent = $total > 0 ? min(($used / $total) * 100, 100) : 0; $visits = count($treatmentHistory ?? []); @endphp Patient Record
{{ now()->format('D, d M Y') }}
🔔

Patient Record

{{ $name }} · {{ $queueNo }}

{{ $initial }}

{{ $name }}

{{ $patientId }} · {{ $role }}
Active {{ $role }} {{ $queueNo }}
DOB {{ $dobText }}
Blood Type {{ $bloodType }}
Allergies {{ $allergies }}
Faculty {{ $faculty }}

Allocation Status

Used RM{{ number_format($used,2) }} RM{{ number_format($balance,2) }} left

Treatment History

{{ $visits }} visits total
@forelse($treatmentHistory ?? [] as $treatment) @php $treatmentName = $treatment['treatment_type'] ?? $treatment['service_name'] ?? 'Dental Treatment'; $date = !empty($treatment['treatment_date']) ? date('d M Y', strtotime($treatment['treatment_date'])) : '-'; $doctorText = $treatment['doctor_name'] ?? $displayDoctorName; $notes = $treatment['notes'] ?? $treatment['description'] ?? 'No clinical notes recorded.'; $price = (float)($treatment['price'] ?? $treatment['amount'] ?? 0); @endphp

{{ $treatmentName }}

{{ $date }} · {{ $doctorText }}

“{{ $notes }}”
RM{{ number_format($price,2) }}
@empty
No treatment history found for this patient.
@endforelse