generate_comorbidity_df: Generate a comorbidity dataframe

Description Usage Arguments Details Value Examples

View source: R/icd9cm.R

Description

Merges a given DF of IDs and ICD-9-CM codes to one of the ICD9CM maps, removes redundant comorbidities, and returns a dataframe.

Usage

1
2
3
4
5
6
7
8
9
generate_comorbidity_df(
  df,
  idvar = "id",
  icd9var = "icd9cm",
  icd9mapfn = icd9cm_charlson_quan,
  .progress = "none",
  .parallel = FALSE,
  .paropts = NULL
)

Arguments

df

a data frame with at least two columns, specified as idvar and icd9var.

idvar

string with name of ID variable within df (defaults to "id")

icd9var

string with name of ICD code variable within df (defaults to icd9cm)

icd9mapfn

Function to generate comorbidity data frame from ICD-9 codes (defaults to icd9cm_charlson_quan)

.progress

passed to ddply

.parallel

passed to ddply

.paropts

passed to ddply

Details

Redundancy rules: * If "tumor" and "mets", only "mets" will be returned. * If "htn" and "htncx", only "htncx" will be returned. * If "dm" and "dmcx", only "dmcx" will be returned. * If "liver" and "modliver", only "modliver" will be returned.

Van Walraven has a modification adopted here where the following "dmcx" codes are downgraded to "dm" if the specific DM complication is separately coded: * D2(49|50)4x is DM w renal * D2(49|50)6x is DM w neuro * D2(49|50)7x is DM w PVD

Cases without any comorbidities will not appear in the returned data frame.

Value

a dataframe with column idvar and a logical column for each comorbidity

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
cases <- data.frame(id=c(1,1,1,2,2,2,2,2),
         icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403","D1960","D1958"),
         stringsAsFactors=TRUE)
generate_comorbidity_df(cases)
# generate categories for patients in the \code{\link{vt_inp_sample}}
generate_comorbidity_df(vt_inp_sample)
# in this example, D25071 is reduced to "dm" from "dmcx" because D4439 already codes perivasc
# also, D20206 "tumor" and D1970 "mets" lead to just "mets"
# D25001 and D25040 are just "dmcx"
# D45621 and D570 are just "modliver"
cases <- data.frame(id=c(1,1,1,1,2,2,2,2),
  icd9cm=c("D1970","D20206","D25071","D4439","D25001","D25040","D45621","D570"),
  stringsAsFactors=TRUE)
generate_comorbidity_df(cases)

medicalrisk documentation built on March 26, 2020, 6:31 p.m.