简体   繁体   中英

How to convert a list of ICD9 and ICD10 codes into their meaning (English names) in R?

I have a list of ICD9 AND ICD10 codes like this:

706.2

L81.0

D23.5

782

I want to decode these to English (to the actual name of the diseases). I thought of using the ICD package in R, especially the "explain_table()" function but it's only decoding either the ICD9 codes or the ICD10 codes. Not the two at the same time. I am getting this:

Sebaceous cyst

NA

NA

Symptoms involving skin and other integumentary tissue

It seems the type of ICD code of the first element in the list will decide what kind of code will be translated. In my example, the first one was an ICD9 code so only the ICD9 codes were translated. The two ICD10 codes in the middle were not.

Suggestions?

Do you also have an indicator for whether any given code is ICD9 or ICD10? There is no "safe" way to do this reliably that covers all possible codes, especially if you are using short codes. For example "E882" is an accidental fall out of a building in ICD9 and unclassified lipomatosis in ICD10.

icd::explain_table()'s "helpful" default S3 method is to check whether the first code is a valid ICD10 code. If it is, everything is ICD10, otherwise everything is ICD9.

If you don't know whether any given code is ICD9 or ICD10 but eg always want to use ICD10 if a code is represented in both systems you can take an approach like:

my_icd9 <- structure(my_character_vector, class = "icd10")
my_icd10 <- structure(my_character_vector, class = "icd9")

dplyr::coalesce(
  explain_table(my_icd10)$short_desc,
  explain_table(my_icd9)$short_desc
)

which gets you the short desc for ICD10 if that exists, and ICD9 only as a fallback if no ICD10 code matches a character element.

This is coming late but you can use the icdcoder library from their repo .

library(tidyverse)
library(devtools)
devtools::install_github("wtcooper/icdcoder")
library(icdcoder)


df <- tibble("codes" = c("706.2", "L81.0", "D23.5", "782")) %>% 
  mutate(
    codes_mod =  toupper(gsub("\\.","", codes)) # Remove dots.
  )
 

res <- df %>% 
  filter(codes_mod %in% icd10Hierarchy$icd10) %>% # First handle ICD10 codes.
  left_join(icd10Hierarchy, by = c("codes_mod" = "icd10")) %>% 
  bind_rows( # Then handle and append ICD9 codes.
    df %>% 
      filter(codes_mod %in% icd9Hierarchy$icd9) %>% 
      left_join(icd9Hierarchy, by = c("codes_mod" = "icd9"))
  )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM