04VigiRegistro · Pharmacy safety
An offline safety registry for a hospital pharmacy
Personal product for a hospital pharmacy · Lima, PeruAI
- Problem
- The head of pharmacy at a public hospital in Lima copied every paper safety notification by hand into a yearly Excel file, on a locked-down PC with no paid AI.
- My call
- Keep the reader on the hospital PC and let it only propose. The user confirms every field, and there is no button to confirm them all.
- What I produced
- A local registry with two modules, a scan reader with a weighted evaluation rubric, a dashboard of 18 cards and an Excel export that matches the pharmacy's workbook cell by cell.
- Result
- The drug-safety export matches the pharmacy's workbook with 0 differences. The reader scores 74.4% against a 70% target, and the user still confirms every field.
Problem
The head of pharmacy at a public hospital in Lima, the decision maker on the hospital side, receives drug-safety and medical-device-safety notifications on paper and used to copy every field by hand into a yearly Excel file. That copying was the workload, and the same records feed statistics for management, the pharmacotherapy committee and, once a year, DIGEMID, the national medicines authority.
The setting ruled out the easy answers. The hospital PC allows no installs without IT, no USB sticks and no paid AI. Under Peru’s Ley 29733 patients appear as initials only, and a scan with a crossed-out name is still personal data. The pharmacy’s existing workbook is the format other offices expect.
I was the product owner of this personal build: I set the product, brought the pharmacy head’s requests from our calls into the plan and decided what to ship. Claude Code and Codex designed the mechanisms and wrote the code on my brief.
The system
Paper goes in at one end and the pharmacy’s own workbook comes out at the other. In between, a model may propose and only a person decides. The limits in the last row shaped every part above them.
Everything happens on one PC. Paper goes in at one end and the pharmacy's own workbook comes out at the other. Pick a part to read what it does, or follow one thing through.
Limits that shaped it
One notification
- Paper form. A clinician fills the paper form. The pharmacy head crosses out the name and scans it.
- Scan. The app straightens the scan and shows it beside a form that follows the paper.
- Reader. The reader proposes the fields from the scan, with no network.
- Confirm. The user confirms or corrects each field. Names arrive as initials.
- Registry. Only confirmed values become data.
- Table. The notification joins the table and the dashboard's counts.
- Workbook. The year's workbook is generated in the pharmacy's own layout.
- Yearly send. The sheet for the national authority leaves with no patient data.
One field the reader gets wrong
- Reader. The model misreads a handwritten name, or fills a box that is empty on paper.
- Confirm. The field shows in amber beside the scan. The user corrects it against the paper and confirms.
- Registry. Only the confirmed value is saved, so the mistake costs a correction and never becomes a record.
- Paper form
- A clinician fills the official notification by hand. The pharmacy head crosses out the patient's name and scans it.
- Scan
- The app straightens the page and shows it beside the form. Straightening raised the reader's score and whitening the page lowered it, so the page is passed on as it is.
- Reader
- A small model on a bundled llama.cpp engine reads the scan and proposes each field. It runs with no network.
- Confirmrules I set
- Each proposal shows in amber with a confirm button. Correcting a field does not confirm it, and anything left unconfirmed returns to its old value on save.
- Registry
- One database on the PC is the source of truth, with both modules driven by one field list. An upgrade never drops or renames a column.
- Table
- Every notification, with the filters and chosen columns an Excel user expects.
- Dashboardrules I set
- Eighteen cards for drug safety, device safety or both. Counts describe reporting load, not harm, and a change on a small base is written in words.
- Workbookrules I set
- One Excel file per module. The drug-safety one reproduces the pharmacy's own workbook, and a test compares the two cell by cell.
- Yearly send
- A sheet for the national medicines authority, with no patient data on it.
- Privacy law
- Patients appear as initials. A crossed-out scan is not anonymous and sending it abroad is a cross-border transfer, so whatever reads scans stays on the PC.
- The PC
- No installs without IT, no USB sticks, no paid AI. The app is a portable folder with its own Python, offline and at zero cost.
- Old workbook
- The pharmacy's existing workbook is the reference: the design may change, the values may not.
- The user
- An Excel expert who is not technical. A misread percentage on a small base led to changes written in words and last year drawn as a ghost bar.
Key decision
- The call
- Keep the reader on the hospital PC and let it only propose: the user confirms every field, and there is no button to confirm them all.
- Alternatives
- A newer cloud model. A 2026 study put the best of them at about 85% on fixed fields.
- A confirm-all button to make registering faster.
- Why
- Privacy law rules out sending a scan abroad and the PC has no paid AI, so the model had to be small and local. A small model does not only miss handwriting, it invents plausible medicine names and lot numbers, and in drug safety an invention is worse than a blank. The reader cleared its 70% target at 74.4%, saves typing and still cannot be trusted with a record, so every proposal waits for a person.
What I built
The product is a local web app with two modules, drug safety and device safety, on one page. A notification opens with the scan, straightened automatically, beside a form that follows the official paper. A table with Excel-like filters, a dashboard of 18 cards and each module’s workbook cover reporting.
The rules I set are tagged in the project record with my words and the date, such as «no quiero esconder nada» (“I don’t want to hide anything”) on 27 September, and change only on request. The user’s calls become decisions the same way: after my call with the pharmacy head on 30 October I added a device-safety workbook and hid three device-safety fields the user no longer needed, keeping their columns so that no real value is erased.
The product's rules
One field list
- Then
- A field is defined once and drives the form, the table and the Excel export
An upgrade never loses a value
- When
- A newer version opens an older database
- Then
- Columns are added, never dropped or renamed, and a differing value is never overwritten
The workbook is the acceptance bar
- When
- The code changes
- If
- The generated workbook still matches the pharmacy's original, cell by cell
- Then
- The change may ship
Small bases in words
- When
- A change is computed on a small base
- Then
- It is written in words, and last year shows as a ghost bar
The pharmacy head had misread a percentage.
The reader's rules
rules I setA proposal is not data
- When
- The reader fills a field
- Then
- It shows in amber and waits for the user
Correcting a field does not confirm it.
Unconfirmed never saves
- When
- The user saves with fields unconfirmed
- Then
- Each one returns to its previous value
No confirm-all
- Then
- Every proposal is accepted one at a time
A button that accepts everything at once was left out on purpose. Small models invent plausible values, so review is field by field.
Names become initials
- When
- The reader returns a person's name
- Then
- It arrives as initials, and an unreadable value leaves the field empty



AI design choices
- Where the model runs. On the hospital PC: Qwen3.5-4B, a 4-billion-parameter model, on a llama.cpp engine bundled with the app, about 3.4 GB, with no network. Four local models were compared by size and license.
- What it may decide. Nothing on its own. It proposes field values from the scan, and a proposal is not data until the user confirms it. The screens do not say AI: the button reads «leer el escaneo», “read the scan”.
- How quality is measured. A rubric scores the reader field by field against three filled forms I copied by hand, and weighs each field by what it costs to read well. The chart shows where it earns its points.
- The human in the loop. Checkboxes, dates and codes are read well enough to save typing. Doctors’ handwriting is harder: names and free text score under the target, and a small model can fill a gap with a plausible invention. So the user checks every field against the paper. Judging harm stays with people too: counts describe reporting load, not harm, and the product has no risk score.
- Checkboxweight 1100%
- Short datumweight 284%
- Codeweight 382%
- Blank boxweight 177%
- Long textweight 667%
- Short textweight 359%
Share of rubric points earned on three filled forms, 10 October 2026: 73.5% overall. Read the way the app reads, from the straightened page, the reader reaches 74.4%. Handwritten text is what stays under the line.
How the reader is measured
A weighted rubric
blank 1 · checkbox 1 · short datum 2code 3 · short text 3 · long text 6score = points earned ÷ 276 possiblepass mark 70%
Each field weighs what it costs to read well. The reference is three filled forms I copied by hand.
An invention scores zero
- When
- The model fills a box that is empty on paper
- Then
- It earns nothing
It filled 11 of 63 empty boxes.
A blank form must come out blank
- When
- A new version of the instructions is tried
- If
- A form with nothing filled in is read
- Then
- Every field must come back empty
Shorter instructions scored the same and wrote two fields into a blank form, so the longer ones stayed.
The ceiling is the model, not the prompt
14 set-ups: 66.5% to 74.6%best of the 14, field by field: 84.0%
The model errs on the same fields each time, so a vote over several readings does not help.
Outcome
The drug-safety export matches the pharmacy’s workbook with 0 differences in every cell, style, width and chart, checked on synthetic records. The reader scores 74.4% against its 70% target, and still nothing it reads becomes data without the user. The update is packaged for the pharmacy’s Windows PC as a portable folder; handover is the next step.
Learnings
Keep the agents’ context lean from the first week. By October their working context had grown into a verbatim history so heavy that Codex truncated the instruction file, and the agents kept rebuilding screen rounds I had already replaced. I approved a rewrite into lean topic files: current rules with an owner and date beat a transcript.
This is the kind of work I do in a 10-day product discovery
Back to the work