mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 11:51:59 +02:00
WHONET fix
This commit is contained in:
10
R/mo.R
10
R/mo.R
@ -122,6 +122,7 @@
|
||||
#' @importFrom dplyr %>% pull left_join
|
||||
#' @examples
|
||||
#' # These examples all return "B_STPHY_AUR", the ID of S. aureus:
|
||||
#' as.mo("sau") # WHONET code
|
||||
#' as.mo("stau")
|
||||
#' as.mo("STAU")
|
||||
#' as.mo("staaur")
|
||||
@ -598,6 +599,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
||||
}
|
||||
|
||||
# TRY OTHER SOURCES ----
|
||||
# WHONET and other common LIS codes
|
||||
if (toupper(x_backup[i]) %in% AMR::microorganisms.codes[, 1]) {
|
||||
mo_found <- AMR::microorganisms.codes[toupper(x_backup[i]) == AMR::microorganisms.codes[, 1], "mo"][1L]
|
||||
if (length(mo_found) > 0) {
|
||||
@ -606,6 +608,7 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
||||
}
|
||||
}
|
||||
if (!is.null(reference_df)) {
|
||||
# self-defined reference
|
||||
if (x_backup[i] %in% reference_df[, 1]) {
|
||||
ref_mo <- reference_df[reference_df[, 1] == x_backup[i], "mo"]
|
||||
if (ref_mo %in% microorganismsDT[, mo]) {
|
||||
@ -617,6 +620,13 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
|
||||
}
|
||||
}
|
||||
|
||||
# allow no codes less than 4 characters long, was already checked for WHONET above
|
||||
if (nchar(x_trimmed[i]) < 4) {
|
||||
x[i] <- microorganismsDT[mo == "UNKNOWN", ..property][[1]]
|
||||
failures <- c(failures, x_backup[i])
|
||||
next
|
||||
}
|
||||
|
||||
check_per_prevalence <- function(data_to_check,
|
||||
a.x_backup,
|
||||
b.x_trimmed,
|
||||
|
Reference in New Issue
Block a user