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.
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"
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
"4280 " %i9s% "4289 ""V80 " %i9s% "V8210 "# the following should give all codes in 428 EXCEPT "428",# and all codes upto 43014 EXCEPT 430 and 4301icd9ExpandRangeShort("4280 ", "43014")