Check whether ICD-9 codes are syntactically valid
This does not check whether the code corresponds to a real ICD-9-CM billing
code, or parent grouping. For that, see
1 2 3 4 5 6 7 8 9 10 11 12
icd_is_valid(x, ...) ## S3 method for class 'icd10' icd_is_valid(x, short_code = icd_guess_short(x), whitespace_ok = TRUE, ...) ## S3 method for class 'icd9' icd_is_valid(x, short_code = icd_guess_short(x), whitespace_ok = TRUE, ...) ## S3 method for class 'icd_comorbidity_map' icd_is_valid(x, short_code, ...)
An ICD-9 or 10 code. If the class is set to
arguments passed on to other functions
Single logical, if
character vector of 'major' part of ICD-9 codes, i.e. that part which falls before the decimal point, in decimal notation. (In five digit notation, the 'major' part is be the first three characters (with leading zeroes), and includes V or E prefix.
Factors are accepted, and since the validation is done with
these are handled correctly.
Currently, there is a limitation on NA values. Calling with
is a logical vector of length one by default) fails, because it is not a
string. This is rarely of significance in real life, since the NA will be
part of a character vector of codes, and will therefore be cast already to
NA values result in a return value of
Leading zeroes in the decimal form are not ambiguous. Although integer ICD-9 codes could be intended by the user, there is a difference between 100, 100.0, 100.00. Therefore a warning is given if a numeric value is provided.
logical vector with
FALSE for each ICD code
provided according to its validity
Methods (by class)
icd10: Test whether generic ICD-10 code is valid
icd9: Test whether generic ICD-10 code is valid
icd_comorbidity_map: Validate a mapping of ICD codes to comorbidities.
icd9_is_valid_major validates just
the 'major' three-digit part of an ICD-9 code. This can in fact be provided
as a numeric, since there is no ambiguity. Numeric-only codes should be one
to three digits, V codes are followed by one or two digits, and E codes
always by three digits between 800 and 999.
S3 class of on object in R is just a vector. Attributes are
lost with manipulation, with the exception of class: therefore, elements of
the class vector are used to describe features of the data. If these are
not present, the user may specify (e.g. decimal vs short_code type, ICD-9
vs ICD-10 WHO), but if they are, the correct functions are called without
any guess work. There is overlap between sets with combinations of
decimal_code, and ICD-9 or ICD-10 codes, so
guessing is never going to be perfect.
1 2 3 4 5 6 7 8