How to Extract ICD Codes from Medical Bills PDFs (and Check Them)
You probably won’t find this in a law-firm blog, but a 2016 American Journal of Neuroradiology history says the United States adopted Jacques Bertillon’s list of causes of death in 1898, and that ICD-10 grew the code count from 17,000 to about 155,000.
Hello, and welcome to everyone who has typed S13.4XXA from a bill and wondered whether that was an X or a K.
Every medical bill in a personal injury file carries the same quiet row: a handful of ICD-10-CM codes that say what the provider is billing for.
I spent December 2, 2026 reading the instructions for the two standard US claim forms, Amazon’s ICD-10-CM documentation and a 2016 history of the code system, instead of the vendor blogs that quote each other.
Three things stood out. The CMS-1500 form tells billers to leave the decimal point out, a code that fits a 7-character slot can still be wrong, and many itemized bills carry no codes at all.
Short answer: To extract ICD codes from a medical bills PDF, read the diagnosis boxes with OCR or a vision AI model, put the decimal back (S134XXA becomes S13.4XXA), check each code against the official ICD-10-CM list for the date of service, link each to the billed line it supports, and send unreadable or unmatched codes to a paralegal.
What does an ICD-10-CM code look like on a medical bill?
An ICD-10-CM code is three to seven letters and digits: a letter, two characters, then up to four more that add detail. Written for people it has a decimal after the third character, such as M54.2.
The 2016 AJNR history says the codes are alphanumeric, with a possible 7 digits of specificity
, against 5 in ICD-9. The first three characters name the general condition, and each later one narrows it.
| Code with decimal | As printed on a CMS-1500 | What it says |
|---|---|---|
| S13.4XXA | S134XXA | Sprain of ligaments of cervical spine, initial encounter |
| M54.2 | M542 | Cervicalgia (neck pain) |
| G44.309 | G44309 | Post-traumatic headache, unspecified, not intractable |
| V43.52XA | V4352XA | Car driver injured in collision with another type of car in a traffic accident, initial encounter |
The X in S13.4XXA is a placeholder, and the last letter A marks the initial encounter. A reader that drops either one has not read the code; it has read a different one.
Where do the CMS-1500 and the UB-04 print ICD codes?
On a physician’s CMS-1500, the codes sit in Item 21 and each billed line points to them from Item 24E. On a hospital’s UB-04, the principal diagnosis is form locator 67, with others beside it.
The NUCC instructions for the 1500 claim form say Item 21 takes an ICD indicator (0 for ICD-10-CM) and up to 12 codes, and that the decimal point is not entered because it is implied. Item 24E holds the letters A to L that point back to those codes.
| Form and box | What it holds | What to do with it |
|---|---|---|
| CMS-1500 Item 21 | ICD indicator and up to 12 diagnosis codes, lettered A to L | Read all 12 slots; restore decimals |
| CMS-1500 Item 24E | Pointer letters tying each billed line to Item 21 | Link code to visit and CPT line |
| CMS-1500 Item 24D | CPT or HCPCS procedure code (what was done) | Keep beside the diagnosis; it is a different code set |
| UB-04 form locator 67 | Principal diagnosis | The headline diagnosis of the stay or visit |
| UB-04 form locators 67A to 67Q | Other diagnoses at the time of admission or procedure | Read every one; the count differs by payer |
| UB-04 form locator 69 | Admitting diagnosis | Inpatient stays only |
| UB-04 form locator 74 | Principal procedure: ICD-10-PCS (inpatient) or CPT (outpatient) | Procedure codes, not diagnoses |
Premera’s UB-04 billing guide says the same of the hospital form: The ICD-10 CM code can be up to seven digits without a decimal.
So both standard bills leave the decimal off, while chart notes and many portals print it.
One honest limit: we could not open the NUCC manual itself or the CMS chapter 25 text, so the box details come from the instructions as other sources quote them. Check the box numbers against a bill from your own providers before you build on them.
Why do some medical bills carry no ICD codes at all?
Because many bills in a file are not claim forms. A patient statement, a ledger or a charge list shows dates, descriptions and amounts, and the diagnosis codes live on the claim the provider sent to the insurer.
A personal injury vendor’s billing itemization playbook, as a search summary showed it to us, says an itemized record should list dates of service, CPT and ICD codes, line charges and payments, and that a missing code can be fixed by asking the billing department for a corrected statement. We did not open the full page.
Say you open a clinic’s one-page ledger and see Office visit, March 4, $180
with no code anywhere. No reader, human or machine, can find a code that was never printed. The right move is a records request for the claim or a corrected statement, which is why automated medical record retrieval follow up sits right beside this job.
So a good extractor does not guess. A page with no code gets the label no diagnosis code on this page
, and the request goes back to the provider.
How do you extract ICD codes from a medical bills PDF automatically?
You extract ICD codes automatically in four steps: read the diagnosis boxes, fix and check each code, link it to its billed line, and flag whatever fails.
- Read. OCR or a vision AI model finds the diagnosis boxes on each bill page, even when the scan is crooked, and returns each code with its page number and the box it came from.
- Fix and check. The decimal goes back after the third character, letters are checked against digits, and each code is looked up in the ICD-10-CM list that was in force on the date of service.
- Link. The pointer letters in Item 24E tie each code to the billed line, so S13.4XXA is attached to the March 4 visit and its CPT code.
- Flag. A code that is not on the list, a bill with no code, or a code with no matching visit note waits for a paralegal with the page image beside it.
The sample bill in the diagram is invented. On a real file, the same four steps run on every bill page before a person opens the stack.
Why does a simple ICD code pattern grab vitamin B12 and miss I10?
Because a code is just a letter and a few digits, and so are lots of other things on a medical page. A pattern loose enough to catch every code also catches B12 and T12; a strict one misses valid short codes like I10.
We ran two patterns of our own on six short test lines. The loose one, a letter, two characters and then an optional decimal and up to four more, found every real code in our bill lines, with or without decimals. It also returned “B12” from a vitamin B12 level and “T12” from a spinal level.
The strict one, which demands a decimal or at least four characters, ignored both. It also ignores I10, which is a real three-character code for hypertension, so it would miss one on a real bill.
| Pattern | Caught real codes | False hits on our lines | Misses |
|---|---|---|---|
| Loose: letter, two characters, optional decimal, up to four more | All of them, with or without decimals | B12 (vitamin), T12 (vertebra) | None on our lines |
| Strict: needs a decimal, or at least four characters | All the longer ones | None on our lines | Valid three-character codes such as I10 |
The cure is not a cleverer pattern. It is the look-up: every candidate is checked against the real code list, and the words around it (“Dx”, “Diagnosis”, Item 21) decide whether it was meant as a code.
One more small thing I found while reading. The AJNR history says the letter U is the only letter not used in ICD-10-CM codes. That was true in 2016, but the American Hospital Association’s March 18, 2020 note shows U07.1 (COVID-19) took effect on April 1, 2020. Any pattern that skips U is out of date.
Which tools can read ICD codes from medical bills?
Three kinds of tool do the job: a service that finds codes in text, a service that reads the page, and a vision model that does both in one request.
The calm part of a checked code list is the decimal. Nobody has to remember where it goes; the list already has it, and the page is one click away.
| Service | What it does with codes | What you still build |
|---|---|---|
| Amazon Comprehend Medical InferICD10CM | Reads text that describes a condition and suggests matching ICD-10-CM codes with confidence scores, listed in descending order of confidence | OCR first; it maps clinical wording to codes, so it is a poor reader for a code that is already printed on a bill |
| Amazon Textract Queries | Answers plain questions on a scanned page, such as What are the diagnosis codes?, with a confidence score and location | The question list per bill type and the code checks |
| Claude PDF support | Reads each page as text plus an image, so it can list every printed code with its box, line and pointer in one JSON answer | Splitting large packets and the look-up against the official code list |
Read the Comprehend Medical row twice. Its InferICD10CM operation is made for the opposite job: Use InferICD10CM to detect possible medical conditions as entities and link them to codes
from the 2026 ICD-10-CM version. That is useful on a chart note that says neck pain
with no code, and it is a guess, not a reading.
For a bill that already prints S13.4XXA, you want to read the code, not infer it. Amazon also says that in this service a time expression is only returned if they are associated with an entity
, so dates need a separate step, as extract dates from medical records PDF shows.
My pick for printed codes is a vision model for the reading, plus a plain code-list look-up for the checking. I would add Comprehend Medical only for chart notes with no code. Skip all of it if your bills come as clean electronic files, where the codes are already data.
Which year’s ICD-10-CM list does a bill’s code belong to?
It belongs to the list in force on the date of service. The CDC says FY 2027 codes apply to services from October 1, 2026 through September 30, 2027, and the release replaces the FY 2026 one.
That matters for a file with bills from three different years. A code can be valid in 2025 and gone by 2027, so the look-up must use the right year’s list for each visit.
| Source type | New codes | Caveat |
|---|---|---|
| Summaries citing the CDC/NCHS addendum | 190 new, 30 deleted, total 74,879 (up from 74,719) | We did not open the CDC addendum; the arithmetic is consistent (190 minus 30 is 160, and 74,719 plus 160 is 74,879) |
| Some vendor articles | 238 new | Different counting; does not reconcile with the 74,879 total |
| One code-list site | 150 new | Looks like an outlier |
| CDC files page | No count on the page | States the October 1, 2026 to September 30, 2027 use period |
In short: do not quote a new-code count to anyone until you have opened the CDC addendum yourself. The part that does not change is the rule: look the code up in the year of the visit.
The same AJNR history gives the scale of the whole system: ICD-10 expanded from 17,000 codes to approximately 155,000
.
We could not tell how that count was made, so we use it only as the history’s own figure, not as a count of the diagnosis list.
How long does it take to copy ICD codes from medical bills by hand?
At 45 seconds a bill page, hand-copying codes from 300 bill pages takes about 3.75 hours. A person must find the box, read each code and type it with the decimal.
| Bill pages | Hours by hand at 45 seconds a page | Wage cost at $30.24 an hour | Amazon Textract Queries | Claude Sonnet 5.5 |
|---|---|---|---|---|
| 100 | 1.25 | $38 | $1.50 | $0.76 to $1.06 |
| 300 | 3.75 | $113 | $4.50 | $2.29 to $3.19 |
| 600 | 7.5 | $227 | $9.00 | $4.58 to $6.38 |
Assumptions: 45 seconds a page is our round figure for finding the diagnosis boxes, reading up to a dozen codes and typing them, not a measured time. The wage is the US median paralegal pay of $30.24 an hour from the Bureau of Labor Statistics (May 2025), with no benefits or overhead.
Machine costs use the list prices and the per-page token estimates we set out in our date-extraction guide, with one Textract query per page. More queries per page cost more. These numbers cover the reading only, not the review of flagged pages.
The real saving is not the reading. It is that a person opens only the pages the checks flag, not every page in the stack.
What checks stop a wrong ICD code reaching the demand letter?
Six checks catch most wrong codes before they reach a chronology, and any failure sends the page to a person instead of the file.
- The code exists in the ICD-10-CM list for the year of the date of service.
- The code has the right shape: the decimal after the third character and a placeholder X where the code calls for one.
- Every pointer letter in Item 24E points to a code that is actually filled in on Item 21.
- Each billed visit has a matching visit note, and the note’s description fits the code (a neck sprain code beside a note about a knee gets flagged).
- The same code is not simply repeated on every page of the packet; if it is, check whether it is a header or a template.
- A bill with no code is labelled
no code on this page
and added to the records request list.
The extracted codes then feed the next steps: a chronology that medical chronology software for personal injury builds, and a first draft when you automate demand letter drafting. A code list that is checked and cited makes both safer.
Is it safe to send medical bills to AI, and where should a firm start?
Sending bills to an AI service is safe only when the vendor is covered by a business associate agreement or equivalent terms, does not train on your files, and your bar’s guidance on client confidentiality is followed.
A diagnosis code is health information tied to a person. Amazon Textract and Comprehend Medical are on the AWS HIPAA eligible services list, which AWS says applies after an AWS business associate agreement is signed. Ask any vendor in writing where files are stored and for how long.
Then start small. A sensible first week runs the extraction on one closed file whose bills your team already logged by hand:
- Day 1: pick a closed file with a mix of claim forms, ledgers and a hospital bill.
- Day 2: run the bills through one reader and produce the code list with page cites.
- Day 3: compare it with your paralegal’s list, code by code, and count misses and false hits.
- Day 4: add the checks above for the misses you found.
- Day 5: run a new bill stack in shadow mode while your team works as usual.
If the reader cannot match your team on its own closed file, it is not ready for a live case.
Here is what the pieces add up to.
A code only means something for its year, its visit and its pointer, and a ledger carries none of the three. So when a bill gives you no code, the fastest fix is a records request, not a better scanner, and the most useful thing the software does is tell you which requests to send.
The United States took up Bertillon’s list of causes of death in 1898, according to that AJNR history. More than a century on, the same idea sits in a box on a bill, and a checked code in that box still beats a retyped one.
How we researched this
- Read the Amazon Comprehend Medical InferICD10CM documentation, the CDC’s ICD-10-CM files page, Premera’s UB-04 billing guide, the American Hospital Association’s March 18, 2020 note on U07.1 and the 2016 AJNR history
ICD-10: History and Context
on December 2, 2026, plus the Textract and Claude pages used in our date-extraction guide on November 27, 2026. - The NUCC 1500 manual and CMS chapter 25 would not open as text for us, so the CMS-1500 and UB-04 box details come from secondary summaries of those instructions. The Attorney Assistant playbook was seen only as a search summary. The FY 2027 code counts come from secondary sources, not the CDC addendum.
- We ran two simple code patterns on six invented test lines to see what they caught; that is our own small test, not a benchmark. Our search for Reddit threads on this exact job returned no usable discussion, so we cite none. We did not test any vendor tool or set up any system for this article.
Let the reading happen first, keep the judgment with your paralegal, and see which bills still need a call to the provider.
Sources and further reading
- NUCC: 1500 Claim Form Reference Instruction Manual (Items 21 and 24E)
- Premera: UB-04 billing (form locators 67, 69, 74)
- Amazon Comprehend Medical: ICD-10-CM linking (InferICD10CM)
- Amazon Textract: Queries
- Anthropic: Claude PDF support
- CDC NCHS: ICD-10-CM files (FY 2027 use period)
- American Hospital Association: new COVID-19 ICD-10-CM code coming earlier (March 18, 2020)
- AJNR 2016: ICD-10: History and Context (Hirsch et al.)
- AWS: HIPAA eligible services reference
- BLS: paralegals and legal assistants, median pay
- Attorney Assistant: medical billing itemization, a PI firm playbook (vendor guide, seen as a search summary)
Questions and answers
Can I use AI to extract ICD codes from a medical bills PDF?
Yes. OCR or a vision AI model can read the diagnosis boxes on a CMS-1500 or UB-04 bill, restore the decimal, and list each code with its page citation. A paralegal should check every code against the official ICD-10-CM list for the date of service and review anything the software flags.
Where are the ICD codes on a medical bill?
On a CMS-1500 physician bill, diagnosis codes are in Item 21, up to 12 of them lettered A to L, and each billed line points to them in Item 24E. On a UB-04 hospital bill, the principal diagnosis is form locator 67 and other diagnoses follow in 67A to 67Q.
Why do ICD codes on a bill have no decimal point?
The NUCC instructions for the CMS-1500 say not to enter the decimal because it is implied, and the UB-04 guides say the same. So S13.4XXA prints as S134XXA, and an extraction tool has to put the decimal back after the third character.
What if the medical bill has no ICD codes on it?
Then the bill is probably a ledger or patient statement, not the claim form. Ask the provider’s billing department for the itemized claim or a corrected statement that lists the codes, and mark that page in your file as having no diagnosis code.
Is an ICD code the same as a CPT code?
No. An ICD-10-CM code says what the diagnosis is, such as M54.2 for neck pain. A CPT code says what was done, such as 99213 for an office visit. A bill lists both, and the pointer letters in Item 24E connect each procedure to its diagnosis.