Functions for working with ICD codes.
ICD-10 code "C00" is a header code because the four-character codes C00.0, C00.1, C00.2, C00.3, C00.4, C00.5, C00.6, C00.7, C00.8, and C00.9 exist. Those four-character codes are assignable (as of 2025) because no five-character descendants (e.g., C00.40) exist.
When the source is the World Health Organization (WHO), CDC Mortality, or Socialstyrelsen, years refer to calendar years. CMS sources use the U.S. federal fiscal year, which starts on October 1 (e.g., fiscal year 2024 runs 2023-10-01 to 2024-09-30). IHACPA sources use the Australian financial year, which starts on July 1 and ends on June 30.
Arguments
- x
Character vector of ICD codes (full or compact form). When
regex = TRUE,xmust contain at least one non-empty, non-missing string.- regex
Logical scalar. If
TRUE, treatxas regular expressions; ifFALSE, use exact matching.- full.codes
Logical scalar. If
TRUE(default), match codes that include the decimal point where applicable.- compact.codes
Logical scalar. If
TRUE(default), match codes without the decimal point.- ...
Passed to
base::grep()whenregex = TRUE
Value
A data.frame with one or more rows per input, including columns
match_type: did the input match a full or compact codeicdv: icd version (9 or 10)dx: diagnostic code (1) or procedure code (0)full_code: the full code stringcode: the compact codes stringsrc: the source - CMS, CDC, or WHO.year ranges (
known_*,assignable_*).
Details
ICD codes should be character vectors. These tools work with either "full codes" (decimal point present when appropriate) or "compact codes" (decimal point omitted).
Similarly for ICD-9-CM: "055" is a header for measles; 055.0, 055.1, 055.2, 055.8, and 055.9 are assignable. Codes 055.3–055.6 do not exist. Code 055.7 is a header because 055.71 and 055.72 exist.
Some codes change status across years. For example, ICD-9-CM 516.3 was assignable in fiscal years 1997–2011 for the CDC extracts (2006–2011 for CMS) and became a header in 2012–2015.
See also
get_icd_codes()to retrieve the internal lookup table of ICD codes.is_icd()to test if a string is a known ICD code.icd_compact_to_full()converts a string from a compact format to the full format based on ICD version and type (diagnostic or procedure).
Other ICD tools:
icd_compact_to_full(),
is_icd()