1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 08:32:04 +02:00

(v1.5.0.9011) small dosage update

This commit is contained in:
2021-01-24 23:27:11 +01:00
parent 286eaa9699
commit 24eb4453db
29 changed files with 207 additions and 110 deletions

View File

@ -207,12 +207,12 @@ ab_selector <- function(ab_class, function_name) {
} else {
agents_formatted <- paste0("column '", font_bold(agents, collapse = NULL), "'")
agents_names <- ab_name(names(agents), tolower = TRUE, language = NULL)
need_name <- tolower(agents) != tolower(agents_names)
need_name <- tolower(gsub("[^a-zA-Z]", "", agents)) != tolower(gsub("[^a-zA-Z]", "", agents_names))
agents_formatted[need_name] <- paste0(agents_formatted[need_name],
" (", agents_names[need_name], ")")
message_("Selecting ", ab_group, ": ", paste(agents_formatted, collapse = ", "),
as_note = FALSE,
extra_indent = nchar(paste0("Selecting ", ab_group, ": ")))
extra_indent = 4)
}
remember_thrown_message(function_name)
}

View File

@ -29,7 +29,7 @@
#' @inheritSection lifecycle Stable Lifecycle
#' @param x vector of dates (class `Date` or `POSIXt`)
#' @param episode_days required episode length in days, can also be less than a day, see *Details*
#' @param ... arguments passed on to [as.POSIXct()]
#' @param ... currently not used
#' @details
#' Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least `episode_days` days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least `episode_days` days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
#'
@ -106,8 +106,6 @@
get_episode <- function(x, episode_days, ...) {
meet_criteria(x, allow_class = c("Date", "POSIXt"))
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
stop_if(inherits(x, "Date") & episode_days < 1,
"argument `episode_days` must be at least 1 (day) when `x` is not a date-time object")
exec_episode(type = "sequential",
x = x,
@ -120,8 +118,6 @@ get_episode <- function(x, episode_days, ...) {
is_new_episode <- function(x, episode_days, ...) {
meet_criteria(x, allow_class = c("Date", "POSIXt"))
meet_criteria(episode_days, allow_class = c("numeric", "integer"), has_length = 1, is_positive = TRUE, is_finite = TRUE)
stop_if(inherits(x, "Date") & episode_days < 1,
"argument `episode_days` must be at least 1 (day) when `x` is not a date-time object")
exec_episode(type = "logical",
x = x,
@ -130,7 +126,7 @@ is_new_episode <- function(x, episode_days, ...) {
}
exec_episode <- function(type, x, episode_days, ...) {
x <- as.double(as.POSIXct(x, ...)) # as.POSIXct() for Date classes
x <- as.double(as.POSIXct(x)) # as.POSIXct() for Date classes
# since x is now in seconds, get seconds from episode_days as well
episode_seconds <- episode_days * 60 * 60 * 24

View File

@ -1196,7 +1196,7 @@ eucast_dosage <- function(ab, administration = "iv", version_breakpoints = 11.0)
ab <- as.ab(ab)
df <- AMR::dosage[which(AMR::dosage$ab %in% ab & AMR::dosage$administration %in% administration), , drop = FALSE]
df <- df[match(ab, df$ab), colnames(df)[colnames(df) != "administration"], drop = FALSE]
df <- df[which(df$ab == ab), colnames(df)[colnames(df) != "administration"], drop = FALSE]
rownames(df) <- NULL
df$ab <- ab
df