diff --git a/R/checkers.R b/R/checkers.R index adfea514..d36629ee 100644 --- a/R/checkers.R +++ b/R/checkers.R @@ -289,10 +289,10 @@ )) } if (!rlang::is_lgl_na(onset_to_death_eval)) { - if (rlang::is_lgl_na(hosp_death_risk)) { + if (rlang::is_lgl_na(hosp_death_risk) && !rlang::is_lgl_na(hosp_risk)) { msg <- c(msg, paste( - "hosp_death_risk is set to NA but onset_to_death is specified \n", - "set hosp_death_risk to numeric value" + "hosp_death_risk is set to NA but hosp_risk and onset_to_death is", + "specified \n set hosp_death_risk to numeric value" )) } if (rlang::is_lgl_na(non_hosp_death_risk)) { diff --git a/tests/testthat/test-sim_linelist.R b/tests/testthat/test-sim_linelist.R index ebc3394b..11015c89 100644 --- a/tests/testthat/test-sim_linelist.R +++ b/tests/testthat/test-sim_linelist.R @@ -332,7 +332,7 @@ test_that("sim_linelist fails when onset-to-event are given by risk is NA", { onset_to_death = onset_to_death, hosp_death_risk = NA ), - regexp = "(hosp_death_risk is set to NA but onset_to_death is specified)" + regexp = "(hosp_death_risk is set to NA but hosp_risk and onset_to_death)" ) expect_error( sim_linelist(