mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 20:41:58 +02:00
(v0.7.1.9063) septic_patients -> example_isolates
This commit is contained in:
@ -25,7 +25,7 @@ test_that("first isolates work", {
|
||||
# first isolates
|
||||
expect_equal(
|
||||
sum(
|
||||
first_isolate(x = septic_patients,
|
||||
first_isolate(x = example_isolates,
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -37,7 +37,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
|
||||
# let syntax determine these automatically:
|
||||
# col_date = "date",
|
||||
# col_patient_id = "patient_id",
|
||||
@ -51,7 +51,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% dplyr::as_tibble() %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% dplyr::as_tibble() %>% mutate(keyab = key_antibiotics(.)),
|
||||
# let syntax determine these automatically:
|
||||
# col_date = "date",
|
||||
# col_patient_id = "patient_id",
|
||||
@ -65,7 +65,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -79,7 +79,7 @@ test_that("first isolates work", {
|
||||
expect_equal(
|
||||
suppressWarnings(
|
||||
sum(
|
||||
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
|
||||
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -92,7 +92,7 @@ test_that("first isolates work", {
|
||||
# first non-ICU isolates
|
||||
expect_equal(
|
||||
sum(
|
||||
first_isolate(septic_patients,
|
||||
first_isolate(example_isolates,
|
||||
col_mo = "mo",
|
||||
col_date = "date",
|
||||
col_patient_id = "patient_id",
|
||||
@ -106,7 +106,7 @@ test_that("first isolates work", {
|
||||
random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE)
|
||||
expect_lt(
|
||||
sum(
|
||||
first_isolate(x = mutate(septic_patients,
|
||||
first_isolate(x = mutate(example_isolates,
|
||||
specimen = if_else(row_number() %in% random_rows,
|
||||
"Urine",
|
||||
"Other")),
|
||||
@ -121,7 +121,7 @@ test_that("first isolates work", {
|
||||
# same, but now exclude ICU
|
||||
expect_lt(
|
||||
sum(
|
||||
first_isolate(x = mutate(septic_patients,
|
||||
first_isolate(x = mutate(example_isolates,
|
||||
specimen = if_else(row_number() %in% random_rows,
|
||||
"Urine",
|
||||
"Other")),
|
||||
@ -137,7 +137,7 @@ test_that("first isolates work", {
|
||||
1501)
|
||||
|
||||
# "No isolates found"
|
||||
expect_message(septic_patients %>%
|
||||
expect_message(example_isolates %>%
|
||||
mutate(specimen = "test") %>%
|
||||
mutate(first = first_isolate(., "date", "patient_id",
|
||||
col_mo = "mo",
|
||||
@ -145,7 +145,7 @@ test_that("first isolates work", {
|
||||
filter_specimen = "something_unexisting")))
|
||||
|
||||
# printing of exclusion message
|
||||
expect_output(septic_patients %>%
|
||||
expect_output(example_isolates %>%
|
||||
first_isolate(col_date = "date",
|
||||
col_mo = "mo",
|
||||
col_patient_id = "patient_id",
|
||||
@ -154,29 +154,29 @@ test_that("first isolates work", {
|
||||
|
||||
# errors
|
||||
expect_error(first_isolate("date", "patient_id", col_mo = "mo"))
|
||||
expect_error(first_isolate(septic_patients,
|
||||
expect_error(first_isolate(example_isolates,
|
||||
col_date = "non-existing col",
|
||||
col_mo = "mo"))
|
||||
|
||||
# look for columns itself
|
||||
expect_message(first_isolate(septic_patients))
|
||||
expect_message(first_isolate(septic_patients %>%
|
||||
expect_message(first_isolate(example_isolates))
|
||||
expect_message(first_isolate(example_isolates %>%
|
||||
mutate(mo = as.character(mo)) %>%
|
||||
left_join_microorganisms()))
|
||||
|
||||
# if mo is not an mo class, result should be the same
|
||||
expect_identical(septic_patients %>%
|
||||
expect_identical(example_isolates %>%
|
||||
mutate(mo = as.character(mo)) %>%
|
||||
first_isolate(col_date = "date",
|
||||
col_mo = "mo",
|
||||
col_patient_id = "patient_id"),
|
||||
septic_patients %>%
|
||||
example_isolates %>%
|
||||
first_isolate(col_date = "date",
|
||||
col_mo = "mo",
|
||||
col_patient_id = "patient_id"))
|
||||
|
||||
# missing dates should be no problem
|
||||
df <- septic_patients
|
||||
df <- example_isolates
|
||||
df[1:100, "date"] <- NA
|
||||
expect_equal(
|
||||
sum(
|
||||
@ -189,19 +189,19 @@ test_that("first isolates work", {
|
||||
1322)
|
||||
|
||||
# unknown MOs
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
|
||||
mutate(first = first_isolate(., include_unknown = FALSE)) %>%
|
||||
.$first %>%
|
||||
sum(),
|
||||
1062)
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
|
||||
mutate(first = first_isolate(., include_unknown = TRUE)) %>%
|
||||
.$first %>%
|
||||
sum(),
|
||||
1529)
|
||||
expect_equal(septic_patients %>%
|
||||
expect_equal(example_isolates %>%
|
||||
mutate(mo = ifelse(mo == "B_ESCHR_COL", NA, mo)) %>%
|
||||
mutate(first = first_isolate(.)) %>%
|
||||
.$first %>%
|
||||
|
Reference in New Issue
Block a user