From a64903188ecbb9df1be198dfe010cdd40eb86727 Mon Sep 17 00:00:00 2001 From: kenantang Date: Thu, 14 Nov 2024 10:52:19 -0500 Subject: [PATCH] Update target date --- Sources/LoopAlgorithm/Insulin/DoseMath.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/LoopAlgorithm/Insulin/DoseMath.swift b/Sources/LoopAlgorithm/Insulin/DoseMath.swift index b741aa9..abc1fb9 100644 --- a/Sources/LoopAlgorithm/Insulin/DoseMath.swift +++ b/Sources/LoopAlgorithm/Insulin/DoseMath.swift @@ -263,8 +263,9 @@ extension Array where Element: GlucoseValue { } // Choose either the minimum glucose or eventual glucose as the correction delta - let minGlucoseTargets = correctionRange.closestPrior(to: minGlucose.startDate)!.value - let eventualGlucoseTargets = correctionRange.closestPrior(to: eventualGlucose.startDate)!.value + // KT: Now the targets are taken from the current time point (date) + let minGlucoseTargets = correctionRange.closestPrior(to: date)!.value + let eventualGlucoseTargets = correctionRange.closestPrior(to: date)!.value // Treat the mininum glucose when both are below range if minGlucose.quantity < minGlucoseTargets.lowerBound &&