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

Description Usage Arguments Details Functions 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
as.icd9(x)

as.icd9cm(x)

as.icd9cm_pc(x)

as.icd10(x)

as.icd10cm(x, short_code = NULL)

as.icd10cm_pc(x)

as.icd10who(x, short_code = NULL)

as.icd10fr(x, short_code = NULL)

as.icd10be(x, short_code = NULL)

Arguments

x

object to set class icd9

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.

Details

The as.* functions e.g. as.icd9, do checking and try to put multiple classes in a nice order. Calling the internal bare constructor, e.g. icd:::icd9 just prepends the new class and returns without any checks, which is much faster.

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

Functions

See Also

Other ICD data types: as.comorbidity_map(), wide_vs_long

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]]))

jackwasey/icd documentation built on Nov. 23, 2021, 9:56 a.m.