CASE STUDY · Hospital Pharmacy · Forecasting & Optimization

Pharmaceutical Inventory Management: AI forecasting + Genetic Algorithm reorder optimization.

AiSPRY built a forecast-and-optimize platform that solves the two interlocking problems of hospital pharmacy inventory: predicting medication demand accurately, then deciding what to order to satisfy that demand at minimum cost and minimum stockout risk. An ensemble of ARIMA, Random Forest, and Prophet predicts per-SKU demand; a Genetic Algorithm optimizer converts those forecasts into multi-objective reorder plans that respect cost, stockout risk, shelf life, supplier minimum order quantities, lead times, and storage limits — delivering 90% forecast accuracy, 25% inventory cost reduction, 80% stockout reduction, and 300% ROI.

Industry
Hospital Pharmacy · Healthcare
Technology
ARIMA · RF · Prophet · GA · Python
Deployment
AWS — cloud-native
Status
Production
Read time
~12 min

The Pharmaceutical Inventory Management Platform is an AI-powered forecasting and optimization system built by AiSPRY for hospital pharmacies. Six families of demand signals — historical consumption, patient admissions, seasonal disease trends, prescription patterns, supplier lead times, and drug master data — flow through an AWS-based Python pipeline into an ensemble of ARIMA, Random Forest, and Prophet, and a Genetic Algorithm optimizer converts the forecasts into reorder plans that satisfy multiple constraints simultaneously.

Industry
Hospital Pharmacy · Healthcare
Technology
GA, ARIMA, Random Forest, Prophet, Python
Deployment
AWS — cloud-native
Status
Production
90%
Forecast accuracy
80%
Stockout reduction on critical meds
300%
Return on investment

Project facts & technologies

A citation-friendly summary of the Pharmaceutical Inventory Management Platform — scope, technology, and headline outcomes.

Client context
Hospital pharmacy with recurring stockouts of critical medications and overstocking of slow-movers
Industry segment
Hospital Pharmacy, Healthcare, Pharma Supply Chain
Engagement type
AI forecasting + optimization platform — design, build, and deployment
Forecast accuracy
90% across blended horizons and SKUs
Inventory cost reduction
25% reduction in inventory carrying cost
Stockout reduction
80% reduction in stockouts of critical medications
Return on investment
300% ROI on the platform deployment
Forecasting models
ARIMA · Random Forest · Prophet (ensemble)
Optimization layer
Genetic Algorithm — multi-objective reorder planning
GA objectives
Minimise cost, minimise stockout risk, respect shelf life, supplier MOQ, lead time, storage limits
Data signals ingested
Historical consumption, patient admissions, seasonal disease trends, prescription patterns, supplier lead times, drug master data
Cloud platform
AWS — ingestion, feature store, training and inference, optimizer hosting
Implementation language
Python end-to-end — forecasting, ensemble combination, optimization, integration
Downstream consumption
Auto-reorder recommendations, stockout risk alerts, slow-mover action list, cost/ROI dashboard, ERP/HIS integration

Why does hospital pharmacy inventory fail in both directions?

Hospital pharmacies sit at the intersection of two problems that pull in opposite directions. On one side, stockouts of critical medications are not just an operational inconvenience — they delay treatment, force substitutions, and in the worst cases compromise patient safety. On the other, overstocking of slow-moving drugs locks up working capital, occupies cold-chain and shelf space, and exposes the hospital to write-offs when medications expire on the shelf.

Both happen simultaneously because hospital medication demand is driven by admission patterns, acuity mix, prescribing patterns that vary by department and protocol, and seasonal disease waves (flu, dengue, respiratory infections, vector-borne disease cycles) — none of which is captured by static reorder rules. What pharmacies actually need is two cooperating capabilities: a forecasting layer that predicts demand with operational accuracy, and an optimization layer that translates those forecasts into reorder plans under real-world constraints — shelf life, supplier MOQs, lead time variability, storage and cold-chain capacity, working capital limits.

What problem does the forecast-and-optimize platform solve?

Hospital pharmacies faced significant challenges with frequent stockouts of critical medications and overstocking of slow-moving drugs, resulting in treatment delays, wastage, and capital lock-up. The platform needed to address four failure modes that no traditional pharmacy inventory system could close.

Key challenges

  • Stockouts of critical medications delayed treatment — static reorder thresholds did not adapt to admission spikes, seasonal disease waves, or shifts in prescribing patterns.
  • Slow-moving drugs accumulated and expired — slow-movers were ordered on the same periodic basis as fast-movers, reaching expiry while still in stock and tying up working capital.
  • Reorder decisions ignored multi-constraint reality — supplier MOQs, lead times, shelf life, storage capacity, cold-chain limits, and working capital ceilings could not be juggled by any spreadsheet.
  • Pharmacy and procurement worked from different signals — without a single source for forecasts and reorder recommendations, the two functions built their own views and disagreed routinely.

How does the platform forecast and optimize?

AiSPRY built the Pharmaceutical Inventory Management Platform as a six-layer forecast-and-optimize architecture. Six families of demand and supply signals are ingested into AWS, harmonised through a Python feature pipeline, and passed through an ensemble of three complementary forecasting models. The ensemble's output is combined with weights tuned per SKU and per horizon, and the resulting demand forecasts are handed to a Genetic Algorithm optimizer that solves the multi-constraint reorder problem.

Demand signals and feature engineering

  • Historical consumption — by SKU, ward, and period — the foundation of every forecast
  • Patient admissions — volume, acuity mix, and length-of-stay that drive medication demand
  • Seasonal disease trends — flu, dengue, respiratory, and vector-borne cycles relevant to the catchment
  • Prescription patterns and supplier lead times — by department and protocol, with supplier reliability for safe reorder timing
  • Drug master data — shelf life, unit cost, storage requirements, and cold-chain needs feed the optimization constraints

Three forecasting models, blended by SKU and horizon

  • ARIMA — short-horizon trend and momentum on per-SKU demand series; fast to retrain and the interpretable baseline
  • Random Forest — non-linear interactions between admissions, disease trends, and prescribing protocols; feature-importance for explanations
  • Prophet — seasonality and event-driven demand waves like flu and dengue seasons
  • Ensemble combiner — weights tuned per SKU and per horizon through backtesting, with calibrated confidence intervals

Genetic Algorithm reorder optimization

  • Multi-objective optimization — minimise inventory carrying cost and minimise stockout risk simultaneously
  • Constraint-respecting — shelf life, supplier MOQ, lead time variability, storage and cold-chain capacity
  • Confidence-aware weighting — stockout-aversion weighted higher for critical medications, cost-minimisation higher for non-critical SKUs
  • Operational consumption — auto-reorder recommendations, stockout risk alerts, slow-mover action lists, cost/ROI dashboards, ERP/HIS integration

See the pharmacy platform in action

A walkthrough of the platform — ingesting demand signals from admissions and disease trends, running the ARIMA + Random Forest + Prophet ensemble, and converting forecasts into Genetic Algorithm reorder plans that respect shelf life, MOQ, and storage constraints.

Pharmaceutical Inventory Management — forecast-and-optimize in action

Click to play · Three-model ensemble plus Genetic Algorithm reorder planning

Demo. Walkthrough of the forecasting ensemble and Genetic Algorithm optimizer — auto-reorder recommendations, stockout risk alerts, slow-mover action lists, and the cost/ROI dashboard.
  • Ensemble forecasts — ARIMA + Random Forest + Prophet weighted per SKU and horizon
  • GA reorder plans — multi-objective optimization respecting shelf life, MOQ, lead time, and storage
  • Stockout risk alerts — calibrated warning windows on critical medications
  • ERP/HIS integration — approved orders flow through to procurement without manual re-entry

What is the architecture of the forecast-and-optimize platform?

The architecture is organised as six layers: hospital pharmacy data sources, the AWS data pipeline and feature engineering, the three-family forecasting ensemble, the ensemble combiner, the Genetic Algorithm optimization layer that converts forecasts into reorder plans, and the pharmacy operations consumption layer with ERP and HIS integration. Raw signals never reach forecasting models without harmonisation; models never see future data during training; the optimizer is the only layer that converts forecasts into actual order decisions; and downstream consumption reads the GA's output rather than touching individual forecasts directly.

Pharmaceutical Inventory Management Platform architecture diagram showing data signals, AWS feature pipeline, ARIMA + Random Forest + Prophet ensemble, Genetic Algorithm optimization, and pharmacy operations consumption
Figure 1. Pharmaceutical Inventory Management Platform solution architecture — hospital pharmacy data → AWS pipeline → ARIMA + Random Forest + Prophet ensemble → Genetic Algorithm optimization → pharmacy operations.

How is the platform engineered for pharmacy reality?

The platform's design choices reflect the operational constraints of hospital pharmacy inventory — shelf life, supplier MOQs, lead time variability, storage capacity, and the genuinely different demands of forecasting and ordering.

Forecasting and optimization as separate cooperating layers

  • Forecasting (what demand will be) and optimization (what to order under constraints) have different inputs and validation methods
  • Treating them separately is what allows 90% forecast accuracy and a defensible cost reduction simultaneously
  • Most off-the-shelf inventory tools collapse them into a single rule-based formula and lose both

Three complementary models because no single one is best

  • ARIMA wins on short-horizon trend and interpretability
  • Random Forest wins on multi-feature non-linear interactions
  • Prophet wins on seasonality and event-driven demand
  • The ensemble combiner is the only place where outputs are blended — keeping the system auditable rather than a black box

Confidence intervals propagate into the optimizer

  • Every forecast carries a calibrated confidence interval from backtesting
  • The Genetic Algorithm weights stockout-aversion higher for critical medications and cost-minimisation higher for non-critical SKUs
  • Buffers grow where they matter and shrink everywhere else — 80% stockout reduction with 25% lower inventory cost

What measurable results did the platform deliver?

The platform was evaluated against the operational pain points it was built to address — stockout frequency on critical medications, working capital tied up in inventory, expiry write-offs from slow-movers, and the overall economic return.

Forecasting and inventory outcomes

  • 90% forecast accuracy across blended horizons and SKUs
  • 25% reduction in inventory carrying cost from compressed buffers on slow-movers
  • Reduced expiry write-offs as inventory matches actual forecast demand

Stockouts and patient outcomes

  • 80% reduction in stockouts of critical medications
  • Routine substitutions and emergency procurement runs materially decreased
  • Care delivery without medication-driven treatment delay improved measurably

Economic and organisational impact

  • 300% return on investment on the platform deployment
  • Pharmacy and procurement now operate from one plan rather than competing views
  • Storage and cold-chain capacity reclaimed for items that actually turn over

Pharmaceutical Inventory — frequently asked questions

The questions most often asked about the Pharmaceutical Inventory Management Platform. Each answer is self-contained, so it can be quoted, cited, or surfaced as a standalone response.

What is the Pharmaceutical Inventory Management Platform?
It is an AI-powered forecasting and optimization platform built by AiSPRY for hospital pharmacies. The platform predicts per-SKU medication demand from historical consumption, patient admissions, seasonal disease trends, prescription patterns, supplier lead times, and drug master data using an ensemble of three forecasting models — ARIMA, Random Forest, and Prophet — and then runs a Genetic Algorithm optimizer to convert those forecasts into reorder plans that minimise cost and stockout risk while respecting drug shelf life, supplier MOQs, lead time, and storage limits.
What measurable results did the platform achieve?
The platform delivered 90% forecast accuracy across blended horizons and SKUs, an 80% reduction in stockouts of critical medications, a 25% reduction in inventory carrying cost, and a 300% return on investment. It also eliminated the periodic clash between pharmacy and procurement, recovered storage and cold-chain capacity from overstocked slow-movers, and reduced expiry write-offs by matching inventory to actual forecast demand rather than static thresholds.
Why combine forecasting with a Genetic Algorithm optimizer rather than using a simpler reorder rule?
Forecasting and ordering are genuinely different problems. Forecasting tells the pharmacy what demand will be. Ordering decides what to do about it — under multiple constraints that cannot be collapsed into a single rule: shelf life, supplier MOQs, lead time variability, storage and cold-chain capacity, working capital limits, and the competing objectives of cost minimisation versus stockout aversion. Genetic Algorithms produce reorder plans that respect all constraints simultaneously — rather than violating one constraint to satisfy another, which is what rule-based heuristics tend to do.
Why use three different forecasting models?
Each model family is genuinely better at some part of the problem. ARIMA captures short-horizon trend and momentum and provides the interpretable baseline. Random Forest captures non-linear interactions between admission acuity, disease season, and prescription protocol, and exposes feature importance. Prophet handles calendar effects and seasonal waves like flu and dengue cycles. The ensemble combiner blends all three with weights tuned per SKU and per horizon through backtesting, so each model contributes where it is genuinely strongest.
How does the platform cut stockouts by 80% without bloating inventory?
Three design choices stack together. First, the forecasts are admission-aware, disease-aware, and season-aware. Second, every forecast carries a calibrated confidence interval that flows into the optimizer rather than being discarded. Third, the Genetic Algorithm weights stockout-aversion higher for critical medications and cost-minimisation higher for non-critical SKUs. Buffers grow where they matter and shrink everywhere else — which is why stockouts fall 80% and inventory cost falls 25% at the same time.

Talk to AiSPRY about deploying forecast-and-optimize AI across your hospital pharmacy operations — predicting medication demand and generating cost-minimising, stockout-aware reorder plans.

More case studies