set_icd_class: Construct ICD-9 and ICD-10 data types

Description Usage Arguments Details Deprecated function names See Also Examples

Description

Takes an R structure and sets class to an ICD type. In the case of ICD-9 and ICD-10 codes, if a particular sub-type is set, e.g. ICD-9-CM (icd9cm), then an ICD-9 class (icd9) is also set.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21

Arguments

x

object to set class icd9

...

arguments passed on to other functions

warn

single logical value, if TRUE will gives warning when converting between types. ICD-9 to ICD-10 will cause an error regardless.

Details

The as. function e.g. as.icd9, do checking and try to put multiple classes in a nice order. Calling the bare constructor, e.g. icd9 just prepends the new class and returns without any checks. The latter is much faster, but for most uses, as.icd9 and siblings would be better.

Some features make more sense as attributes. E.g. setting code type to short or decimal.

Using attributes instead of class is a better fit for the data. It simplifies S3 dispatch, and appears to be very fast to get or set using the built-in R functions.

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.

See Also

icd_long_data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
x = as.icd10("A1009")
attr(x, "icd_short_diag") <- TRUE
x
attributes(x) <- list(icd_short_diag = NULL)
x

y <- as.decimal_diag(as.icd10("A10.09"))
y
is.short_diag(y)

j <- as.short_diag(as.icd10(c("A11", "B2222")))
j[2] <- "C33"
stopifnot(is.short_diag(j))
stopifnot(is.icd10(j), is.icd10(j[1]), is.icd10(j[[1]]))
j[[1]] <- "D44001"
stopifnot(is.short_diag(j))
stopifnot(is.icd10(j), is.icd10(j[2]), is.icd10(j[[2]]))

icd documentation built on Nov. 19, 2018, 1:05 a.m.