{{-- The prescription document. One template, two renderers. The browser draws it as a premium A4-shaped card and prints it; DomPDF draws the same markup for the downloadable copy. That is why the layout is built from tables and simple boxes rather than flex and grid: DomPDF understands CSS 2.1, and a second template for the PDF would be a second thing to keep in step with a legal document. Screen-only chrome — the page background, the toolbar, the card shadow — lives inside @media screen, which DomPDF ignores. --}} {{ $prescription->reference }} @if ($forBrowser ?? false) {{-- Screen only, and hidden from the paper by the print media query above. DomPDF never reaches this branch at all. --}}
{{ __('prescriptions::messages.prescriptions.title') }} / {{ $prescription->reference }} {{ __('common.back') }} {{ __('prescriptions::messages.print.pdf') }} {{-- Wired in print.js: an onclick attribute is inline script, which the Content-Security-Policy refuses. --}}
@vite('resources/js/print.js') @endif @php /* | Every clinic detail is optional. | | A settings screen with an empty email box must not take the prescription | down with it, and the callers of this view — the page, the PDF and a | test — should not each have to know the full shape of the array. */ $clinicName = $clinicName ?? ''; $clinicPhone = $clinic['phone'] ?? ''; $clinicEmail = $clinic['email'] ?? ''; $clinicAddress = $clinicAddress ?? ''; $clinicRegistration = $clinicRegistration ?? ''; $clinicContact = collect([$clinicPhone, $clinicEmail])->filter()->implode(' · '); @endphp
{{-- The clinic's own letterhead, when one has been uploaded. It replaces the typed clinic block rather than sitting above it: a designed header band already carries the name, the address and the contact details, and printing them twice is how a prescription starts looking like a draft. --}} @if ($letterhead['header'] ?? null) @endif {{-- The clinic, and nothing else. The reference number, its status and its date used to sit opposite, which printed the reference twice — once here and once in the patient panel below. They now live in that panel, under the reference they describe, where somebody reading the sheet meets them together. --}} @unless ($letterhead['header'] ?? null)
{{ $clinicName }}
@if ($clinicAddress)
{{ $clinicAddress }}
@endif
{{ $clinicContact }}
@if ($clinicRegistration)
{{ __('prescriptions::messages.print.clinic_registration') }}: {{ $clinicRegistration }}
@endif
@endunless {{-- ── Patient ───────────────────────────────────────────────────────── --}}
{{ __('prescriptions::messages.print.patient_information') }}
{{-- Ruled apart, as in the reference: three short facts run together read as one sentence. --}} {{-- The reference and the date it was written. The status and the copy number are not printed: on paper handed to a patient they say nothing the sheet itself does not, and both are on the screen where the decisions about them are actually made. --}}
{{ $patient?->name ?? '—' }}
{{ __('prescriptions::messages.print.mrn') }}: {{ $patient?->mrn ?? '—' }}
{{ __('prescriptions::messages.print.age') }}
{{ $patient?->ageLabel ?: '—' }}
{{ __('prescriptions::messages.print.title') }}
{{ $prescription->reference }}
{{ __('prescriptions::messages.print.date') }}: {{ ($prescription->issued_at ?? $prescription->created_at)?->format('d M Y') ?? '—' }}
{{ __('prescriptions::messages.print.valid_until') }}
{{ $prescription->valid_until?->format('d M Y') ?? '—' }}
{{-- ── Allergies ─────────────────────────────────────────────────────── --}}
{{ __('prescriptions::messages.allergy.recorded') }}
@if ($prescription->allergy_warnings) {{-- Recorded at the moment of issue: what the prescriber saw and acted on, not what the record says today. --}}
{{ __('prescriptions::messages.allergy.overridden') }} @foreach ($prescription->allergy_warnings as $warning)
{{ $warning['drug'] }} — {{ $warning['allergen'] }}
@endforeach
@else
{{ __('prescriptions::messages.allergy.none') }}
@endif
{{-- ── Problem list ──────────────────────────────────────────────────── --}} {{-- What the prescription was written for. A pharmacist handed a list of drugs with no indication either dispenses blind or telephones. Printed only when there is something to print: an empty "Problem list" heading takes a centimetre of a sheet that already pins its footer. --}} @if (($conditions ?? []) !== [])
{{ __('prescriptions::messages.conditions.title') }}
@foreach ($conditions as $condition) @endforeach
{{ $condition->name }} {{-- Resolved is worth printing and worth marking: a pharmacist reading "hypertension" needs to know it is history, not why this sheet was written. --}} @unless ($condition->isCurrent) · {{ __('patients::messages.status.'.$condition->status) }} @endunless @if ($condition->diagnosedOn) {{ __('prescriptions::messages.conditions.since') }} {{ \Illuminate\Support\Carbon::parse($condition->diagnosedOn)->format('M Y') }} @endif
@endif {{-- ── Medicines ─────────────────────────────────────────────────────── --}}
℞ {{ __('prescriptions::messages.print.medications') }}
@forelse ($prescription->items as $item) @empty @endforelse
# {{ __('prescriptions::messages.items.drug') }} {{ __('prescriptions::messages.items.dose') }} {{ __('prescriptions::messages.items.frequency') }} {{ __('prescriptions::messages.items.duration') }} {{ __('prescriptions::messages.items.quantity') }}
{{ str_pad((string) $loop->iteration, 2, '0', STR_PAD_LEFT) }} {{ $item->drug_name }} @if ($item->strength) {{ $item->strength }} @endif @if ($item->form) {{ $item->form }} @endif @if ($item->is_controlled) CD @endif @if ($item->generic_name && $item->generic_name !== $item->drug_name)
{{ $item->generic_name }}
@endif @if ($item->indication)
{{ __('prescriptions::messages.items.indication') }}: {{ $item->indication }}
@endif {{-- The line the patient follows, kept with the medicine it belongs to rather than split across columns that vanish on a phone. --}} @if ($item->instructions)
{{ $item->instructions }}
@endif
{{ $item->dose ?: '—' }} {{ $item->frequency ?: '—' }} @if ($item->is_prn)
{{ __('prescriptions::messages.items.prn') }}
@endif
{{ $item->duration ? $item->durationLabel() : '—' }} {{ $item->quantity ? trim(rtrim(rtrim((string) $item->quantity, '0'), '.').' '.$item->quantity_unit) : '—' }}
{{ __('prescriptions::messages.items.empty') }}
{{-- ── Advice that prints with the medicines ─────────────────────────── --}} @foreach ($prescription->protocols as $attached)
{{ $attached->title }}
@endforeach @if ($prescription->notes)
{{ __('prescriptions::messages.print.notes') }}
{{ $prescription->notes }}
@endif {{-- ── Prescriber ────────────────────────────────────────────────────── --}} {{-- A ruled line, not a stored image: nothing in this product holds a signature, and drawing one that was never given would be a forgery on a legal document. --}}
{{ __('prescriptions::messages.print.prescriber') }}
{{-- Only what is on file. A prescriber is resolved through their clinician profile — qualifications, specialty and registration number all live there. An account that issues a prescription without one has no details to print, and inventing them on a legal document is not an option, so the sheet says plainly that they are missing and where they come from. --}} @if ($doctor)
{{ $doctor->name }}
@if ($doctor->qualifications)
{{ $doctor->qualifications }}
@endif @if ($doctor->specialty)
{{ $doctor->specialty }}
@endif @if ($doctor->licenseNumber)
{{ __('prescriptions::messages.print.registration') }}: {{ $doctor->licenseNumber }}
@endif @else
{{ __('prescriptions::messages.print.prescriber_missing') }}
@endif
{{ __('prescriptions::messages.print.signature') }}
{{-- Below the signature, above the letterhead band. A pharmacist checking whether a prescription is genuine reads it after the prescriber's name, not before — and the block has to sit inside the content flow rather than in the pinned foot, which the letterhead owns. --}} @isset ($authenticity) @endisset {{-- ── Footer ──────────────────────────────────────────────────────────── Pinned to the foot of the page rather than left to follow the last medicine. A prescription rarely fills a sheet, and a letterhead band floating halfway down with white space under it looks like the document ran out rather than ended. --}}
{{-- Our own line first, the clinic's artwork last. The band is designed to finish the sheet, so nothing of ours belongs under it — printing the reference below the letterhead looks like a stamp somebody added afterwards. --}} @if ($letterhead['footer'] ?? null) @endif