Design an AI Chart Review Pipeline for EMR Encounter Codes
Pull finished patient encounters from hospital record systems, check each billing code against the visit documents with an AI reviewer, and send one notice back when a code does not match.
Problem statement
For this exercise, assume a company checks medical billing codes for hospitals and clinics. Each customer runs an electronic medical record (EMR) system.
When a patient visit, called an encounter, is finished, the EMR holds the visit's documents, mostly PDF notes (some of them scanned images), and the billing codes that a coder assigned to it.
Design a pipeline that fetches each finished encounter's files and codes from the customer's EMR, checks with an AI reviewer whether each assigned code is supported by the documents, and sends a notification back to the EMR when a code does not match. The same review must work for encounters from every EMR vendor.
Human coders read the notice in the EMR and decide what to change.
Assume every EMR offers an API to list encounters finished or changed since a given time, to download an encounter's files and codes, and to post a review notice on an encounter. Different EMR vendors return different formats.
Assume the AI reviewer is a hosted model that reads one encounter record and returns, for each code, whether the documents support it, with a confidence score and the passages it relied on.
Patient data must stay protected inside each customer's boundary, and every verdict and notice must be traceable to the exact documents, model and prompt that produced it. Changing codes automatically, submitting claims, building the EMR connectors' authentication, and training the model are out of scope.
What to build
- Fetch the documents and assigned codes of every finished encounter from each customer's EMR, once per version of the encounter, including encounters that change after an earlier review.
- Review encounters from every EMR vendor's format in the same way, and keep every passage a verdict cites traceable to its document and page.
- Check every assigned code against the encounter record with the AI reviewer and store a verdict per code with its confidence, the passages it used, and the model and prompt versions.
- Send exactly one notice to the source EMR for each encounter version that has a confident mismatch, and let customer staff see each encounter's review status.
At scale
- For this exercise, assume about 200 customer organizations and about 1 million finished encounters a day in total, with an evening peak of about 50 encounters a second that lasts about two hours. The largest customer finishes about 30,000 encounters a day.
- Assume each encounter's files total about 2 MB. Fetching one encounter takes about 7 EMR API calls, each customer's EMR allows about 20 calls a second, and an EMR is sometimes down for a few hours.
- Assume the AI reviewer takes about 20 seconds per encounter and the model account allows about 600 calls running at once.
- Assume a mismatch notice must reach the EMR within 4 hours of the encounter being finished. Review results and the record each one was based on are kept for 7 years; original PDFs only need to be kept for 30 days, because the EMR stays the system of record.