is_icd_code: Test whether a string is a valid ICD code

View source: R/icd_parse.R

is_icd_codeR Documentation

Test whether a string is a valid ICD code

Description

An ICD code consists of, at a minimum, a three digit ICD-10 code (i.e. one upper-case letter followed by two digits). This may optionally be followed by a two digit subcode, selected punctuation symbols (cross "*", dagger "U2020" or exclamation mark "!"). Both the period separating the three-digit code from the subcode, and the hyphen indicating an "incomplete" subcode, are optional. Finally, in the ambulatory system, an additional letter G, V, Z or A may be appended to signify the status ("security") of the diagnosis.

Usage

is_icd_code(str, year = NULL, parse = TRUE)

Arguments

str

Character vector to be tested

year

Year for which to test whether the specification is a valid code. Default: NULL (test whether str matches a code from any year since 2003)

parse

logical. Whether to first parse the input str using icd_parse (Default: TRUE). If FALSE, assumes that str is already formatted as icd_sub (i.e. without separating period or other punctuation)

Value

Logical vector the same length as the character input

See Also

icd_parse()

Examples

is_icd_code("A09.9")
is_icd_code("A099")
is_icd_code("A09.9-")

is_icd_code("AA9")

# The following code is syntactically correct but
# has never been in use
is_icd_code("E15.9")


edonnachie/ICD10gm documentation built on Sept. 25, 2023, 5:58 a.m.