Doctor Management System: Patient Records & OCR
Live at dms.jiddatlabs.comOutcome
A live system in which a doctor, once approved, keeps patients, appointments, visit notes, prescriptions and scanned reports in one place, from a phone or a computer, in English, Urdu or both, with staff doing the data entry under the doctor's control. Each doctor's records stay theirs, enforced in the API and again in the database, every change to a record is in an audit log, and records and files are backed up every 6 hours.
Overview
A web platform for doctors in Pakistan: patient records with allergies flagged, appointments, SOAP visit notes, printable prescriptions and scanned reports turned into text. A new doctor can't log in until an administrator approves them, after seeing their details and any licence document they attached. Doctors add staff accounts to book appointments and keep records for them, and can publish a clinic page with timings and Call and WhatsApp buttons. Every screen works in English, Urdu or both at once, with large text and plain wording on the doctor side.
Several doctors share one database, and none of them may reach another's patients. One FastAPI dependency resolves every request for patient data, from a doctor or their staff, to a single doctor ID that the queries filter on, and re-checks approval each time, so suspending a doctor locks out their staff too. The database enforces it as well: appointments, visit notes and prescriptions reference the patient together with that patient's doctor through composite foreign keys, so no row can name one doctor's patient and appear in another doctor's lists. Staff can add and edit but not delete: they ask, with a reason, and the doctor decides.
Tesseract reads the English text of scanned and photographed reports on the server, in a background task off the event loop, so the upload returns at once; the page polls until the text is ready, and the doctor can correct anything misread. No patient document goes to an outside OCR service. Uploads live in a SeaweedFS (S3-compatible) container only the other containers can reach, and are streamed to the browser only after an access check. It all runs as one Docker Compose stack on one server, with the database and every uploaded file backed up together every 6 hours.
Architecture & Pipeline
01
Sign-up & Approval
FastAPI · licence upload · admin review
- FastAPI
02
Login & Doctor Scope
JWT cookie · bcrypt · optional PIN
03
Patient Records
PostgreSQL · composite foreign keys · audit log
- PostgreSQL
04
Document OCR
Tesseract · FastAPI background task
- FastAPI
05
File Store
SeaweedFS (S3-compatible) · signed requests
- Requests
06
Doctor & Staff Screens
React · TypeScript · Tailwind · English/Urdu
- React
- Tailwind
- TypeScript
07
Serving & Backups
nginx · Docker · Caddy HTTPS · every 6 h
- Docker
End-to-end flow, in order. Scroll sideways on a narrow screen.
Key Features
- Doctor approval: a new doctor can't log in until an administrator with the approve-doctors permission accepts them, a rejection shows its reason at login, and a rejected applicant's uploaded document is deleted from the file store
- Every query scoped to the acting doctor's ID, with composite foreign keys so PostgreSQL itself refuses a record under another doctor's patient; 68 backend tests run against a real database, including cross-doctor checks on each kind of record
- Staff accounts the doctor creates and can switch off, which add and edit records but can't delete: they send a request with a reason, the doctor approves or rejects it, and the audit log credits every change to whoever made it
- On-server OCR: Tesseract reads the English text of scanned or photographed reports (PNG, JPEG, TIFF) in a background task, the page polls every 2.5 s until it's done, and the text stays editable for corrections
- Appointments in 15-, 30- or 60-minute slots that only the doctor sets, a warning rather than a block on double-booking, and a "Needs your review" list of past appointments nobody has marked as attended or missed
- Patient charts with allergies shown as a warning, also inside the prescription form, SOAP visit notes, vitals tracked over time, and prescriptions printed under the doctor's own name and licence number
- English, Urdu or both at once on every page, Urdu right to left in a self-hosted Nastaliq font, a build check that fails on untranslated text, and every page and dialog checked on a 360 px phone in all three modes
- A public page per clinic, rendered as plain HTML by the backend so Google and WhatsApp link previews read it, listed in the sitemap, with Call and WhatsApp buttons; a page that's off, or a suspended doctor's, gives the same 404 as one that never existed