spellLength: Find actual start and end of a patients in-hospital spell

Usage Arguments Details Author(s) Examples

View source: R/splitFillCatFns.R

Usage

1
spellLength(adm, disch)

Arguments

adm

Admission dates for (subset of) patient records.

disch

Discharge dates for (subset of) patient record.

Details

Chains of linked discharge and admission dates are made to then determine what the overall first admission and last disscharge times are and then these are substituted in to all of the relevant records.

Author(s)

N Green

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
##---- 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 (adm, disch) 
{
    for (i in 1:length(adm)) {
        dupl <- adm[i] == disch
        disch[dupl] <- disch[i]
        if (any(dupl, na.rm = TRUE)) {
            adm[i] <- adm[dupl] <- min(adm[dupl], na.rm = TRUE)
        }
    }
    list(adm = adm, disch = disch)
  }

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