Anonymized Case — Clinic EMR AI Automation: keep the legacy system, wrap it in AI and automation
Replacing an EMR that has run a clinic for a decade is too risky. So we didn't — we wrapped it in AI reporting, automated integrations, and a tested disaster-recovery loop, and the old system grew new capabilities.
A modern automation layer built around a family clinic's open-source EMR (electronic medical record) production system: nightly incremental AI summary reports for 4,000+ patients, a PDF requisition auto-fill microservice, fully automated lab-result and fax in/out flows, and multi-tier backups with daily off-site restore drills. No downtime, no data migration. Client identity anonymized.
Many clinics are stuck in the same dilemma: the legacy EMR is dated, but migrating means downtime risk, data risk, and a six-figure implementation. We took the third path — keep the old system as the source of truth and build a modern automation layer around it: AI reads its data to produce clinical reports, a microservice fills its forms, bots pull its faxes and push its lab results, and the backup system rehearses its disaster recovery every day. The physicians' working screens didn't change. How the clinic runs did.
Privacy note: clinic name and all patient information have been removed. Every pipeline that touches medical records runs on the clinic's own servers — report data never leaves the clinic environment.
The challenge
The clinic's open-source EMR holds over a decade of records and cannot be casually replaced — yet daily operations leaned on manual labor: requisition forms copied by hand, lab results downloaded and uploaded manually, faxes processed one by one. A physician wanting the full picture of a long-term patient had to page through years of records. And if the system went down, the whole clinic stopped — while the existing backups had never once been proven restorable.
Our approach
Leave the legacy system untouched and build four layers around it. First, an AI reporting layer: every night it detects which patients have new data, extracts their records from the EMR database, runs AI analysis, and generates summary reports with urgent/routine flags plus a bilingual index. Second, a forms layer: a generic PDF auto-fill microservice where each requisition type is one JSON field-mapping config, with patient and clinic fields injected automatically. Third, an integration layer: lab results sync and upload into the EMR every 3 hours, and two fax lines are pulled hourly via API into the EMR's incoming queue — replacing manual work and a paid vendor tool. Fourth, a disaster-recovery layer: nightly database and document backups, off-site sync, and automated restore drills on a standby server proving the backups actually work.
Results
Coverage of 4,465 patients and roughly 8,900 AI summary reports generated to date — physicians see a risk-flagged overview of each patient before the visit. Requisitions went from hand-copied to auto-filled. Lab and fax flows run unattended with dedup and checkpoint tracking. Backups are no longer 'hopefully fine' — they are restore-tested every day. The legacy stack has run over two months without manual intervention.
AI patient-report pipeline: nightly, incremental, risk-tiered
The pipeline is deterministic and re-runnable:
- A nightly job detects which patients have new encounters, labs, or documents — only the increment is processed.
- Structured records are extracted straight from the EMR database and summarized by AI.
- Reports carry urgent/routine flags, with abnormal values surfaced first.
- A bilingual index lets physicians and staff search quickly.
- Everything runs on the clinic's own servers — medical data never leaves the building.
AI here is a chart-reading assistant: it aggregates and highlights. Diagnostic decisions remain the physician's.
The PDF requisition auto-fill microservice
Turning 'write code for every form' into 'write a config for every form':
- Each PDF requisition template maps to one JSON field-mapping config.
- Patient and clinic fields auto-fill from the EMR database; form-specific fields come from the frontend.
- Runs as an independent container service, called directly by the EMR's eForms.
- Adding a new form type means adding a config — no code changes.
Labs and faxes: fully automated in and out
The clinic's paper traffic with external parties is handled by two sets of automation:
- Lab results sync and upload into the EMR every 3 hours, with processed-file tracking for dedup.
- Two fax accounts are pulled hourly via API into the EMR's incoming-documents queue, replacing a paid vendor tool.
Disaster recovery: a real restore drill every day
The backup system is multi-tier: nightly database + patient-document + container-image backups, synced off-site to a standby server where an automated restore test runs — whether backups work is verified daily, not assumed. A watchdog service also monitors customized page files and auto-restores them if anything overwrites them.
Technical breakdown
- Source of truth: the open-source EMR production stack (containerized: database, lab gateway, fax service).
- AI reporting pipeline: Python incremental detection + direct database reads + LLM analysis, scheduled nightly.
- PDF fill microservice: FastAPI with config-driven field mapping, deployed as an independent container.
- Integration automation: browser automation uploads lab results; fax APIs are polled on schedule into the queue.
- DR: multi-tier backup scripts + off-site sync + automated restore drills + a page-file watchdog service.
Reusable lessons
- 'Don't migrate' is often the right answer: keep the legacy system as source of truth and bolt every new capability on the outside — controlled risk, fast results.
- Medical AI pipelines must be incremental, re-runnable, and idempotent — recomputing everything nightly is wasteful and unauditable.
- The only acceptance test for a backup system is 'did today's restore drill pass' — everything else is comfort.
- AI analysis of medical records belongs inside the clinic environment. Data not leaving the building is the compliance baseline.
Want results like these?
Tell us about your business and we'll scope a proof of concept.