Compare ICD-10 character string or search whether a diagnosis fall into the range?

498 Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

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.