Downloads and loads Clinical Classifications Software Refined (CCSR) mapping files directly from the Agency for Healthcare Research and Quality (AHRQ) Healthcare Cost and Utilization Project (HCUP) website.
Arguments
- type
Character string specifying the type of CCSR file to download. Must be one of: "diagnosis" (or "dx") for ICD-10-CM diagnosis codes, or "procedure" (or "pr") for ICD-10-PCS procedure codes. Default is "diagnosis".
- version
Character string specifying the CCSR version to download. Use "latest" to download the most recent version, or specify a version like "v2026.1", "v2025.1", etc. Default is "latest".
- cache
Logical. If TRUE (default), the downloaded file is cached in a temporary directory to avoid re-downloading on subsequent calls.
- clean_names
Logical. If TRUE (default), column names are cleaned to follow R naming conventions (snake_case).
Value
A tibble containing the CCSR mapping data with the following columns:
For diagnosis files: ICD-10-CM code, CCSR category, default CCSR category, and clinical descriptions
For procedure files: ICD-10-PCS code, CCSR category, and descriptions
Details
This function downloads CCSR mapping files directly from the HCUP website. The package does not redistribute these files but facilitates access to the official AHRQ data sources.
The function handles:
Automatic URL construction based on type and version
ZIP file download and extraction
Proper encoding of special characters
Preservation of leading zeros in ICD-10 codes
Conversion to tidy tibble format
Examples
# \donttest{
# Download latest diagnosis CCSR mapping
dx_map <- download_ccsr("diagnosis")
#> Warning: Could not determine latest version from HCUP website. Using fallback version: v2026.1. This may not be the actual latest version.
#> Downloading from: https://hcup-us.ahrq.gov/toolssoftware/ccsr/DXCCSR-v2026-1.zip
#> Error in value[[3L]](cond): Failed to download file: Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Timeout was reached [hcup-us.ahrq.gov]:
#> Connection timed out after 60000 milliseconds
# Download specific version of procedure CCSR mapping
pr_map <- download_ccsr("procedure", version = "v2025.1")
#> Downloading from: https://hcup-us.ahrq.gov/toolssoftware/ccsr/PRCCSR_v2025-1.zip
#> Error in value[[3L]](cond): Failed to download file: Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Timeout was reached [hcup-us.ahrq.gov]:
#> Connection timed out after 60001 milliseconds
# Download without caching
dx_map <- download_ccsr("diagnosis", cache = FALSE)
#> Warning: Could not determine latest version from HCUP website. Using fallback version: v2026.1. This may not be the actual latest version.
#> Downloading from: https://hcup-us.ahrq.gov/toolssoftware/ccsr/DXCCSR-v2026-1.zip
#> Error in value[[3L]](cond): Failed to download file: Failed to perform HTTP request.
#> Caused by error in `curl::curl_fetch_memory()`:
#> ! Timeout was reached [hcup-us.ahrq.gov]:
#> Connection timed out after 60002 milliseconds
# }
