getPatientGroupings: Group patients by risk factors

Description Usage Arguments Value Examples

View source: R/hospCodesFns.R

Description

Use a combination of fields identified through partial word-matching and fields explicitly identified by subject matter experts and look-up table sources.

Usage

1
getPatientGroupings(inf.data, mix.data)

Arguments

inf.data

data.frame of infected patient data.

mix.data

data.frame of non-infected patient data.

Value

data.frame of logical indicators whether a patient belongs to a risk group.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (inf.data, mix.data) 
{
    SMEcodes <- read.csv(".\Reference_tables\explicitSMEcodes.csv")
    codeColnames <- c("Code", "Group", "Description", "Scheme")
    SSI_OPCS_codes <- read.csv(".\Reference_tables\SSI_OPCS_codes.csv")
    colnames(SSI_OPCS_codes) <- codeColnames
    SSI_OPCS_codes$Code <- clean.ref(SSI_OPCS_codes$Code)
    opcode_cols.inf <- grep("hes_op([0-9]+)_(main)?code", names(inf.data))
    opcode_cols.mix <- grep("operativeprocedure", names(mix.data))
    inf.data <- clean.data(inf.data, opcode_cols.inf)
    mix.data <- clean.data(mix.data, opcode_cols.mix)
    surgFlags.inf <- facFlags(SSI_OPCS_codes, "OPCS", inf.data[, 
        opcode_cols.inf])
    surgFlags.mix <- facFlags(SSI_OPCS_codes, "OPCS", mix.data[, 
        opcode_cols.mix])
    SMEcodesFlags.inf <- facFlags(SMEcodes, "OPCS", inf.data[, 
        opcode_cols.inf])
    SMEcodesFlags.mix <- facFlags(SMEcodes, "OPCS", mix.data[, 
        opcode_cols.mix])
    diagcode_cols.mix <- seq(13, 51, by = 2)
    diagcode_cols.inf <- grep("hes_diag([0-9]+)_code", names(inf.data))
    inf.data <- clean.data(inf.data, diagcode_cols.inf)
    mix.data <- clean.data(mix.data, diagcode_cols.mix)
    SMEcodesFlags.inf <- SMEcodesFlags.inf | facFlags(SMEcodes, 
        "ICD10", inf.data[, diagcode_cols.inf])
    SMEcodesFlags.mix <- SMEcodesFlags.mix | facFlags(SMEcodes, 
        "ICD10", mix.data[, diagcode_cols.mix])
    ICDGroup.match <- read.table(".\Reference_tables\ICDGroup_match.txt")
    ICDgroupFlag.mix <- facFlags(ICDGroup.match, "ICD10", mix.data[, 
        diagcode_cols.mix])
    ICDgroupFlag.inf <- facFlags(ICDGroup.match, "ICD10", inf.data[, 
        diagcode_cols.inf])
    cathCodesgroupFlags.inf <- SMEcodesFlags.inf[, "invasive"]
    cathCodesgroupFlags.mix <- SMEcodesFlags.mix[, "invasive"]
    premCodesgroupFlags.inf <- SMEcodesFlags.inf[, "low birth"]
    premCodesgroupFlags.mix <- SMEcodesFlags.mix[, "low birth"]
    codesIndicators.inf <- data.frame(surg = surgFlags.inf, cong = SMEcodesFlags.inf[, 
        "congenital"], head = SMEcodesFlags.inf[, "head"], infection = SMEcodesFlags.inf[, 
        "infection"], cath = cathCodesgroupFlags.inf, prem = premCodesgroupFlags.inf, 
        mental = SMEcodesFlags.inf[, "mental"], other = SMEcodesFlags.inf[, 
            "other"], Tai = SMEcodesFlags.inf[, "Tai"], unknown = SMEcodesFlags.inf[, 
            "unknown"], cancer = ICDgroupFlag.inf[, "cancer"])
    codesIndicators.mix <- data.frame(surg = surgFlags.mix, cong = SMEcodesFlags.mix[, 
        "congenital"], head = SMEcodesFlags.mix[, "head"], infection = SMEcodesFlags.mix[, 
        "infection"], cath = cathCodesgroupFlags.mix, prem = premCodesgroupFlags.mix, 
        mental = SMEcodesFlags.mix[, "mental"], other = SMEcodesFlags.mix[, 
            "other"], Tai = SMEcodesFlags.mix[, "Tai"], unknown = SMEcodesFlags.mix[, 
            "unknown"], cancer = ICDgroupFlag.mix[, "cancer"])
    codesIndicators.inf <- cbind(codesIndicators.inf, highRisk = rowSums(codesIndicators.inf) > 
        0)
    codesIndicators.mix <- cbind(codesIndicators.mix, highRisk = rowSums(codesIndicators.mix) > 
        0)
    list(inf = codesIndicators.inf, mix = codesIndicators.mix)
  }

n8thangreen/HESmanip documentation built on March 21, 2020, 12:20 a.m.