ropensci-archive/cleanEHR

Partial ICNARC code conversion

Closed this issue · 1 comments

In some anonymised version, users will only receive a fraction of the ICNARC code (less than 5 digits). We should be able to map first digits to diagnosis category. E.g.
1.1.1 - > Upper airway or trachea

See
https://www.icnarc.org/Our-Audit/Audits/Cmp/Resources/Icm-Icnarc-Coding-Method

#' Label up ICNARC organ level code
#' @export
label.icnarc.dc2 <- function(dt, dc.2.col="dc.2") {
    # Add organ coding labels # as factor labels
    i <- data.table(
        llabel = c(
            "Respiratory",
            "Cardiovascular",
            "Gastrointestinal",
            "Neurological (including eyes)",
            "Poisoning",
            "Genito-urinary",
            "Endocrine, Metabolic, Thermoregulation and Poisoning",
            "Haematological/Immunological",
            "Musculoskeletal",
            "Dermatological",
            "Psychiatric",
            "Trauma" ),
        # Order is as per coding (there is no 5)
        dc.2 = c(1,2,3,4,6,7,8,9,10,11,12,13))
    dt[, (dc.2.col) := factor(get(dc.2.col), levels=i$dc.2, labels=i$llabel)]
}