Add Clinical Classifications Software Refined categories to a DuckDB query.
Arguments
- .data
Lazy DuckDB query with
YEARand canonicalI10_DX<n>orI10_PR<n>slots. When present,DQTRidentifies Q4 2015 andDXVERorPRVERmust be 10 or missing for ICD-10 records.- categories
Optional character vector of CCSR category codes, such as
"CIR019", to keep. The default returns all assigned categories.- type
"dx"for diagnoses or"pr"for procedures.- position
"any"checks all slots,"principal"checks slot 1, and"default"returns the inpatient principal diagnosis default.- version
Optional bundled version, such as
"2025.1", to use across years.- name
Name of the new column.
Details
Matches full ICD-10 codes. The any-position and principal modes return distinct categories as a list. The diagnosis default mode returns one inpatient principal diagnosis category.
The bundled 2025.1 mappings cover Q4 2015 and calendar years 2016 through 2024. Pin a version to use the same categories across years. Out-of-coverage discharges receive missing results. Within coverage, unmatched discharges receive an empty list or a missing default category.
Examples
nis <- nis_open(nis_example(years = 2019:2020))
nis |>
nis_add_ccsr(position = "default") |>
dplyr::count(ccsr) |>
dplyr::collect()
#> # A tibble: 2 × 2
#> ccsr n
#> <chr> <dbl>
#> 1 RSP002 84
#> 2 CIR019 108