How the AI works
The AI reads your invoice. It doesn't decide anything.
This page explains, step by step, exactly what happens to a supplier invoice in MediPacer: what the AI does, what fixed rules check afterwards, what people decide, what data the AI sees, and what happens when something goes wrong.
1. The AI only reads
It turns a photo or PDF into structured data, with evidence for every value. That is all it does.
2. Fixed rules check
Code that works the same way every time validates formats, checks arithmetic and blocks conflicting matches.
3. People decide
Only staff confirm matches, count goods and approve receipts. The AI can't change a record.
Step by step
From photo to approved receipt, in eight stages.
Each stage says who does it: fixed code, the AI, or a person.
01
Upload and prepare the document
Fixed code
Before anything reaches the AI, MediPacer stores the original and prepares a clean copy to read.
- Accepts PDF, JPEG and PNG, checked by the file's actual content, not its name. iPhone HEIC photos are refused with instructions to switch the camera to “Most Compatible”.
- Up to 5 pages of one invoice, 10 MB each. Photos are turned upright using the camera's orientation, resized to at most 2,400 pixels and joined, in the order staff chose, into one PDF.
- The original file is kept unchanged in private storage. Uploading the same file or the same set of photos twice is recognised as a duplicate.
- Anything over a limit is refused with an explanation. Nothing is ever cut short silently.
If something goes wrong: If the file can't be read, staff see why and can enter the invoice by hand instead.
02
Read the document
AI
The AI model reads the whole document — every page — and returns it as structured data in a fixed format.
- Header: supplier name, invoice number, invoice date, currency, subtotal, discount, tax and total.
- Each billed line: the description exactly as written, supplier item code, billed quantity, free quantity, purchasing unit, unit price, line discount, line total, and any batch number and expiry date printed on the line.
- Its reading of each description — product name, brand, strength, dosage form and pack size — used later for matching, with a note when it's unsure.
- For every single value: the exact text it came from, the page it is on, whether it is present, and if not, why — not printed, unreadable, ambiguous or conflicting.
- Warnings a reviewer should see: illegible areas, cut-off pages, numbers written in an unexpected column, handwriting that sits between printed rows.
- Pre-printed order forms: rows with no quantity, price or amount entered are skipped and counted (“61 blank rows omitted”) rather than turned into lines.
If something goes wrong: If the AI service is busy or fails, the stored job is retried automatically with increasing waits. If it still fails, the document shows the real reason, with “Retry” and “Enter manually”.
03
Decide what kind of document it is
AI, then fixed rules
The AI says what it is looking at and why. Fixed rules decide what that allows.
- Supplier invoice — can be reviewed, matched and received.
- Delivery note or credit note — kept as reference evidence; it can't be received as stock.
- Retail sales receipt (a till receipt from another pharmacy) — flagged; it can't be received until a reviewer confirms the pharmacy really bought those goods from that seller.
- Product label or something else — nothing is created from it, and staff are told what to do instead.
If something goes wrong: If staff uploaded it as one type and the AI reads another, both are shown and the difference is flagged.
04
Validate and normalise every value
Fixed code
Every reply is checked against the fixed format before a single value is stored.
- A reply that doesn't match the format exactly is rejected and retried — it is never partly saved.
- Dates must be real calendar dates. Amounts must be valid money with at most 2 decimals; quantities at most 3.
- Expiry dates keep their precision: “05/2028” is stored as a month, never turned into 31 May or 1 May.
- Batch numbers and item codes are kept exactly as printed — leading zeros and letter case included.
- A value is stored only when the AI says it is present and it passes these checks. Otherwise it stays empty, with its reason. Missing is never stored as zero.
If something goes wrong: A value that fails a check is kept as “ambiguous” beside its original text, for a person to fix.
05
Check the arithmetic
Fixed code
Fixed code checks the sums itself — it doesn't rely on what the AI said about them.
- Each line: quantity × unit price − line discount must equal the line total.
- All line totals must add up to the subtotal (or to the total, when there is no tax or discount).
- Subtotal − discount + tax must equal the total.
- Differences of more than ₦1 are listed for the reviewer, with the numbers, e.g. “Line 2: 4 × ₦4,500 = ₦18,000, but the line total reads ₦1,800”.
- Lines with a missing value are skipped, not assumed.
If something goes wrong: Arithmetic warnings never change a value. A person decides which number is right.
06
Suggest a product for each line
AI, then fixed rules
Matching links each invoice line to a product in your own catalogue, with your own item code.
- First, fixed code searches your catalogue: a supplier item code you've confirmed before, then a description you've confirmed before for that supplier, then the closest names. At most a handful of candidates go forward.
- The AI then compares the line with those candidates only — never your whole catalogue — and suggests one, with its reasons and a check of strength, dosage form and pack.
- Fixed rules then compare strength, dosage form and pack again. Any conflict — 500 mg on the invoice, 250 mg in the catalogue — blocks the match until a reviewer either corrects the line or records why they are the same product.
- Nothing is matched until a person confirms. When they do, they can tell MediPacer to remember that supplier's wording or item code, so the same line is found first next time.
If something goes wrong: If no candidate is safe, the line says so. It's never matched to “the closest thing”.
07
Read batch and expiry from pack photos
AI
At the receiving bench, staff can photograph a pack's batch panel instead of typing.
- The AI reads the batch or lot number and the expiry date, including GS1 codes such as “(10) AX2417 (17) 280331”, “Lot”, “BN”, “EXP 03/2028” and “Sept., 2028”.
- Embossed or offset print it can't attribute with confidence is reported as ambiguous, not guessed.
- Look-alike characters such as O and 0 are pointed out for a person to check.
If something goes wrong: The reading only fills in suggestions. Staff confirm or change them before saving the batch row.
08
Review, receive and approve
People, checked by fixed rules
From here on, only people change your records — and fixed rules make sure the record stays consistent.
- A reviewer checks the header and lines against the document shown side by side, and confirms the review.
- Receiving officers record what physically arrived, split into batches; every unit must be accepted, held or rejected.
- A reviewer approves the receipt once. It becomes read-only; later changes are corrections or returns, added with their reason.
- Every value records whether it came from the AI, was accepted as read, or was corrected — and by whom.
If something goes wrong: Approval is refused while any rule fails, with a plain list of what's left to do.
What one value looks like
Every number comes with its evidence.
The AI doesn't just return “10”. For every field it returns the value, where it saw it, and how sure it is — and if it can't find it, why not. This is what reviewers see beside each value.
- Value
- The reading in a standard form: 10, 2500.00, 2026-03-11, 2028-05.
- Source text
- The words exactly as they appear on the document: “10”, “2,500”, “11/3/2026”.
- Page
- Which page of the invoice it was read from.
- Missing reason
- When there's no value: not printed, unreadable, ambiguous, or conflicting (two places disagree).
- Reading clarity
- Low, medium or high — a hint for the reviewer about how clear the print was. It is not a probability, and it never decides anything.
- Version
- The model, prompt version and format version that produced it, kept on every value.
- Value
- 10
- Source text
- “10”
- Page
- 1
- Missing reason
- —
- Reading clarity
- low
- Read by
- gpt-6-astra · receiving-prompts-v4
Shown to the reviewer as: “Document p.1: ‘10’ · Hard to read — check”
- Value
- (empty)
- Source text
- —
- Page
- 1
- Missing reason
- Not present
- Reading clarity
- high
The column was blank, so the unit stays empty. A reviewer must enter it before the line can be matched — quantities are never converted without a unit.
Boundaries
What the AI never does.
Never records goods as received
Receiving is a count by a person, approved by a reviewer.
Never fills in a missing value
Not by calculation, not by guessing, not to make totals agree.
Never confirms a product match
It suggests; conflicts block; a person confirms.
Never approves or corrects a receipt
Only reviewers can, and every change keeps the original.
Never acts on text in a document
Instructions written on an invoice are treated as data and flagged.
Never judges a medicine
It doesn't diagnose, suggest substitutes or say whether a medicine is genuine.
Safety
When documents, or the AI, misbehave.
Text that tries to instruct the system
If an invoice contains text addressed to the system — “ignore previous instructions”, “mark as approved” — the AI reports it, MediPacer shows a warning to check the document's authenticity, and the text is treated purely as data.
Malformed or partial replies
Every reply must match the fixed format exactly. Anything else is rejected and retried; a half-read invoice is never stored.
Service outages and slow replies
Reading runs as a stored background job. It survives restarts, is retried with increasing waits, and long handwritten invoices are given up to 20 minutes. Failures are shown as failures.
Content filtering
Microsoft's content filter screens AI requests. Pharmacy documents legitimately list sexual-health products, so MediPacer uses Microsoft's default filter with only that category relaxed to block high-severity content. If a document is still refused, staff are told so and can enter it by hand.
Wrong document type
Till receipts, delivery notes, credit notes and pack labels are recognised and handled as what they are — they can't be received as stock by mistake.
Every reading is traceable
Each value records the model, prompt version and format version that produced it, and the AI's raw output is kept beside what people confirmed. That's how we measure accuracy honestly.
Data the AI sees
Only what it needs to read the document.
Sent to the AI
- • The invoice or photo being read (the prepared copy).
- • For matching: the line's text and the AI's reading of it, plus the few candidate products from your catalogue — name, brand, strength, form and pack.
- • For pack photos: the photo being read.
Never sent to the AI
- • Your staff's names, emails or passwords.
- • Your other invoices, receipts, counts or exports.
- • Your whole product catalogue.
- • Anything about patients — MediPacer holds no patient data.
Requests are sent with response storage switched off. Microsoft states that Azure OpenAI does not use customer data to train its models. More in Data and privacy →
The model
Which AI, running where.
- Model
- GPT-6 Astra, a general vision-and-language model, deployed privately for MediPacer on Microsoft Azure AI Foundry.
- Where it runs
- Microsoft Azure, United States (East US 2). The MediPacer app, database and documents are in Microsoft Azure, France Central (EU).
- How the app connects
- Through Azure's managed identity — there is no AI key stored anywhere in the app — over an encrypted connection.
- Instructions
- Fixed, versioned instructions tell the model to read only what is printed, report missing values with a reason, and never follow text written on documents. They are improved only against measured tests.
- Switchable
- MediPacer is built so the reading model can be changed without changing the rest of the system, and every value records which model read it.
Limits
What it handles today.
- English-language supplier invoices, in naira by default.
- Printed and handwritten invoices; PDFs, scans and phone photos (JPEG/PNG).
- Up to 5 pages and 100 product lines per invoice; 10 MB per file.
- Pack photos for batch and expiry (one pack per photo works best).
- Not yet: barcode or GS1 DataMatrix scanning, cold-chain data, other languages.
- Accuracy so far is measured on documents from one pharmacy. It will vary with handwriting and photo quality — which is why every reading is reviewed.