Skip to content

Commit

Permalink
updates to calibration assistant function
Browse files Browse the repository at this point in the history
- low both long and short-term stability are considered in an effort to detect when there is outliers/noise in the last 90 minutes (configurable) or situations that indicate that either carbs or insulin would have been used recently that could mean the BG is about the change
- variable/constants renamed for clarity
- alert logic changed. If the user is informed that their BG has been rising/falling, there is no need to inform that that their BG is also unstable
- in the long term instability message, the number of minutes are added so that the user understands that it's a historical issue, not just with current BG values.
  • Loading branch information
paulplant committed Feb 2, 2023
1 parent 3c56477 commit 89a26c9
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 50 deletions.
26 changes: 17 additions & 9 deletions xdrip/Constants/ConstantsCalibrationAssistant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,31 @@ import Foundation
/// constants used by the calibration assistant
enum ConstantsCalibrationAssistant {

/// the number of minutes of readings that we should use for the calibration assistant calculations
static let minutesToUseForCalculations: Double = 20
/// the number of minutes of readings that we should use for the long-term calibration assistant calculations
static let minutesToUseForLongTermCalculations: Double = 90

/// the number of minutes of readings that we should use for the short-term calibration assistant calculations
static let minutesToUseForShortTermCalculations: Double = 25

// Delta
/// the value over which we will consider that the delta change is significant to display as a concern to the user
static let deltaResultLimit: Double = 90
static let shortTermDeltaResultLimit: Double = 90

/// the weighting that will be applied to the delta change value to push the result up
static let deltaMultiplier: Double = 30
static let shortTermDeltaMultiplier: Double = 30


// Standard Deviation (long-term)
/// the value over which we will consider that the long-term variance value is significant to display as a concern to the user
static let longTermStdDeviationValueLimit: Double = 20


// Standard Deviation
/// the value over which we will consider that the variation in change is significant to display as a concern to the user
static let stdDeviationResultLimit: Double = 60
// Standard Deviation (short-term)
/// the value over which we will consider that the short-term variance result is significant to display as a concern to the user
static let shortTermStdDeviationResultLimit: Double = 60

/// the weighting that will be applied to the standard deviation value to push the result up
static let stdDeviationMultiplier: Double = 50
/// the weighting that will be applied to the short-term standard deviation value to push the result up
static let shortTermStdDeviationMultiplier: Double = 50


// Very high BG levels
Expand Down
3 changes: 2 additions & 1 deletion xdrip/Storyboards/en.lproj/CalibrationRequest.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"doNotCalibrate" = "You should not calibrate now. Wait for a better time";
"bgValuesRising" = "BG values have been rising";
"bgValuesDropping" = "BG values have been dropping";
"bgValuesNotStable" = "BG values are not stable enough";
"bgValuesNotStableShortTerm" = "BG is not currently stable";
"bgValuesNotStableLongTerm" = "BG values have been unstable over the last %@ minutes";
"bgValueTooHigh" = "Current BG value is too high";
"bgValuesSlightlyHigh" = "Current BG value is slightly high";
"bgValueTooLow" = "Current BG value is too low";
Expand Down
11 changes: 6 additions & 5 deletions xdrip/Storyboards/es.lproj/CalibrationRequest.strings
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"doNotCalibrate" = "No se debe calibrar ahora mismo";
"bgValuesRising" = "Los valores de glucosa han estado subiendo";
"bgValuesDropping" = "Los valores de glucosa han estado bajando";
"bgValuesNotStable" = "Los valores de glucosa son poco estables";
"bgValueTooHigh" = "La glucosa actual es demasiado alto";
"bgValuesSlightlyHigh" = "La glucosa actual es ligeramente alto";
"bgValueTooLow" = "La glucosa actual es demasiado bajo";
"bgValuesSlightlyLow" = "La glucosa actual es ligeramente bajo";
"bgValuesNotStableShortTerm" = "Los valores de glucosa son poco estables";
"bgValuesNotStableLongTerm" = "Los valores de glucosa no han sido suficientes estables durante los últimos %@ minutos";
"bgValueTooHigh" = "El valor de glucosa actual es demasiado alto";
"bgValuesSlightlyHigh" = "El valor de glucosa actual es ligeramente alto";
"bgValueTooLow" = "El valor de glucosa actual es demasiado bajo";
"bgValuesSlightlyLow" = "El valor de glucosa actual es ligeramente bajo";
8 changes: 6 additions & 2 deletions xdrip/Texts/TextsCalibration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ enum Texts_Calibrations {
return NSLocalizedString("bgValuesDropping", tableName: filename, bundle: Bundle.main, value: "BG values have been dropping", comment: "a message to inform that the BG values have been dropping too much to calibrate")
}()

static let bgValuesNotStable:String = {
return NSLocalizedString("bgValuesNotStable", tableName: filename, bundle: Bundle.main, value: "BG values are not stable enough", comment: "a message to inform that the BG values are not stable enough to calibrate")
static let bgValuesNotStableShortTerm:String = {
return NSLocalizedString("bgValuesNotStableShortTerm", tableName: filename, bundle: Bundle.main, value: "BG is not currently stable", comment: "a message to inform that the BG values are not stable enough to calibrate")
}()

static let bgValuesNotStableLongTerm:String = {
return String(format: NSLocalizedString("bgValuesNotStableLongTerm", tableName: filename, bundle: Bundle.main, value: "BG values have been unstable over the last %@ minutes", comment: "a message to inform that the historical BG values are not stable enough to consider calibrating"), Int(ConstantsCalibrationAssistant.minutesToUseForLongTermCalculations).description)
}()

static let bgValueTooHigh:String = {
Expand Down
Loading

0 comments on commit 89a26c9

Please sign in to comment.