# Dosing

Dosing can be added to any trial (see trial types) using the `doses`

argument. The following dosing types are currently supported.

## Dose types

`PumasQSP.Bolus`

— Type`Bolus(state, amount, t)`

A bolus dose, increasing the value of `state`

of the model by `amount`

. The dose takes places at time `t`

.

**Example**

`dose = Bolus(state = s1, amount = 0.5, t = 2.0)`

`PumasQSP.PeriodicBolus`

— Type`PeriodicBolus(state, amount, t_period, t_first = 0, initial_affect = !iszero(t_first))`

A periodic bolus dose, increasing the value of `state`

of the model by `amount`

with a period equal to `t_period`

. A delay until the first dose can be added using the `t_first`

argument.

`t_first`

defaults to zero, in which case only`t_period`

determines the dosing times.- If
`initial_affect = true`

, then`t_first`

is the time of the first dose and all doses

after it will follow the period `t_period`

. If `t_first`

is not zero, then `initial_affect`

will default to `true`

.

- If
`initial_affect = false`

, then the first dose will take place one period after`t_first`

so at time equal to `t_first + t_period`

. In this case `t_first`

works only as a time delay and does not represent the time of first dose.

**Example**

```
# Dose at t = 2.0, 4.0, 6.0, ...
dose = PeriodicBolus(state = s1, amount = 0.5, t_period = 2.0)
# Dose at t = 1.0, 3.0, 5.0, ...
dose = PeriodicBolus(state = s1, amount = 0.5, t_period = 2.0, t_first = 1.0)
# Dose at t = 3.0, 5.0, 7.0 ...
dose = PeriodicBolus(state = s1, amount = 0.5, t_period = 2.0, t_first = 1.0, initial_affect = false)
```

`PumasQSP.Infusion`

— Type`Infusion(state, rate, t, duration)`

An infusion increasing the rate of change of `state`

of the model by `rate`

. The dose takes places at time `t`

and lasts for a time equal to `duration`

.

**Example**

`dose = Infusion(state = s1, rate = 0.05, t = 2.0, duration = 5.0)`

`PumasQSP.PeriodicInfusion`

— Type`PeriodicInfusion(state, rate, t_period, duration, t_first = 0, initial_affect = !iszero(t_first))`

A periodic infusion increasing the rate of change of `state`

of the model by `rate`

for a time window equal to `duration`

, repeated every `t_period`

time units. The time period counts from the onset of the infusion, so `t_period > duration`

needs to hold for non-overlapping infusions. A delay until the first dose can be added using the `t_first`

argument.

`t_first`

defaults to zero, in which case only`t_period`

determines the onset of each infusion.- If
`initial_affect = true`

, then`t_first`

is the time of the first dose and all doses

after it will follow the period `t_period`

. If `t_first`

is not zero, then `initial_affect`

will default to `true`

.

- If
`initial_affect = false`

, then the first dose will take place one period after`t_first`

so at time equal to `t_first + t_period`

. In this case `t_first`

works only as a time delay and does not represent the time of first dose.

**Example**

```
# Infusions at t = [2.0, 4.0, 6.0, ...] lasting 0.5 each
doses = PeriodicInfusion(state = s1, rate = 0.1, t_period = 2.0, duration = 0.5)
# Infusions at t = [1.0, 3.0, 5.0, ...] lasting 0.5 each
doses = PeriodicInfusion(state = s1, rate = 0.1, t_period = 2.0, duration = 0.5, t_first = 1)
# Infusions at t = [3.0, 5.0, 7.0 ...] lasting 0.5 each
doses = PeriodicInfusion(state = s1, rate = 0.1, t_period = 2.0, duration = 0.5, t_first = 1, initial_affect = false)
```