expand_range: Generate a set of codes between two ICD codes including...

Description Usage Arguments Details Methods (by class) See Also Examples

View source: R/ranges.R

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

 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
expand_range(start, end, ...)

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

## S3 method for class '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

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.

Methods (by class)

See Also

Other ICD-9 ranges: children(), condense()

Examples

1
2
3
4
5
6
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"

Example output

The 'icd9' package is deprecated, and should be removed to avoid conflicts with  'icd' . The 'icd' package up to version 2.1 contains tested versions of all the deprecated function names which overlap with those in the old 'icd9' package, e.g., 'icd9ComorbidAhrq' '. It is highly recommended to run the command: 'remove.packages("icd9")'
 [1] "428.0"  "428.1"  "428.2"  "428.20" "428.21" "428.22" "428.23" "428.3" 
 [9] "428.30" "428.31" "428.32" "428.33" "428.4"  "428.40" "428.41" "428.42"
[17] "428.43" "428.9" 
 [1] "4280"  "4281"  "4282"  "42820" "42821" "42822" "42823" "4283"  "42830"
[10] "42831" "42832" "42833" "4284"  "42840" "42841" "42842" "42843" "4289" 
[1] "4280"  "4281"  "42820" "42821"
[1] "42799" "42800" "42801" "42802"
[1] "427.99" "428.00" "428.01" "428.02"
[1] "V80"   "V800"  "V8001" "V8009" "V801"  "V802"  "V803"  "V810" 

icd documentation built on July 2, 2020, 4:07 a.m.