Learn R Programming

icd9 (version 0.5)

icd9ExpandRangeShort: 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.

Usage

icd9ExpandRangeShort(start, end, inferParents = TRUE,
  invalidAction = icd9InvalidActions)

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"
inferParents
single logical value, if TRUE, will infer and include a parent code if a range ends with a value which terminates a higher-level code. E.g. "043"the codes from 0440 to 04499, are covered, but "044" is not explicit. If inferParents is TRUE, "0
invalidAction
character string (unit length) containing one of: "ignore", "silent", "warn", "stop"

- ignore no check for validity of ICD-9 code is made implicitly. This is the fastest option. If the function call is explicitly to check validity, e

See Also

Other ICD-9 ranges: %i9d%, icd9ExpandRangeDecimal; %i9mj%, icd9ExpandRangeMajor; icd9ChildrenDecimal; icd9Children, icd9ChildrenShort; icd9CondenseToExplain; icd9CondenseToMajor; icd9ExpandMinor, icd9ExpandMinorE, icd9ExpandMinorNV; icd9PrecedingMinors, icd9SubsequentMinors

Examples

Run this code
"4280 " %i9s% "4289 "
"V80 " %i9s% "V8210 "

# the following should give all codes in 428 EXCEPT "428",
# and all codes upto 43014 EXCEPT 430 and 4301
icd9ExpandRangeShort("4280 ", "43014")

Run the code above in your browser using DataLab