icd (version 4.0.6)

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

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

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.

Functions

  • as.icd9: Use generic ICD-9 class for this data. Ideally, use the more specific icd9cm or other sub-classes (when available).

  • as.icd9cm: Use ICD-9-CM

  • as.icd9cm_pc: Indicate the data are ICD-9-CM procedure codes.

  • as.icd10: Use generic ICD-10 class for this data. If possible, use the more specific icd10who or icd10cm.

  • as.icd10cm: Use ICD-10-CM (USA) class for the given data

  • as.icd10cm_pc: Indicate the data are ICD-10-CM procedure codes.

  • as.icd10who: Use WHO ICD-10 class for the given data

  • as.icd10fr: Use ICD-10-FR (France) class for the given data

  • as.icd10be: Use ICD-10-BE (Belgium) class for the given 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.

See Also

Other ICD data types: as.comorbidity_map, wide_vs_long

Examples

Run this code
# NOT RUN {
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]]))
# }

Run the code above in your browser using DataLab