edonnachie / ICD10gm

R Package: ICD-10-GM Metadata
https://edonnachie.github.io/ICD10gm/
Other
10 stars 2 forks source link

Function for fast interactive lookup #25

Closed edonnachie closed 1 year ago

edonnachie commented 1 year ago

It is useful to be able to look up an ICD-10 code quickly without much typing or having to navigate to the web version of the ICD-10.

Need a function like the following, with more elegant handling of icd3 vs. icd_sub, and an option to choose whether all codes for a 3-digit key should be returned.

icd_lookup <- function(icd) {
  icd3 <- substr(icd, 1, 3)
  subset(
    ICD10gm::icd_meta_codes,
    icd_sub == icd3 & year == max(ICD10gm::icd_meta_codes$year),
    select = c("year", "icd_sub", "label")
  )
}
icd_lookup("E1009")