Skip to content

Commit

Permalink
add t_inf to sc doses in new_regimen
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanBrooks33 committed Jun 3, 2024
1 parent 9dcb9a4 commit dde74ea
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions R/new_regimen.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ new_regimen <- function(
} else if (any(is.na(t_inf))) {
t_inf[is.na(t_inf)] <- 1
}
if(any(type == "sc") && (is.null(t_inf) || length(t_inf) == 0)) {
reg$t_inf = 1/60
} else if (any(is.na(t_inf))) {
t_inf[is.na(t_inf)] <- 1/60
}
}
if(ss) {
if(is.null(amt) || is.null(interval)) {
Expand Down Expand Up @@ -135,6 +140,12 @@ new_regimen <- function(
reg$t_inf[reg$type == "oral"] <- 0
reg$rate[reg$type == "oral"] <- 0
}
if(any(reg$type == "sc")) {
if(any(reg$t_inf == 0)) {
reg$t_inf[reg$t_inf == 0] <- 1/60
reg$rate[reg$t_inf == 0] <- 60
}
}
if(!is.null(cmt)) {
if(length(cmt) != length(reg$dose_times)) {
cmt <- rep(cmt[1], length(reg$dose_times))
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test_new_regimen.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@ test_that("new_regimen can take arbitrary values for `type`", {
test_that("do not creat regimens of `type` 'covariate'", {
expect_error(new_regimen(100, times = 0, type = "covariate"))
})

test_that("sc doses accept an infusion length argument'", {
reg1 <- new_regimen(
amt = 100,
times = c(0, 12, 24, 36, 48),
type = "sc",
t_inf = 30/60
)
expect_equal(reg1$t_inf, rep(0.5,5))
})

0 comments on commit dde74ea

Please sign in to comment.