R/Lookup.R

Defines functions get_icd get_hcpcs_description get_icd10_from_icd9 get_icd9_from_icd10

#devtools::load_data()

##### Getters #####
get_icd <- function(codes,icd9year = 2014,icd10year=2018){
  codes <- c(codes)
  icd9year <- as.character(icd9year)
  icd10year <- as.character(icd10year)

  icd9_matches <- icd9[[icd9year]][match(codes,icd9[[icd9year]]$code),]
  icd9_matches <- na.omit(icd9_matches)
  icd9_matches <- mutate(icd9_matches,icd.version = 9)

  icd10_matches <- icd10[[icd10year]][match(codes,icd10[[icd10year]]$code),]
  icd10_matches <- na.omit(icd10_matches)
  icd10_matches <- mutate(icd10_matches,icd.version=10)

  matches <- bind_rows(icd9_matches,icd10_matches)
  return(matches[match(codes, matches$code),])
}

get_hcpcs_description <- function(codes,year=2018){
  year = as.character(year)
  ret <- filter(hcpcs[[year]],code %in% codes)
  return(ret)
}


get_icd10_from_icd9 <- function(icd9.codes,year=2018){
  year = as.character(year)
  ret <- filter(gem.cm.forward[[year]],ICD9 %in% icd9.codes)
  return(ret)
}


get_icd9_from_icd10 <- function(icd10.codes,year=2018){
  year = as.character(year)
  ret <- filter(gem.cm.backward[[year]],ICD10 %in% icd10.codes)
  return(ret)
}
connerpike/icdr documentation built on May 20, 2019, 4:28 p.m.