Learn R Programming

icd9 (version 1.3.1)

icd9ExpandRange: take two ICD-9 codes and expand range to include all child codes

Description

this is cumbersome code, covering a whole load of edge cases relating to the fact that icd9 codes are not in numeric order. An alternative strategy would be to list all the ICD9 codes, then a range would just pick out start and finish positions, and return subset of the list. Not all ICD-9 codes are valid, including some parent codes which have valid children. However, I expect at least some of these have been used in some billing databases.

As with link{icd9ExpandRangeShort} great care is taken not to include codes which have children not in the range. E.g. "100.9" to "101.1" would _not_ include code "101".

onlyReal default is TRUE (a change from previous versions) since this is far more likely to be useful to the end user.

Usage

icd9ExpandRange(start, end, isShort = icd9GuessIsShort(c(start, end)), onlyReal = TRUE, excludeAmbiguousStart = TRUE, excludeAmbiguousEnd = TRUE)
icd9ExpandRangeShort(start, end, onlyReal = TRUE, excludeAmbiguousStart = TRUE, excludeAmbiguousEnd = TRUE)
icd9ExpandRangeMajor(start, end, onlyReal = TRUE)
icd9ExpandRangeDecimal(start, end, onlyReal = TRUE, excludeAmbiguousStart = TRUE, excludeAmbiguousEnd = TRUE)
start %i9da% end
start %i9sa% end
start %i9d% end
start %i9mj% end
start %i9s% end

Arguments

start, end
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"
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.
onlyReal
single logical value, if TRUE, will limit the search to those codes which appear in the master list, not just syntactically valid codes. Since nearly valid, out-dated or new codes may be missed, not limiting to 'real' values will be useful. Ultimately, there will need to be annual (and all-time) master lists of codes and the ability to test against a given master list given the year of the ICD-9 coding.
excludeAmbiguousStart
single logical value, if TRUE the range returned will not include codes which are explicitly listed in the range, but would imply a broader range than specified. E.g. V10 V1009 would by default (FALSE) include V10 even though V10 itself is parent to everything up to V11.
excludeAmbiguousEnd
single logical, same as excludeAmbiguousStart but affects codes at the end of the range. E.g. 99.99 to 101.01 would by default exclude 101 and 101.0

See Also

Other ICD-9 ranges: icd9Children, icd9Condense, icd9ExpandMinor

Examples

Run this code
"4280 " %i9s% "4289 "
"4280 " %i9s% "42821"
"42799 " %i9sa% "42802" # doesn't include 428 or 4280
"427.99 " %i9da% "428.02"
"V80 " %i9s% " V810 "

Run the code above in your browser using DataLab