knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(hcup) library(dplyr) library(purrr)
Although I'm not a fan of procedures myself (clinical practice), I am aficionado of ICD-10 procedure codes (ICD-10-PCS). Compared to their predecessor (ICD-9), ICD-10-PCS is much more eloquent and specific, so it's actually pleasant to work with!
The most straightforward of the HCUP software tools included in this package are the Procedure Classes. Procedure classes identify procedures as [1] diagnostic or therapeutic and [2] whether they major (expected to be performed in an operating room) or minor.
library(hcup) classify_pr("0PS443Z") # Spine surgery classify_pr("009U3ZX") # Lumbar puncture
This function can be vectorized (e.g. using dplyr::mutate
) as shown below:
# Using the dplyr workflow library(dplyr) tibble( Patients = c("A", "B", "C"), ICD_10 = c("0PS443Z", "3E05305", "F13ZHZZ")) %>% mutate(pr_class = classify_pr(ICD_10))
Although applications using ICD-9 codes aren't covered here, this function also works the same for ICD-9 procedure codes.
classify_pr("0015") # Infusion of IL-2
Much more powerful is the Clinical Classifications Software Refined (CCSR) categories, which aggregates the expansive number of ICD-10-PCS procedure codes into a smaller number of clinically meaningful categories.
Similar to the procedure classes (and all functions starting with classify_
), this categorizes ICD
codes into mutually exclusive categories.
classify_ccsr_pr("0016070")
Again, this can be vectorized for use within data frames. The helper function explain_ccsr
can
convert these categories into human-readable labels.
library(dplyr) tibble(icd_10 = c("04L04DZ", "009Y40Z", "0F7C7DZ", "GZ2ZZZZ")) %>% mutate(CCSR = classify_ccsr_pr(icd_10), explained = explain_ccsr(CCSR))
You can also use the "detailed" option within explain_ccsr(ccsr, detailed=TRUE)
to return
additional data about the CCSR category. This returns a named list, which can be helpful
in conjunction with the purrr package.
library(purrr) # NOTE: The results returned when `detailed = TRUE` depends on the # type of CCSR category. See the `CCSR_PR_categories` or # `CCSR_DX_categories` in the `hcup.data` package for details tibble(CCSR_PR = c("URN001", "RES010", "CAR004")) %>% mutate(Explained = explain_ccsr(CCSR_PR), details = explain_ccsr(CCSR_PR, detailed = TRUE), domain = map_chr(details, "clinical_domain"))
icd_pr_codes <- c("0PS443Z", "3E05305", "F13ZHZZ", "04L04DZ", "009Y40Z", "0F7C7DZ", "GZ2ZZZZ") tibble(icd_pr10 = icd_pr_codes) %>% mutate(CCSR = classify_ccsr_pr(icd_pr_codes), PR_cls = classify_pr(icd_pr_codes), explained = explain_ccsr(CCSR))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.