mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 18:01:50 +02:00
(v0.7.1.9072) key_antibiotics() for foreign systems
This commit is contained in:
52
R/mo.R
52
R/mo.R
@ -432,13 +432,13 @@ exec_as.mo <- function(x,
|
||||
}
|
||||
x <- y
|
||||
|
||||
} else if (all(x %in% read_mo_history(uncertainty_level,
|
||||
force = force_mo_history)$x)) {
|
||||
# previously found code
|
||||
x <- microorganismsDT[data.table(mo = get_mo_history(x,
|
||||
uncertainty_level,
|
||||
force = force_mo_history)),
|
||||
on = "mo", ..property][[1]]
|
||||
# } else if (all(x %in% read_mo_history(uncertainty_level,
|
||||
# force = force_mo_history)$x)) {
|
||||
# # previously found code
|
||||
# x <- microorganismsDT[data.table(mo = get_mo_history(x,
|
||||
# uncertainty_level,
|
||||
# force = force_mo_history)),
|
||||
# on = "mo", ..property][[1]]
|
||||
|
||||
} else if (all(tolower(x) %in% microorganismsDT$fullname_lower)) {
|
||||
# we need special treatment for very prevalent full names, they are likely!
|
||||
@ -561,17 +561,17 @@ exec_as.mo <- function(x,
|
||||
|
||||
progress$tick()$print()
|
||||
|
||||
if (initial_search == TRUE) {
|
||||
found <- microorganismsDT[mo == get_mo_history(x_backup[i],
|
||||
uncertainty_level,
|
||||
force = force_mo_history),
|
||||
..property][[1]]
|
||||
# previously found result
|
||||
if (length(found) > 0) {
|
||||
x[i] <- found[1L]
|
||||
next
|
||||
}
|
||||
}
|
||||
# if (initial_search == TRUE) {
|
||||
# found <- microorganismsDT[mo == get_mo_history(x_backup[i],
|
||||
# uncertainty_level,
|
||||
# force = force_mo_history),
|
||||
# ..property][[1]]
|
||||
# # previously found result
|
||||
# if (length(found) > 0) {
|
||||
# x[i] <- found[1L]
|
||||
# next
|
||||
# }
|
||||
# }
|
||||
|
||||
found <- microorganismsDT[mo == toupper(x_backup[i]), ..property][[1]]
|
||||
# is a valid MO code
|
||||
@ -826,6 +826,7 @@ exec_as.mo <- function(x,
|
||||
if (initial_search == TRUE) {
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history)
|
||||
}
|
||||
next
|
||||
} else if (grepl("[sS]almonella [A-Z][a-z]+ ?.*", x_backup_without_spp[i], ignore.case = FALSE)) {
|
||||
# Salmonella with capital letter species like "Salmonella Goettingen" - they're all S. enterica
|
||||
x[i] <- microorganismsDT[mo == 'B_SLMNL_ENT', ..property][[1]][1L]
|
||||
@ -833,11 +834,11 @@ exec_as.mo <- function(x,
|
||||
set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history)
|
||||
}
|
||||
uncertainties <- rbind(uncertainties,
|
||||
data.frame(uncertainty_level = 1,
|
||||
input = x_backup_without_spp[i],
|
||||
result_mo = "B_SLMNL_ENT"))
|
||||
format_uncertainty_as_df(uncertainty_level = 1,
|
||||
input = x_backup_without_spp[i],
|
||||
result_mo = "B_SLMNL_ENT"))
|
||||
next
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
# trivial names known to the field:
|
||||
@ -1850,8 +1851,11 @@ mo_renamed <- function() {
|
||||
#' @export
|
||||
#' @noRd
|
||||
print.mo_renamed <- function(x, ...) {
|
||||
items <- getOption("mo_renamed")
|
||||
base::message(blue(paste("NOTE:", names(items), "was renamed", items, collapse = "\n"), collapse = "\n"))
|
||||
items <- x #getOption("mo_renamed")
|
||||
old <- names(x)
|
||||
new <- x
|
||||
|
||||
cat(blue(paste("NOTE:", italic(names(items)), "was renamed", italic(items), collapse = "\n"), collapse = "\n"))
|
||||
}
|
||||
|
||||
nr2char <- function(x) {
|
||||
|
Reference in New Issue
Block a user