mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 21:42:01 +02:00
(v2.1.1.9196) fix eucast, unit tests
This commit is contained in:
@ -304,12 +304,13 @@ eucast_rules <- function(x,
|
||||
"AMX",
|
||||
"CIP",
|
||||
"ERY",
|
||||
"FOX1",
|
||||
"FOX-S",
|
||||
"GEN",
|
||||
"MFX",
|
||||
"NAL",
|
||||
"NOR",
|
||||
"PEN",
|
||||
"NAL-S",
|
||||
"NOR-S",
|
||||
"OXA-S",
|
||||
"PEN-S",
|
||||
"PIP",
|
||||
"TCY",
|
||||
"TIC",
|
||||
@ -330,10 +331,6 @@ eucast_rules <- function(x,
|
||||
}
|
||||
cols_ab <- c(cols_ab, c(AMP = unname(cols_ab[names(cols_ab) == "AMX"])))
|
||||
}
|
||||
if (!"FOX" %in% names(cols_ab) && "FOX1" %in% names(cols_ab)) {
|
||||
# cefoxitin column is missing, but cefoxitin screening is available
|
||||
cols_ab <- c(cols_ab, c(FOX = unname(cols_ab[names(cols_ab) == "FOX1"])))
|
||||
}
|
||||
|
||||
# data preparation ----
|
||||
if (isTRUE(info) && NROW(x) > 10000) {
|
||||
@ -631,6 +628,24 @@ eucast_rules <- function(x,
|
||||
eucast_rules_df[which(eucast_rules_df$reference.rule %like% "ampc"), "to_value"] <- as.character(ampc_cephalosporin_resistance)
|
||||
}
|
||||
|
||||
# sometimes, the screenings are missing but the names are actually available
|
||||
# we only hints on remaining rows in `eucast_rules_df`
|
||||
screening_abx <- c("FOX", "BTL", "CLI", "NAL", "NOR", "OXA", "PEF", "PEN", "TCY")
|
||||
screening_abx <- screening_abx[screening_abx %in% unique(unlist(strsplit(EUCAST_RULES_DF$and_these_antibiotics[!is.na(EUCAST_RULES_DF$and_these_antibiotics)], ", *")))]
|
||||
for (ab in screening_abx) {
|
||||
ab_s <- paste0(ab, "-S")
|
||||
if (ab %in% names(cols_ab) && !ab_s %in% names(cols_ab)) {
|
||||
if (isTRUE(info)) {
|
||||
message_("Using column '", cols_ab[names(cols_ab) == ab],
|
||||
"' as ", ab_name(ab_s, language = NULL, tolower = TRUE),
|
||||
" since a column '", ab_s, "' is missing but required for the chosen rules",
|
||||
add_fn = font_red
|
||||
)
|
||||
}
|
||||
cols_ab <- c(cols_ab, setNames(unname(cols_ab[names(cols_ab) == ab]), ab_s))
|
||||
}
|
||||
}
|
||||
|
||||
## Go over all rules and apply them ----
|
||||
for (i in seq_len(nrow(eucast_rules_df))) {
|
||||
rule_previous <- eucast_rules_df[max(1, i - 1), "reference.rule", drop = TRUE]
|
||||
|
Reference in New Issue
Block a user