ropensci-archive / cleanEHR

:warning: ARCHIVED :warning: Essential tools and utility functions to facilitate the data processing pipeline, data cleaning and data analysing of clinical data from CC-HIC
GNU General Public License v3.0
54 stars 23 forks source link

Partial ICNARC code conversion #132

Closed sinanshi closed 7 years ago

sinanshi commented 7 years ago

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

docsteveharris commented 7 years ago
#' 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)]
}