@extends('layouts.app') @section('title', __('prescriptions::messages.prescriptions.title')) @php use App\Modules\Prescriptions\Enums\PrescriptionStatus; use App\Modules\Prescriptions\Models\Prescription; /* | The brief names five states; the record stores four, and two of the five | are the same status seen at different points in the calendar. | | issued + still valid → Active | issued + past its date → Expired | draft → Pending | superseded → Renewed (it was reissued, and this is the | prescription that was replaced) | cancelled → Cancelled | | Expiry is derived rather than stored, so it is worked out once here | rather than in three places that can disagree. */ $presentation = static function (Prescription $p): array { if ($p->status === PrescriptionStatus::Issued && $p->hasExpired()) { return ['px-pill--red', __('prescriptions::messages.prescriptions.state_expired')]; } return match ($p->status) { PrescriptionStatus::Issued => ['px-pill--green', __('prescriptions::messages.prescriptions.state_active')], PrescriptionStatus::Draft => ['px-pill--amber', __('prescriptions::messages.prescriptions.state_pending')], PrescriptionStatus::Superseded => ['px-pill--blue', __('prescriptions::messages.prescriptions.state_renewed')], PrescriptionStatus::Cancelled => ['px-pill--grey', $p->status->label()], }; }; $cards = [ [ 'key' => 'active', 'label' => __('prescriptions::messages.prescriptions.card_active'), 'icon' => 'bi-capsule', 'tone' => 'violet', ], [ 'key' => 'expiring', 'label' => __('prescriptions::messages.prescriptions.card_expiring'), 'icon' => 'bi-hourglass-bottom', 'tone' => 'pink', ], [ 'key' => 'renewed', 'label' => __('prescriptions::messages.prescriptions.card_renewed'), 'icon' => 'bi-arrow-repeat', 'tone' => 'blue', ], [ 'key' => 'controlled', 'label' => __('prescriptions::messages.prescriptions.card_controlled'), 'icon' => 'bi-shield-lock-fill', 'tone' => 'green', ], ]; /* | Whether anything is actually narrowing the list. | | search_field is excluded: it always carries a value — the pill shown as | selected — so counting it would make a screen nobody has filtered offer | to clear filters that were never applied. It narrows nothing on its own; | it only says where the term beside it is aimed. */ $hasFilters = collect($filters) ->except(['search_field']) ->filter(fn ($v): bool => $v !== '') ->isNotEmpty(); @endphp @section('content') {{-- ── Page head ──────────────────────────────────────────────────────── --}}
{{ __('prescriptions::messages.prescriptions.subtitle') }}
{{ $card['label'] }}
{{ number_format($value) }}
@if ($delta !== 0) @endif {{ __('prescriptions::messages.prescriptions.vs_previous', [ 'delta' => $delta > 0 ? '+'.$delta : (string) $delta, ]) }}
{{ __('prescriptions::messages.prescriptions.title') }}
{{ __('prescriptions::messages.prescriptions.showing', [ 'from' => number_format($prescriptions->firstItem() ?? 0), 'to' => number_format($prescriptions->lastItem() ?? 0), 'total' => number_format($prescriptions->total()), ]) }}
{{ __('prescriptions::messages.prescriptions.empty_title') }}
{{ $hasFilters ? __('prescriptions::messages.prescriptions.empty_filtered') : __('prescriptions::messages.prescriptions.empty_text') }}
| {{ __('prescriptions::messages.prescriptions.patient') }} | {{ __('prescriptions::messages.prescriptions.prescriber') }} | {{ __('prescriptions::messages.items.title') }} | {{ __('prescriptions::messages.prescriptions.issued_at') }} | {{ __('prescriptions::messages.prescriptions.valid_until') }} | {{ __('common.status') }} | {{ __('common.actions') }} |
|---|---|---|---|---|---|---|
|
@if ($patient !== null && Route::has('patients.show'))
{{ $patientName }}
@else
{{ $patientName }}
@endif
{{-- Guarded: a prescription written before the
patient was matched has no MRN, and an
unconditional line left a blank gap
between the name and the reference. --}}
@if ($patient?->mrn)
{{ $patient->mrn }}
@if ($patient->ageLabel)
· {{ $patient->ageLabel }}
@endif
@endif
{{-- Still the link to the prescription: it was
what the removed column linked from, and
it is how staff refer to one aloud. --}}
{{ $prescription->reference }}
|
{{ $doctor?->name ?? '—' }}
@if ($doctor?->specialty)
{{ $doctor->specialty }}
@endif
|
@foreach ($prescription->items->take(2) as $item)
{{ $item->drug_name }}
@endforeach
@if ($prescription->items_count > 2)
+{{ $prescription->items_count - 2 }}
@endif
{{-- The prescriber went ahead over an allergy warning. Visible
from the list, because by the time somebody has opened the
record they are already committed. --}}
@if ($prescription->allergy_warnings)
@endif
|
{{ $prescription->issued_at?->format('d M Y') ?? '—' }} | @if ($prescription->valid_until === null) — @else {{ $prescription->valid_until->format('d M Y') }} @if ($prescription->status === PrescriptionStatus::Issued) {{ $remaining < 0 ? __('prescriptions::messages.prescriptions.expired_ago', ['days' => abs($remaining)]) : trans_choice('prescriptions::messages.prescriptions.days_left', $remaining, ['count' => $remaining]) }} @endif @endif | {{ $stateLabel }} |
|