Learn R Programming

icd (version 4.0.6)

expand_range: Generate a set of codes between two ICD codes including encompassed children

Description

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. See the extensive tests covering this area for much more detail.

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, ...)

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 or 00010.

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.

defined

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.

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

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

Details

The default for the argument defined is TRUE since this is far more likely to be useful to the end user, dealing with real ICD codes.

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.

See Also

Other ICD-9 ranges: children, condense

Examples

Run this code
# NOT RUN {
expand_range("428.0", "428.9")
"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