Skip to content

Fix pk.calc.ceoi() for intervals with more than one dose row (#695) - #734

Closed
PavanLomati wants to merge 1 commit into
humanpred:mainfrom
PavanLomati:fix/695-ceoi-multiple-dose-rows
Closed

PavanLomati wants to merge 1 commit into
humanpred:mainfrom
PavanLomati:fix/695-ceoi-multiple-dose-rows

Conversation

@PavanLomati

Copy link
Copy Markdown
Contributor

pk.calc.ceoi() assumed a scalar duration.dose, so an interval with two infusion rows stopped pk.nca() with "the condition has length > 1".

  • Add a time.dose argument so the end of infusion is located as max(time.dose + duration.dose) among doses with duration.dose > 0. Bolus rows (zero or missing duration) are ignored, and infusions separated by a gap use the end of the last infusion.
  • Return NA with an exclude reason instead of a bare NA when there is no infusion, or no non-missing concentration at the end of the infusion.
  • Error on a negative duration.dose instead of treating it as no infusion.
  • Match the sample time with a small tolerance so sums like 0.1 + 0.2 still find a sample at 0.3.
  • ceoi now reports requires_dose_time = TRUE, so update the check.intervals expectation.

Tests cover contiguous segments, a single infusion, a late-start infusion, bolus plus infusion, gaps, unsampled and missing end concentrations, invalid durations, and an end-to-end pk.nca() run.

…ed#695)

pk.calc.ceoi() assumed a scalar duration.dose, so an interval with two
infusion rows stopped pk.nca() with "the condition has length > 1".

- Add a time.dose argument so the end of infusion is located as
  max(time.dose + duration.dose) among doses with duration.dose > 0.
  Bolus rows (zero or missing duration) are ignored, and infusions
  separated by a gap use the end of the last infusion.
- Return NA with an exclude reason instead of a bare NA when there is no
  infusion, or no non-missing concentration at the end of the infusion.
- Error on a negative duration.dose instead of treating it as no
  infusion.
- Match the sample time with a small tolerance so sums like 0.1 + 0.2
  still find a sample at 0.3.
- ceoi now reports requires_dose_time = TRUE, so update the
  check.intervals expectation.

Tests cover contiguous segments, a single infusion, a late-start
infusion, bolus plus infusion, gaps, unsampled and missing end
concentrations, invalid durations, and an end-to-end pk.nca() run.
@billdenney

Copy link
Copy Markdown
Member

I think that multiple Ceoi measures within a period are not expected and would need to be handled as separate intervals.

But, a duration should be validated to be non-negative (zero or greater). Can you please add that validation in a different PR?

@billdenney billdenney closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants