# Setup shared test data + sampling vectors. Sourced by run-harness.R.
library(data.table)

load('param.RData')

# map() is defined inside the function file, but examples build param2 before that
# is sourced into scope; define a local copy here for data prep.
.map <- function(x, from, to) to[match(x, table = from)]

param$DOSEINT <- .map(param$REGIMEN, from = c(2, 3), to = c(336, 504))

param2 <- param[!duplicated(param[c('NDOSE', 'REGIMEN')]), ]
param2$DOSEINT <- .map(param2$REGIMEN, from = c(2, 3), to = c(336, 504))
param2$INFTIME <- c(2, 2, 1, 1, 1, NA, 0.5, 0.5, 0.5)
param2$DU      <- c('mg', rep('mg/kg', 2), rep('mg', 4), rep('mg/kg', 2))
param2$DOSECMT <- c(1, 2, 2, 1, 1, 2, 2, 2, 1)
# Columns the examples reference but do not build explicitly:
param2$NUMDOSE <- 3

# param3: param2 plus a second dosing compartment / infusion for sec.* code paths
param3 <- param2
param3$SDOSECMT <- 2
param3$SINFTIME <- -2

# Sampling-time vectors
st.2w <- c(0.5, 1, 2, 4, 6, 8, 24, 48, 72, 168, 336)
st.3w <- c(0.5, 1, 2, 4, 6, 8, 24, 48, 72, 168, 336, 504)
st.4w <- c(0.5, 1, 2, 4, 6, 8, 24, 48, 72, 168, 336, 672)
st.8w <- c(st.4w, 1344)
st.qd  <- c(0.5, 1, 2, 4, 6, 8, 24)
st.q2d <- c(0.5, 1, 2, 4, 6, 8, 24, 48)
st.q4d <- c(0.5, 1, 2, 4, 6, 8, 24, 48, 72, 96)
