@extends('layouts.app')
@section('title', $prescription->reference)
@php
/*
| The status enum reports a Bootstrap contextual name, because that is what
| it was written against. Mapped here rather than changed there: the same
| enum labels a badge on the listing and in the print view, and this
| screen's design language is not a reason to move it.
*/
$statusPill = match ($prescription->status->tone()) {
'success' => 'px-pill--green',
'warning' => 'px-pill--amber',
'danger' => 'px-pill--red',
'primary', 'info' => 'px-pill--blue',
default => 'px-pill--grey',
};
/*
| Live warnings while the prescription is a draft; for an issued one, the
| warnings recorded at the moment of issue, because those are what the
| prescriber actually saw and acted on.
*/
$shownWarnings = $prescription->isEditable() ? $warnings : [];
@endphp
@section('content')
{{-- ── Page head ──────────────────────────────────────────────────────── --}}
{{ $patient?->name ?? '—' }}
{{ $prescription->reference }}
@can('print', $prescription)
{{-- Its own tab: the prescription stays on screen behind the
printout, and a target also tells the page swapper to leave
this click alone — the print page is a standalone document
with its own styles, not something it can put in this layout. --}}
{{ __('prescriptions::messages.prescriptions.print') }}
@endcan
{{-- Everything that identifies this prescription, on one line: what state
it is in, whose it is, who wrote it, when, and how many times it has
been printed. --}}
@endif
@endif
{{-- Allergy conflicts. Loud on purpose: this is the one thing on the screen
that should stop somebody mid-click. --}}
@if ($shownWarnings !== [])
@endforelse
@can('update', $prescription)
{{--
The prescribing form.
Every data attribute here is load-bearing: Clinic.prescribing
reads them to run the formulary type-ahead and to check what is
being typed against the patient's allergies before it is added.
The names, the hidden fields and the results list are its
contract with this markup.
--}}
@endcan
{{--
Lifestyle and dietary advice. Prints with the prescription, so
the patient leaves with the plan and the medicines on the same
page rather than being told the plan and expected to remember.
--}}
@forelse ($prescription->protocols as $attached)
@endforelse
@can('issue', $prescription)
{{--
Read it before you sign it.
Issuing is the moment a draft becomes something a patient
collects from a pharmacy, and it used to be one click from
a sidebar that shows none of what is being issued — the
medicines are in the other column, and on a long list the
last one added is off the bottom of the screen.
The button now opens the whole prescription as it will be
dispensed. Nothing is submitted until Issue is pressed
inside it.
--}}
@endcan
@can('cancel', $prescription)
{{-- Two different endings, kept apart on purpose. Reissuing
replaces this prescription with a corrected one;
cancelling ends it and leaves nothing in its place. --}}
@if ($prescription->status->isDispensable())
@endif
@endcan
{{--
The review, rendered outside the two columns.
A modal inside the sidebar inherits that column's stacking and clipping,
and on a narrow screen it opens as a panel trapped in a scrolling box
rather than over the page.
--}}
@can('issue', $prescription)
{{-- Disabled on an empty prescription only to keep somebody from
pressing it; the service refuses an empty issue regardless,
which is what actually enforces it. --}}
@endcan
@endsection