HomeCase studiesBatch-Traceable Pharmacy Management System with FEFO Inventory...

Case study · Dublin, Ireland

Batch-Traceable Pharmacy Management System with FEFO Inventory Control and Automated Dispensing Verification

Retail & Hospital Pharmacy Operations

Community and hospital pharmacies face severe compliance and patient-safety risks when generic retail POS tools fail to enforce batch-level expiry rules, serialized barcode verification, and immutable controlled-drug ledgers. We engineered a pharmacy management system using Laravel, Vue, and MySQL tailored for high-volume dispensing workflows, FEFO stock rotation, and clinical interaction screening. Atomic MySQL stock deductions and keyboard-first Vue dispensing screens keep counter throughput crisp while maintaining end-to-end medicinal traceability.

Industry
Retail & Hospital Pharmacy Operations
Solution
A Laravel, Vue, and MySQL pharmacy operations platform integrating FEFO batch inventory control, serialized barcode verification, drug-interaction screening, and multi-branch replenishment.
Platforms
Web & API
Stack
Laravel · Vue · MySQL · TypeScript · Redis · Docker
Location
Dublin, Ireland · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Dublin, Ireland. Names withheld by agreement.

Project Overview

A pharmacy counter is not an ordinary retail checkout. Every dispensed pack carries strict batch provenance, cold-chain or expiry constraints, patient allergy checks, and statutory reporting duties—yet many dispensaries still run on aging desktop software or generic retail ERP extensions bolted onto fragmented spreadsheets. When a national medicine recall hits or a patient arrives with overlapping prescriptions from multiple specialists, staff lose precious minutes hunting paper batch logs or manually reconciling shelf stock.

Designed around European and Irish community and hospital pharmacy workflows in Dublin, we built a pharmacy management system powered by Laravel, Vue, and MySQL. The platform connects electronic prescription intake, real-time drug interaction screening, GS1 DataMatrix barcode verification, First-Expired-First-Out (FEFO) lot control, and automated wholesaler replenishment inside one fast, keyboard-first dispensary interface.

Dispensary & Stock Control Failures

Observations across busy urban dispensaries and clinical stockrooms highlighted four persistent bottlenecks:

  • Blind batch consumption: Generic SKU inventory counted total boxes on hand while ignoring lot expiry dates, leaving expiring stock buried at the back of shelves and complicating targeted supplier recalls.
  • Slow mouse-heavy counter interfaces: Pharmacists wearing gloves or juggling physical packs lost rhythm when legacy web forms forced repeated mouse clicks between barcode scans and label printing.
  • Disconnected safety checks: Allergy flags, duplicate-therapy warnings, and controlled-drug thresholds sat in separate reference books or external portals rather than triggering inline before label print.
  • Stockout surprises on critical lines: Replenishment relied on manual end-of-day walkarounds instead of real-time par-level velocity and supplier EDI availability.

Architectural Strategy

We anchored the backend around an immutable double-entry inventory ledger in MySQL controlled by a modular Laravel API, paired with a keyboard-first Vue 3 dispensary application. Rather than storing mutable stock_on_hand integers that hide discrepancies, every medication movement—wholesaler receipt, split-pack dispensing, inter-branch transfer, return, or wastage—writes an auditable movement record linked to a specific batch lot and actor.

To match physical counter speed, Vue manages local scanner focus states cleanly in Pinia and pre-loads active formulary interaction indexes in Redis so clinical safety checks execute in milliseconds as items hit the dispensing basket.

Core Capabilities

  • FEFO Lot Allocation & Recall Tracing: Automatically picks earliest-expiring eligible lots during prescription filling and isolates recalled batch numbers across every branch in seconds.
  • GS1 & FMD Barcode Verification: Parses 2D DataMatrix codes directly from HID scanners to verify GTIN, batch, expiry, and unique serial identifiers against anti-counterfeiting registries.
  • Inline Clinical Screening: Cross-checks patient medication profiles for drug-drug interactions, therapeutic duplication, and documented allergies before dispensing sign-off.
  • Split-Pack & Compounded Unit Math: Tracks full packs alongside loose tablet balances and fractional liquid volumes cleanly without rounding drift.
  • Automated EDI Replenishment: Monitors real-time rolling demand and minimum shelf thresholds to stage draft purchase orders for pharmaceutical wholesalers.

Technical Architecture

USB barcode scanners feed GS1 payloads directly into the Vue dispensary client, which communicates over authenticated APIs with Laravel. Laravel runs clinical safety checks against Redis-cached formulary rules, allocates stock lots inside atomic MySQL InnoDB transactions, triggers external serialization verification where required, and dispatches thermal ZPL label jobs and asynchronous wholesaler ledger updates.

Flow: Barcode Scanner & Vue Dispensary UI → Laravel API & Clinical Screening (Redis Formulary) → MySQL InnoDB (FEFO Batch Locks & Ledger) → FMD Serialization & EDI Gateways → Thermal Label Print & Branch Sync

Separating high-frequency formulary lookups into Redis from transactional lot deductions in MySQL ensures busy multi-terminal counters never bottleneck on read contention.

Technology Stack

Category Technology detail
Backend Application Laravel 11 API orchestrating dispensing queues, clinical checks, and supplier orders
Dispensary & POS UI Vue 3 with TypeScript and Pinia delivering keyboard-driven scanning and verification screens
Inventory & Ledger DB MySQL 8 managing lot-level stock balances, controlled-drug ledgers, and sales transactions
Cache & Job Queues Redis powering drug-formulary lookup caches and Laravel background replenishment workers
Serialization & Scanners GS1 DataMatrix and EU FMD verification gateways integrated with USB/HID barcode scanners
Clinical Decision Rules Formulary drug-drug interaction, allergy, and dosage-range screening service in PHP/Redis
Label & Receipt Engine Direct thermal label formatting (ZPL/ESC-POS) for prescription vials and patient leaflets
Container Runtime Dockerized PHP-FPM, Nginx, and worker nodes with zero-downtime deployment pipelines
Audit & Reporting Append-only MySQL dispensing registers and scheduled EDI procurement exports

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Concurrent dispensing across multiple stations risks overselling scarce cold-chain lots Ordered MySQL SELECT ... FOR UPDATE row locks by (branch_id, batch_id) inside dispensing commits; enforces strict transaction discipline while preventing negative lot balances.
Running drug-interaction matrices across thousands of formulary pairs slows checkout Pre-indexed interaction pairs and allergy class trees in Redis hash structures refreshed on formulary updates, avoiding multi-table SQL joins per scanned pack.
External FMD serialization APIs occasionally spike in latency during peak afternoon hours Implemented non-blocking verification calls with configurable SOP fallback queues so pharmacists continue urgent dispensing cleanly and reconcile exceptions asynchronously.
Split-pack dispensing creates fractional inventory discrepancies in standard integer schemas Modeled inventory at the base dispensing unit (tablet/ml) with pack-size conversion metadata on receipt, adding slight display formatting logic in Vue while keeping stock math exact.

Regulatory Traceability & Access Controls

Operating retail and hospital pharmacies in Ireland demands stringent oversight over controlled schedules, patient medication histories, and anti-counterfeiting verification. Access policies inside Laravel enforce sharp role separation: pharmacy technicians can stage prescriptions, verify stock batches, and print labels, while clinical overrides for high-severity drug interactions and final controlled-substance release require verified pharmacist credentials or PIN re-authentication at the terminal.

Controlled-drug registers operate strictly as append-only ledgers inside MySQL. Wastage, broken vials, or stocktake adjustments require dual-staff sign-off and structured reason codes, producing exportable statutory audit trails without manual spreadsheet transcription. Encrypted backups and scoped branch permissions guarantee multi-site supervisors review aggregate stock metrics without exposing uninvolved patients' clinical profiles unnecessarily.

Dispensary Throughput & Ledger Integrity

Afternoon prescription surges test both database locking and UI ergonomics. In Vue, a dedicated hardware-scanner input parser distinguishes rapid barcode bursts from manual keyboard typing regardless of which form field currently holds focus, allowing staff to scan five packs consecutively without clicking back into a search box.

On the backend, stock balances reconcile against materialized batch summaries maintained inside the same MySQL transaction as ledger appends, keeping shelf-availability checks instantaneous while preserving full historical movement lineage. Scheduled Laravel workers calculate branch reorder proposals and expiring-stock alerts overnight so opening teams start every morning with actionable procurement queues.

Operational Outcomes

Replacing fragmented POS workflows with a batch-traceable Laravel and Vue pharmacy platform strengthened safety, speed, and stock accuracy across dispensing counters:

  • End-to-end batch accountability: Automated FEFO allocation and GS1 barcode checks tie every dispensed unit back to its exact supplier lot and expiry window.
  • Safer, faster counter verification: Inline clinical interaction screening and keyboard-driven Vue workflows protect patients without slowing peak-hour queues.
  • Exact controlled-drug auditing: Immutable double-entry registers eliminate end-of-week reconciliation surprises and simplify statutory inspections.
  • Proactive inventory health: Real-time split-pack tracking and automated wholesaler replenishment reduce emergency stockouts and minimize expired-shelf write-offs.

01 — Questions

asked about this kind of project

How does the system enforce First-Expired, First-Out (FEFO) dispensing across split packs?

Every stock receipt records batch number, expiry date, and unit-level quantity (boxes and individual tablets/units) in MySQL. During dispensing, Laravel locks and deducts quantities from the earliest-expiring active lot via InnoDB row locks, blocking expired or quarantined batches even if scanned manually.

How does Vue handle fast barcode scanning without forcing pharmacists to use a mouse?

The Vue dispensary interface uses dedicated global scanner-input listeners and deterministic keyboard shortcuts (`F2` verify, `F4` interaction override, `F9` thermal label print). Pharmacists move from prescription intake to pack verification and label printing entirely via scanner triggers and function keys.

How are EU Falsified Medicines Directive (FMD) serialization checks handled without stalling the counter?

GS1 DataMatrix scans trigger non-blocking verification calls to national FMD repository gateways with aggressive timeouts and idempotent status tracking. If an external verification hub experiences temporary latency, packs can be queued for deferred reconciliation according to configured pharmacy SOPs.

How is the controlled-substance register protected against silent inventory edits?

Controlled schedules never allow direct quantity overwrites. Every receipt, dispensed dose, broken-pack wastage, or cycle-count adjustment writes an immutable double-entry ledger row requiring dual-pharmacist verification signatures and reason codes.

What prevents overselling the last unit of a medication when two dispensing terminals run concurrently?

Stock reservation occurs inside MySQL transactions using `SELECT ... FOR UPDATE` ordered deterministically by batch ID. Concurrent terminals immediately reflect remaining open-shelf quantities and avoid race conditions on scarce cold-chain or compounded medications.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.