@extends('layouts.app')
@section('title', 'EHR Timeline')
@section('content')
EHR Timeline
{{ $patient->user->name ?? '-' }} · MRN {{ $patient->mrn }}
@php
$events = collect();
foreach (($history['appointments'] ?? []) as $a) { $events->push(['at' => $a->scheduled_at, 'type' => 'Appointment', 'data' => $a]); }
foreach (($history['diagnoses'] ?? []) as $d) { $events->push(['at' => $d->diagnosed_at, 'type' => 'Diagnosis', 'data' => $d]); }
foreach (($history['prescriptions'] ?? []) as $p) { $events->push(['at' => $p->issued_at, 'type' => 'Prescription', 'data' => $p]); }
foreach (($history['medical_records'] ?? []) as $m) { $events->push(['at' => $m->recorded_at, 'type' => 'Medical Record', 'data' => $m]); }
foreach (($history['lab_tests'] ?? []) as $t) { $events->push(['at' => $t->ordered_at, 'type' => 'Lab Test', 'data' => $t]); }
$events = $events->sortByDesc('at')->values();
@endphp