From 31e58532ecb333280271b62cb75088996aa1d768 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Sat, 26 Mar 2022 14:40:11 -0500 Subject: [PATCH] Add bolusVolume to NS enacted struct --- NightscoutServiceKit/Extensions/StoredDosingDecision.swift | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/NightscoutServiceKit/Extensions/StoredDosingDecision.swift b/NightscoutServiceKit/Extensions/StoredDosingDecision.swift index 09e59fb..c1bf0c9 100644 --- a/NightscoutServiceKit/Extensions/StoredDosingDecision.swift +++ b/NightscoutServiceKit/Extensions/StoredDosingDecision.swift @@ -61,11 +61,10 @@ extension StoredDosingDecision { } var loopStatusEnacted: LoopEnacted? { - guard case .some(.tempBasal(let tempBasal)) = pumpManagerStatus?.basalDeliveryState else { + guard let automaticDoseRecommendation = automaticDoseRecommendation, errors.isEmpty, let tempBasal = automaticDoseRecommendation.basalAdjustment else { return nil } - let duration = tempBasal.endDate.timeIntervalSince(tempBasal.startDate) - return LoopEnacted(rate: tempBasal.unitsPerHour, duration: duration, timestamp: tempBasal.startDate, received: true) + return LoopEnacted(rate: tempBasal.unitsPerHour, duration: tempBasal.duration, timestamp: date, received: true, bolusVolume: automaticDoseRecommendation.bolusUnits ?? 0) } var loopStatusFailureReason: String? {