diff --git a/.Rbuildignore b/.Rbuildignore index 284a847..3c0feba 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,5 @@ Makefile .travis.yml appveyor.yml paper.md +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.gitignore b/.gitignore index bebd5cd..71c1977 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ vignettes/*.pdf # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 *.httr-oauth +.Rproj.user diff --git a/R/ccTable.R b/R/ccTable.R index 8fa20d8..f12dd51 100644 --- a/R/ccTable.R +++ b/R/ccTable.R @@ -452,9 +452,13 @@ getEpisodePeriod <- function (e, unit="hours") { # The failure of POSIX conversion indicates that this episode is either # anonymised or has a missing or incorrect value of discharge or admission # time. - if (is.na(tadm) || is.na(tdisc)) - period_length <- findMaxTime(e) - else { + if (is.na(tdisc)) { + period_length <- ceiling( + as.numeric( + difftime( + as.POSIXct.numeric(findMaxTime(e), origin = "1970-01-01 00:00:00"), tadm, units = unit) + )) + } else { if (any(is.null(tdisc), is.null(tadm))) period_length <- NULL else @@ -466,6 +470,8 @@ getEpisodePeriod <- function (e, unit="hours") { if (period_length == 0) period_length <- period_length + 1 } + + if (is.null(period_length)) warning("This episode does not have any time series data: ",