Skip to contents

Look up CCSR category descriptions

Usage

explain_ccsr(ccsr, detailed = FALSE)

Arguments

ccsr

Vector of CCSR codes to be explained. Can be a mix of diagnosis and/or procedure CCSR groups.

detailed

Single logical value which indicates if more details should be returned. The default is FALSE, in which case only the description of the CCSR category is returned. If set to TRUE, it will return a list of named character vectors

Examples

# Explain the CCSR for diagnosis categories
explain_ccsr("SKN003")
#> [1] "Pressure ulcer of skin"

# The same function works for procedures
explain_ccsr("LYM007")
#> [1] "Bone marrow biopsy"

# Vectorized using `mutate()`
library(dplyr)
dplyr::tibble(
  CCSR = c("NVS011", "DIG021", "MBD028", "URN001", "RES010", "CAR004"),
  Type = c("DX", "DX", "DX", "PR", "PR", "PR")) %>%
mutate(explained = explain_ccsr(CCSR))
#> # A tibble: 6 × 3
#>   CCSR   Type  explained                                     
#>   <chr>  <chr> <chr>                                         
#> 1 NVS011 DX    Neurocognitive disorders                      
#> 2 DIG021 DX    Gastrointestinal hemorrhage                   
#> 3 MBD028 DX    Opioid-related disorders; subsequent encounter
#> 4 URN001 PR    Cystoscopy and ureteroscopy (including biopsy)
#> 5 RES010 PR    Tracheostomy                                  
#> 6 CAR004 PR    Percutaneous coronary interventions (PCI)     

## Examples using the detailed option
detailed <- tibble(CCSR_PR = c("URN001", "RES010", "CAR004")) %>%
  mutate(Explained = explain_ccsr(CCSR_PR),
         details   = explain_ccsr(CCSR_PR, detailed = TRUE))

library(purrr) # use purrr to extract one option
detailed %>%
  mutate(domain = map_chr(details, "clinical_domain"))
#> # A tibble: 3 × 4
#>   CCSR_PR Explained                                      details   domain       
#>   <chr>   <chr>                                          <list>    <chr>        
#> 1 URN001  Cystoscopy and ureteroscopy (including biopsy) <chr [7]> Urinary Syst…
#> 2 RES010  Tracheostomy                                   <chr [7]> Respiratory …
#> 3 CAR004  Percutaneous coronary interventions (PCI)      <chr [7]> Cardiovascul…

library(tidyr) ## use unnest_wider to see all details
detailed %>%
  unnest_wider(details)
#> # A tibble: 3 × 9
#>   CCSR_PR Explained      CCSR  CCSR_desc clinical_domain PCS_roots PCS_bodyparts
#>   <chr>   <chr>          <chr> <chr>     <chr>           <chr>     <chr>        
#> 1 URN001  Cystoscopy an… URN0… Cystosco… Urinary System… Inspecti… "Bladder, Ur…
#> 2 RES010  Tracheostomy   RES0… Tracheos… Respiratory Sy… Bypass, … "Trachea"    
#> 3 CAR004  Percutaneous … CAR0… Percutan… Cardiovascular… Dilation… "\"Coronary …
#> # … with 2 more variables: PCS_devices <chr>, PCS_approaches <chr>