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

Share:

Description

this is cumbersome code, covering a whole load of edge cases relating to the fact that ICD-9 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
icd_expand_range(start, end, ...)

## S3 method for class 'character'
icd_expand_range(start, end, short_code = NULL,
  defined = TRUE, ...)

## S3 method for class 'icd9'
icd_expand_range(start, end,
  short_code = icd_guess_short(c(start, end)), defined = TRUE,
  ex_ambig_start = TRUE, ex_ambig_end = TRUE, ...)

icd9_expand_range_short(start, end, defined = TRUE, ex_ambig_start = TRUE,
  ex_ambig_end = TRUE)

icd9_expand_range_decimal(start, end, defined = TRUE, ex_ambig_start = TRUE,
  ex_ambig_end = 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"

short_code

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.

ex_ambig_start

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 %i9sa% V1009 would by default (FALSE) include V10 even though V10 itself is parent to everything up to V11.

ex_ambig_end

single logical, same as ex_ambig_start but affects codes at the end of the range. E.g. 99.99 to 101.01 would by default exclude 101 and 101.0

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 officially defined 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.

Details

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.

When the class is not known, it must be guessed from the start and end codes. If this guessing fails, e.g. start is ICD-9 whereas end is ICD-10, then an error is thrown. Otherwise, the appropriate S3 method is called.

Expand range of short_code-form ICD-9 codes

Methods (by class)

  • character: Expand a range of ICD-9 or ICD-10 codes when the class is not known

  • icd9: Expand a range of ICD-9 codes

See Also

Other ICD-9 ranges: icd_children, icd_condense, icd_expand_minor

Examples

1
2
3
4
5
"4280 " %i9s% "4289 "
"4280 " %i9s% "42821"
"42799 " %i9sa% "42802" # doesn't include 428 or 4280
"427.99 " %i9da% "428.02"
"V80 " %i9s% " V810 "

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.