|
|
@@ -511,12 +511,13 @@ final class BaseHealthKitManager: HealthKitManager, Injectable {
|
|
|
|
|
|
// Calculate the insulin rate and adjusted delivered units
|
|
|
let predecessorEntryRate = predecessorEntry.tempBasal?.rate?.doubleValue ?? 0
|
|
|
- let adjustedDurationHours = adjustedDuration / 3600 // Precise duration in hours
|
|
|
- let adjustedDeliveredUnits = adjustedDurationHours * predecessorEntryRate
|
|
|
-
|
|
|
+
|
|
|
// Round the rate to a supported basal rate using pumpManager's rounding function
|
|
|
let roundedRate = deviceDataManager?.pumpManager?
|
|
|
.roundToSupportedBasalRate(unitsPerHour: predecessorEntryRate) ?? predecessorEntryRate
|
|
|
+
|
|
|
+ let adjustedDurationHours = adjustedDuration / 3600 // Precise duration in hours
|
|
|
+ let adjustedDeliveredUnits = adjustedDurationHours * roundedRate
|
|
|
|
|
|
// Recalculate the delivered units using the rounded rate
|
|
|
let adjustedDeliveredUnitsRounded = adjustedDurationHours * adjustedDeliveredUnits
|