Learn R Programming

icd (version 3.3)

expand_range: 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 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

expand_range(start, end, ...)

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

# S3 method for icd9 expand_range(start, end, short_code = 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

icd_expand_range.character(...)

icd_expand_range.icd10cm(...)

icd_expand_range.icd9(...)

icd_expand_range_major.icd9(...)

icd_expand_range(...)

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"

...

arguments passed on to other functions

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.

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

Deprecated function names

Future versions of icd will drop the icd_ prefix. For example, charlson should be used in favor of icd_charlson. To distinguish icd function calls, consider using the prefix icd:: instead, e.g., icd::charlson. Functions which specifically operate on either ICD-9 or ICD-10 codes or their sub-types will retain the prefix. E.g. icd9_comorbid_ahrq. icd specific classes also retain the prefix, e.g., icd_wide_data.

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

See Also

Other ICD-9 ranges: children, condense, expand_minor

Examples

Run this code
# NOT RUN {
"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