Building an Audit-First Hospital Management System

TL;DR
To replace paper registers in a hospital, build the system around accountability: every bill, discount, lab result and shift closing is tied to a named staff member and logged, nothing is edited or deleted without a trail, and cash is reconciled against the system at the end of every shift. The LCGH system has tracked 14,578 patient visits and Rs 11.38M this way.
Key takeaways
- Design a hospital system around accountability: every bill, discount and lab result belongs to a named person.
- Never allow silent edits or deletes; every change needs a logged reason.
- Close and reconcile cash per staff member at the end of every shift.
- Gate lab results behind quality-control rules, and log every override with a reason.
- So far: 14,578 patient visits, Rs 11,385,060 reconciled and 2,233 repeat patients.
Lahore Children & General Hospital ran on paper registers across reception, OPD, lab, ultrasound and billing. Paper was slow and error-prone, but the real problem was worse: when money or results went missing, there was no way to find out what happened.
I built the hospital's management system from scratch, and I still run it. The core design decision was to make every shift, bill and lab result accountable to a named person. This post covers how that works and what it changed.
Why build around accountability instead of features?
Most hospital software is sold as a list of modules: registration, billing, lab, pharmacy. Those are necessary, but they do not fix the problem a paper hospital actually has. Paper fails because nobody can answer three questions:
- Who collected this money?
- Who changed this bill or result, and why?
- Does the cash in the drawer match what was billed?
So the system is designed so that every record answers those questions by default:
- Every bill, discount and doctor's share is logged and traceable.
- Nothing is edited or deleted without a trail and a reason.
- Every lab result is tied to the person who entered and released it.
- Every shift closing is tied to one staff member.
How does a patient visit flow through the system?
| Step | Who | What the system records |
|---|---|---|
| Reception | Receptionist | Registration, queue position, services, discounts, live bill preview |
| OPD / clinical | Doctor, nurse | Consultation and orders |
| Lab and ultrasound | Lab technician | Sample on a worklist from collection to delivery, results through QC rules |
| Billing | Reception / billing staff | Receipts, discounts, doctor's shares |
| Shift closing | Each staff member | Cash collected reconciled against system records |
Each role works in its own view. Reception, nurses, doctors, lab technicians and admins see only what they need, and a Super Admin oversees the whole hospital in real time.
How does shift cash reconciliation work?
At the end of every shift, each staff member who took payments closes their own shift. The system compares the cash they report against what it recorded for them during that shift. A mismatch is visible immediately and belongs to one person and one shift, instead of surfacing weeks later as an unexplained gap in a ledger.
It is designed to build trust between hospital management and staff: honest staff are protected, because their numbers are provably correct, and gaps can no longer hide in shared registers.
How do lab quality-control rules work?
Lab results do not go straight from the technician to the doctor. They pass through quality-control rules first. A result that fails a rule can only be released through an override, and every override is logged with a reason. That keeps clinical judgement possible while making it visible.
The lab worklist tracks every sample from collection to delivery, so "where is my report?" has an answer.
What about paper files patients already have?
Patients arrive with years of paper: old prescriptions, reports and files. Staff capture them straight from a phone camera, with automatic cropping and clean-up, and store them against the patient record.
Patients get a QR-code portal, protected by a PIN, where they can see their own medical history and documents at any time.
What are the results so far?
Since launch, the system has processed:
- 14,578 patient visits
- Rs 11,385,060 in takings, every rupee reconciled to a shift and a bill
- 2,233 repeat patients, each with their full history one lookup away
- An average bill of Rs 781 per visit, each traceable to a shift and a staff member
The stack is deliberately boring: Next.js and TypeScript, PostgreSQL through Prisma, Supabase and Vercel. Hospital software has to be dependable more than clever.
What would I tell another hospital going digital?
- Start with the money and the results. Audit trails on billing and lab results pay for the project faster than any other feature.
- Reconcile per person, per shift. Hospital-wide totals hide problems; per-shift closings expose them while they are small.
- Make overrides possible but loud. Clinicians need flexibility; the system's job is to record who used it and why.
- Digitise the old paper too, or staff will keep going back to the cabinet.
See the LCGH Hospital Management System case study for screenshots and the demo video. For how I approach agent workflows with human oversight, read AI Receptionist Design: The LLM Writes, Code Decides.
Frequently asked questions
What does a hospital management system do?
A hospital management system connects reception, outpatient consultations, laboratory, ultrasound and billing in one platform, so patient registration, orders, results, bills and payments are recorded digitally instead of in separate paper registers.
Why does a hospital management system need an audit trail?
Without an audit trail, missing money or changed lab results cannot be traced. Logging who created, edited or overrode every bill, discount and result makes each record accountable to a named staff member and deters quiet changes.
What is shift closing reconciliation in a hospital?
At the end of each shift, every staff member who collected payments closes their shift, and the cash they hold is compared against what the system recorded for them. Differences show up immediately and are tied to one person and one shift.
How do lab quality-control rules work in the LCGH system?
Lab results pass through quality-control rules before they are released to doctors or patients. A result that fails a rule can only be released through an override, and every override is logged with a reason.
How do patients access their records?
Patients use a QR-code portal with PIN protection to view their own medical history and documents at any time. Paper files, prescriptions and reports are scanned with a phone camera, auto-cropped and stored with the patient record.
Keep reading
- Building a Proactive AI Health Agent: Lessons From Production
What makes an AI health agent proactive (profile, guidelines, urgency, specialist routing, booking) and the four quiet failures that matter most in production.
- AI Receptionist Design: The LLM Writes, Code Decides
How Deskly answers every inbound lead in under a minute without letting the LLM make business decisions: deterministic scoring, booking, escalation and handoff.
- Multilingual YouTube RAG: Architecture Notes
A practical retrieval pipeline for long-form video: transcript embedding, FAISS search, multilingual models and session-aware Q&A with Gemini.