Learn R Programming

icd9 (version 1.3.1)

icd9IsValid: check whether ICD-9 codes are syntactically valid

Description

This does not check whether the code coresponds to a real ICD-9-CM billing code, or parent grouping. For that, see icd9IsReal.

Factors are accepted, and since the validation is done with grepl these are handled correctly.

Currently, there is a limitation on NA values. Calling with NA (which 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_character

NA values result in a return value of FALSE.

Usage

icd9IsValid(icd9, isShort)
icd9Valid(icd9, isShort)
icd9IsValidDecimal(icd9Decimal)
icd9ValidDecimal(icd9)
icd9IsValidShort(icd9Short)
icd9ValidShort(icd9)
icd9IsValidShortV(icd9Short)
icd9IsValidShortE(icd9Short)
icd9IsValidShortN(icd9Short)
icd9IsValidMajor(major)

Arguments

icd9
is a character vector or factor of ICD-9 codes. If fewer than five characters is given in a code, then the digits are greedily assigned to hundreds, then tens, then units, before the decimal parts. E.g. "10" becomes "010", not "0010".
isShort
single logical value which determines whether the ICD-9 code provided is in short (TRUE) or decimal (FALSE) form. Where reasonable, this is guessed from the input data.
icd9Decimal
character vector of ICD-9 codes. If fewer than five characters is given in a code, then the digits are greedily assigned to hundreds, then tens, then units, before the decimal parts. E.g. "10" becomes "010", not "0010"
icd9Short
is a character vector of ICD-9 codes. If fewer than five characters is given in a code, then the digits are greedily assigned to hundreds, then tens, then units, before the decimal parts. E.g. "10" becomes "010", not "0010"
major
character vector of 'major' part of ICD-9 codes, i.e. that part which falls before the decimal point, in decimal notation. (In 5 digit notation, the 'major' part is be the first three characters (with leading zeroes), and includes V or E prefix. xyz

Value

logical vector with TRUE or FALSE for each icd9 code provided according to its validity

Three-digit validation

isValidMajor 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 digitis, V codes are followed by one or two digits, and E codes always by three digits between 800 and 999.

Details

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

See Also

icd9IsValidDecimal, icd9IsValidShort, http://www.stata.com/users/wgould/icd9/icd9.hlp urlhttp://www.sascommunity.org/wiki/Validate_the_format_of_ICD-9_codes

Other ICD9 validation: icd9IsValidMapping

Examples

Run this code
  icd9IsValidShort(c("", "1", "22", "333", "4444", "123.45", "V",
                     "V2", "V34", "V567", "E", "E1", "E70", "E"))
  icd9IsValidMajor(c("", "1", "22", "333", "4444", "123.45", "V",
                     "V2", "V34", "V567", "E", "E1", "E70", "E"))

Run the code above in your browser using DataLab