@php $active = $allergies->where('status', \App\Modules\Patients\Enums\ClinicalRecordStatus::Active); $highest = $active->sortByDesc(fn ($a) => $a->severity->isHigh() ? 1 : 0)->first(); /* | The severity enum names a Bootstrap contextual colour, because that is | what it was written against and the clinical list still reads it. Mapped | here rather than renamed underneath everything that already uses it. */ $pill = static fn (string $tone): string => match ($tone) { 'danger' => 'px-pill--red', 'warning' => 'px-pill--amber', 'success' => 'px-pill--green', 'info' => 'px-pill--blue', default => 'px-pill--grey', }; // The banner takes its accent from the worst allergy on the record: one // anaphylaxis among five mild rashes is what the room needs to see. $advice = match ($highest?->severity->tone()) { 'danger' => 'px-advice--critical', 'warning' => 'px-advice--caution', default => 'px-advice--caution', }; @endphp {{-- The single most important thing on this screen. It sits above the fold, before demographics, before anything else, and it states the absence of records as clearly as their presence: "none recorded" and "none known" are different facts, and a blank space reads as the second when it usually means the first. --}} @if ($active->isNotEmpty()) @else @endif