AI School · Level 4 · Owners

Building an agent that does your ordering

Léelo en español →

It is the number one request from any pharmacy owner: "look at my purchases and my sales and place the order — or propose it and I'll say yes." It can be done, it works very well, and half of what people picture is the wrong way round.

The whole lesson in one sentence. How much to order is not calculated by AI: it is calculated by arithmetic. The AI is for everything around it — explaining why demand is climbing, flagging that this is seasonal, drafting the query to the lab, pointing at what is behaving oddly. The agent calculates with maths and narrates with AI.

Why the model must not do the sums

A language model looking at a sales table will give you a number. The problem is it will give you a different one tomorrow from the same data, it will not tell you when it got it wrong, and it charges you every time. For a 200-line daily order that is expensive, slow and irreproducible — and when it fails you will not know why.

Replenishment is a solved problem and fits in four variables: mean demand, supplier lead time, demand variability and target cover. It is deterministic, you can check it in a spreadsheet, and it costs nothing.

The arithmetic does thisThe AI does this
How many units are missingWhy demand is spiking this month
Reorder point and safety stock"This is seasonal — watch it in October"
Days of coverDrafting the claim to the lab
What is overstocked or about to expireSummarising the order in three lines
Which lines do not moveProposing an alternative during a shortage

What data it needs — and where the line is

Per line: current stock, sales per period (weekly is usually enough), what is already on order, the pack size, and the flags that change the decision: sale-or-return, shortage, controlled drug, short expiry. All of it comes out of your PMR or stock system.

The line, and it is the same one as the rest of the school. An ordering agent works on business data: products, units, purchase dates. Never on named dispensing lines. If your export carries the patient, the prescription number or an NHS number, strip it before the data leaves the system — not after. Aggregating by product is not only the lawful choice: it is that the agent needs nothing else.

← Back to the AI School