@php $patient = $patient ?? null; $encounter = $encounter ?? null; $openEncounters = $openEncounters ?? collect(); $types = $types ?? []; $doseUnits = $doseUnits ?? []; $routes = $routes ?? []; $frequencies = $frequencies ?? []; $defaults = $defaults ?? []; $submitLabel = $submitLabel ?? 'Send to pharmacy'; $action = $action ?? route('prescriptions.store'); $method = $method ?? 'POST'; $backRoute = $backRoute ?? route('prescriptions.index'); $encounterOptions = $openEncounters ->mapWithKeys(fn ($row) => [ $row->id => $row->encounter_no .' · '.lookup_label('encounter_type', $row->encounter_type, $row->encounter_type) .' · '.($row->doctor?->name ?? 'Unassigned') .' · '.($row->started_at?->format('d M Y') ?? ''), ])->all(); // A bounced submission comes back with the rows the prescriber had already // filled in. The display-only columns of each row travel in a `snapshot` // field the browser writes, so the line can be rebuilt exactly as it looked. $lineErrors = function (int $index): array { if (! isset($errors)) { return []; } return collect($errors->getMessages()) ->filter(fn ($messages, $key) => str_starts_with($key, "items.{$index}.")) ->mapWithKeys(fn ($messages, $key) => [Str::afterLast($key, '.') => $messages]) ->all(); }; $seedLines = collect(is_array(old('items')) ? array_values(old('items')) : []) ->map(function ($row, $index) use ($lineErrors) { $row = is_array($row) ? $row : []; $snapshot = is_string($row['snapshot'] ?? null) ? json_decode($row['snapshot'], true) : []; return array_merge(is_array($snapshot) ? $snapshot : [], [ 'drug_id' => $row['drug_id'] ?? '', 'dose' => $row['dose'] ?? '', 'dose_unit' => $row['dose_unit'] ?? 'mg', 'route' => $row['route'] ?? 'oral', 'frequency' => $row['frequency'] ?? 'bd', 'duration_days' => $row['duration_days'] ?? '', 'quantity' => $row['quantity'] ?? '', 'quantity_unit' => $row['quantity_unit'] ?? 'tablet', 'is_stat' => ! empty($row['is_stat']), 'is_prn' => ! empty($row['is_prn']), 'prn_indication' => $row['prn_indication'] ?? '', 'instructions' => $row['instructions'] ?? '', 'substitution_allowed' => ! empty($row['substitution_allowed']), 'errors' => $lineErrors($index), ]); }) ->values() ->all(); @endphp
@csrf @if ($method !== 'POST') @method($method) @endif @if (isset($errors) && $errors->any())

The script was not sent to the pharmacy.

    @foreach ($errors->all() as $message)
  • {{ $message }}
  • @endforeach
@endif Drugs are picked from the formulary, which carries the default dose, frequency and duration for each entry. The pharmacy dispenses exactly what is written here.
@if ($encounterOptions !== []) @endif
@if ($encounter)
This script will be filed against {{ $encounter->encounter_no }} @if ($encounter->visit) (visit {{ $encounter->visit->visit_no }}@if ($encounter->visit->token_number), token {{ $encounter->visit->token_number }}@endif) @endif — {{ lookup_label('encounter_type', $encounter->encounter_type, $encounter->encounter_type) }}.
@elseif ($encounterOptions !== [])

Leaving the encounter blank writes a standalone script — it still reaches the pharmacy, but it is not filed against a clinical record.

@else

No encounter is open for this patient, so the script is written standalone.

@endif

Medicine

Search the formulary and the drug is added as a line below.

line(s)
@include('prescriptions._picker', ['placeholder' => 'Search by brand, generic or code…', 'autofocus' => true])

No medicine on the script yet

Search the formulary above to add the first line.

Cancel
@if ($patient)
{{ Str::of($patient->first_name)->substr(0, 1)->upper() }}{{ Str::of($patient->last_name)->substr(0, 1)->upper() }}

{{ $patient->full_name }}

{{ $patient->medical_record_number }}

{{ $patient->age_display }} · {{ $patient->gender_label }} @if ($patient->phone) · {{ $patient->phone }} @endif

@if ($patient->isRestricted())
Restricted record — handle per facility policy.
@endif @else

No patient chosen.

@endif
Lines
Controlled
Estimated charge
{{ currency_code() }}

An estimate only — the charge is raised when the pharmacy dispenses, at the price of the batch that actually leaves the shelf.

  • A controlled drug on the script sends it to the register, and the schedule prints on the slip.
  • The line can be amended only until the pharmacy hands the first dose over.
  • Quantity is what leaves the shelf, so write it to match the course.
@push('scripts') @endpush