@php $patient = $prescription->patient; $items = $prescription->items; $outstanding = $items->filter(fn ($item) => ! $item->is_dispensed); $void = in_array($prescription->status, ['cancelled', 'expired'], true); // A script on hold, cancelled or expired has no counter work left to do. $canDispense = ! $void && $prescription->status !== 'on_hold'; $estimate = $items->sum(fn ($item) => (float) ($item->line_total ?? 0)); $priced = $items->whereNotNull('line_total')->count(); $trim = fn ($value) => rtrim(rtrim(number_format((float) $value, 2), '0'), '.'); $seed = is_array(old('items.0')) ? old('items.0') : []; $initials = $patient ? Str::of($patient->full_name)->explode(' ')->filter()->take(2) ->map(fn (string $part) => Str::upper(Str::substr($part, 0, 1)))->implode('') : '—'; $typeLabel = match ($prescription->prescription_type) { 'ipd' => 'Inpatient', 'discharge' => 'Discharge', 'emergency' => 'Emergency', 'controlled' => 'Controlled', default => 'Outpatient', }; @endphp @if ($prescription->is_controlled) Controlled @endif @if ($patient?->isRestricted()) Restricted record @endif Print slip @can('prescriptions.create') @if ($prescription->is_editable) Amend @endif @endcan @can('prescriptions.dispense') @if ($prescription->status === 'on_hold') @elseif (in_array($prescription->status, ['pending', 'partially_dispensed'], true)) @endif @endcan @can('prescriptions.cancel') @if ($prescription->is_cancellable) @endif @endcan {{-- ------------------------------------------------------------ notices --}} @if ($errors->any())
    @foreach ($errors->all() as $message)
  • {{ $message }}
  • @endforeach
@endif @if ($prescription->status === 'cancelled')
{{ $prescription->cancellation_reason }} Cancelled by {{ $prescription->cancelledBy?->name ?? 'an unknown account' }} @if ($prescription->cancelled_at) on {{ $prescription->cancelled_at->format('d M Y \a\t H:i') }} @endif — nothing may be handed over against it.
@elseif ($prescription->status === 'on_hold')
The counter has paused this script. Release it to the queue before anything is dispensed.
@endif @if ($patient?->isRestricted())
Access to this record is limited. You are seeing it because your account holds the restricted-access permission, and this access has been logged.
@endif @if ($prescription->is_controlled && ! $void)
Record every hand-over in the controlled register against {{ $prescription->prescription_no }}, and keep the prescription slip with it.
@endif
{{-- ------------------------------------------------------- the lines --}}
{{ $items->count() }} line(s) · {{ $items->count() - $outstanding->count() }} fully dispensed @if ($outstanding->isNotEmpty()) · {{ $outstanding->count() }} outstanding @endif @can('prescriptions.create') @if ($prescription->is_editable) @endif @endcan
    @foreach ($items as $index => $item) @php $batches = $batchesByItem[$item->id] ?? collect(); $remaining = round((float) $item->quantity - (float) $item->quantity_dispensed, 2); $stocked = (bool) $item->drug?->inventory_item_id; $canSubstitute = ! $void && $prescription->status !== 'dispensed' && (float) $item->quantity_dispensed <= 0 && $item->substitution_allowed; $canRemove = $prescription->is_editable && (float) $item->quantity_dispensed <= 0 && $items->count() > 1; @endphp
  • {{ $index + 1 }}

    {{ $item->drug_name }}

    @if ($item->is_stat) Stat @endif @if ($item->is_prn) PRN @endif @if ($item->drug?->is_controlled) {{ $item->drug->controlled_schedule_label }} @endif @if ($item->drug?->is_high_alert) High alert @endif @if (! $item->substitution_allowed) Dispense as written @endif @if (! $item->drug) Off the formulary @endif

    {{ collect([ $item->drug?->form ? $item->drug->form_label : null, $item->drug?->strength, $item->drug?->generic_name, $item->drug?->code, ])->filter()->implode(' · ') ?: 'Not linked to a formulary entry' }}

    Dose
    {{ $item->dose }} {{ lookup_label('dose_unit', $item->dose_unit, '') }} by {{ lookup_label('drug_route', $item->route, $item->route) }}
    Frequency
    {{ lookup_label('drug_frequency', $item->frequency, $item->frequency) }}
    Duration
    {{ $item->duration ?? '—' }}
    @if ($item->instructions)

    {{ $item->instructions }}

    @endif @if ($item->is_prn && $item->prn_indication)

    Give when required for: {{ $item->prn_indication }}

    @endif @if ($item->notes)

    {{ $item->notes }}

    @endif

    {{ $trim($item->quantity) }} {{ lookup_label('dose_unit', $item->quantity_unit, $item->quantity_unit) }}

    @if ((float) $item->quantity_dispensed > 0)

    {{ $trim($item->quantity_dispensed) }} handed over

    @endif @if ($item->is_dispensed)

    Complete

    @elseif ((float) $item->quantity_dispensed > 0)

    {{ $trim($remaining) }} still to give

    @else

    Nothing handed over

    @endif @if ($item->dispensedBatch)

    Batch {{ $item->dispensedBatch->batch_number }} @if ($item->dispensedBatch->expiry_date) · exp {{ $item->dispensedBatch->expiry_date->format('m/Y') }} @endif

    @endif @if ($item->line_total !== null)

    {{ money((float) $item->line_total) }} @if ($item->unit_price !== null) ({{ money((float) $item->unit_price) }} each) @endif

    @else

    No price on the shelf

    @endif
    @can('prescriptions.dispense') @if ($canDispense && ! $item->is_dispensed) @endif @endcan @can('prescriptions.substitute') @if ($canSubstitute) @endif @endcan @can('prescriptions.create') @if ($canRemove)
    @csrf @method('DELETE')
    @endif @endcan
  • @endforeach
@if ($items->isNotEmpty())
{{ $priced }} of {{ $items->count() }} line(s) priced. The charge is raised when the pharmacy hands the medicine over, not when it is prescribed. Estimated {{ money($estimate) }}
@endif
@if ($prescription->diagnosis_notes || $prescription->general_instructions)
@if ($prescription->diagnosis_notes)

Working diagnosis

{{ $prescription->diagnosis_notes }}

@endif @if ($prescription->general_instructions)

Instructions to the patient

{{ $prescription->general_instructions }}

@endif
@endif @if ($prescription->pharmacist_notes) Holds, substitutions and remarks, newest last

{{ $prescription->pharmacist_notes }}

@endif
{{-- --------------------------------------------------------- the file --}}
{{ $initials }}

{{ $patient?->full_name ?? 'Unattached' }}

{{ $patient?->medical_record_number ?? '—' }} @if ($patient) · {{ $patient->age_display }} · {{ $patient->gender_label }} @endif

@if ($patient?->phone)

{{ $patient->phone }}

@endif
@if ($patient) @if ($patient->isRestricted())
Restricted record — handle per facility policy.
@endif
@can('patients.view') Record @endcan @can('patients.view-clinical') Clinical chart @endcan
@endif
Status
{{ $prescription->status_label }}
Written
{{ $prescription->prescribed_at?->format('d M Y H:i') ?? '—' }} @if ($prescription->prescribedBy) {{ $prescription->prescribedBy->name }} @endif
@if ($prescription->encounter)
Encounter
@php $encounterUrl = route_if('encounters.show', $prescription->encounter); @endphp @if ($encounterUrl) {{ $prescription->encounter->encounter_no }} @else {{ $prescription->encounter->encounter_no }} @endif {{ lookup_label('encounter_type', $prescription->encounter->encounter_type, $prescription->encounter->encounter_type) }}
@endif @if ($prescription->visit)
Visit
{{ $prescription->visit->visit_no }} @if ($prescription->visit->token_number) · token {{ $prescription->visit->token_number }} @endif
@endif
Lines
{{ $items->count() }} line(s), {{ $items->where('is_dispensed', true)->count() }} complete
@if ($prescription->is_charged)
Billing
Charged to the bill. @if ($prescription->invoice_id && ($invoiceUrl = route_if('invoices.show', $prescription->invoice_id))) Open the invoice @endif
@else
Billing
Not yet charged — the pharmacy raises it at the counter.
@endif @if ($prescription->dispensedBy)
Dispensed
{{ $prescription->dispensedBy->name }} @if ($prescription->dispensed_at) {{ $prescription->dispensed_at->format('d M Y H:i') }} @endif
@endif @if ($prescription->cancelledBy)
Cancelled
{{ $prescription->cancelledBy->name }} @if ($prescription->cancelled_at) {{ $prescription->cancelled_at->format('d M Y H:i') }} @endif @if ($prescription->cancellation_reason) {{ $prescription->cancellation_reason }} @endif
@endif
  • Draw stock shortest-dated first — the batch list is already in that order.
  • A stocked line leaves in whole units, because the shelf is counted in whole units.
  • Substitution needs the prescriber's leave, and is only possible before any of the line has gone out.
  • Nothing is removed from a line that has already been partly handed over.
{{-- --------------------------------------------------------------- modals --}} @can('prescriptions.create') @if ($prescription->is_editable)
@csrf

Add a line to {{ $prescription->prescription_no }}

The drug is taken from the formulary so the line carries the same shape as one written at the bedside.

@include('prescriptions._picker', ['placeholder' => 'Search the formulary — brand, generic or code…']) {{-- Display only: the server copies the name off the formulary entry. --}}
@endif @endcan @can('prescriptions.dispense') @if ($canDispense) @foreach ($outstanding as $item) @php $batches = $batchesByItem[$item->id] ?? collect(); $remaining = round((float) $item->quantity - (float) $item->quantity_dispensed, 2); $stocked = (bool) $item->drug?->inventory_item_id; $batchOptions = $batches->mapWithKeys(fn ($batch) => [ $batch->id => trim(sprintf( '%s · exp %s · %d on the shelf', $batch->batch_number, $batch->expiry_date?->format('d M Y') ?? 'no expiry', $batch->quantity_available, )), ])->all(); $wholeUnits = $stocked; @endphp
@csrf

Dispense {{ $item->drug_name }}

{{ $item->dose }} {{ lookup_label('dose_unit', $item->dose_unit, '') }} by {{ lookup_label('drug_route', $item->route, $item->route) }}, {{ lookup_label('drug_frequency', $item->frequency, $item->frequency) }}. {{ $trim($remaining) }} {{ lookup_label('dose_unit', $item->quantity_unit, $item->quantity_unit) }} still outstanding on this line.

@if ($stocked && $batches->isEmpty())
{{ $item->drug_name }} has a stock record but no live batch with stock left. Receive a batch, or take this line out of the stock ledger first.
@endif
@if ($stocked && $batches->isNotEmpty()) @endif
@endforeach @endif @endcan @can('prescriptions.substitute') @foreach ($items as $item) @php $canSubstitute = ! $void && $prescription->status !== 'dispensed' && (float) $item->quantity_dispensed <= 0 && $item->substitution_allowed; @endphp @if ($canSubstitute)
@csrf @method('PATCH')

Substitute {{ $item->drug_name }}

The prescriber allowed a swap on this line. Choose the pack that is actually going out — the line is rewritten, and the reason is kept on the pharmacy notes.

@include('prescriptions._picker', ['placeholder' => 'Search for the replacement…'])
@endif @endforeach @endcan @can('prescriptions.dispense') @if (in_array($prescription->status, ['pending', 'partially_dispensed'], true))
@csrf @method('PATCH')

Hold {{ $prescription->prescription_no }}?

The script leaves the dispensing queue until it is released. Nothing can be handed over against it while it is held.

@endif @if ($prescription->status === 'on_hold')
@csrf @method('PATCH')

Release {{ $prescription->prescription_no }}?

The script returns to the dispensing queue at the point it was held.

@endif @endcan @can('prescriptions.cancel') @if ($prescription->is_cancellable)
@csrf @method('PATCH')

Cancel {{ $prescription->prescription_no }}?

The script stands on the record as cancelled and can no longer be dispensed. Nothing has been handed over against it yet, so nothing needs reversing.

@endif @endcan @push('scripts') @endpush