Browse Source

Remove manualBolusErrorString

Since Trio doesn't use manualBolusErrorString, we are removing it from
the determination to help simplify the dosing logic. This commit also
removes a unit test from low eventual glucose that we meant to remove
previously as we instead switch to unit tests vs going through
determineBasal.
Sam King 10 months ago
parent
commit
711b77b4fd

+ 0 - 8
Model/JSONImporter.swift

@@ -518,8 +518,6 @@ extension Determination: Codable {
         case isf = "ISF"
         case isf = "ISF"
         case current_target
         case current_target
         case tdd = "TDD"
         case tdd = "TDD"
-        case insulinForManualBolus
-        case manualBolusErrorString
         case minDelta
         case minDelta
         case expectedDelta
         case expectedDelta
         case minGuardBG
         case minGuardBG
@@ -553,7 +551,6 @@ extension Determination: Codable {
         isf = try container.decodeIfPresent(Decimal.self, forKey: .isf)
         isf = try container.decodeIfPresent(Decimal.self, forKey: .isf)
         current_target = try container.decodeIfPresent(Decimal.self, forKey: .current_target)
         current_target = try container.decodeIfPresent(Decimal.self, forKey: .current_target)
         tdd = try container.decodeIfPresent(Decimal.self, forKey: .tdd)
         tdd = try container.decodeIfPresent(Decimal.self, forKey: .tdd)
-        manualBolusErrorString = try container.decodeIfPresent(Decimal.self, forKey: .manualBolusErrorString)
         minDelta = try container.decodeIfPresent(Decimal.self, forKey: .minDelta)
         minDelta = try container.decodeIfPresent(Decimal.self, forKey: .minDelta)
         expectedDelta = try container.decodeIfPresent(Decimal.self, forKey: .expectedDelta)
         expectedDelta = try container.decodeIfPresent(Decimal.self, forKey: .expectedDelta)
         minGuardBG = try container.decodeIfPresent(Decimal.self, forKey: .minGuardBG)
         minGuardBG = try container.decodeIfPresent(Decimal.self, forKey: .minGuardBG)
@@ -594,7 +591,6 @@ extension Determination: Codable {
         try container.encodeIfPresent(isf, forKey: .isf)
         try container.encodeIfPresent(isf, forKey: .isf)
         try container.encodeIfPresent(current_target, forKey: .current_target)
         try container.encodeIfPresent(current_target, forKey: .current_target)
         try container.encodeIfPresent(tdd, forKey: .tdd)
         try container.encodeIfPresent(tdd, forKey: .tdd)
-        try container.encodeIfPresent(manualBolusErrorString, forKey: .manualBolusErrorString)
         try container.encodeIfPresent(minDelta, forKey: .minDelta)
         try container.encodeIfPresent(minDelta, forKey: .minDelta)
         try container.encodeIfPresent(expectedDelta, forKey: .expectedDelta)
         try container.encodeIfPresent(expectedDelta, forKey: .expectedDelta)
         try container.encodeIfPresent(minGuardBG, forKey: .minGuardBG)
         try container.encodeIfPresent(minGuardBG, forKey: .minGuardBG)
@@ -632,9 +628,6 @@ extension Determination: Codable {
         guard let isf = isf else {
         guard let isf = isf else {
             throw JSONImporterError.missingRequiredPropertyInDetermination("ISF")
             throw JSONImporterError.missingRequiredPropertyInDetermination("ISF")
         }
         }
-        guard let manualBolusErrorString = manualBolusErrorString else {
-            throw JSONImporterError.missingRequiredPropertyInDetermination("manualBolusErrorString")
-        }
         guard let cob = cob else {
         guard let cob = cob else {
             throw JSONImporterError.missingRequiredPropertyInDetermination("COB")
             throw JSONImporterError.missingRequiredPropertyInDetermination("COB")
         }
         }
@@ -685,7 +678,6 @@ extension Determination: Codable {
         newOrefDetermination.sensitivityRatio = decimalToNSDecimalNumber(sensitivityRatio)
         newOrefDetermination.sensitivityRatio = decimalToNSDecimalNumber(sensitivityRatio)
         newOrefDetermination.expectedDelta = decimalToNSDecimalNumber(expectedDelta)
         newOrefDetermination.expectedDelta = decimalToNSDecimalNumber(expectedDelta)
         newOrefDetermination.cob = Int16(Int(cob ?? 0))
         newOrefDetermination.cob = Int16(Int(cob ?? 0))
-        newOrefDetermination.manualBolusErrorString = decimalToNSDecimalNumber(manualBolusErrorString)
         newOrefDetermination.smbToDeliver = units.map { NSDecimalNumber(decimal: $0) }
         newOrefDetermination.smbToDeliver = units.map { NSDecimalNumber(decimal: $0) }
         newOrefDetermination.carbsRequired = Int16(Int(carbsReq ?? 0))
         newOrefDetermination.carbsRequired = Int16(Int(carbsReq ?? 0))
         newOrefDetermination.isUploadedToNS = true
         newOrefDetermination.isUploadedToNS = true

+ 0 - 4
Trio.xcodeproj/project.pbxproj

@@ -663,7 +663,6 @@
 		DD30BA162E0780A500DA677C /* AdjustedGlucoseTargets.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD30BA152E0780A500DA677C /* AdjustedGlucoseTargets.swift */; };
 		DD30BA162E0780A500DA677C /* AdjustedGlucoseTargets.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD30BA152E0780A500DA677C /* AdjustedGlucoseTargets.swift */; };
 		DD30BA182E078F8900DA677C /* ComputedInsulinSensitivities+Getter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD30BA172E078F8100DA677C /* ComputedInsulinSensitivities+Getter.swift */; };
 		DD30BA182E078F8900DA677C /* ComputedInsulinSensitivities+Getter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD30BA172E078F8100DA677C /* ComputedInsulinSensitivities+Getter.swift */; };
 		DD30BA1A2E08AB9F00DA677C /* CarbImpactParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD30BA192E08AB9F00DA677C /* CarbImpactParams.swift */; };
 		DD30BA1A2E08AB9F00DA677C /* CarbImpactParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD30BA192E08AB9F00DA677C /* CarbImpactParams.swift */; };
-		DD30BA1C2E08BA8800DA677C /* DetermineBasal+Dosing.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD30BA1B2E08BA8100DA677C /* DetermineBasal+Dosing.swift */; };
 		DD32CF982CC82463003686D6 /* TrioRemoteControl+Bolus.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD32CF972CC82460003686D6 /* TrioRemoteControl+Bolus.swift */; };
 		DD32CF982CC82463003686D6 /* TrioRemoteControl+Bolus.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD32CF972CC82460003686D6 /* TrioRemoteControl+Bolus.swift */; };
 		DD32CF9A2CC8247B003686D6 /* TrioRemoteControl+Meal.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD32CF992CC8246F003686D6 /* TrioRemoteControl+Meal.swift */; };
 		DD32CF9A2CC8247B003686D6 /* TrioRemoteControl+Meal.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD32CF992CC8246F003686D6 /* TrioRemoteControl+Meal.swift */; };
 		DD32CF9C2CC82499003686D6 /* TrioRemoteControl+TempTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD32CF9B2CC82495003686D6 /* TrioRemoteControl+TempTarget.swift */; };
 		DD32CF9C2CC82499003686D6 /* TrioRemoteControl+TempTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD32CF9B2CC82495003686D6 /* TrioRemoteControl+TempTarget.swift */; };
@@ -1598,7 +1597,6 @@
 		DD30BA152E0780A500DA677C /* AdjustedGlucoseTargets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdjustedGlucoseTargets.swift; sourceTree = "<group>"; };
 		DD30BA152E0780A500DA677C /* AdjustedGlucoseTargets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdjustedGlucoseTargets.swift; sourceTree = "<group>"; };
 		DD30BA172E078F8100DA677C /* ComputedInsulinSensitivities+Getter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ComputedInsulinSensitivities+Getter.swift"; sourceTree = "<group>"; };
 		DD30BA172E078F8100DA677C /* ComputedInsulinSensitivities+Getter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ComputedInsulinSensitivities+Getter.swift"; sourceTree = "<group>"; };
 		DD30BA192E08AB9F00DA677C /* CarbImpactParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbImpactParams.swift; sourceTree = "<group>"; };
 		DD30BA192E08AB9F00DA677C /* CarbImpactParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarbImpactParams.swift; sourceTree = "<group>"; };
-		DD30BA1B2E08BA8100DA677C /* DetermineBasal+Dosing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DetermineBasal+Dosing.swift"; sourceTree = "<group>"; };
 		DD32CF972CC82460003686D6 /* TrioRemoteControl+Bolus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrioRemoteControl+Bolus.swift"; sourceTree = "<group>"; };
 		DD32CF972CC82460003686D6 /* TrioRemoteControl+Bolus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrioRemoteControl+Bolus.swift"; sourceTree = "<group>"; };
 		DD32CF992CC8246F003686D6 /* TrioRemoteControl+Meal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrioRemoteControl+Meal.swift"; sourceTree = "<group>"; };
 		DD32CF992CC8246F003686D6 /* TrioRemoteControl+Meal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrioRemoteControl+Meal.swift"; sourceTree = "<group>"; };
 		DD32CF9B2CC82495003686D6 /* TrioRemoteControl+TempTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrioRemoteControl+TempTarget.swift"; sourceTree = "<group>"; };
 		DD32CF9B2CC82495003686D6 /* TrioRemoteControl+TempTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrioRemoteControl+TempTarget.swift"; sourceTree = "<group>"; };
@@ -3765,7 +3763,6 @@
 			isa = PBXGroup;
 			isa = PBXGroup;
 			children = (
 			children = (
 				DD30BA072E076CAA00DA677C /* DeterminationError.swift */,
 				DD30BA072E076CAA00DA677C /* DeterminationError.swift */,
-				DD30BA1B2E08BA8100DA677C /* DetermineBasal+Dosing.swift */,
 				DD30BA052E07667000DA677C /* DetermineBasal+Helpers.swift */,
 				DD30BA052E07667000DA677C /* DetermineBasal+Helpers.swift */,
 				DD30B9C62E06257300DA677C /* DetermineBasalGenerator.swift */,
 				DD30B9C62E06257300DA677C /* DetermineBasalGenerator.swift */,
 				3BAE876D2E47F12900FCA8D2 /* DosingEngine.swift */,
 				3BAE876D2E47F12900FCA8D2 /* DosingEngine.swift */,
@@ -5107,7 +5104,6 @@
 				583684062BD178DB00070A60 /* GlucoseStored+helper.swift in Sources */,
 				583684062BD178DB00070A60 /* GlucoseStored+helper.swift in Sources */,
 				49B9B57F2D5768D2009C6B59 /* AdjustmentStored+Helper.swift in Sources */,
 				49B9B57F2D5768D2009C6B59 /* AdjustmentStored+Helper.swift in Sources */,
 				F90692D6274B9A450037068D /* HealthKitStateModel.swift in Sources */,
 				F90692D6274B9A450037068D /* HealthKitStateModel.swift in Sources */,
-				DD30BA1C2E08BA8800DA677C /* DetermineBasal+Dosing.swift in Sources */,
 				BD1661312B82ADAB00256551 /* CustomProgressView.swift in Sources */,
 				BD1661312B82ADAB00256551 /* CustomProgressView.swift in Sources */,
 				C967DACD3B1E638F8B43BE06 /* ManualTempBasalStateModel.swift in Sources */,
 				C967DACD3B1E638F8B43BE06 /* ManualTempBasalStateModel.swift in Sources */,
 				38E4453B274E411700EC9A94 /* Disk+VolumeInformation.swift in Sources */,
 				38E4453B274E411700EC9A94 /* Disk+VolumeInformation.swift in Sources */,

+ 0 - 1
Trio/Sources/APS/OpenAPS/OpenAPS.swift

@@ -54,7 +54,6 @@ final class OpenAPS {
             newOrefDetermination.sensitivityRatio = self.decimalToNSDecimalNumber(determination.sensitivityRatio)
             newOrefDetermination.sensitivityRatio = self.decimalToNSDecimalNumber(determination.sensitivityRatio)
             newOrefDetermination.expectedDelta = self.decimalToNSDecimalNumber(determination.expectedDelta)
             newOrefDetermination.expectedDelta = self.decimalToNSDecimalNumber(determination.expectedDelta)
             newOrefDetermination.cob = Int16(Int(determination.cob ?? 0))
             newOrefDetermination.cob = Int16(Int(determination.cob ?? 0))
-            newOrefDetermination.manualBolusErrorString = self.decimalToNSDecimalNumber(determination.manualBolusErrorString)
             newOrefDetermination.smbToDeliver = determination.units.map { NSDecimalNumber(decimal: $0) }
             newOrefDetermination.smbToDeliver = determination.units.map { NSDecimalNumber(decimal: $0) }
             newOrefDetermination.carbsRequired = Int16(Int(determination.carbsReq ?? 0))
             newOrefDetermination.carbsRequired = Int16(Int(determination.carbsReq ?? 0))
             newOrefDetermination.isUploadedToNS = false
             newOrefDetermination.isUploadedToNS = false

+ 0 - 31
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DetermineBasal+Dosing.swift

@@ -1,31 +0,0 @@
-import Foundation
-
-extension DeterminationGenerator {
-    struct DosingMetrics {
-        var rate: Decimal?
-        var duration: Decimal?
-        var units: Decimal? // microbolus
-        var insulinReq: Decimal?
-        var carbsReq: Decimal?
-        var reason: String
-        var manualBolusErrorString: Int?
-        var insulinForManualBolus: Decimal?
-        var minGuardBG: Decimal?
-        var minPredBG: Decimal?
-        var smbEnabled: Bool
-    }
-
-    static func determineDosing(
-        profile _: Profile,
-        currentTemp _: TempBasal,
-        iobData _: IobResult,
-        mealData _: ComputedCarbs,
-        autosensData _: Autosens,
-        forecastResult _: ForecastResult,
-        glucoseStatus _: GlucoseStatus,
-        enableSMB _: Bool,
-        currentTime _: Date
-    ) -> DosingMetrics? {
-        nil
-    }
-}

+ 0 - 5
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DetermineBasalGenerator.swift

@@ -109,7 +109,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                manualBolusErrorString: nil,
                 minDelta: nil,
                 minDelta: nil,
                 expectedDelta: nil,
                 expectedDelta: nil,
                 minGuardBG: nil,
                 minGuardBG: nil,
@@ -326,7 +325,6 @@ enum DeterminationGenerator {
             timestamp: currentTime,
             timestamp: currentTime,
             tdd: nil,
             tdd: nil,
             current_target: nil,
             current_target: nil,
-            manualBolusErrorString: smbDecision.manualBolusError.map { Decimal($0) },
             minDelta: nil,
             minDelta: nil,
             expectedDelta: expectedDelta,
             expectedDelta: expectedDelta,
             minGuardBG: smbDecision.minGuardGlucose ?? forecastResult.minGuardGlucose,
             minGuardBG: smbDecision.minGuardGlucose ?? forecastResult.minGuardGlucose,
@@ -510,7 +508,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                manualBolusErrorString: nil,
                 minDelta: minDelta,
                 minDelta: minDelta,
                 expectedDelta: nil,
                 expectedDelta: nil,
                 minGuardBG: nil,
                 minGuardBG: nil,
@@ -543,7 +540,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                manualBolusErrorString: nil,
                 minDelta: minDelta,
                 minDelta: minDelta,
                 expectedDelta: nil,
                 expectedDelta: nil,
                 minGuardBG: nil,
                 minGuardBG: nil,
@@ -576,7 +572,6 @@ enum DeterminationGenerator {
                 timestamp: currentTime,
                 timestamp: currentTime,
                 tdd: nil,
                 tdd: nil,
                 current_target: profile.targetBg,
                 current_target: profile.targetBg,
-                manualBolusErrorString: nil,
                 minDelta: minDelta,
                 minDelta: minDelta,
                 expectedDelta: nil,
                 expectedDelta: nil,
                 minGuardBG: nil,
                 minGuardBG: nil,

+ 0 - 5
Trio/Sources/APS/OpenAPSSwift/DetermineBasal/DosingEngine.swift

@@ -9,7 +9,6 @@ enum DosingEngine {
     /// struct to keep the relevant state needed for the output of the SMB decision logic
     /// struct to keep the relevant state needed for the output of the SMB decision logic
     struct SMBDecision {
     struct SMBDecision {
         let isEnabled: Bool
         let isEnabled: Bool
-        let manualBolusError: Int?
         let minGuardGlucose: Decimal?
         let minGuardGlucose: Decimal?
         let reason: String?
         let reason: String?
     }
     }
@@ -129,11 +128,9 @@ enum DosingEngine {
         // function in JS but we should keep all of the smb enabling logic
         // function in JS but we should keep all of the smb enabling logic
         // in one place. Note: We can't shortcut the return value because
         // in one place. Note: We can't shortcut the return value because
         // the determineBasal logic always evaluates this logic
         // the determineBasal logic always evaluates this logic
-        var manualBolusError: Int?
         var minGuardGlucoseDecision: Decimal?
         var minGuardGlucoseDecision: Decimal?
         var reason: String?
         var reason: String?
         if smbIsEnabled, minGuardGlucose < threshold {
         if smbIsEnabled, minGuardGlucose < threshold {
-            manualBolusError = 1
             minGuardGlucoseDecision = minGuardGlucose
             minGuardGlucoseDecision = minGuardGlucose
             smbIsEnabled = false
             smbIsEnabled = false
         }
         }
@@ -147,7 +144,6 @@ enum DosingEngine {
 
 
         return SMBDecision(
         return SMBDecision(
             isEnabled: smbIsEnabled,
             isEnabled: smbIsEnabled,
-            manualBolusError: manualBolusError,
             minGuardGlucose: minGuardGlucoseDecision,
             minGuardGlucose: minGuardGlucoseDecision,
             reason: reason
             reason: reason
         )
         )
@@ -313,7 +309,6 @@ enum DosingEngine {
 
 
             let glucoseUndershoot = targetGlucose - minGuardGlucose
             let glucoseUndershoot = targetGlucose - minGuardGlucose
             if minGuardGlucose < threshold {
             if minGuardGlucose < threshold {
-                newDetermination.manualBolusErrorString = 2
                 newDetermination.minGuardBG = minGuardGlucose
                 newDetermination.minGuardBG = minGuardGlucose
             }
             }
 
 

+ 3 - 2
Trio/Sources/APS/OpenAPSSwift/Logging/OrefFunction.swift

@@ -57,11 +57,12 @@ enum OrefFunction: String, Codable {
                 "ISF",
                 "ISF",
                 "current_target",
                 "current_target",
                 "TDD",
                 "TDD",
-                "insulinForManualBolus",
-                "manualBolusErrorString",
                 "minDelta",
                 "minDelta",
                 "received",
                 "received",
                 "reason",
                 "reason",
+                // intentionally removed from Swift, but in JS
+                "insulinForManualBolus",
+                "manualBolusErrorString",
                 // in JS but not in Swift
                 // in JS but not in Swift
                 "tick",
                 "tick",
                 "BGI",
                 "BGI",

+ 0 - 1
Trio/Sources/APS/Storage/DeterminationStorage.swift

@@ -183,7 +183,6 @@ final class BaseDeterminationStorage: DeterminationStorage, Injectable {
                         isf: self.decimal(from: orefDetermination.insulinSensitivity),
                         isf: self.decimal(from: orefDetermination.insulinSensitivity),
                         timestamp: orefDetermination.timestamp,
                         timestamp: orefDetermination.timestamp,
                         current_target: self.decimal(from: orefDetermination.currentTarget),
                         current_target: self.decimal(from: orefDetermination.currentTarget),
-                        manualBolusErrorString: self.decimal(from: orefDetermination.manualBolusErrorString),
                         minDelta: self.decimal(from: orefDetermination.minDelta),
                         minDelta: self.decimal(from: orefDetermination.minDelta),
                         expectedDelta: self.decimal(from: orefDetermination.expectedDelta),
                         expectedDelta: self.decimal(from: orefDetermination.expectedDelta),
                         minGuardBG: nil,
                         minGuardBG: nil,

+ 0 - 2
Trio/Sources/Models/Determination.swift

@@ -29,7 +29,6 @@ struct Determination: JSON, Equatable {
     var tdd: Decimal?
     var tdd: Decimal?
 
 
     var current_target: Decimal?
     var current_target: Decimal?
-    var manualBolusErrorString: Decimal?
     var minDelta: Decimal?
     var minDelta: Decimal?
     var expectedDelta: Decimal?
     var expectedDelta: Decimal?
     var minGuardBG: Decimal?
     var minGuardBG: Decimal?
@@ -69,7 +68,6 @@ extension Determination {
         case current_target
         case current_target
         case tdd = "TDD"
         case tdd = "TDD"
         case insulinForManualBolus
         case insulinForManualBolus
-        case manualBolusErrorString
         case minDelta
         case minDelta
         case expectedDelta
         case expectedDelta
         case minGuardBG
         case minGuardBG

+ 0 - 1
Trio/Sources/Modules/Treatments/TreatmentsStateModel.swift

@@ -875,7 +875,6 @@ extension Treatments.StateModel {
                     carbsReq: 0,
                     carbsReq: 0,
                     temp: nil,
                     temp: nil,
                     reservoir: 0,
                     reservoir: 0,
-                    manualBolusErrorString: 0,
                     carbRatio: 0,
                     carbRatio: 0,
                     received: false
                     received: false
                 )
                 )

+ 0 - 1
TrioTests/JSONImporterTests.swift

@@ -276,7 +276,6 @@ class BundleReference {}
         #expect(determination.reservoir == Decimal(string: "3735928559").map(NSDecimalNumber.init))
         #expect(determination.reservoir == Decimal(string: "3735928559").map(NSDecimalNumber.init))
         #expect(determination.insulinSensitivity == Decimal(string: "4.6").map(NSDecimalNumber.init))
         #expect(determination.insulinSensitivity == Decimal(string: "4.6").map(NSDecimalNumber.init))
         #expect(determination.currentTarget == Decimal(string: "94").map(NSDecimalNumber.init))
         #expect(determination.currentTarget == Decimal(string: "94").map(NSDecimalNumber.init))
-        #expect(determination.manualBolusErrorString == Decimal(string: "0").map(NSDecimalNumber.init))
         #expect(determination.minDelta == NSDecimalNumber(5))
         #expect(determination.minDelta == NSDecimalNumber(5))
         #expect(determination.expectedDelta == Decimal(string: "-5.9").map(NSDecimalNumber.init))
         #expect(determination.expectedDelta == Decimal(string: "-5.9").map(NSDecimalNumber.init))
         #expect(determination.threshold == Decimal(string: "3.7").map(NSDecimalNumber.init))
         #expect(determination.threshold == Decimal(string: "3.7").map(NSDecimalNumber.init))

+ 0 - 1
TrioTests/OpenAPSSwiftTests/DetermineBasalEnableSmbTests.swift

@@ -155,7 +155,6 @@ import Testing
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
             trioCustomOrefVariables: inputs.trioCustomOrefVariables, clock: inputs.clock
         )
         )
         #expect(decision.isEnabled == false)
         #expect(decision.isEnabled == false)
-        #expect(decision.manualBolusError == 1)
         #expect(decision.minGuardGlucose == 65)
         #expect(decision.minGuardGlucose == 65)
     }
     }
 
 

+ 1 - 153
TrioTests/OpenAPSSwiftTests/DetermineBasalLowEventualGlucoseTests.swift

@@ -2,161 +2,10 @@ import Foundation
 import Testing
 import Testing
 @testable import Trio
 @testable import Trio
 
 
-@Suite("DetermineBasal low eventual glucose") struct DetermineBasalLowEventualGlucoseTests {
-    // Helper to create a mock IOB array with linear decay for testing purposes
-    private func mockIobArray(iob: Decimal, activity: Decimal, currentTime: Date) -> [IobResult] {
-        (0 ..< 48).map { i in
-            IobResult(
-                iob: iob - (activity * Decimal(i)),
-                activity: activity,
-                basaliob: 0,
-                bolusiob: 0,
-                netbasalinsulin: 0,
-                bolusinsulin: 0,
-                time: currentTime,
-                iobWithZeroTemp: IobResult.IobWithZeroTemp(
-                    iob: 0, activity: 0, basaliob: 0, bolusiob: 0, netbasalinsulin: 0, bolusinsulin: 0, time: currentTime
-                ),
-                lastBolusTime: nil,
-                lastTemp: IobResult.LastTemp(
-                    rate: 0,
-                    timestamp: currentTime,
-                    started_at: currentTime,
-                    date: UInt64(currentTime.timeIntervalSince1970 * 1000),
-                    duration: 0
-                )
-            )
-        }
-    }
-
-    private func createDefaultInputs(currentTime: Date = Date()) -> (
-        profile: Profile,
-        preferences: Preferences,
-        currentTemp: TempBasal,
-        iobData: [IobResult],
-        mealData: ComputedCarbs,
-        autosensData: Autosens,
-        reservoirData: Decimal,
-        glucoseStatus: GlucoseStatus,
-        trioCustomOrefVariables: TrioCustomOrefVariables,
-        currentTime: Date
-    ) {
-        var profile = Profile()
-        profile.maxIob = 2.5
-        profile.dia = 3
-        profile.currentBasal = 1.0
-        profile.maxDailyBasal = 1.3
-        profile.maxBasal = 3.5
-        profile.maxBg = 120
-        profile.minBg = 100
-        profile.sens = 50
-        profile.carbRatio = 10
-        profile.thresholdSetting = 80
-        profile.temptargetSet = false
-        profile.bolusIncrement = 0.1
-        profile.useCustomPeakTime = false
-        profile.curve = .rapidActing
-        profile.enableUAM = false // Important for these tests
-
-        var preferences = Preferences()
-        preferences.useNewFormula = false
-        preferences.sigmoid = false
-        preferences.adjustmentFactor = 0.8
-        preferences.adjustmentFactorSigmoid = 0.5
-        preferences.curve = .rapidActing
-        preferences.useCustomPeakTime = false
-
-        let currentTemp = TempBasal(duration: 0, rate: 0, temp: .absolute, timestamp: currentTime)
-        let iobData = mockIobArray(iob: 0, activity: 0, currentTime: currentTime)
-        let mealData = ComputedCarbs(
-            carbs: 0,
-            mealCOB: 0,
-            currentDeviation: 0,
-            maxDeviation: 0,
-            minDeviation: 0,
-            slopeFromMaxDeviation: 0,
-            slopeFromMinDeviation: 0,
-            allDeviations: [0, 0, 0, 0, 0],
-            lastCarbTime: 0
-        )
-        let autosensData = Autosens(ratio: 1.0, newisf: nil)
-        let glucoseStatus = GlucoseStatus(
-            delta: 0,
-            glucose: 115,
-            noise: 1,
-            shortAvgDelta: 0,
-            longAvgDelta: 0.1,
-            date: currentTime,
-            lastCalIndex: nil,
-            device: "test"
-        )
-
-        let trioCustomOrefVariables = TrioCustomOrefVariables(
-            average_total_data: 0,
-            weightedAverage: 0,
-            currentTDD: 0,
-            past2hoursAverage: 0,
-            date: currentTime,
-            overridePercentage: 100,
-            useOverride: false,
-            duration: 0,
-            unlimited: false,
-            overrideTarget: 0,
-            smbIsOff: false,
-            advancedSettings: false,
-            isfAndCr: false,
-            isf: false,
-            cr: false,
-            smbIsScheduledOff: false,
-            start: 0,
-            end: 0,
-            smbMinutes: 30,
-            uamMinutes: 30,
-            shouldProtectDueToHIGH: false
-        )
-
-        return (
-            profile: profile,
-            preferences: preferences,
-            currentTemp: currentTemp,
-            iobData: iobData,
-            mealData: mealData,
-            autosensData: autosensData,
-            reservoirData: 100,
-            glucoseStatus: glucoseStatus,
-            trioCustomOrefVariables: trioCustomOrefVariables,
-            currentTime: currentTime
-        )
-    }
-
-    @Test("should set a low temp when eventual BG is low and rising") func lowTempRising() throws {
-        var (
-            profile, preferences, currentTemp, _, mealData, autosensData, reservoirData, _, trioCustomOrefVariables, currentTime
-        ) = createDefaultInputs()
-
-        profile.minBg = 100
-        let glucoseStatus = GlucoseStatus(
-            delta: 1, glucose: 90, noise: 1, shortAvgDelta: 1, longAvgDelta: 0.1, date: currentTime, lastCalIndex: nil,
-            device: "test"
-        )
-        let iobData = mockIobArray(iob: 0, activity: 0, currentTime: currentTime)
-
-        let result = try DeterminationGenerator.determineBasal(
-            profile: profile, preferences: preferences, currentTemp: currentTemp, iobData: iobData, mealData: mealData,
-            autosensData: autosensData, reservoirData: reservoirData, glucoseStatus: glucoseStatus,
-            trioCustomOrefVariables: trioCustomOrefVariables, currentTime: currentTime
-        )
-
-        #expect(result?.rate == 0.7)
-        #expect(result?.duration == 30)
-        #expect(result?.reason.contains("setting 0.7U/hr") == true)
-    }
-}
-
 /// these tests should be an exact copy of the JS tests here:
 /// these tests should be an exact copy of the JS tests here:
 /// - https://github.com/kingst/trio-oref/blob/dev-fixes-for-swift-comparison/tests/determine-basal-low-eventual-glucose.test.js
 /// - https://github.com/kingst/trio-oref/blob/dev-fixes-for-swift-comparison/tests/determine-basal-low-eventual-glucose.test.js
 /// We had to extract the key functionality from JS and put it in a function to facilitate testing
 /// We had to extract the key functionality from JS and put it in a function to facilitate testing
-@Suite("DosingEngine.handleLowEventualGlucose") struct HandleLowEventualGlucoseTests {
+@Suite("DetermineBasal low eventual glucose") struct HandleLowEventualGlucoseTests {
     private func defaultProfile() -> Profile {
     private func defaultProfile() -> Profile {
         var profile = Profile()
         var profile = Profile()
         profile.minBg = 100
         profile.minBg = 100
@@ -215,7 +64,6 @@ import Testing
             timestamp: nil,
             timestamp: nil,
             tdd: nil,
             tdd: nil,
             current_target: nil,
             current_target: nil,
-            manualBolusErrorString: nil,
             minDelta: nil,
             minDelta: nil,
             expectedDelta: nil,
             expectedDelta: nil,
             minGuardBG: nil,
             minGuardBG: nil,

+ 0 - 1
TrioTests/OpenAPSSwiftTests/SetTempBasalTests.swift

@@ -48,7 +48,6 @@ import Testing
             timestamp: Date(),
             timestamp: Date(),
             tdd: nil,
             tdd: nil,
             current_target: nil,
             current_target: nil,
-            manualBolusErrorString: nil,
             minDelta: nil,
             minDelta: nil,
             expectedDelta: nil,
             expectedDelta: nil,
             minGuardBG: nil,
             minGuardBG: nil,