| Title: | Medical Risk and Comorbidity Tools for ICD-9-CM Data |
|---|---|
| Description: | Generates risk estimates and comorbidity flags from ICD-9-CM codes available in administrative medical datasets. The package supports the Charlson Comorbidity Index, the Elixhauser Comorbidity classification, the Revised Cardiac Risk Index, and the Risk Stratification Index. Methods are table-based, fast, and use the 'plyr' package, so parallelization is possible for large jobs. Also includes a sample of real ICD-9 data for 100 patients from a publicly available dataset. Compatibility updates by Renova. |
| Authors: | Patrick McCormick [aut, cre], Thomas Joseph [aut] |
| Maintainer: | Patrick McCormick <[email protected]> |
| License: | GPL-3 | file LICENSE |
| Version: | 1.3.9001 |
| Built: | 2026-11-15 20:39:31 UTC |
| Source: | https://github.com/renova-r/medicalrisk |
List of Charlson comorbidities
charlson_listcharlson_list
A list, with one column for each comorbidity; value is a textual description
# List the strings used to refer to Charlson comorbidities names(charlson_list) # List descriptions of comorbidities charlson_list# List the strings used to refer to Charlson comorbidities names(charlson_list) # List descriptions of comorbidities charlson_list
List that links the Charlson comorbidity categories to revised weights as calculated by Schneeweiss in Table 4 of his paper.
charlson_weightscharlson_weights
A list, with Charlson comorbidities as names and weight as value
Revised Schneeweiss weights:
0 = Connective tissue dz, Ulcer
1 = MI, PVD, CVD, Diabetes, Hemiplegia
2 = CHF, Chronic pulm dz, Mild liver dz, Diabetes with end organ damage, Any tumor, Leukemia, Lymphoma
3 = Dementia, Mod or severe renal dz
4 = Moderate or severe liver dz, AIDS
6 = Metastatic solid tumor
1. Schneeweiss S, Wang PS, Avorn J, Glynn RJ: Improved comorbidity adjustment for predicting mortality in Medicare populations. Health services research 2003; 38:1103 http://www.ncbi.nlm.nih.gov/pubmed/12968819
charlson_weights_orig,
icd9cm_charlson_deyo,
icd9cm_charlson_romano,
icd9cm_charlson_quan,
melt_icd9list
charlson_weights["dementia"]charlson_weights["dementia"]
List that links the Charlson comorbidity categories to the original weights (specified in the original Charlson paper, Table 3)
charlson_weights_origcharlson_weights_orig
A list, with Charlson comorbidities as names and weight as value
Original Weights:
1 = MI, CHF, PVD, CVD, Dementia, Chronic pulm dz, Connective tissue dz, Ulcer, Mild liver dz, Diabetes
2 = Hemiplegia, Mod or severe renal dz, Diabetes with end organ damage, Any tumor, Leukemia, Lymphoma
3 = Moderate or severe liver dz
6 = Metastatic solid tumor, AIDS
1. Charlson ME, Pompei P, Ales KL, MacKenzie CR: A new method of classifying prognostic comorbidity in longitudinal studies: development and validation. Journal of chronic diseases 1987; 40:373-83 http://www.ncbi.nlm.nih.gov/pubmed/3558716
charlson_weights,
icd9cm_charlson_deyo,
icd9cm_charlson_romano,
icd9cm_charlson_quan,
melt_icd9list
charlson_weights_orig["aids"]charlson_weights_orig["aids"]
List of Elixhauser comorbidities
elixhauser_listelixhauser_list
A list, with one column for each comorbidity; value is a textual description
# List the strings used to refer to Elixhauser comorbidities names(elixhauser_list) # List descriptions of comorbidities elixhauser_list# List the strings used to refer to Elixhauser comorbidities names(elixhauser_list) # List descriptions of comorbidities elixhauser_list
generate_charlson_index_df merges a data frame of Charlson
comorbidities with charlson_weights and sums the results per
patient.
generate_charlson_index_df( df, idvar = "id", weights = medicalrisk::charlson_weights )generate_charlson_index_df( df, idvar = "id", weights = medicalrisk::charlson_weights )
df |
a data frame with ID column |
idvar |
string with name of ID variable within |
weights |
defaults to |
a dataframe with two columns, idvar and "index"
generate_comorbidity_df,
charlson_weights, charlson_weights_orig
# calculate Charlson Comorbidity Index for all patients in the \code{\link{vt_inp_sample}} data(vt_inp_sample) generate_charlson_index_df(generate_comorbidity_df(vt_inp_sample))# calculate Charlson Comorbidity Index for all patients in the \code{\link{vt_inp_sample}} data(vt_inp_sample) generate_charlson_index_df(generate_comorbidity_df(vt_inp_sample))
Merges a given DF of IDs and ICD-9-CM codes to one of the ICD9CM maps, removes redundant comorbidities, and returns a dataframe.
generate_comorbidity_df( df, idvar = "id", icd9var = "icd9cm", icd9mapfn = icd9cm_charlson_quan, .progress = "none", .parallel = FALSE, .paropts = NULL )generate_comorbidity_df( df, idvar = "id", icd9var = "icd9cm", icd9mapfn = icd9cm_charlson_quan, .progress = "none", .parallel = FALSE, .paropts = NULL )
df |
a data frame with at least two columns, specified as |
idvar |
string with name of ID variable within |
icd9var |
string with name of ICD code variable within |
icd9mapfn |
Function to generate comorbidity data frame from ICD-9 codes
(defaults to |
.progress |
passed to |
.parallel |
passed to |
.paropts |
passed to |
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.
a dataframe with column idvar and a logical column for each comorbidity
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)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)
Function that generates a data frame linking ICD-9-CM codes to the Charlson comorbidity categories using the Deyo mapping.
icd9cm_charlson_deyo(icd9)icd9cm_charlson_deyo(icd9)
icd9 |
a unique character vector of ICD-9-CM codes |
NOTE: The input vector of ICD-9-CM codes must be unique, because the output dataframe uses the ICD-9-CM code as row.name.
Uses regular expressions created from the paper by Deyo in 1992.
ICD-9-CM codes must have periods removed. Diagnostic codes are prefixed with
'D' while procedure codes are prefixed with 'P'. So, diagnostic code
404.03 should be "D40403".
A data frame, with ICD9 codes as row names and one logical column for each
comorbidity in charlson_list
1. Deyo RA, Cherkin DC, Ciol MA: Adapting a clinical comorbidity index for use with ICD-9-CM administrative databases. Journal of clinical epidemiology 1992; 45:613-9 http://www.ncbi.nlm.nih.gov/pubmed/1607900
icd9cm_charlson_quan, icd9cm_charlson_romano,
icd9cm_elixhauser_quan, icd9cm_elixhauser_ahrq37,
charlson_weights,
# Identify Charlson categories in ICD-9-CM listing cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_charlson_deyo(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })# Identify Charlson categories in ICD-9-CM listing cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_charlson_deyo(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })
Function that creates a dataframe that links ICD-9-CM codes to the Charlson comorbidity categories using Quan's method.
icd9cm_charlson_quan(icd9)icd9cm_charlson_quan(icd9)
icd9 |
a unique character vector of ICD-9-CM codes |
NOTE: The input vector of ICD-9-CM codes must be unique, because the output dataframe uses the ICD-9-CM code as row.name.
Uses regular expressions created from the paper by Quan in 2005.
ICD-9-CM codes must have periods removed. Diagnostic codes are prefixed with
'D' while procedure codes are prefixed with 'P'. So, diagnostic code
404.03 should be "D40403".
A data frame, with ICD9 codes as row names and one logical column for each
comorbidity in charlson_list
1. Quan H, Sundararajan V, Halfon P, Fong A, Burnand B, Luthi J-C, Saunders LD, Beck CA, Feasby TE, Ghali WA: Coding algorithms for defining comorbidities in ICD-9-CM and ICD-10 administrative data. Medical care 2005; 43:1130-9 http://www.ncbi.nlm.nih.gov/pubmed/16224307
icd9cm_charlson_deyo, icd9cm_charlson_romano,
icd9cm_charlson_quan, icd9cm_elixhauser_quan
# Identify Charlson categories in ICD-9-CM listing cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_charlson_quan(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })# Identify Charlson categories in ICD-9-CM listing cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_charlson_quan(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })
Function that creates a dataframe which links ICD-9-CM codes to the Charlson comorbidity categories using the Romano mapping.
icd9cm_charlson_romano(icd9)icd9cm_charlson_romano(icd9)
icd9 |
a unique character vector of ICD-9-CM codes |
NOTE: The input vector of ICD-9-CM codes must be unique, because the output dataframe uses the ICD-9-CM code as row.name.
Uses regular expressions created from the paper by Romano in 1993.
ICD-9-CM codes must have periods removed. Diagnostic codes are prefixed with
'D' while procedure codes are prefixed with 'P'. So, diagnostic code
404.03 should be "D40403".
A data frame, with ICD9 codes as row names and one logical column for each
comorbidity in charlson_list
1. Romano PS, Roos LL, Jollis JG: Adapting a clinical comorbidity index for use with ICD-9-CM administrative data: differing perspectives. Journal of clinical epidemiology 1993; 46:1075-9; discussion 1081-90 http://www.ncbi.nlm.nih.gov/pubmed/8410092
icd9cm_charlson_quan, icd9cm_charlson_deyo,
icd9cm_elixhauser_quan, icd9cm_elixhauser_ahrq37,
charlson_weights,
# Identify Charlson categories in ICD-9-CM listing cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_charlson_romano(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })# Identify Charlson categories in ICD-9-CM listing cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_charlson_romano(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })
Function makes a dataframe that links ICD-9-CM codes to the Elixhauser comorbidity categories using the AHRQ v3.7 mapping.
icd9cm_elixhauser_ahrq37(icd9)icd9cm_elixhauser_ahrq37(icd9)
icd9 |
a unique character vector of ICD-9-CM codes |
Uses regular expressions based on the file "comformat2012-2013.txt" from AHRQ.
The Agency for Healthcare Research and Quality (AHRQ) has developed Comorbidity Software as part of the Healthcare Cost and Utilization Project (HCUP). The software was developed to report on the comorbidity measures reported by Elixhauser (1998).
The AHRQ software has two parts, one that classifies ICD-9-CM codes by comorbidity, and another that performs heuristics to eliminate duplicate comorbidities and ignore comorbidities which are the primary reason for the hospital visit, as per the DRG.
This table is a translation of the first part of the software, the
classifier, as implemented in the SAS file Comformat2012-2013.txt.
ICD-9-CM codes must have periods removed. Diagnostic codes are prefixed with
'D' while procedure codes are prefixed with 'P'. So, diagnostic code
404.03 should be "D40403".
A data frame, with ICD9 codes as row names and one logical column for each
comorbidity in elixhauser_list
1. http://www.hcup-us.ahrq.gov/toolssoftware/comorbidity/comorbidity.jsp
icd9cm_charlson_deyo, icd9cm_charlson_romano,
icd9cm_charlson_quan, icd9cm_elixhauser_quan
# Identify Elixhauser categories cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_elixhauser_ahrq37(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })# Identify Elixhauser categories cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_elixhauser_ahrq37(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })
Function to make a dataframe that links ICD-9-CM codes to the Elixhauser comorbidity categories using the Quan mapping.
icd9cm_elixhauser_quan(icd9)icd9cm_elixhauser_quan(icd9)
icd9 |
a unique character vector of ICD-9-CM codes |
Uses regular expressions created from the Quan paper from 2005.
ICD-9-CM codes must have periods removed. Diagnostic codes are prefixed with
'D' while procedure codes are prefixed with 'P'. So, diagnostic code
404.03 should be "D40403".
Some ICD-9-CM codes will correspond to more than one category. For example,
404.03 (Hypertensive heart and chronic kidney disease ... stage V) is
in both chf and renlfail categories.
A data frame, with ICD9 codes as row names and one logical column for each
comorbidity in elixhauser_list
1. Quan H, Sundararajan V, Halfon P, Fong A, Burnand B, Luthi J-C, Saunders LD, Beck CA, Feasby TE, Ghali WA: Coding algorithms for defining comorbidities in ICD-9-CM and ICD-10 administrative data. Medical care 2005; 43:1130-9 http://www.ncbi.nlm.nih.gov/pubmed/16224307
icd9cm_charlson_deyo, icd9cm_charlson_romano,
icd9cm_charlson_quan, icd9cm_elixhauser_ahrq37
# Identify Elixhauser categories cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_elixhauser_quan(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })# Identify Elixhauser categories cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) cases_with_cm <- merge(cases, icd9cm_elixhauser_quan(levels(cases$icd9cm)), by.x="icd9cm", by.y="row.names", all.x=TRUE) # generate crude comorbidity summary for each patient library(plyr) ddply(cases_with_cm, .(id), function(x) { data.frame(lapply(x[,3:ncol(x)], any)) })
ICD-9-CM codes have the periods removed. Diagnostic codes are prefixed with
'D' while procedure codes are prefixed with 'P'. So, diagnostic code
404.03 appears as "D40403".
icd9cm_listicd9cm_list
A string vector
Obsolete codes not active in 2012 are not present, and may cause this dataset to miss certain classifications when applied to older datasets. For example, codes 043 and 044 (both obsolete AIDS codes) are not included.
1. https://www.cms.gov/Medicare/Coding/ICD9ProviderDiagnosticCodes/codes.html
# Count procedural codes length(icd9cm_list[grep('^P',icd9cm_list)])# Count procedural codes length(icd9cm_list[grep('^P',icd9cm_list)])
Function to generate data frame that links ICD-9-CM codes to the RCRI comorbidity categories.
icd9cm_rcri(icd9)icd9cm_rcri(icd9)
icd9 |
a unique character vector of ICD-9-CM codes |
Lee et al in 1999 published a "Revised Cardiac Risk Index" based on the work on Goldman in 1997. The RCRI is used to determine the major cardiac complication risk for a patient about to undergo major noncardiac surgery. The six predictors that make up the RCRI are: 1. high-risk surgery 2. history of ischemic heart disease 3. history of congestive heart failure 4. history of cerebrovascular disease 5. preoperative treatment with insulin 6. preoperative serum creatinine with Cr > 2 mg/dL.
In 2005 Boersma et al demonstrated that the Lee indexed can be adapted to use administrative data to predict cardiovascular mortality. They used the following for each point above: 1. retroperitoneal, intrathoracic, or suprainguinal vascular procedure; 2. Ischemia: ICD-9 codes 410.*, 411.*, 412.*, 413.*, 414.*; 3. CVA: ICD-9 428.*; 4. CHF: ICD-9 943.0; 5. DM: ICD-9 425.0; 6. Renal: ICD-9 958.0.
This function merges the ICD-9 guidelines
used by Boersma with some of the other ICD-9 classifiers in this package.
This data set uses the following for each aspect of the RCRI:
1. procedure is left to you
2. 'ischemia' as defined in Boersma
3. 'cvd' as defined by Quan in icd9cm_charlson_quan
4. 'chf' as defined by AHRQ in icd9cm_elixhauser_ahrq37
5. 'dm' as defined by AHRQ (both 'dm' and 'dmcx')
6. renlfail' as defined by AHRQ.
A data frame, with ICD9 codes as row names and logical columns for
chf, cvd, dm, ischemia, and renlfail.
1. Lee TH, Marcantonio ER, Mangione CM, Thomas EJ, Polanczyk CA, Cook EF, Sugarbaker DJ, Donaldson MC, Poss R, Ho KK, Ludwig LE, Pedan A, Goldman L: Derivation and prospective validation of a simple index for prediction of cardiac risk of major noncardiac surgery. Circulation 1999; 100:1043-9 http://www.ncbi.nlm.nih.gov/pubmed/10477528
2. Boersma E, Kertai MD, Schouten O, Bax JJ, Noordzij P, Steyerberg EW, Schinkel AFL, Santen M van, Simoons ML, Thomson IR, Klein J, Urk H van, Poldermans D: Perioperative cardiovascular mortality in noncardiac surgery: validation of the Lee cardiac risk index. The American journal of medicine 2005; 118:1134-41 http://www.ncbi.nlm.nih.gov/pubmed/16194645
icd9cm_charlson_quan, icd9cm_elixhauser_quan,
icd9cm_elixhauser_ahrq37
ICD-9-CM codes must have periods removed. Diagnostic codes are prefixed with
'D' while procedure codes are prefixed with 'P'. So, diagnostic code
404.03 should be "D40403".
icd9cm_sessler_rsi(icd9)icd9cm_sessler_rsi(icd9)
icd9 |
a unique character vector of ICD-9-CM codes |
Note: A subsequent publication (Sigakis, 2013) found the following: "Calibration "in-the-large" for RSI in-hospitalmortality illustrated a discrepancy between actual (1.5 identified a regression constant (-2.198) in the published RSI "all-covariates.xls" file that was not used in the published SPSS implementation macro."
The risk stratification index score
Tom Joseph <[email protected]>, Patrick McCormick <[email protected]>
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d.
2. Sigakis MJG, Bittner EA, Wanderer JP: Validation of a risk stratification index and risk quantification index for predicting patient outcomes: in-hospital mortality, 30-day mortality, 1-year mortality, and length-of-stay. Anesthesiology 2013; 119:525-40
# Calculate RSI for each patient ("id") in dataframe cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) library(plyr) ddply(cases, .(id), function(x) { icd9cm_sessler_rsi(x$icd9cm) } )# Calculate RSI for each patient ("id") in dataframe cases <- data.frame(id=c(1,1,1,2,2,2), icd9cm=c("D20206","D24220","D4439","D5064","DE8788","D40403"), stringsAsFactors=TRUE) library(plyr) ddply(cases, .(id), function(x) { icd9cm_sessler_rsi(x$icd9cm) } )
melt_icd9list uses ddply to melt a column of comma-separated ICD-9-CM
codes into a series of rows, one for each code.
melt_icd9list( df, idvar = "id", icd9var = "icd9cm", .progress = "none", .parallel = FALSE, .paropts = NULL )melt_icd9list( df, idvar = "id", icd9var = "icd9cm", .progress = "none", .parallel = FALSE, .paropts = NULL )
df |
a data frame with at least two columns, specified as |
idvar |
string with name of ID variable within |
icd9var |
string with name of ICD code variable within |
.progress |
passed to |
.parallel |
passed to |
.paropts |
passed to |
a dataframe with two columns, idvar and "icd9cm"
cases <- data.frame(id=c(1,2), icd9list=c('162.4,070.30,155.0,401.9','996.52,E878.8,V45.86'), stringsAsFactors=TRUE) melt_icd9list(cases, "id", "icd9list")cases <- data.frame(id=c(1,2), icd9list=c('162.4,070.30,155.0,401.9','996.52,E878.8,V45.86'), stringsAsFactors=TRUE) melt_icd9list(cases, "id", "icd9list")
Merges a dataframe containing ICD-9-CM diagostic codes with a dataframe containing ICD-9 procedure codes Diagnostic codes are prefixed with 'D', while procedure codes are prefixed with 'P'
merge_icd9_dx_and_procs( dx_df, proc_df, icd9dxvar = "icd9cm", icd9pvar = "icd9cm" )merge_icd9_dx_and_procs( dx_df, proc_df, icd9dxvar = "icd9cm", icd9pvar = "icd9cm" )
dx_df |
a data frame with at least two columns, specified as |
proc_df |
a data frame with at least two columns, specified as |
icd9dxvar |
name of icd9 diagnostic code column, default "icd9cm" |
icd9pvar |
name of icd9 procedure code column, default "icd9cm" |
a merged dataframe with common columns and "icd9cm"
cases <- data.frame(id=c(1,2), icd9dxlist=c('162.4,070.30,155.0,401.9','996.52,E878.8,V45.86'), icd9plist=c('38.16','38.42'), stringsAsFactors=TRUE) dx_df <- melt_icd9list(cases, "id", "icd9dxlist") proc_df <- melt_icd9list(cases, "id", "icd9plist") merge_icd9_dx_and_procs(dx_df, proc_df)cases <- data.frame(id=c(1,2), icd9dxlist=c('162.4,070.30,155.0,401.9','996.52,E878.8,V45.86'), icd9plist=c('38.16','38.42'), stringsAsFactors=TRUE) dx_df <- melt_icd9list(cases, "id", "icd9dxlist") proc_df <- melt_icd9list(cases, "id", "icd9plist") merge_icd9_dx_and_procs(dx_df, proc_df)
Values for calculating RSI for 1 year mortality
rsi_beta_1yrpodrsi_beta_1yrpod
A hash (see package "hash"), where key is icd9cm code, and value is beta. Special key "popbeta" has the population beta for the entire table.
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d. http://my.clevelandclinic.org/anesthesiology/outcomes-research/risk-stratification-index.aspx
Values for calculating RSI for 30-day length of stay
rsi_beta_30dlosrsi_beta_30dlos
A hash (see package "hash"), where key is icd9cm code, and value is beta. Special key "popbeta" has the population beta for the entire table.
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d. http://my.clevelandclinic.org/anesthesiology/outcomes-research/risk-stratification-index.aspx
Values for calculating RSI for 30-day mortality
rsi_beta_30dpodrsi_beta_30dpod
A hash (see package "hash"), where key is icd9cm code, and value is beta. Special key "popbeta" has the population beta for the entire table.
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d. http://my.clevelandclinic.org/anesthesiology/outcomes-research/risk-stratification-index.aspx
Values for calculating RSI for in-hospital mortality.
rsi_beta_inhosprsi_beta_inhosp
A hash (see package "hash"), where key is icd9cm code, and value is beta. Special key "popbeta" has the population beta for the entire table.
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d. http://my.clevelandclinic.org/anesthesiology/outcomes-research/risk-stratification-index.aspx
Sample data for validating RSI
rsi_sample_datarsi_sample_data
A data table with a patient ID and several columns with ICD-9-CM codes.
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d. http://my.clevelandclinic.org/anesthesiology/outcomes-research/risk-stratification-index.aspx
rsi_sample_results, verify_sessler_rsi
Sample results for validating RSI
rsi_sample_resultsrsi_sample_results
A data table with a patient ID, principal diagnosis, principal procedure, and RSI result columns.
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d. http://my.clevelandclinic.org/anesthesiology/outcomes-research/risk-stratification-index.aspx
rsi_sample_data, verify_sessler_rsi
Returns the covariate coefficient for a particular diagnosis or procedure code, along with the actual code that was found in the internal database of coefficients. If a child code is supplied but its parent is in the database, the coefficient for the parent will be returned, along with that parent code. For example, if D1231 is supplied but only D123 is available, D123 will be used. This is apparently how the SPSS sample code works.
sessler_get_single_beta(code, betalist)sessler_get_single_beta(code, betalist)
code |
A single ICD-9-CM code |
betalist |
One of the rsi_beta_* datasets (supplied with this package) |
Covariate coefficient. You must sum all of these for a given patient and then subtract the appropriate population beta (e.g. rsi_beta_1yrpod$popbeta)
# get coefficient for hypercholesterolemia sessler_get_single_beta('D2720', rsi_beta_inhosp) # Also works with extra 0 on the end sessler_get_single_beta('D27200', rsi_beta_inhosp)# get coefficient for hypercholesterolemia sessler_get_single_beta('D2720', rsi_beta_inhosp) # Also works with extra 0 on the end sessler_get_single_beta('D27200', rsi_beta_inhosp)
Requires that "sample data rev2.csv" and "sample results rev2.csv" be available in datasrc directory
verify_sessler_rsi()verify_sessler_rsi()
Table of patients with scores >0.001 difference.
Patrick McCormick <[email protected]>
1. Sessler DI, Sigl JC, Manberg PJ, Kelley SD, Schubert A, Chamoun NG. Broadly applicable risk stratification system for predicting duration of hospitalization and mortality. Anesthesiology. 2010 Nov;113(5):1026-37. doi: 10.1097/ALN.0b013e3181f79a8d.
rsi_sample_data, rsi_sample_results
## Not run: verify_sessler_rsi() ## End(Not run)## Not run: verify_sessler_rsi() ## End(Not run)
Diagnostic ICD-9 codes are prefixed with 'D', while procedural ICD-9 codes are prefixed with 'P'.
vt_inp_samplevt_inp_sample
A data frame, with column "id" (numeric), some descriptive columns, "dx" (factor), and "icd9cm" (factor)
http://healthvermont.gov/research/hospital-utilization/RECENT_PU_FILES.aspx
icd9cm_charlson_deyo,
icd9cm_charlson_quan,
icd9cm_charlson_romano,
icd9cm_elixhauser_quan,
icd9cm_elixhauser_ahrq37
max(vt_inp_sample$scu_days)max(vt_inp_sample$scu_days)