فهرست منبع

Update external insulin bolus

- add guardrail about max bolus if external insulin as Trio (3 x max bolus)

- change the label "apply" ➡️ "log"
Pierre L 11 ماه پیش
والد
کامیت
4d78df03dd

+ 13 - 0
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -129104,6 +129104,16 @@
         }
       }
     },
+    "Log external insulin bolus ${bolusQuantity} U" : {
+      "localizations" : {
+        "fr" : {
+          "stringUnit" : {
+            "state" : "translated",
+            "value" : "Enregistrer un bolus d’insuline externe ${bolusQuantity} U"
+          }
+        }
+      }
+    },
     "Log FPU" : {
       "localizations" : {
         "bg" : {
@@ -202852,6 +202862,9 @@
         }
       }
     },
+    "The external bolus cannot be larger than 3 x the pump setting max bolus (%@)." : {
+
+    },
     "The Fat and Protein Delay setting defines the time between when you log fat and protein and when the system starts delivering insulin for the Fat-Protein Unit Carb Equivalents (FPUs)." : {
       "localizations" : {
         "bg" : {

+ 13 - 6
Trio/Sources/Shortcuts/Bolus/BolusIntent.swift

@@ -39,16 +39,23 @@ import Swinject
     ) var confirmBeforeApplying: Bool
 
     static var parameterSummary: some ParameterSummary {
-        When(\.$confirmBeforeApplying, .equalTo, true, {
-            Summary("Applying \(\.$bolusQuantity) U") {
+        When(\.$externalInsulin, .equalTo, true, {
+            Summary("Log external insulin bolus \(\.$bolusQuantity) U") {
                 \.$externalInsulin
                 \.$confirmBeforeApplying
             }
         }, otherwise: {
-            Summary("Immediately applying \(\.$bolusQuantity) U") {
-                \.$externalInsulin
-                \.$confirmBeforeApplying
-            }
+            When(\.$confirmBeforeApplying, .equalTo, true, {
+                Summary("Applying \(\.$bolusQuantity) U") {
+                    \.$externalInsulin
+                    \.$confirmBeforeApplying
+                }
+            }, otherwise: {
+                Summary("Immediately applying \(\.$bolusQuantity) U") {
+                    \.$externalInsulin
+                    \.$confirmBeforeApplying
+                }
+            })
         })
     }
 

+ 11 - 11
Trio/Sources/Shortcuts/Bolus/BolusIntentRequest.swift

@@ -30,22 +30,22 @@ import Foundation
 
     func bolusExternal(_ bolusAmount: Double) async throws -> String {
         var bolusQuantity: Decimal = 0
-        if Decimal(bolusAmount) > settingsManager.pumpSettings.maxBolus {
+        var maxExternal: Decimal { settingsManager.pumpSettings.maxBolus * 3 }
+        if Decimal(bolusAmount) > maxExternal {
             return String(
                 localized:
-                "The bolus cannot be larger than the pump setting max bolus (\(settingsManager.pumpSettings.maxBolus.description))."
+                "The external bolus cannot be larger than 3 x the pump setting max bolus (\(settingsManager.pumpSettings.maxBolus.description))."
             )
         } else {
             bolusQuantity = apsManager.roundBolus(amount: Decimal(bolusAmount))
-        }
-
-        await pumpHistoryStorage.storeExternalInsulinEvent(amount: bolusQuantity, timestamp: Date())
-        // perform determine basal sync
-        try await apsManager.determineBasalSync()
+            await pumpHistoryStorage.storeExternalInsulinEvent(amount: bolusQuantity, timestamp: Date())
+            // perform determine basal sync
+            try await apsManager.determineBasalSync()
 
-        return String(
-            localized:
-            "A external bolus of \(bolusQuantity.formatted()) U of insulin was recorded."
-        )
+            return String(
+                localized:
+                "A external bolus of \(bolusQuantity.formatted()) U of insulin was recorded."
+            )
+        }
     }
 }