@extends('layouts.app') @section('title', __('pharmacy::messages.dispense.title', ['reference' => $prescription->reference])) @section('content')

{{ $patient?->name ?? __('pharmacy::messages.queue.unknown_patient') }}

{{ $prescription->reference }} {{ $prescription->issuedAt?->format('d M Y') ?? '—' }} @if ($patient?->mrn) {{ $patient->mrn }} @endif

{{ __('common.back') }}
@if ($prescription->containsControlledDrug) @endif
@csrf {{-- Carried on the form, so a double submit — a slow connection and an impatient second click — returns the first result instead of dispensing the course twice. --}} @error('quantities') @enderror
@foreach ($lines as $line) @php $stock = $available[$line->id] ?? 0; $out = $dispensed[$line->id] ?? 0; $suggestion = $suggested[$line->id] ?? null; @endphp @endforeach
{{ __('pharmacy::messages.dispense.medicine') }} {{ __('pharmacy::messages.dispense.directions') }} {{ __('pharmacy::messages.dispense.in_stock') }} {{ __('pharmacy::messages.dispense.already') }} {{ __('pharmacy::messages.dispense.quantity') }}
{{ $line->label() }} @if ($line->form) {{ $line->form }} @endif {{ collect([$line->dose, $line->frequency, $line->duration]) ->filter()->implode(' · ') ?: '—' }} @if ($line->instructions) {{ $line->instructions }} @endif @if ($line->drugId === null) {{-- Written by name only: there is no formulary entry behind it, so there is no shelf to take it off. --}} {{ __('pharmacy::messages.dispense.not_stocked') }} @else {{ number_format($stock) }} @endif {{ $out > 0 ? number_format($out) : '—' }} @if ($line->drugId !== null && $canDispense) @if ($suggestion === null) {{-- The parser refuses far more readily than it guesses; an unsure figure typed by nobody is worse than an empty box. --}} {{ __('pharmacy::messages.dispense.enter_quantity') }} @endif @else — @endif
@if ($canDispense)
{{ __('pharmacy::messages.dispense.all_or_nothing') }}
@endif
@if ($history->isNotEmpty()) @foreach ($history as $entry)
@if ($entry->is_reversal) @endif {{ $entry->drug_name }} {{ $entry->strength }} × {{ number_format($entry->quantity) }} {{ $entry->dispensed_at?->format('d M Y, H:i') }} @foreach ($entry->batches as $slice) · {{ __('pharmacy::messages.dispense.from_batch', [ 'batch' => $slice->batch_number, 'quantity' => $slice->quantity, ]) }} @endforeach @if ($entry->reversal_reason) · {{ $entry->reversal_reason }} @endif
@if ($canDispense && ! $entry->is_reversal && ! $entry->restocked) {{-- Undoing puts the medicine back in the batch it came out of, so a recall still finds it. --}}
@csrf
@elseif ($entry->restocked) {{ __('pharmacy::messages.dispense.reversed_pill') }} @endif
@endforeach
@endif
@endsection