How I Built a Medical Store POS in 8 Phases with AI Agents

How I Built a Medical Store POS in 8 Phases with AI Agents

●4 ●24
calendar_today ago • schedule9 min read
— Originally published at rehmanahmad.com

To build a medical store POS that a real shop in Pakistan can actually use, I had to stop thinking like a developer and start thinking like the man behind the counter. He sells medicine by the strip and the tablet, not the box. Half his customers pay later. His printer is a small Bluetooth thermal machine, if he has one at all. I built RePharma for that counter — a full point-of-sale system for Pakistani medical stores, shipped in eight phases in a single day, with a team of AI agents doing the building while I did the deciding.

Key Takeaways

  • Ship the counter first: billing that works with no printer beats a beautiful dashboard nobody opens.
  • Build in phases, each tested — a phase is done when its flow is proven, not when the code exists.
  • Design for the shop's reality: goli/patta/dabba units, udhaar khata, JazzCash and Easypaisa, 58mm thermal bills.
  • Verification is a phase of its own: a barcode that only looks real is worse than no barcode at all.

Why a Medical Store POS, and Why Phases

A medical store is not a general shop with different products. The stock expires. The same salt sells under ten brand names. A customer asks for "that white tablet for fever" and expects you to know. The law wants prescription and narcotic registers kept for years. And the margin on a strip of tablets is so thin that one wrong entry eats the day's profit.

I had watched small shops try software before. The usual failure is the same: a big system arrives all at once, the owner cannot enter his 2,000 medicines, the first busy hour breaks it, and the paper register comes back. So the build went in phases — each one a working slice the pilot shop could actually use, billing first — and the owner knew the system would start empty, his first medicines going in through Excel import or quick manual entry.

The name joins the family I have been building: RePharma, after RePage, RePen and ReIndexer. The spec was eleven pages in Roman Urdu — the language the shop owner thinks in — because a spec the user cannot read is a spec nobody follows.

Phase 1: The Counter First

Phase 1 was the whole bet: if billing did not feel faster than paper, nothing else mattered. The screen searches by medicine name or salt, sells by goli, patta or dabba, and takes Cash, JazzCash, Easypaisa or Udhaar — the four ways money moves in a Pakistani medical store.

Underneath, the important piece is FEFO: first-expiry-first-out. A sale takes stock from the batch that expires soonest, not the one that arrived first — one rule that stops expired stock hiding at the back of the shelf, and the kind of detail a generic POS never gets right.

Phase 1 also laid the foundations: stock with batch and expiry alerts, purchases and suppliers, Excel and CSV import plus manual entry, the udhaar khata (credit ledger), reports, and settings carrying both pricing models and the printer width. The bill prints on 58mm or 80mm thermal paper, or goes out as a WhatsApp bill — which matters, because the pilot shop has no printer yet. A system that only works with a printer does not work on day one.

One more Phase 1 decision: three language modes — pure Urdu in Nastaliq (right-to-left), Roman Urdu, and pure English — one tap to switch, remembered. The software adapts to the counter staff, not the other way round.

Phases 2–3: Trust — Staff, Returns and Day Closing

Phase 2 was about trust: who did what, and can it be undone honestly? Hold Bill and Returns came first — a customer changing their mind mid-sale is a daily event, not an edge case. Then staff roles (Owner, Pharmacist, Cashier) with PINs and permissions, supplier payments, an Rx and narcotic register, advanced reports, and backup and export.

Phase 3 closed the day properly: Day Closing reconciles expected cash against actual cash, with the difference stated plainly. Expenses got their own book, prescriptions are recorded with doctor and reference on the bill, and the khata got WhatsApp reminders and a customer statement. Stock corrections require a reason, and over-removal is blocked — a correction that can silently erase stock is a hole, not a feature.

The lesson: trust features feel boring to build and are the first thing a shop owner asks about. Nobody has asked me for a prettier dashboard. Plenty have asked, "who changed this, and can I see it?"

Phases 4–6: Money Truth — Profit, Voids and Stock Counts

Phase 4 put a net profit card on the table — profit minus expenses, with the breakdown visible. Purchase returns to suppliers now reduce stock and the supplier balance automatically, stock count mode corrects from a real shelf count, and a reorder message goes to the supplier on WhatsApp in one tap.

Phase 5 was the small-things phase: a cash and change calculator, same-salt alternatives when a medicine is out of stock, a quick-pick list for regular customers, a 14-day sales trend chart, a supplier WhatsApp directory, and backup restore with a guard that stops it on a heavy shop. One quiet fix mattered most: numbers entered as 0300… convert to the 92… format automatically — a reminder that never arrives is worse than no reminder feature.

Phase 6 added a reorder level per medicine, whole purchase invoices entered at once with batch, stock and supplier ledger updated in one save, and bill void restricted to the Owner — stock and ledger reversed, the bill excluded from accounts, and a returned bill never voidable, since that would double-reverse the same money. Day closing gained an opening cash float.

Three phases, one pattern: every feature answers a question the owner asks at closing time — how much did I really make, who owes me, what is actually on my shelves? Software that cannot answer those three is decoration.

Phases 7–8: The Human Edge Cases

By Phase 7 the system handled the normal day; Phases 7 and 8 handled the day as it really is. Card and bank transfer joined the payment methods, discounts can be rupees or percent, and the staff member's name prints on the bill. Batch recall finds remaining stock and every bill where a batch was sold, from the batch number alone. And the khata got a credit limit: cross it and the counter sees a warning, but the bill is not blocked — refusing medicine to a regular customer is the owner's decision, not the software's.

Phase 8 finished the core: split payment — part now, the rest on khata, each part accounted separately — khata due dates with an overdue badge, the reminder naming the promised date, a printable khata statement, and a daily WhatsApp summary for the owner: sales, outstanding amounts, overdue accounts, low stock, expiry. The button only appears once the shop's phone number is saved — a summary with nowhere to go is clutter.

That is my favourite kind of design decision: a feature that hides itself until it can actually work. Most software shows you everything and lets you discover the dead ends; hiding the dead end is kinder.

What the Market-Gap Audit Forced Me to Add

After the eight phases, twenty agents swept the Pakistani and Indian pharmacy-software market for what rivals had that I did not. Seventeen gaps came back, built as Phases 9, 10 and 11 the same day.

The biggest gap was the cold start: rivals ship with 15,000 to 80,000 medicines preloaded, and mine started empty. Phase 9 added a starter catalogue of 374 medicines across 13 categories, one tap to add, with prices marked "check this" — a wrong preloaded price is worse than no price. The same phase added GS1 barcode parsing, an MRP warning with an owner hard-block, a hard block on expired batches, fridge logs with 2–8°C alerts, a printable register pack, licence expiry alerts, and a three-year retention lock.

Phases 10 and 11 added offline billing — the shop keeps selling with no internet, bills queue in an outbox, and sync is idempotent, so a bill is never deducted twice — plus rack locations, a Short Book for stock-outs, an audit log nobody can delete, patient profiles with allergy warnings at billing, refill reminders over WhatsApp, dosage on the bill and packet label, loyalty points that reverse on returns and voids, 10+2 schemes with the real per-pack cost verified, and an accountant pack whose totals tally to the rupee.

The audit's lesson is blunt: my counter features already matched the rivals'. The gap was day-one setup, offline trust and compliance — the things a demo never shows.

The Barcode Bug That Almost Shipped

Phase 11 taught me the sharpest lesson of the day: the printed packet label had a barcode, and it was decorative. The bars were drawn, not encoded — they looked like a barcode and scanned like nothing.

I replaced them with real Code 39 encoding, then verified the rendered bars by decoding them at pixel level from both the A4 and the 58mm views — the test code RP000002 read back with zero difference. Billing also got an exact-match check on RP codes. Only then was Phase 11 done.

That is now my standard for every phase: a feature is not done when it renders, but when the outside world can prove it works — a scanner reading the label, a WhatsApp message arriving, a synced bill deducting stock exactly once. If you cannot verify it from outside the app, you have drawn it, not built it.

What I Would Do Differently Next Time I Build a Medical Store POS

First, I would run the market-gap audit before Phase 1, not after Phase 8 — the starter catalogue and offline mode changed the product's shape, and building them after the core meant rework planning would have avoided.

Second, I would write each phase's verification before building it — the test that proves the phase, in words, before a line of code. The barcode bug survived because verification was an afterthought; after that fix, it became the gate.

Third, I would keep the interface deliberately plain for longer — polish stays deferred until the pilot shop has used the system and told me what slows them down. My taste is not data; their tired hands at 9 p.m. are.

And what I would repeat exactly: phases, each independently usable; the pilot shop as the specification; two pricing models — low upfront with a monthly fee, or higher upfront with little or no monthly — because a shop that cannot afford your pricing never becomes your customer; and a sandbox test of the real flow at the end of every phase.

Builder's checklist — steal this for your own phased build

  • [ ] Phase 1 is the user's busiest hour, not your favourite feature.
  • [ ] Every phase ends with a proven flow, not a code review.
  • [ ] Edge cases get their own phase — they are the product, not the polish.
  • [ ] Verify from outside the app: scan it, send it, sync it, count it.
  • [ ] Run a market-gap audit before you call the product done.

Frequently Asked Questions

How long did the eight phases take?
One day of focused building with AI agents, phase by phase, each tested in a sandbox before the next began. The Phases 9–11 gap work landed the same day.

Does it work without a printer?
Yes. The bill shows on screen and can go out as a WhatsApp bill or PDF; printing becomes the primary route once the shop buys a small Bluetooth thermal printer.

What about expired medicines?
FEFO selling uses the soonest-expiring batch first, expired batches are hard-blocked, and the owner can set an MRP warning or hard block. Expiry alerts run from the stock screen.

The Counter Is Still the Boss

RePharma now does billing, stock, batches, expiry, purchases, suppliers, khata, staff, returns, voids, day closing, profit, recalls, offline sales, patient profiles and loyalty — in three languages, on web and as a PWA, with an APK to come. The interface is functional, not beautiful, on purpose: polish waits for the pilot shop's verdict.

If you build software for a real shop, a real classroom, or anywhere the user is busy and the margin is thin, take the same deal: small phases, each proven; the user's busiest hour as Phase 1; verification from outside the app; polish last. The counter is still the boss — and it never asked for a prettier dashboard.

I write about shipping solo tools on rehmanahmad.com/blog, and the free Windows utilities at my desk live on filecobra.com. If you run a medical store, tell me what your counter needs first: the next phase starts with your busiest hour, not my roadmap.


Want more #ai-agents & #solo-developer deep dives?

Join 5,992+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

Optimizing the Clinical Interface: Data Management for Efficient Medical Outcomes

Huifer - Jan 26

What Security Teams Want From AI Agents Before They Let Them Act Alone

Tom Smithverified - Nov 18

Shipping Software with AI Agents: How I Built a 48-Rule Scanner in 2 Days

irehmanahmad - Nov 4

A coach complained, so I built sports academy management software

rahuldk1105 - Oct 26
chevron_left
513 Points • 28 Badges
16Posts
1Comments
Rehman Ahmad Chaudhary is a full-stack developer who builds FileCobra.com — an open software catalog... Show more

Related Jobs

View all jobs →

Commenters (This Week)

4 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!