These functions take a set of ICD codes, and look for parent ICD codes in the hierarchy. If all the children of a parent are found, then the returned vector will just contain the parents of those codes. Any additional codes which did not have all the siblings present are retained. This can be thought of as the inverse operation to children.

condense(x, short_code = guess_short(x), defined = NULL, warn = TRUE, ...)

# S3 method for character
condense(x, short_code = guess_short(x), defined = NULL, ...)

# S3 method for factor
condense(x, short_code = guess_short(x), defined = NULL, ...)

icd9_condense_decimal(
  x,
  defined = NULL,
  warn = TRUE,
  keep_factor_levels = FALSE
)

Arguments

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.

...

arguments passed on to other functions

icd9

is a character vector or factor 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.

icd9Short

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.

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.

Methods (by class)

  • character: Condense a set of ICD codes, guessing ICD version from input data

  • factor: Condense a factor of ICD codes

See also

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

Examples

kids <- children("V40") kids
#> [1] "V40" "V400" "V401" "V402" "V403" "V4031" "V4039" "V409"
condense(kids, defined = TRUE)
#> [1] "V40"
kids_with_undefined <- children("V40", defined = FALSE) head(kids_with_undefined)
#> [1] "V40" "V400" "V4000" "V4001" "V4002" "V4003"
length(kids_with_undefined)
#> [1] 111
condense(kids, defined = FALSE)
#> [1] "V40"
# what happens if we have additional codes? # (condense will warn if we don't explicitly ask to condense # based on defined or possible codes.) condense(c(kids, "41100"), warn = FALSE)
#> [1] "41100" "V40"
# a good use is to summarise the contents of a comorbidity: icd9_map_elix$CHF
#> [1] "39891" "40211" "40291" "40411" "40413" "40491" "40493" "4280" "42800" #> [10] "42801" "42802" "42803" "42804" "42805" "42806" "42807" "42808" "42809" #> [19] "4281" "42810" "42811" "42812" "42813" "42814" "42815" "42816" "42817" #> [28] "42818" "42819" "4282" "42820" "42821" "42822" "42823" "42824" "42825" #> [37] "42826" "42827" "42828" "42829" "4283" "42830" "42831" "42832" "42833" #> [46] "42834" "42835" "42836" "42837" "42838" "42839" "4284" "42840" "42841" #> [55] "42842" "42843" "42844" "42845" "42846" "42847" "42848" "42849" "4285" #> [64] "42850" "42851" "42852" "42853" "42854" "42855" "42856" "42857" "42858" #> [73] "42859" "4286" "42860" "42861" "42862" "42863" "42864" "42865" "42866" #> [82] "42867" "42868" "42869" "4287" "42870" "42871" "42872" "42873" "42874" #> [91] "42875" "42876" "42877" "42878" "42879" "4288" "42880" "42881" "42882" #> [100] "42883" "42884" "42885" "42886" "42887" "42888" "42889" "4289" "42890" #> [109] "42891" "42892" "42893" "42894" "42895" "42896" "42897" "42898" "42899"
condense(icd9_map_elix$CHF, warn = FALSE)
#> [1] "39891" "40211" "40291" "40411" "40413" "40491" "40493" "428"
# explaining big groups of codes takes advantage of this: explain_code(icd9_map_elix$CHF, condense = TRUE, warn = FALSE)
#> [1] "Rheumatic heart failure (congestive)" #> [2] "Benign hypertensive heart disease with heart failure" #> [3] "Unspecified hypertensive heart disease with heart failure" #> [4] "Hypertensive heart and chronic kidney disease, benign, with heart failure and with chronic kidney disease stage I through stage IV, or unspecified" #> [5] "Hypertensive heart and chronic kidney disease, benign, with heart failure and chronic kidney disease stage V or end stage renal disease" #> [6] "Hypertensive heart and chronic kidney disease, unspecified, with heart failure and with chronic kidney disease stage I through stage IV, or unspecified" #> [7] "Hypertensive heart and chronic kidney disease, unspecified, with heart failure and chronic kidney disease stage V or end stage renal disease" #> [8] "Heart failure"