AI medical coding
AI medical coding explained: how a trained model suggests ICD-10 and CPT codes from clinical notes, and how to test one on your own charts before you use it.
Updated
AI medical coding means using a trained model to read clinical notes and suggest the codes for a claim, such as ICD-10-CM diagnosis codes and CPT procedure codes. Each suggestion comes with the phrase from the note that supports it. A certified coder checks every suggestion before it is billed, so the model does the reading and the coder keeps the final call.
Coding is high volume and easy to get slightly wrong. A wrong code can mean a denied claim, a rework cycle or an audit finding. Speed matters, but accuracy on rare codes matters more, because rare codes are where a general model guesses most often.
Why coding suits a trained model
The output is a closed set. Every answer comes from a published code list, and each code has to be backed by a phrase in the note. A general model can produce a plausible code. A trained model learns which phrases in your notes support which codes, and which wording in your specialty tends to be ambiguous.
Training on one task also fixes the output shape. The model returns the code, the supporting text and a confidence flag in the same structure every time, so your billing system can read it without parsing prose. A code with no supporting phrase is a question for the reviewer, not an answer. Batch pricing and prompt caching do not fix consistency, so a prompt-only setup still drifts. See prompt caching: what it saves and when it doesn’t.
A worked example from one visit note
Take a follow-up note that reads: “Established patient. Type 2 diabetes with peripheral neuropathy in both feet. Foot exam documented, medication continued, return in three months.” A useful suggestion has three parts:
- A diagnosis code for the diabetes and the neuropathy together, with both conditions quoted from the note. The coder confirms the exact code against the current set.
- An office visit level that matches the history, exam and decision making the note documents.
- A flag when support is thin, such as a condition that appears only in the history section with no assessment or plan.
The coder’s check then has three parts: does the quoted phrase support the code, is the code set current, and do the payer’s edits allow these codes on the same claim. The model can flag the first. The other two need a coder and a current code set.
Testing against your own coded charts
Build the test from your own charts. Pull a sample of notes that certified coders already coded, and treat their final codes as the answer key. Split the set by patient, not by note, so the same patient never appears in both training and testing. Use enough notes that rare codes appear in the test at all. Score the model you use today on that set first, then train a candidate and score it on the same notes. For the method in general, see how to test an LLM on your own data before you switch.
Our public benchmark applies the same discipline to contract extraction across 510 documents with 5-fold cross-validation, and a trained model outscored the frontier models we tested. It does not measure coding accuracy on your charts, so treat it as evidence for the method, not a promise for your codes. See full results.
Mistakes that inflate the score
Several errors make a coding model look better than it is:
- Splitting by note instead of by patient. Repeat visits leak phrasing from training into testing, and the score rises for the wrong reason.
- Using the final bill as the answer key. Claims get edited after coding, so take the coder’s final note-level codes and check them against the documentation.
- Reporting one overall accuracy number. A model can score well on common diagnoses and miss rare codes, which are expensive when wrong.
- Scoring the code but not the evidence. A correct code with a quoted phrase that does not support it still fails audit.
- Tuning against the test set. Once the prompt is edited to fix test misses, the set is no longer a test. Freeze it and build a new one for the next round.
- Ignoring code-set revisions. ICD-10-CM and CPT change on a schedule, so rerun the test against the code set your claims use on the date they are filed.
Keeping a coder in the loop
The model suggests and a certified coder approves. Show the supporting phrase next to every suggested code, so the reviewer can check it in seconds. Log every change the coder makes, because those corrections are the best source of future test cases. A coder who overrides a suggestion has produced test data, not a failure.
Set the confidence threshold from your test results. A lower threshold sends fewer suggestions to manual review and lets more errors through. A higher one sends more to the full manual queue, which costs coder time.
Coding notes contain protected health information, so where the model runs is a real decision. A trained model can run in your own cloud account or inside your building, under your own access, logging and retention rules, and then the notes never go to a third-party API. Which legal and payer rules apply is for your compliance team and counsel to decide. For the data path questions, see LLM data privacy: where your prompts go.
Where to start
Start with one specialty or one note type, not the whole coding department. Pick the note type with the most volume and the clearest answer key, then work through this order:
- Confirm which code set and version your claims use today.
- Freeze a patient-level test split from coded notes.
- Score your current process on that split and record the result.
- Train a candidate and score it on the same split, by code family.
- Run a shadow period where coders see suggestions but do not act on them.
- Track how often coders accept a suggestion as written, and how often they fix it.
Compare cost per encounter against your current process, on the same cost basis for both. The Own Weights homepage shows how the whole path fits together.
Want to know whether one coding task at your volume is worth moving to a trained model? Book a free audit or a call. We will map where your AI spend goes today and whether medical coding is the right first task.
Questions
Can an AI model replace a medical coder?
Not in a setup we would recommend. The model suggests codes, and a certified coder checks each one before it goes on a claim. Whether your payers and compliance rules allow any automated step is a question for your compliance team.
What does a medical coding model need before it can be tested?
A set of past encounters that certified coders have already coded, with their final codes as the answer key. Keep that set out of training so the test stays honest. Your current model or process is the baseline the candidate has to beat.
Where do clinical notes go during training and inference?
When the model runs in your own cloud account or inside your building, the notes stay in your environment. Nothing needs to go to a third-party API in that setup. Your own access and retention controls still apply.