test_that("readmissions within 90 days is giving the right expected answer", {
readmissions_dt <- readRDS("testdata/plot_readmissions_timeseries/dt_readmission_test.rds")
# Specify correct results
correct_answers <- tibble::tibble(
x = as.Date(c("2019-01-01", "2019-02-01", "2019-03-01", "2019-04-01", "2019-06-01")),
y = as.numeric(c(33.3, 50, 50, 50, 50))
)
# Run four_hr_performance
result <- plot_readmissions_timeseries(
data = readmissions_dt,
startDate = as.POSIXct("2019-01-01 00:00:00", tz = "Europe/London"),
endDate = as.POSIXct("2019-12-31 00:00:00", tz = "Europe/London"),
readmissionBy = 90,
returnPlot = FALSE,
hospitalName = "Hospital_name"
)
result <- result %>%
dplyr::select(x, y) %>%
dplyr::slice(1:5) %>%
tibble::as_tibble()
result$y <- round(result$y, digits = 1)
# Test results are correct
expect_equal(result, correct_answers, tolerance = 0.1)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.