21

I cannot find a definitive guide to icd9 code formats.

Can anyone explain the format - especially the use of trailing and leading zeros?

A C# regex for icd9 and icd10 codes would also be nice.

Thanks!

mson
  • 7,762
  • 6
  • 40
  • 70
  • Are you looking for fully qualified codes, or are incomplete codes also allowed in your application? – Tim Pietzcker Apr 08 '11 at 06:41
  • 1
    Just a note: using regex for ICD only validates it is in the correct pattern. It does not ensure that the code exists! Consult CMS code lists for all possible [ICD9](https://www.cms.gov/Medicare/Coding/ICD9ProviderDiagnosticCodes/codes.html) and [ICD10](https://www.cms.gov/Medicare/Coding/ICD10/2016-ICD-10-CM-and-GEMs.html) codes. – cacti5 Apr 12 '18 at 21:31

4 Answers4

34

I was looking for the same thing and found what I believe to be a more complete answer. Thought I'd help anyone else coming in the future.

ICD-9 Regex

The ICD 9 format has a bunch of ways it can be formatted. It can begin with V, E, or a number.

  • If it begins with V, then it has 2 numbers, a decimal, then up to two numbers
    • Examples: V10.12 and V12
  • If it begins when E, then it has 3 numbers, the decimal place, then up to two numbers
    • Examples: E000.0 and E002
  • If it begins with a number, then it is up to 3 numbers, a decimal, then up to two numbers
    • Examples: 730.12 and 730

A good regex that checks all these rules is (Credit goes to sascomunitt)

^(V\d{2}(\.\d{1,2})?|\d{3}(\.\d{1,2})?|E\d{3}(\.\d)?)$

ICD-10 Regex

According to www.cms.gov ICD-10 has the following rules:

  • 3-7 Characters
  • Character 1 is alpha (cannot be U)
  • Character 2 is numeric
  • Characters 3-7 are alphanumeric
  • After 3 characters you use a decimal
  • Use of dummy placeholder "x" (This is the only one I am not accounting for in my regex...)
  • Alpha characters are not case sensitive

Here is the regex I came up with:

^[A-TV-Z][0-9][A-Z0-9](\.[A-Z0-9]{1,4})?$

Note These regexes are for javascript and may need tweaked for C# (I'm too lazy to test it right now)

Gordon Tucker
  • 6,653
  • 3
  • 27
  • 41
  • Thanks! this is a better answer than the accepted one since it includes E Codes and V Codes. Only annoying thing is this us government form I'm writing a program for requires the '.' after the first three numbers, so lame! – Peter Turner Feb 12 '13 at 20:00
  • 1
    Technically, the character "U" is valid. It's been reserved for future use by the WHO, but is a valid character. [Reference](http://www.cihi.ca/CIHI-ext-portal/internet/en/document/standards+and+data+submission/standards/classification+and+coding/codingclass_icd10struct) – Andrew Larned Jun 01 '15 at 12:55
  • according to the link you have for ICD-9 the correct regex is `^([V\d]\d{2}(\.\d{1,2})?|E\d{3}(\.\d)?|\d{2}(\.\d{1,2})?)$` because in the last section he states ` Note that ICD-9 *procedure* codes are different yet again--these move the decimal *up* a place.` – abc123 Jun 08 '15 at 19:05
  • Works ok for most; but some icd 9 begining with V match both regexes.Examples :V01, V01.0, V01.1, V01.2, V01.3 – Pete_ch Oct 16 '15 at 20:32
  • @chohi That is because they are valid both as ICD-9 and as ICD-10 codes. – Gordon Tucker Oct 16 '15 at 22:01
  • are you saying the format is valid or the values themselves are valid? they seem different here https://www.cms.gov/medicare-coverage-database/staticpages/icd-10-code-lookup.aspx?KeyWord=V01&bc=AAAAAAAAAAACAA%3d%3d& and here https://www.cms.gov/medicare-coverage-database/staticpages/icd-9-code-lookup.aspx?KeyWord=v01&bc=AAAAAAAAAAAEAA%3d%3d& – Pete_ch Oct 17 '15 at 00:18
  • While not billable, it is a valid code. Try downloading the entire CMS ICD-10 codes file and it will include V01.1 with the description "Pedestrian injured in collision with pedal cycle in traffic accident". The link you provided only includes billable codes. – Gordon Tucker Oct 19 '15 at 15:03
  • Doesn't ICD9 have 3-5 characters (without the decimal place)? Wouldn't that make the codes that begin with E "If it begins when E, then it has 3 numbers, the decimal place, then up to 1 number" instead of "then up to 2 numbers"? The regular expression works for E123.4 but not E123.45 anyway. – yvesmancera Aug 30 '16 at 21:19
  • 1
    For ICD9/10 duplicate codes, see: http://www.icd10data.com/ICD10CM/Duplicate_Codes – jjwdesign Dec 19 '16 at 16:24
10

An ICD-9 code looks like this:

  • two/three-digit numeric code (may have leading zeroes to pad to three digits)
  • an optional dot
  • if that dot is present, there will be one or two following digits, depending on the preceding three digits. Which digits are allowed specifically is very variable.
  • Some codes are prefixed by an E or V.

An ICD-10 code looks like this:

  • an uppercase ASCII letter (A-Z)
  • two digits
  • an optional dot
  • if that dot is present, there will be one or two following digits. Again, it's highly variable which ICD codes allow for which digits after the dot.
  • Sometimes, you'll find an asterisk, a plus sign (at least in ASCII texts), or an exclamation point after a code. They are used in certain combination codes.

So, in essence, you could use regex to find ICD codes in a text, but you won't be able to validate them.

A C# regex for ICD-9 codes could look like this: @"\b[EV]?\d{2,3}(?:\.\d{1,2})?\b".

For an ICD-10 code: @"\b[A-Z]\d{2}(?:\.\d{1,2})?\b[*+!]?"

Tim Pietzcker
  • 328,213
  • 58
  • 503
  • 561
  • What are the rules for trailing zeroes? I thought I've seen 2 digit codes without the leading zero. – mson Apr 08 '11 at 12:04
  • Tim is correct, there are codes with only 2 digits prior to the dot, such as 00.12 and 99.75. These are just 2 examples. There are many more. – fooMonster Jul 05 '11 at 16:30
  • See Section 1-B-3 for more details on coding format: http://www.cdc.gov/nchs/data/icd/icd9cm_guidelines_2011.pdf That document states that ICD-9 _diagnosis_ codes should be 3, 4, or 5 characters long. This section actually says 'digits' not 'characters' but this is obviously incorrect as one of the subsequent sections refers to V and E codes as @lecrank mentioned. – Jesse Clark Aug 28 '14 at 19:45
1

There are 2 types of ICD 9 codes: Diagnosis Codes & Procedure Codes

for the Diagnosis Codes Gordon Tucker has the correct answer:

^(V\d{2}(\.\d{1,2})?|\d{3}(\.\d{1,2})?|E\d{3}(\.\d)?)$

ICD-9-CM procedure codes are 2 numbers, a decimal, then up to two numbers (to be a complete code 2 numbers are required)

A regex for these codes would be:

^\d{2}.\d{1,2}$

ICD-9-CM Procedure Codes 2012 ICD-9-CM Diagnosis Codes

sushant-hiray
  • 1,838
  • 2
  • 21
  • 28
1

Are you referring to ICD-9 diagnosis codes? Then see this thread: ICD-9 Code List in XML, CSV, or Database format.

Community
  • 1
  • 1
Marius Bancila
  • 16,053
  • 9
  • 49
  • 91