knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Adapts the software provided by the Healthcare Cost and Utilization Project (HCUP) for analyses of administrative database using International Classification of Diseases (ICD) codes within the R statistical environment.
# Hide the warning messages library(hcup) library(dplyr) library(purrr) library(tidyr)
You can install the development version of hcup from GitHub with:
# install.packages("devtools") devtools::install_github("HunterRatliff1/hcup")
This works for ICD-9 or ICD-10 diagnosis codes, although the categories differ across ICD versions
library(hcup) classify_chronic(icd_dx = "G4730", icd_version = "dx10") classify_chronic(icd_dx = "56081", icd_version = "dx9") # Vectorized version icd_codes <- c("G4730", "L563", "M25151") classify_chronic(icd_codes, icd_version = "dx10")
Identifies procedures by Procedure Classes, which can be [1] diagnostic or therapeutic and [2] whether they major (expected to be performed in an operating room) or minor. This works with both ICD-9-CM procedure codes and ICD-10-PCS procedure codes.
classify_pr("0PS443Z") # Spine surgery classify_pr("009U3ZX") # Lumbar puncture classify_pr("0015") # Infusion of IL-2
This function categorizes ICD codes for both diagnoses and procedures into mutually exclusive Clinical Classifications Software (CCS) categories. This was designed for use with ICD-9 codes, but the HCUP used to provide a beta version that works with ICD-10
library(dplyr) ## Look up ICD-9 DX codes classify_ccs("8442", code_type = "dx9", level = "single") # Vectorized tibble(ICD = c("8442", "1403", "9682", "36463", "3595")) %>% mutate(CCS = classify_ccs(ICD, code_type = "dx9", "single"), CCS_expl = explain_ccs(CCS)) ## Works the same for ICD-9 PR codes classify_ccs("066", code_type = "pr9")
As mentioned above, classify_ccs()
will also work with ICD-10 using a beta version that is no longer
updated, but the CCSR (below) is preferred. However, if you're working with a mix of ICD-9 and ICD-10
codes, you can use classify_ccs() understanding the limitations
# Fake patient data tibble::tribble( ~patient, ~pr_vers, ~code, "A", 10, "0TY10Z1", "B", 10, "0RJM4ZZ", "C", 10, "0210088", "D", 9, "3352", "E", 9, "3323", "F", 9, "3639" ) %>% mutate(CCS = case_when( pr_vers==9 ~ classify_ccs(code, code_type = "pr9"), pr_vers==10 ~ classify_ccs(code, code_type = "pr10"))) %>% mutate(expln = explain_ccs(CCS))
The Clinical Classifications Software Refined (CCSR) software for ICD-10 works similar to CCS for procedures, but capitalizes on ICD-10's specificity
classify_ccsr_pr("0016070") library(dplyr) tibble(icd_10 = c("04L04DZ", "009Y40Z", "0F7C7DZ", "GZ2ZZZZ")) %>% mutate(CCSR = classify_ccsr_pr(icd_10), explained = explain_ccsr(CCSR))
For ICD-10 diagnostic codes, the specificity actually creates a bit of a problem as
CCSR doesn't categorize diagnoses into mutually exclusive categories (see vignette("ccsr-dx")
).
ccsr_dx("I110") # Hypertensive heart disease with heart failure ccsr_dx("I110") %>% explain_ccsr()
This is wonderful in some senses, because it captures more information, but makes it difficult to answer some questions (e.g. do admissions for heart failure cost more than admissions for hypertension?). To address this, the principal diagnosis can still be categorized into a single CCSR category.
tibble::tribble( ~Pt_id, ~DX_NUM, ~ICD, "A", "DX_1", "I110", "A", "DX_2", "F17210", "B", "DX_1", "I150", "B", "DX_2", "Z370", "B", "DX_3", "E876" ) %>% # Limit to the principal diagnosis filter(DX_NUM == "DX_1") %>% mutate(prin_CCSR = classify_ccsr_dx1(ICD, setting="ip"), principal_CCSR = explain_ccsr(prin_CCSR))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.