|
|
@@ -27,20 +27,36 @@ import Swinject
|
|
|
) var bolusQuantity: Double
|
|
|
|
|
|
@Parameter(
|
|
|
+ title: LocalizedStringResource("External Insulin"),
|
|
|
+ description: LocalizedStringResource("If toggled, Insulin will be added to IOB but it will not be delivered"),
|
|
|
+ default: false,
|
|
|
+ requestValueDialog: IntentDialog(stringLiteral: String(localized: "External Insulin?"))
|
|
|
+ ) var externalInsulin: Bool
|
|
|
+
|
|
|
+ @Parameter(
|
|
|
title: LocalizedStringResource("Confirm Before applying"),
|
|
|
description: LocalizedStringResource("If toggled, you will need to confirm before applying."),
|
|
|
default: true
|
|
|
) 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") {
|
|
|
- \.$confirmBeforeApplying
|
|
|
- }
|
|
|
+ When(\.$confirmBeforeApplying, .equalTo, true, {
|
|
|
+ Summary("Applying \(\.$bolusQuantity) U") {
|
|
|
+ \.$externalInsulin
|
|
|
+ \.$confirmBeforeApplying
|
|
|
+ }
|
|
|
+ }, otherwise: {
|
|
|
+ Summary("Immediately applying \(\.$bolusQuantity) U") {
|
|
|
+ \.$externalInsulin
|
|
|
+ \.$confirmBeforeApplying
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -55,18 +71,24 @@ import Swinject
|
|
|
dialog: IntentDialog(
|
|
|
stringLiteral: String(
|
|
|
localized:
|
|
|
- "Are you sure to bolus \(bolusFormatted) U of insulin?"
|
|
|
+ externalInsulin ? "Are you sure to log \(bolusFormatted) U of external insulin?" :
|
|
|
+ "Are you sure to bolus \(bolusFormatted) U of insulin?"
|
|
|
)
|
|
|
)
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
- let finalBolusDisplay = try await BolusIntentRequest().bolus(amount)
|
|
|
- return .result(
|
|
|
- dialog: IntentDialog(stringLiteral: finalBolusDisplay)
|
|
|
- )
|
|
|
-
|
|
|
+ if externalInsulin {
|
|
|
+ let finalExternalBolusDisplay = try await BolusIntentRequest().bolusExternal(amount)
|
|
|
+ return .result(
|
|
|
+ dialog: IntentDialog(stringLiteral: finalExternalBolusDisplay)
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ let finalBolusDisplay = try await BolusIntentRequest().bolus(amount)
|
|
|
+ return .result(
|
|
|
+ dialog: IntentDialog(stringLiteral: finalBolusDisplay)
|
|
|
+ )
|
|
|
+ }
|
|
|
} catch {
|
|
|
throw error
|
|
|
}
|