Skip to content

08 — Prescription Management Module

Status: Implemented in this repository (API + web UI + LM Studio pipeline). Treat this document as the behavioural spec; where the app differs (e.g. extra endpoints or fields), 02-REQUIREMENTS.md §3.4, §7.5 and the code win. Stack and requirements for this area: 01-ARCHITECTURE.md and 02-REQUIREMENTS.md §3.4, §7.5.

Module slug: prescription_management Depends on: medication_dispensing must be active for the tenant. Related code: backend/routers/scripts.py, backend/services/lmstudio.py, backend/services/images.py, frontend/src/pages/Scripts.tsx, ScriptDetail.tsx, scan flow components under frontend/src/components/.

Scan queue (Phase B6 — done 2026-06-02): Jobs live in PostgreSQL (scan_jobs, V075). services/scan_queue.py is a facade over scan_queue_pg.py (enqueue, claim_job, complete_job, fail_job). workers/scan_worker.py claims with FOR UPDATE SKIP LOCKED; SSE uses LISTEN / pg_notify. Redis is not used for scan durability or result delivery. See 04-ROADMAP B6 and 01-ARCHITECTURE.md § Prescription scanning.

Implementation notes (code vs original spec text)

Section titled “Implementation notes (code vs original spec text)”
TopicIn code
Stock formulaWith manual baseline (last_physical_count + last_physical_count_at, V112): on hand = baseline + pharmacy fills since audit − dispensings since audit. Without baseline: legacy fills×qty + stock_adjustment − lifetime dispensings. PATCH pills_available sets baseline via clock_timestamp(). POST …/fills sets baseline to prior on-hand + quantity_added (new pack not reduced by historical dose log). stock_count_needed (V114): admin-only banner on Home/Medications when dose log > 0 and on-hand ≤ 0; prescription_stock_count in Care alerts (bell); tap → edit with How many doses do you have available? highlighted; row auto-clears when a positive count is saved (inline sync). Mark done only if handled without updating stock. StockCountGuidancePanel on Log Dose (form + success) / schedule — never block dispensing. Stock setup “complete” requires quantity_per_fill and total_fills_authorised both > 0.
Dose log (backend only)total_dispensed / total_dispensed_all_time — used for stock mismatch alerts, not shown on family UI.
Medications list cardDoses available + countdown bar (green / amber within 5 of threshold / red). total_stock_on_hand on medicine-summary matches computed on-hand for every status (including exhausted). Exhausted = no repeats left, not zero tablets.
Extra APIGET /api/patients/{id}/scripts/medicine-summary — aggregates scripts per medicine for the Scripts page.
Script statusIncludes archived (migration V005) to hide scripts from the default list without deleting history.
Image uploadNew-script wizard uploads via POST …/scripts/{id}/image after create (Scripts.tsx). EditScriptModal has no image re-attach UI. Files stored under UPLOADS_DIR/<tenant_id>/; DB holds bare filename; served via authenticated GET …/scripts/{id}/image. Missing file on disk shows “Prescription image is unavailable.” in ScriptDetail.tsx (not a re-attach prompt).
LM Studio authLMSTUDIO_API_KEY in backend/.env (dev) or .env.production (VPS). services/lmstudio.py sends Authorization: Bearer … on every /v1/chat/completions call. HTTP 401 surfaces a message pointing at the env var. Probe: scripts/test-lmstudio.ps1.

The Prescription Management module gives care teams a single place to record, track, and act on a patient’s prescribed medications. A carer photographs a script or a dispensed medication label; the system extracts the structured data, associates it with the patient, and uses it to maintain a running stock count. As stock depletes or fills near exhaustion, the dashboard surfaces timely alerts so carers can arrange a pharmacy collection or a doctor visit before medication runs out.


The data model in this module is intentionally aligned with the FHIR R5 clinical standard:

LynCareOS conceptFHIR equivalentNotes
patient_scriptsMedicationRequestThe prescription / order
script_fillsMedicationDispenseEach pharmacy collection
dispensingsMedicationAdministrationEach dose administered

This alignment means future interoperability with My Health Record (AU) or any FHIR-compliant system is achievable without reworking the core data model.


SlugDependency
prescription_managementIncluded on all paid tiers (Essential, Family, Complete). Requires medication_dispensing for dose/stock linkage.

require_module("prescription_management") must wrap all prescription endpoints.

Active-prescription caps (max_medicines in tiers.json, counted as patient_scripts with status = 'active'): Essential 2 · Family 5 · Complete unlimited. Creating beyond the cap raises HTTP 402 LIMIT_MEDICINES with an upgrade hint (enforce_active_medicine_limit → <UpgradeGate>).


TermMeaning in this system
ScriptA prescription issued by a licensed prescriber authorising a medicine for a named patient. AU: PBS script. Other jurisdictions: Rx, prescription.
FillA single collection of the script from a pharmacy. One fill provides a defined quantity (e.g. 28 tablets).
Total fills authorisedThe total number of fills the script permits. In Australia (PBS): original dispensing + number of repeats shown on the script. Example: “5 repeats” = 6 total fills authorised. Terminology varies by country; the field captures the total collectable count.
Fills completedHow many fills have been collected to date against this script. Starts at 0; incremented each time a carer records a pharmacy collection.
Stock on handCurrent available supply from this script. API-computed (stock_on_hand): with manual baseline, baseline + fills/dispensings after last_physical_count_at; otherwise legacy lifetime formula.
Doses available (admin)Physical dose count on hand after audit (unit from script). PATCH pills_available persists last_physical_count + last_physical_count_at (authoritative; overrides prior dose-log history for on-hand).
Low stock thresholdA carer-configurable unit count below which a stock-low alert fires. Default: 7 units.

IDRequirement
REQ-SCRIP-SEC-01A script record is scoped to a patient and a tenant. It must never be readable or writable by any user outside that tenant.
REQ-SCRIP-SEC-02A user may only read or create scripts for patients where they hold an active patient_access row (role carer or observer).
REQ-SCRIP-SEC-03observer role users may read scripts and view images. They may not create, edit, record fills, or delete.
REQ-SCRIP-SEC-04carer role users may create scripts, record fills, and edit non-clinical fields (notes, thresholds). They may not delete a script that has dispensing history.
REQ-SCRIP-SEC-05Tenant admin users may manage all scripts for all patients within their tenant.
REQ-SCRIP-SEC-06Super-admin may access any tenant’s scripts via X-Tenant-ID as with other resources.
REQ-SCRIP-SEC-07Script image files must be stored under a path that is not publicly guessable (UUID-based path). Direct URL access without authentication must be refused.
REQ-SCRIP-SEC-08EXIF metadata must be stripped from all uploaded images before storage.
REQ-SCRIP-SEC-09Medicine pickers / dropdowns shown when creating or editing a script (and elsewhere in the carer UI) must be patient-scoped per REQ-MED-14 — they call GET /api/patients/{id}/medicines, not the tenant-wide GET /api/medicines. This prevents another patient’s medicine names from appearing as suggestions when a carer is creating a script for the active patient. The medicines table itself remains tenant-wide by schema; the filter is applied at the read path.

FieldTypeNotes
idSERIAL PK
tenant_idINTEGER FK → tenantsIsolation; required.
patient_idINTEGER FK → patientsPatient this script belongs to.
medicine_idINTEGER FK → medicines, nullableLinked to formulary medicine if matched; null if unmatched.
medicine_name_rawTEXTDrug name as extracted from image or entered by carer. Always stored even when medicine_id is set.
strengthTEXTe.g. "500mg", "10mg/5ml". From extraction or carer input.
formTEXTe.g. "tablet", "capsule", "liquid".
dose_instructionsTEXTe.g. "1 tablet twice daily with food". Free text from script.
unitTEXTDispensing unit: "tablet", "ml", etc. Defaults to "tablet".
quantity_per_fillINTEGER, nullableUnits provided per fill (e.g. 28 tablets). Required before fill stock tracking is active.
total_fills_authorisedINTEGER, nullableTotal fills permitted by this script (original + repeats). Required before fill tracking is active.
fills_completedINTEGER DEFAULT 0Fills collected to date.
low_stock_thresholdINTEGER DEFAULT 7Units below which a stock-low alert fires.
prescriber_nameTEXT, nullableFrom extraction or carer input.
prescriber_practiceTEXT, nullableFrom extraction or carer input.
issued_dateTEXT, nullableDate script was issued (TEXT, matching date convention in schema).
expiry_dateTEXT, nullableDate script expires. AU standard: 12 months for standard scripts, 3 months for controlled drugs.
image_urlTEXT, nullablePath/URL of stored image.
image_stored_atTIMESTAMPTZ, nullableWhen the image was persisted.
scan_statusTEXT CHECK (unscanned, scanned, confirmed, manual)scanned = extraction run; confirmed = carer reviewed and accepted; manual = entered without scan.
scan_raw_textTEXT, nullableRaw OCR / vision model output retained for audit.
scan_confidenceREAL, nullableOverall 0.0–1.0 confidence from extraction model. Null if manual entry.
statusTEXT CHECK (active, paused, exhausted, expired, superseded)See status lifecycle below.
notesTEXT, nullableFreeform carer notes.
created_byINTEGER FK → usersCarer who created the record.
created_atTIMESTAMPTZ DEFAULT NOW()
updated_atTIMESTAMPTZ DEFAULT NOW()

Indexes: (tenant_id, patient_id), (patient_id, status), (expiry_date).

StatusMeaning
activeScript is current and fills may be recorded.
pausedMedication temporarily on hold (e.g. patient hospitalised, prescriber instruction). No fills or dispensings expected. Alerts are suppressed.
exhaustedfills_completed = total_fills_authorised. No further pharmacy fills; physical doses on hand may still be > 0 and are shown on the card.
expiredexpiry_date is in the past and script is not exhausted.
supersededA new script for the same medicine has been issued. This record is read-only and retained for history.

Each pharmacy collection is recorded here. Provides audit history of when stock was added.

FieldTypeNotes
idSERIAL PK
script_idINTEGER FK → patient_scripts ON DELETE CASCADE
fill_numberINTEGERWhich fill this is (1 = first collection). Set to the new fills_completed value after increment.
quantity_addedINTEGERUnits added. Typically equals quantity_per_fill; may differ for partial pharmacy supplies.
collected_byINTEGER FK → usersCarer who recorded the collection.
collected_atTIMESTAMPTZ DEFAULT NOW()
notesTEXT, nullablee.g. pharmacy name, cost, partial supply reason.

Constraint: UNIQUE (script_id, fill_number).


Applied via a separate migration file — not by modifying schema.sql. See 01-ARCHITECTURE.md for migration conventions.

ColumnTypeNotes
patient_idINTEGER FK → patients, nullableAssociates the dispensing with a patient for stock deduction. Required for stock tracking; NULL for legacy rows.
script_idINTEGER FK → patient_scripts, nullableWhen set, this dispensing deducts from the script’s stock on hand.

The extraction pipeline calls a local LM Studio instance running Qwen2.5-VL 7B via its OpenAI-compatible API. All calls are made server-side from FastAPI using httpx.AsyncClient. The model server is never called directly from the browser.

Config keyDefaultPurpose
LMSTUDIO_BASE_URLhttp://192.168.7.104:1234LM Studio server address
LMSTUDIO_API_KEY(empty)Bearer token from LM Studio Settings → API when server authentication is enabled
LMSTUDIO_MODELqwen/qwen2.5-vl-7bModel identifier as registered in LM Studio
LMSTUDIO_TIMEOUT_CONNECT10Seconds to establish TCP connection. Fails fast if LM Studio is down.
LMSTUDIO_TIMEOUT_READ120Seconds waiting for inference response. Set high — vision model inference on a large prescription image can take 10–40 s; this provides headroom for GPU load and complex images.
LMSTUDIO_TIMEOUT_WRITE30Seconds to upload the image in the request body.

All keys above are loaded from backend/.env and backend/config.py (production VPS also layers .env.production). After changing LMSTUDIO_*, restart scan_worker (and app if using Docker) so containers pick up new values.

The scanning endpoint must return a structured error (not crash) if LM Studio is unreachable, returns HTTP 401/403 (missing or invalid token), or times out, so carers can fall back to manual entry. All other API routes are unaffected by LM Studio availability.

Images are sent to POST {LMSTUDIO_BASE_URL}/v1/chat/completions as base64-encoded content parts in the OpenAI vision message format, with Authorization: Bearer {LMSTUDIO_API_KEY} when the key is set (required on LM Studio 0.3+ servers with authentication enabled). EXIF metadata is stripped from the image bytes before base64 encoding. The prompt instructs the model to return a strict JSON object with null for any field it cannot extract from the image.

Qwen2.5-VL does not natively emit per-field confidence scores. The implementation must derive confidence from the model’s output: fields that are absent, ambiguous in the response, or that required a fallback parse receive lower confidence scores. The three-tier display thresholds (≥0.85 / 0.70–0.84 / <0.70) are applied by the backend before returning the response to the frontend.


IDRequirement
REQ-SCRIP-SCAN-01The system must accept an image upload (JPEG or PNG; maximum 15 MB) of either a printed prescription document or a dispensed medication label on packaging.
REQ-SCRIP-SCAN-02The upload endpoint must be authenticated; the calling user must have carer access to the target patient.
REQ-SCRIP-SCAN-03The image must be processed synchronously. The API must respond with extracted fields; background processing (fire-and-forget) is not acceptable — carers need immediate feedback to review and correct fields.
REQ-SCRIP-SCAN-04The extraction pipeline must return at minimum: medicine_name_raw, strength, form, dose_instructions, prescriber_name, issued_date, and a per-field or overall scan_confidence. Missing fields are returned as null.
REQ-SCRIP-SCAN-05EXIF metadata must be stripped from the image before storage.
REQ-SCRIP-SCAN-06The original image must be stored and associated with the patient_scripts row. It must not be deleted after processing.
REQ-SCRIP-SCAN-07The raw extraction text (scan_raw_text) must be stored on the record for audit purposes regardless of whether the extraction succeeded cleanly.
REQ-SCRIP-SCAN-08The API must return extracted fields without saving the script record. The carer reviews and confirms on the frontend; a separate confirm/save call persists the record. Unreviewed extraction data must never enter the database as a confirmed record.
REQ-SCRIP-SCAN-09A carer may create a script record entirely without scanning (manual entry). scan_status is set to manual and scan_confidence is null.
REQ-SCRIP-SCAN-10If extraction fails or times out, the API returns a structured error. The frontend must offer “Try again” and “Enter details manually” — the carer must never face a dead end.
REQ-SCRIP-SCAN-11A carer may re-scan an existing script (e.g. to attach a clearer image). The image and scan fields are updated; a re-scan does not reset fills_completed or fill history.

Based on validated open source prescription recognition systems, three tiers apply:

TierConfidence rangeUI treatment
Verified≥ 0.85No flag. Field shown normally.
Review recommended0.70 – 0.84Amber border + “Please verify” label below field.
Manual verification required< 0.70Amber border + “Unclear in image — please enter manually” label.

IDRequirement
REQ-SCRIP-LIFE-01After carer review and confirmation, scan_status is set to confirmed (or manual) and the record is persisted with status = active.
REQ-SCRIP-LIFE-02fills_completed starts at 0 on creation. A script with fills_completed = 0 has no stock. Alerts must not fire for zero-fill scripts.
REQ-SCRIP-LIFE-03When fills_completed = total_fills_authorised, status is automatically set to exhausted. No further fills may be recorded.
REQ-SCRIP-LIFE-04When expiry_date is in the past and status is not exhausted or superseded, status is set to expired. This transition is applied lazily on next load (no background sweep required for V1).
REQ-SCRIP-LIFE-05A script may be set to paused by a carer or admin when the medication is temporarily on hold. All stock-based alerts are suppressed while paused. Fills and dispensings may not be recorded against a paused script.
REQ-SCRIP-LIFE-06A script may be marked superseded by an admin or carer when a new script for the same medicine is issued. A superseded script is read-only.
REQ-SCRIP-LIFE-07A script with dispensing history may not be hard-deleted. It may only be archived via status change.

IDRequirement
REQ-SCRIP-FILL-01A single prominently placed action (“Script collected” or “Record fill”) is available on the script detail screen when status = active and fills_completed < total_fills_authorised.
REQ-SCRIP-FILL-02The fill action must complete in 3 taps or fewer from the script detail screen: tap button → review pre-filled confirmation → confirm. This is the maximum acceptable interaction count for a routine care action.
REQ-SCRIP-FILL-03The confirmation shows: fill number (e.g. “Fill 2 of 6”), quantity to be added (pre-populated from quantity_per_fill, editable for partial pharmacy supplies), optional notes, and on hand after collection (prior on-hand + quantity — dose log history does not reduce the new pack).
REQ-SCRIP-FILL-04On confirmation: a script_fills row is inserted; fills_completed is incremented; last_physical_count is set to prior on-hand + quantity_added and last_physical_count_at to clock_timestamp() (new pack not reduced by historical dose log); stock_adjustment zeroed; updated_at set.
REQ-SCRIP-FILL-05A fill event is undoable by a tenant admin within the same calendar day, provided no dispensings have been logged against this script since the fill was recorded. This prevents accidental double-fill entries.
REQ-SCRIP-FILL-06Fill history (all script_fills rows) must be visible on the script detail screen: fill number, date collected, quantity, carer name.
REQ-SCRIP-FILL-07Partial fills (where quantity_added < quantity_per_fill) are supported. The carer edits the quantity field in the confirmation. A visual indicator on the fill history row distinguishes partial fills.

IDRequirement
REQ-SCRIP-STOCK-01Stock on hand is a derived value, never stored. Calculated as: (fills_completed × quantity_per_fill) + stock_adjustment − SUM(dispensings.volume WHERE dispensings.script_id = this script), rounded to a whole unit. stock_adjustment defaults to 0; admins reconcile via PATCH pills_available (physical count).
REQ-SCRIP-STOCK-02Stock tracking is only active when both quantity_per_fill and total_fills_authorised are set. If either is null, the script detail screen must indicate that stock tracking requires these fields and provide a direct edit action.
REQ-SCRIP-STOCK-03When a carer logs a dose via the manual log-dose form for a medicine that has an active linked script for the patient, the system must prompt: “Associate with [script name]?” This is optional — the carer may skip — but the prompt must appear.
REQ-SCRIP-STOCK-04When the association is accepted, dispensings.script_id and dispensings.patient_id are set and the dispensing deducts from stock on hand.

IDNotificationTriggerSeverityRecipients
REQ-SCRIP-NOTIF-01Stock running lowstock_on_hand ≤ low_stock_threshold after any dispensing is recorded against this script.AmberAll carers with patient_access to this patient.
REQ-SCRIP-NOTIF-02Approaching last fillfills_completed = total_fills_authorised − 1 (penultimate fill just recorded).AmberAll carers with patient_access. Message: “One fill remaining — consider arranging a doctor visit or phone consult for a new script.”
REQ-SCRIP-NOTIF-03Last fill collectedfills_completed = total_fills_authorised (script now exhausted).RedAll carers with patient_access.
REQ-SCRIP-NOTIF-04Script expiredstatus transitions to expired.RedAll carers with patient_access.
REQ-SCRIP-NOTIF-05Stock exhaustedstock_on_hand = 0 AND fills_completed = total_fills_authorised.RedAll carers with patient_access.
REQ-SCRIP-NOTIF-06Stock count neededstock_on_hand = 0, stock tracking complete (or physical baseline), lifetime dose log > 0.AmberTenant admin / super_admin only on Home and Medications. Inline guidance on Log Dose / schedule dispense for all carers; dispensing never blocked.

Alert rendering rules:

  • Alerts appear as banner chips on the Dashboard and Medications (/scripts), scoped to the active patient.
  • Alerts are computed from script state (fills, stock, status) on each GET …/scripts/alerts — not stored rows.
  • stock_low only when both quantity_per_fill and total_fills_authorised are set (REQ-SCRIP-STOCK-02). If either is missing after at least one fill, show stock_tracking_incomplete (amber) with deep link to script detail ?setup=stock (admin opens Edit).
  • After Script collected (POST …/fills), the UI refetches alerts via scriptsEvents (see 01-ARCHITECTURE.md — Prescription script alerts).
  • Alerts are suppressed for scripts with status = paused, superseded, or archived.
  • Amber alerts use amber-* tokens; red alerts use red-*. Consistent with 03-DESIGN-SYSTEM.md.
  • Done (2026-06-03): per-user Ignore on each banner — 3-day snooze via script_alert_dismissals (V105); POST …/scripts/alerts/dismiss. Snooze clears when the underlying condition resolves. UI: ScriptAlertBanner on Dashboard and Medications.
  • Pending: Dashboard nav badge count for script alerts.
  • Future phases may route alerts to push notifications (Phase 4 infrastructure).

Implementation note (2026-06-03): Banners still clear immediately when underlying state changes (fill, stock edit). Ignore is for carers who want to defer the reminder without fixing stock yet. Home refetch uses cancelled requests so stale “0 units” copy does not overwrite a fresh alerts response after returning from Medications.


All endpoints require prescription_management module and patient access checks.

MethodPathPurpose
POST/api/patients/{id}/scripts/scanUpload image; returns extracted fields. Does not save.
POST/api/patients/{id}/scriptsCreate a script record (post-review).
GET/api/patients/{id}/scriptsList scripts for patient (active first; filterable by status).
GET/api/patients/{id}/scripts/{script_id}Script detail including fill history and derived stock on hand.
PATCH/api/patients/{id}/scripts/{script_id}Update editable fields (notes, thresholds, medicine_id, status).
POST/api/patients/{id}/scripts/{script_id}/fillsRecord a fill.
DELETE/api/patients/{id}/scripts/{script_id}/fills/{fill_id}Undo fill (admin, same-day, no subsequent dispensings).
GET/api/patients/{id}/scripts/{script_id}/imageServe stored image (authenticated, patient-access-gated).
GET/api/patients/{id}/scripts/alertsActive stock/expiry alerts for this patient (respects per-user dismiss snooze).
POST/api/patients/{id}/scripts/alerts/dismissSnooze one alert for the current user (3 days). Body: { script_id, alert_type }.

IDRequirement
REQ-SCRIP-UX-01The scan flow entry point is in the Medications section. A “Scan script” button is accessible from the medicines list and from the log-dose flow. It must not require more than one tap to reach from either location.
REQ-SCRIP-UX-02Image capture supports both camera (mobile) and file upload (desktop) via <input type="file" accept="image/*" capture="environment">. No separate modes or toggles.
REQ-SCRIP-UX-03A full-width preview of the captured image is shown before upload, with “Retake / Choose different” and “Use this image” actions. The preview must be large enough for the carer to confirm the image is legible before submitting.
REQ-SCRIP-UX-04Once the carer confirms the image, all interactive elements are disabled and a staged progress indicator is shown with a visible label that updates through three named stages: “Uploading image…” → “Processing image…” → “Extracting details…”. A bare unlabelled spinner does not meet this requirement.
REQ-SCRIP-UX-04aIf extraction fails or times out, the progress indicator is replaced with a clear inline error message and two options: “Try again” and “Enter details manually”. The carer must never be left at a dead end.
REQ-SCRIP-UX-05On successful extraction, the review screen displays the captured image and extracted fields simultaneously. On mobile: image occupies approximately the top 40% of the screen; form occupies the remainder and is independently scrollable. On desktop (lg:): image in left column, form in right column.
REQ-SCRIP-UX-05aThe image on the review screen is pinch-zoomable on mobile. A “View full size” tap opens the image in a full-screen overlay.
REQ-SCRIP-UX-05bEvery extracted field is rendered as an editable input pre-populated with the extracted value. No field is read-only on the review screen.
REQ-SCRIP-UX-05cFields are visually flagged per the confidence tier table in Section 7. High-confidence fields (≥0.85) show no special treatment.
REQ-SCRIP-UX-05dquantity_per_fill and total_fills_authorised are grouped under a “Stock tracking” label. If either is missing post-scan, both inputs are highlighted amber with: “Required for stock tracking.”
REQ-SCRIP-UX-06A low-prominence “Clear all extracted fields” action allows the carer to reset the form to blank for fully manual entry without deleting each field individually.
REQ-SCRIP-UX-07The review form has a single primary action: “Save prescription”. Enabled once medicine_name_raw is non-empty. All other fields are optional at save time.
REQ-SCRIP-UX-08The original script image is accessible from the script detail screen at any time, in a full-screen viewer with a download option. Carers must always be able to refer to the original if the extracted data is questioned.
REQ-SCRIP-UX-09The script detail screen shows: status badge, stock on hand with a visual progress bar (units remaining / total available from fills so far), fills used / total authorised, next recommended action (e.g. “Record fill”, “Arrange new script”), and the fill history list.
REQ-SCRIP-UX-10In Australia, the total_fills_authorised field label includes a helper note: “PBS: original dispensing + number of repeats on script.” This note is display-only and does not enforce any AU-specific logic.

15. Non-functional requirements (module-specific)

Section titled “15. Non-functional requirements (module-specific)”
IDRequirement
REQ-SCRIP-NFR-01Script images are PII/PHI. They must never be served without authentication and patient_access validation. UUID-based paths or equivalent must prevent URL guessing.
REQ-SCRIP-NFR-02EXIF data must be stripped on ingest (REQ-SCRIP-SEC-08).
REQ-SCRIP-NFR-03The extraction endpoint must have a timeout and return a structured error on failure so carers can proceed manually. A failed scan must never block script creation.
REQ-SCRIP-NFR-04stock_on_hand is never stored; always derived at query time to remain consistent with the dispensing record.
REQ-SCRIP-NFR-05Scripts may reference medicines not yet in the tenant formulary. medicine_id is nullable; medicine_name_raw is always available. An admin may link a script to a formulary medicine at any time after creation.
REQ-SCRIP-NFR-06No automated process may create a dispensings row on behalf of a carer. Every dispense record must trace to an explicit human confirmation action.

  • Electronic prescription integration (eRx, MedView AU) — future.
  • Controlled drug / Schedule 8 restricted prescriber workflows — future.
  • Prescription cost or PBS claim tracking — future.
  • Push notifications for script alerts (deferred to Phase 4 infrastructure).
  • Automated doctor appointment booking — future.
  • Drug interaction checking or clinical decision support — out of scope for this platform.
  • Expiry sweep as a scheduled background job — lazy expiry check on load is acceptable for V1.