1

I have a question about how to check whether certain diagnosis fall into ICD-10 range in R.

Here is my diagnosis code:

C349
A219
B003
C509
B700
A090

And here is the standard ICD-10 range I wish to compare to:

C01.0-C17
A74.8-A75.9
B00.1-B33.1
B69-B72.0
C00.0-C94.2

I tried to split the character strings into values but since they are still not numeric, I cannot compare them.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Yao Nie
  • 13
  • 2
  • 2
    There is an [icd](https://cran.r-project.org/web/packages/icd/icd.pdf) package. Maybe that's worth investigating. – lmo Jan 17 '19 at 23:31
  • You'll want to be clear on what you want however - does `C01.0 - C17` include all `C17x` four (possibly five?) digit sub-codes? – thelatemail Jan 17 '19 at 23:37
  • For this example particularly, C01.0 - C17 do include all C17x, this is tricky, because it's a range rather than just numeric value ranges. – Yao Nie Jan 21 '19 at 18:56

1 Answers1

3

This is the kind of problem icd was designed to solve. Ranges of ICD-10 codes are hard because there are so many of them compared to ICD-9 codes. In addition, there is no ICD-10 code C01.0 in either World Health Organization or US Clinical Modification. With that in mind:

library(icd)
diagnoses <- c("C349", "A219", "B003", "C509", "B700", "A090")
one_pt <- data.frame(id = rep("patient1", length(diagnoses)),
                     diagnoses)
dif_pt <- data.frame(id = paste0("patient", seq_along(diagnoses)),
                     diagnoses)
my_map <- list(c01to17 = icd::expand_range("C01", "C17"),
               a74to75 = icd::expand_range("A748", "A759"),
               b00to33 = icd::expand_range("B001", "B331"),
               b69to72 = icd::expand_range("B69", "B72"),
               c00to94 = icd::expand_range("C000", "C942"))
icd::comorbid(one_pt, map = my_map)
icd::comorbid(dif_pt, map = my_map)

I recommend trying to be consistent with ICD codes with or without decimal places. I prefer dropping them.

If you are using non-WHO or non-ICD-10-CM codes, you can still work with ICD, but be careful to check that discrepancies, like C01.0, are accounted for correctly. This may mean manually entering codes in a code range in some cases. @thelatemail is correct that you have to be very careful when expanding ranges not to expand through a 'parent' code, and thus be broader than planned. The range expanding code in icd is extremely careful with this.

Jack Wasey
  • 3,360
  • 24
  • 43