A medicine shortage in a hospital pharmacy is the visible end of a much longer process. Before the problem becomes obvious, data on consumption, stock levels, orders, deliveries and contract performance may have been signalling increasing risk for days or weeks.

The question is: can those signals be identified early enough and converted into a practical recommendation for pharmacy staff?

This is the question we are beginning to investigate through the Pharma Flow research and development project.

A medicine shortage is more than an inventory problem

An unavailable medicine may force a change in therapy, delay a procedure, increase the risk of medication errors and trigger an urgent search for an alternative supplier. The American Society of Health-System Pharmacists states that drug shortages can delay treatment, increase the risk of adverse reactions and medication errors, and create additional costs for healthcare organisations.

The problem is international. The European Medicines Agency has launched the European Shortages Monitoring Platform to provide harmonised reporting on medicine supply and demand. Use of the platform became mandatory for national competent authorities and marketing authorisation holders within its scope on 2 February 2025.

In May 2026, Council of the European Union and European Parliament negotiators reached a provisional agreement on the Critical Medicines Act. The planned rules are intended to strengthen security of supply for critical medicines, support supply-chain diversification and develop manufacturing capacity in Europe. The agreement still requires formal approval.

European initiatives improve visibility across the market, but they do not answer every question faced by an individual hospital:

  • How much of a particular product will be required next week or next month?
  • Are current stocks and planned deliveries sufficient?
  • Which changes in consumption represent a genuine trend rather than an isolated event?
  • Is a supplier meeting the agreed contractual conditions?
  • When should the pharmacy begin searching for an alternative source?
  • How can the risk of both shortages and costly excess stock be reduced?

This is the level at which Pharma Flow begins.

Hospitals have data, but not always a forecast

Pharmacy and hospital information systems record thousands of events: receipts and issues, warehouse transfers, ward orders, deliveries, returns, contract performance and historical medicine consumption.

These data are essential for inventory control and financial settlement. Their presence does not automatically provide staff with a reliable forecast of future needs.

Medicine consumption may depend on:

  • the hospital profile and clinical specialties;
  • the number and type of admissions;
  • seasonal disease patterns;
  • local epidemiological conditions;
  • procedures being performed;
  • changes in treatment practice;
  • product and substitute availability;
  • supplier lead times;
  • exceptional events that should not be projected uncritically into the future.

Extending the average consumption of previous months may fail to detect an important change. Maintaining very large stocks “just in case”, on the other hand, ties up financial resources and increases expiry risk.

What is needed is not simply another historical report, but a mechanism that helps answer:

What is likely to happen next, and what action should the pharmacy consider?

We are not assuming in advance that one method and one forecasting horizon will be best for every medicine group and every hospital. Determining this is part of the research.

Pharma Flow is currently an R&D project

This distinction is essential: Pharma Flow is not currently a finished product available for hospital deployment.

We are at the beginning of the project. The work ahead includes preparing and assessing data, establishing baseline models, designing the integration architecture and determining which AI methods can genuinely deliver value in medicines management.

The project covers four connected directions:

  1. forecasting medicine demand and supporting stock optimisation;
  2. monitoring supplier contract performance;
  3. supporting the assessment of deliveries, delays and proposed substitutes;
  4. automating selected routine elements of communication and intervention-order handling.

Pharma Flow is intended to complement existing pharmacy and hospital information systems rather than replace them. Its planned value is to use data already recorded in those systems and add an analytical and decision-support layer.

The first research area: forecasting demand

The first challenge is to determine whether historical data and the context of a healthcare organisation can support sufficiently early forecasts of demand for individual medicines or medicine groups.

The same product may be used very differently in a district hospital, an oncology centre, a large multi-specialty hospital or an organisation delivering highly specialised procedures. Data quality and recording practices may also vary between organisations.

The research therefore needs to start with the fundamentals:

  • assessing data completeness and quality;
  • harmonising product and equivalent-product identification;
  • detecting anomalies and one-off events;
  • defining meaningful levels of data aggregation;
  • establishing simple baseline models;
  • comparing them with more advanced approaches;
  • testing forecast stability across periods and organisations.

An advanced AI model is valuable only when it is demonstrably more useful than a simpler method and when users understand the circumstances in which its recommendations should not be trusted.

The second area: signing a contract is not the same as fulfilling it

A supplier contract does not end the procurement process. Hospitals still need to verify whether deliveries arrive on time, prices match the contract, ordered quantities are supplied and a proposed substitute meets the requirements of both the agreement and the organisation.

In many hospitals, this requires staff to compare documents, deliveries, correspondence and contract clauses. It is time-consuming and may occur only after someone notices a problem.

Through Pharma Flow, we plan to investigate natural-language processing methods that could:

  • organise the most relevant provisions of an agreement;
  • identify parameters important to delivery performance;
  • compare contractual conditions with actual events;
  • flag potential delays or other discrepancies;
  • prepare information for review by a pharmacist or procurement professional.

The system should not make a final legal determination. Its role would be to identify a potential problem and present the information needed for a qualified person to assess it more quickly.

The third area: responding when the standard delivery fails

A particularly difficult situation occurs when a medicine is required but the contracted supplier cannot fulfil an order. Pharmacy staff may then need to contact multiple companies, ask about availability, compare price and delivery time, and prepare further action in accordance with law and the hospital’s procedures.

Pharma Flow will investigate whether an intelligent agent can support this process by preparing supplier enquiries, organising responses and presenting available options.

The critical decision should remain with an authorised professional.

Automation should remove repetitive work, not remove the pharmacist’s control over a medicine purchase.

The possible degree of automation will depend not only on technology, but also on procurement law, internal policies, order value, integration availability and local accountability rules.

Federated learning without one central database

Medicines-management data are distributed across independent hospitals. A shared model could learn from multiple organisations, but centralising detailed operational and medical data would create legal, organisational and security challenges.

One of the approaches under investigation is therefore federated learning.

Under this model, an algorithm can be trained locally in individual organisations. Model updates, rather than complete source datasets, are then used in a collaborative learning process.

Federated learning is not an automatic guarantee of privacy or GDPR compliance. Reviews of healthcare federated-learning research identify risks including information leakage from model updates, attacks on models, differences between local datasets, access control and governance.

The project will therefore need to assess not only forecast quality, but also:

  • which data are genuinely necessary;
  • whether a shared model outperforms local models;
  • how model updates should be protected;
  • how erroneous or malicious updates can be detected;
  • how models can be versioned, audited and rolled back;
  • who is responsible for operating, monitoring and approving new versions.

Federated learning may reduce the need to move raw data, but it does not replace legal assessment, data minimisation, security controls or proper governance.

Research targets are not achieved results

The project documentation defines target criteria for the future solution, including:

  • medicine-demand forecast accuracy of at least 85%;
  • detection of at least 90% of the defined contract-violation cases;
  • automation of at least 80% of the specified intervention-order activities.

These are objectives to be tested during the project, not the performance of an operating system.

The method used to calculate each indicator must also be defined precisely. “85% accuracy” can mean very different things for a product consumed daily, a medicine used occasionally and an item with highly irregular demand. An average result across an entire pharmacy could conceal poor forecasts for the medicines that matter most.

The evaluation of Pharma Flow therefore cannot be reduced to a single score. It should also consider:

  • the frequency of shortages and excessive stocks;
  • the value of products at risk of expiry;
  • forecast error across medicine groups and time horizons;
  • time spent reviewing contracts;
  • the precision and usefulness of detected discrepancies;
  • time required to prepare an intervention response;
  • recommendations accepted and rejected by staff;
  • reasons for rejecting recommendations;
  • the effect on staff workload.

Starting in silent mode

A safe way to begin evaluating a predictive system is to operate it in silent mode.

The model generates forecasts and recommendations, but they do not affect actual orders. Its predictions can later be compared with real consumption and staff decisions.

This helps answer fundamental questions:

  • Does the model capture seasonal patterns?
  • For which medicine groups does it perform best?
  • When do predictions become unstable?
  • Is risk identified earlier than with existing methods?
  • Would the recommendations have been operationally useful?
  • Does the system create an excessive number of warnings?

Only after credible results have been obtained should recommendations gradually enter the operational workflow. Even then, they should initially be treated as decision support rather than automatic instructions.

What could Pharma Flow mean for a hospital?

If the research hypotheses are confirmed, Pharma Flow could create value at several levels.

For hospital pharmacists

The potential benefit is less time spent on repetitive analysis, document comparison and standard correspondence. A recommendation should be accompanied by the basis on which it was generated, allowing the user to verify, accept or reject it.

For executives and managers

The system could provide better visibility into inventory value, shortage risk, supplier performance, tied-up capital and the effectiveness of corrective action. Medicines management would become a process that is easier to measure and improve.

For clinicians and patients

Clinicians are unlikely to interact directly with most Pharma Flow functions. They may nevertheless benefit from more predictable availability and a lower risk of treatment changes driven solely by organisational supply problems.

The patient should remain the ultimate beneficiary, even when the system operates mainly within the hospital’s logistical and pharmaceutical infrastructure.

We are starting with questions, not finished answers

Technology projects are often described as though the future already exists. Pharma Flow is an R&D project, however, and genuine research starts with questions.

We do not yet know:

  • which variables will provide the greatest predictive value;
  • which forecasting horizon will be most useful;
  • whether shared models will outperform local models;
  • which medicine groups can be forecast reliably;
  • how much communication can be automated safely;
  • how often staff will accept the system’s recommendations;
  • where integration with existing systems will prove most difficult.

That is precisely why the project is being conducted.

The goal is not to create a demonstration that looks impressive in a presentation. The goal is to determine whether a tool can genuinely help hospital pharmacies act earlier, respond faster and make decisions using a more complete picture of the situation.

Because the best time to react is not when the required medicine has already run out.

It is when the first signs of that risk become visible in the data.

About the project

  • Name: Pharma Flow
  • Project number: FENG.01.01-IP.02-0638/25
  • Official title: “Development of the Pharma Flow intelligent agent using artificial intelligence and federated machine learning to optimise medicines management and take over routine, time-consuming tasks performed by hospital pharmacy staff”
  • Beneficiary: Infotower Business Solutions sp. z o.o.
  • Project period: 1 March 2026 – 29 February 2028
  • Planned implementation period for the results: 1 March 2028 – 31 August 2028
  • Total project value: PLN 22,137,373.39
  • Funding: PLN 16,146,083.00
  • Programme: European Funds for a Modern Economy — SMART Path
  • Current communication stage: early implementation of research and development work

The project is co-funded by the European Union.

Sources and further reading

  1. American Society of Health-System Pharmacists, “Drug Shortages”: ASHP — Drug Shortages
  2. European Medicines Agency, “European Shortages Monitoring Platform fully operational for monitoring shortages in the EU”: European Medicines Agency
  3. Council of the European Union, “Critical medicines act: Council and Parliament reach provisional deal”, 12 May 2026: Council of the European Union
  4. Pati S. et al., “Privacy preservation for federated learning in health care”, 2024: PubMed
  5. Pharma Flow funding application, FENG.01.01-IP.02-0638/25 — internal source for project objectives, timetable, budget and target indicators.

This article describes the objectives and hypotheses of an R&D project at an early stage of implementation. Planned features and indicators are not achieved results of a finished product. The article does not constitute medical, legal or procurement advice.