One catalogue sits behind both prescribing and dispensing. Categories, stock on hand, what it cost, what it sells for, the generic name and an expiry date.

Medicine catalogue in ICTHospital with stock quantities and prices

The same list the prescription form and the pharmacy counter both read.

Stock follows what was handed over

The quantity here is not typed by a person doing a stock take. It comes down when the pharmacy dispenses, in the same database transaction as the sale, and goes back up when a sale is reversed.

That has a useful consequence. A sale that fails partway through changes nothing at all, so the catalogue cannot end up short by the value of a transaction that never completed.

It refuses to go negative

A sale asking for more than is on the shelf is refused with the number that is actually there. If the same medicine appears twice on one sale, the quantities are added together before the check, so two lines of five cannot slip past a stock of eight.

The read takes a database lock, which matters more than it sounds. Two people dispensing the last few units at the same moment would otherwise both pass the check and both decrement, and the stock figure would go below zero with no record of how.

A medicine in use stays in the catalogue

Anything that has been prescribed or dispensed cannot be deleted. The prescription and the sale both keep their own copy of the name and price, so the old records still read correctly, but the catalogue entry holds the pack size and category that the counter needs. Rename it instead.

Categories

Tablets, syrups, injectables, whatever suits your shelves. A category with medicines in it cannot be removed until they are moved out.

See it rather than read about it. The catalogue is covered in the user guide.

The user guide walks the whole system in the order you would meet it, and the screenshots page has every screen. The source is on GitHub under the GPL v3.