@if ($forBrowser ?? false) {{-- Screen only, and hidden from the paper by the rule above. DomPDF never reaches this branch at all. --}}
{{ $order->reference }} {{ __('common.back') }} {{-- Its own tab, so downloading a copy does not navigate away from the report somebody is about to print. --}} {{ __('laboratory::messages.print.pdf') }} {{-- Wired in print.js: an onclick attribute is inline script, which the Content-Security-Policy refuses. --}}
@endif
{{-- The clinic's own letterhead, when one has been uploaded in Settings. --}}
{{ $clinic['name'] }}
{{ $clinic['address'] }}{{ $clinic['phone'] ? ' · '.$clinic['phone'] : '' }}
{{ __('laboratory::messages.print.report') }}
{{ $order->reference }}
{{ __('laboratory::messages.print.reported_on') }}: {{ now()->format('Y-m-d H:i') }}
{{ __('laboratory::messages.print.patient') }}
{{ $patient?->name }}
{{ __('laboratory::messages.print.mrn') }} {{ $patient?->mrn }} · {{ $patient?->ageLabel }}
{{ __('laboratory::messages.print.requested_by') }}
{{ $order->orderedBy->name }}
{{ __('laboratory::messages.print.requested_on') }}: {{ $order->ordered_at->format('Y-m-d H:i') }}
@php($specimen = $order->specimens->firstWhere('status', '!=', 'rejected')) @if ($specimen)
{{ __('laboratory::messages.print.accession') }}: {{ $specimen->accession_number }} · {{ __('laboratory::messages.print.collected') }} {{ $specimen->collected_at->format('Y-m-d H:i') }}
@endif
@if ($order->clinical_details)

{{ $order->clinical_details }}

@endif {{-- Grouped by panel, in the order the panel defines. A clinician reads a full blood count in a habitual sequence, and a report that lists analytes alphabetically is a report that gets misread under time pressure. --}} @php($grouped = $order->items->groupBy(fn ($item) => $item->panel_id ?? 0)) @foreach ($grouped as $panelId => $items) @if ($panelId !== 0) @endif @foreach ($items as $item) @php($result = $item->results->firstWhere('superseded_by_id', null)) {{-- The bench's remark about this run, on the line it belongs to. Only for a released result, for the same reason the value beside it is withheld: a remark on a number nobody has signed off describes work in progress, and on paper it reads as a finding. --}} {{-- The verdict is the answer the clinician asked for; the index is the working. --}} @if ($result?->isReleased() && $result->cutoff_verdict !== null) @endif {{-- A titre panel's finding is the endpoint per antigen. A row reading "no agglutination" is a result, so every antigen prints, including the negative ones. --}} @if ($result?->isReleased() && $item->result_type === \App\Modules\Laboratory\Enums\ResultType::Titre && $result->titres->isNotEmpty()) @endif {{-- A culture's finding is not its value — it is what grew and what that responded to. Printing only the value would put "Growth" on the page and leave off the one thing the prescriber needs. --}} @if ($result?->isReleased() && $item->result_type === \App\Modules\Laboratory\Enums\ResultType::Culture && $result->isolates->isNotEmpty()) @endif @endforeach @endforeach
{{ __('laboratory::messages.print.test') }} {{ __('laboratory::messages.print.result') }} {{ __('laboratory::messages.print.range') }} {{ __('laboratory::messages.print.comments') }}
{{ $items->first()->panel?->name }}
{{-- The name, and nothing that could be mistaken for part of it. A remark about the run once sat here in small grey type directly under the analyte, where "normal" read as a description of the test rather than of this patient's result. It has a column of its own now, under a heading that says what it is. --}} {{ $item->test_name }} @if ($result?->status === \App\Modules\Laboratory\Enums\ResultStatus::Amended)
{{ __('laboratory::messages.print.amended_note') }}
@endif
@if ($result?->isReleased()) $result->flag?->isAbnormal(), 'critical' => $result->flag?->isCritical(), ])>{{ $result->printableValue($item->decimal_places) }} @if ($item->unit) {{ $item->unit }} @endif {{-- The one thing a clinician scans a report for. Given its own weight rather than trailing the number as a small letter: on a page of forty analytes it is what the eye is hunting. --}} @if ($result->flag && $result->flag->mark() !== '') $result->flag->isCritical()])>{{ $result->flag->mark() }} @endif @else {{-- An unverified value is not a result and does not appear on paper. --}} {{ __('laboratory::messages.print.not_reported') }} @endif {{-- For an assay the threshold takes the place of a range: it is what the number was read against, and a report showing the index without it cannot be interpreted at all. --}} @if ($result?->isReleased() && $item->result_type === \App\Modules\Laboratory\Enums\ResultType::Cutoff && $result->cutoff !== null) {{ __('laboratory::messages.cutoff.threshold', ['value' => rtrim(rtrim((string) $result->cutoff, '0'), '.')]) }} @else {{ $result?->printableRange($item->decimal_places) }} {{-- The unit rides with the value, and there is no value yet on a test still being run — which left its range printing as a bare "13.0 - 18.0". A range with no unit is not a range. So when nothing has been reported, the unit is stated here instead; it is named once either way. --}} @if ($item->unit && ! $result?->isReleased()) {{ $item->unit }} @endif @endif @if ($result?->isReleased() && $result->comment) {{ $result->comment }} @endif
$result->flag?->isAbnormal()])>{{ $result->cutoff_verdict }}
@foreach ($result->titres as $titre) @endforeach
{{ $titre->antigen_name }} {{ $titre->titre ?? __('laboratory::messages.titres.none') }}
@foreach ($result->isolates as $isolate)
{{ $isolate->organism_name }} @if ($isolate->colony_count) — {{ $isolate->colony_count }} @endif @if ($isolate->sensitivities->isNotEmpty()) @foreach ($isolate->sensitivities->chunk(2) as $pair) @foreach ($pair as $s) @endforeach {{-- Keeps the last row aligned when the count is odd. --}} @if ($pair->count() === 1) @endif @endforeach
{{ $s->antibiotic_name }} {{ $s->sensitivity->letter() }}
@endif @if ($isolate->note)
{{ $isolate->note }}
@endif
@endforeach
{{ __('laboratory::messages.cultures.key') }}
{{-- The bench's remarks are a column of the results table above, not a section of their own. They were briefly gathered under their own heading at the foot of the report, because printing them under the analyte's name in small grey type made "normal" look like part of what the test *is*. A column with COMMENTS written over it says what they are without moving them away from the line they describe — which is where a clinician reading across a row expects to find them. `$remarks` is still passed by the controller and is no longer read here. --}} @php($released = $order->items->flatMap->results->filter->isReleased()) {{-- Who this clinic says stands behind the document, and how to check that it is genuine. Above the clinical footnote deliberately: it is the part somebody holding a suspicious report is looking for. --}} @isset ($authenticity) @endisset
@if ($forBrowser ?? false) @vite('resources/js/print.js') @endif