فهرست منبع

Rename 'HbA1c' to 'eA1c', as it is an estimate WIP

Deniz Cengiz 1 سال پیش
والد
کامیت
2611fa09d4

+ 4 - 11
Trio.xcodeproj/project.pbxproj

@@ -37,8 +37,6 @@
 		1967DFBE29D052C200759F30 /* Icons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1967DFBD29D052C200759F30 /* Icons.swift */; };
 		1967DFC029D053AC00759F30 /* IconSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1967DFBF29D053AC00759F30 /* IconSelection.swift */; };
 		1967DFC229D053D300759F30 /* IconImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1967DFC129D053D300759F30 /* IconImage.swift */; };
-		19A910302A24BF6300C8951B /* StatsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A9102F2A24BF6300C8951B /* StatsView.swift */; };
-		199561C1275E61A50077B976 /* HealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 199561C0275E61A50077B976 /* HealthKit.framework */; };
 		19A910362A24D6D700C8951B /* DateFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19A910352A24D6D700C8951B /* DateFilter.swift */; };
 		19B0EF2128F6D66200069496 /* Statistics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B0EF2028F6D66200069496 /* Statistics.swift */; };
 		19D466A329AA2B80004D5F33 /* MealSettingsDataFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19D466A229AA2B80004D5F33 /* MealSettingsDataFlow.swift */; };
@@ -530,7 +528,7 @@
 		DDD1631A2C4C695E00CD525A /* EditOverrideForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD163192C4C695E00CD525A /* EditOverrideForm.swift */; };
 		DDD1631C2C4C697400CD525A /* AddOverrideForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD1631B2C4C697400CD525A /* AddOverrideForm.swift */; };
 		DDD1631F2C4C6F6900CD525A /* TrioCoreDataPersistentContainer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = DDD1631D2C4C6F6900CD525A /* TrioCoreDataPersistentContainer.xcdatamodeld */; };
-		DDD6D4D32CDE90720029439A /* HbA1cDisplayUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD6D4D22CDE90720029439A /* HbA1cDisplayUnit.swift */; };
+		DDD6D4D32CDE90720029439A /* EstimatedA1cDisplayUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD6D4D22CDE90720029439A /* EstimatedA1cDisplayUnit.swift */; };
 		DDE179522C910127003CDDB7 /* MealPresetStored+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE179322C910127003CDDB7 /* MealPresetStored+CoreDataClass.swift */; };
 		DDE179532C910127003CDDB7 /* MealPresetStored+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE179332C910127003CDDB7 /* MealPresetStored+CoreDataProperties.swift */; };
 		DDE179542C910127003CDDB7 /* LoopStatRecord+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDE179342C910127003CDDB7 /* LoopStatRecord+CoreDataClass.swift */; };
@@ -718,9 +716,6 @@
 		1967DFBF29D053AC00759F30 /* IconSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconSelection.swift; sourceTree = "<group>"; };
 		1967DFC129D053D300759F30 /* IconImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconImage.swift; sourceTree = "<group>"; };
 		199561C0275E61A50077B976 /* HealthKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = HealthKit.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS8.0.sdk/System/Library/Frameworks/HealthKit.framework; sourceTree = DEVELOPER_DIR; };
-		199732B4271B72DD00129A3F /* pt-PT */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-PT"; path = "pt-PT.lproj/Localizable.strings"; sourceTree = "<group>"; };
-		199732B5271B9EE900129A3F /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
-		19A9102F2A24BF6300C8951B /* StatsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatsView.swift; sourceTree = "<group>"; };
 		19A910352A24D6D700C8951B /* DateFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateFilter.swift; sourceTree = "<group>"; };
 		19B0EF2028F6D66200069496 /* Statistics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Statistics.swift; sourceTree = "<group>"; };
 		19D466A229AA2B80004D5F33 /* MealSettingsDataFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MealSettingsDataFlow.swift; sourceTree = "<group>"; };
@@ -1241,7 +1236,7 @@
 		DDD163192C4C695E00CD525A /* EditOverrideForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditOverrideForm.swift; sourceTree = "<group>"; };
 		DDD1631B2C4C697400CD525A /* AddOverrideForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddOverrideForm.swift; sourceTree = "<group>"; };
 		DDD1631E2C4C6F6900CD525A /* TrioCoreDataPersistentContainer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = TrioCoreDataPersistentContainer.xcdatamodel; sourceTree = "<group>"; };
-		DDD6D4D22CDE90720029439A /* HbA1cDisplayUnit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HbA1cDisplayUnit.swift; sourceTree = "<group>"; };
+		DDD6D4D22CDE90720029439A /* EstimatedA1cDisplayUnit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EstimatedA1cDisplayUnit.swift; sourceTree = "<group>"; };
 		DDE179322C910127003CDDB7 /* MealPresetStored+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MealPresetStored+CoreDataClass.swift"; sourceTree = "<group>"; };
 		DDE179332C910127003CDDB7 /* MealPresetStored+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MealPresetStored+CoreDataProperties.swift"; sourceTree = "<group>"; };
 		DDE179342C910127003CDDB7 /* LoopStatRecord+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LoopStatRecord+CoreDataClass.swift"; sourceTree = "<group>"; };
@@ -2110,7 +2105,7 @@
 				DD6B7CB32C7B71F700B75029 /* ForecastDisplayType.swift */,
 				DD6B7CB52C7B748B00B75029 /* TotalInsulinDisplayType.swift */,
 				DD9ECB692CA99F6C00AA7C45 /* PushMessage.swift */,
-				DDD6D4D22CDE90720029439A /* HbA1cDisplayUnit.swift */,
+				DDD6D4D22CDE90720029439A /* EstimatedA1cDisplayUnit.swift */,
 			);
 			path = Models;
 			sourceTree = "<group>";
@@ -3673,10 +3668,8 @@
 				5837A5302BD2E3C700A5DC04 /* CarbEntryStored+helper.swift in Sources */,
 				389A572026079BAA00BC102F /* Interpolation.swift in Sources */,
 				DD9ECB702CA9A0BA00AA7C45 /* RemoteControlConfigStateModel.swift in Sources */,
-				58A3D5522C96EFA8003F90FC /* TempTargetStored+CoreDataProperties.swift in Sources */,
 				BD249D942D42FC5E00412DEB /* TDDChart.swift in Sources */,
 				BD249D902D42FC4500412DEB /* MealStatsView.swift in Sources */,
-				19A910382A24EF3200C8951B /* ChartsView.swift in Sources */,
 				DD32CF9A2CC8247B003686D6 /* TrioRemoteControl+Meal.swift in Sources */,
 				BDF34F832C10C5B600D51995 /* DataManager.swift in Sources */,
 				38B4F3C625E5017E00E76A18 /* NotificationCenter.swift in Sources */,
@@ -3708,7 +3701,7 @@
 				DDA6E3202D258E0500C2988C /* OverrideHelpView.swift in Sources */,
 				DDA6E2502D22187500C2988C /* ChartLegendView.swift in Sources */,
 				3811DEAF25C9D88300A708ED /* KeyValueStorage.swift in Sources */,
-				DDD6D4D32CDE90720029439A /* HbA1cDisplayUnit.swift in Sources */,
+				DDD6D4D32CDE90720029439A /* EstimatedA1cDisplayUnit.swift in Sources */,
 				DDA6E3572D25988500C2988C /* ContactImageHelpView.swift in Sources */,
 				38FE826D25CC8461001FF17A /* NightscoutAPI.swift in Sources */,
 				388358C825EEF6D200E024B2 /* BasalProfileEntry.swift in Sources */,

+ 1 - 1
Trio/Resources/json/defaults/freeaps/freeaps_settings.json

@@ -28,7 +28,7 @@
   "delay" : 60,
   "useAppleHealth" : false,
   "smoothGlucose" : false,
-  "hbA1cDisplayUnit" : "percent",
+  "eA1cDisplayUnit" : "percent",
   "high" : 180,
   "low" : 70,
   "hours" : 6,

+ 11 - 11
Trio/Sources/APS/APSManager.swift

@@ -920,7 +920,7 @@ final class BaseAPSManager: APSManager, Injectable {
                 total_average: 0
             )
             let processedGlucoseStats = await glucoseStats
-            let hbA1cDisplayUnit = processedGlucoseStats.hbA1cDisplayUnit
+            let eA1cDisplayUnit = processedGlucoseStats.eA1cDisplayUnit
 
             let dailystat = await Statistics(
                 created_at: Date(),
@@ -942,8 +942,8 @@ final class BaseAPSManager: APSManager, Injectable {
                 Statistics: Stats(
                     Distribution: processedGlucoseStats.TimeInRange,
                     Glucose: processedGlucoseStats.avg,
-                    HbA1c: processedGlucoseStats.hbs,
-                    Units: Units(Glucose: units.rawValue, HbA1c: hbA1cDisplayUnit.rawValue),
+                    EstimatedA1c: processedGlucoseStats.hbs,
+                    Units: Units(Glucose: units.rawValue, EstimatedA1c: eA1cDisplayUnit.rawValue),
                     LoopCycles: loopStats,
                     Insulin: insulin,
                     Variance: processedGlucoseStats.variance
@@ -1109,7 +1109,7 @@ final class BaseAPSManager: APSManager, Injectable {
                 cv: Double,
                 readings: Double
             ),
-            hbA1cDisplayUnit: HbA1cDisplayUnit,
+            eA1cDisplayUnit: EstimatedA1cDisplayUnit,
             numberofDays: Double,
             TimeInRange: TIRs,
             avg: Averages,
@@ -1145,7 +1145,7 @@ final class BaseAPSManager: APSManager, Injectable {
                 cv: Double,
                 readings: Double
             ),
-            hbA1cDisplayUnit: HbA1cDisplayUnit,
+            eA1cDisplayUnit: EstimatedA1cDisplayUnit,
             numberofDays: Double,
             TimeInRange: TIRs,
             avg: Averages,
@@ -1176,19 +1176,19 @@ final class BaseAPSManager: APSManager, Injectable {
                 total: self.roundDecimal(Decimal(totalDaysGlucose.median), 1)
             )
 
-            let hbA1cDisplayUnit = self.settingsManager.settings.hbA1cDisplayUnit
+            let eA1cDisplayUnit = self.settingsManager.settings.eA1cDisplayUnit
 
             let hbs = Durations(
-                day: hbA1cDisplayUnit == .mmolMol ?
+                day: eA1cDisplayUnit == .mmolMol ?
                     self.roundDecimal(Decimal(oneDayGlucose.ifcc), 1) :
                     self.roundDecimal(Decimal(oneDayGlucose.ngsp), 1),
-                week: hbA1cDisplayUnit == .mmolMol ?
+                week: eA1cDisplayUnit == .mmolMol ?
                     self.roundDecimal(Decimal(sevenDaysGlucose.ifcc), 1) :
                     self.roundDecimal(Decimal(sevenDaysGlucose.ngsp), 1),
-                month: hbA1cDisplayUnit == .mmolMol ?
+                month: eA1cDisplayUnit == .mmolMol ?
                     self.roundDecimal(Decimal(thirtyDaysGlucose.ifcc), 1) :
                     self.roundDecimal(Decimal(thirtyDaysGlucose.ngsp), 1),
-                total: hbA1cDisplayUnit == .mmolMol ?
+                total: eA1cDisplayUnit == .mmolMol ?
                     self.roundDecimal(Decimal(totalDaysGlucose.ifcc), 1) :
                     self.roundDecimal(Decimal(totalDaysGlucose.ngsp), 1)
             )
@@ -1263,7 +1263,7 @@ final class BaseAPSManager: APSManager, Injectable {
             )
             let variance = Variance(SD: standardDeviations, CV: cvs)
 
-            result = (oneDayGlucose, hbA1cDisplayUnit, numberOfDays, TimeInRange, avg, hbs, variance)
+            result = (oneDayGlucose, eA1cDisplayUnit, numberOfDays, TimeInRange, avg, hbs, variance)
         }
 
         return result!

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

@@ -43426,7 +43426,11 @@
         }
       }
     },
+    "Choose to display eA1c in percent or mmol/mol." : {
+
+    },
     "Choose to display HbA1c in percent or mmol/mol." : {
+      "extractionState" : "stale",
       "localizations" : {
         "ar" : {
           "stringUnit" : {
@@ -43744,7 +43748,11 @@
         }
       }
     },
+    "Choose which format you'd prefer the eA1c (estimated A1c) value in the statistics view as a percentage (Example: 6.5%) or mmol/mol (Example: 48 mmol/mol)." : {
+
+    },
     "Choose which format you'd prefer the HbA1c value in the statistics view as a percentage (Example: 6.5%) or mmol/mol (Example: 48 mmol/mol)." : {
+      "extractionState" : "stale",
       "localizations" : {
         "ar" : {
           "stringUnit" : {
@@ -64323,6 +64331,12 @@
     "Dynamically adjust your Carb Ratio (CR)." : {
 
     },
+    "eA1c Display Unit" : {
+
+    },
+    "ebA1c" : {
+
+    },
     "Edit" : {
       "localizations" : {
         "ar" : {
@@ -84048,6 +84062,7 @@
     },
     "HbA1c" : {
       "comment" : "Estimated HbA1c",
+      "extractionState" : "stale",
       "localizations" : {
         "ar" : {
           "stringUnit" : {
@@ -84154,6 +84169,7 @@
       }
     },
     "HbA1c Display Unit" : {
+      "extractionState" : "stale",
       "localizations" : {
         "ar" : {
           "stringUnit" : {
@@ -119900,7 +119916,11 @@
         }
       }
     },
+    "Override eA1c Unit" : {
+
+    },
     "Override HbA1c Unit" : {
+      "extractionState" : "stale",
       "localizations" : {
         "ar" : {
           "stringUnit" : {

+ 1 - 1
Trio/Sources/Models/HbA1cDisplayUnit.swift

@@ -1,6 +1,6 @@
 import Foundation
 
-enum HbA1cDisplayUnit: String, JSON, CaseIterable, Identifiable, Codable, Hashable {
+enum EstimatedA1cDisplayUnit: String, JSON, CaseIterable, Identifiable, Codable, Hashable {
     var id: String { rawValue }
     case percent
     case mmolMol

+ 3 - 3
Trio/Sources/Models/Statistics.swift

@@ -117,7 +117,7 @@ struct Durations: JSON, Equatable {
 
 struct Units: JSON, Equatable {
     var Glucose: String
-    var HbA1c: String
+    var EstimatedA1c: String
 }
 
 struct Threshold: JSON, Equatable {
@@ -149,7 +149,7 @@ struct Variance: JSON, Equatable {
 struct Stats: JSON, Equatable {
     var Distribution: TIRs
     var Glucose: Averages
-    var HbA1c: Durations
+    var EstimatedA1c: Durations
     var Units: Units
     var LoopCycles: LoopCycles
     var Insulin: Ins
@@ -211,7 +211,7 @@ extension Stats {
     private enum CodingKeys: String, CodingKey {
         case Distribution
         case Glucose
-        case HbA1c
+        case EstimatedA1c
         case Units
         case LoopCycles
         case Insulin

+ 3 - 3
Trio/Sources/Models/TrioSettings.swift

@@ -49,7 +49,7 @@ struct TrioSettings: JSON, Equatable {
     var delay: Int = 60
     var useAppleHealth: Bool = false
     var smoothGlucose: Bool = false
-    var hbA1cDisplayUnit: HbA1cDisplayUnit = .percent
+    var eA1cDisplayUnit: EstimatedA1cDisplayUnit = .percent
     var high: Decimal = 180
     var low: Decimal = 70
     var hours: Int = 6
@@ -274,8 +274,8 @@ extension TrioSettings: Decodable {
             settings.forecastDisplayType = forecastDisplayType
         }
 
-        if let hbA1cDisplayUnit = try? container.decode(HbA1cDisplayUnit.self, forKey: .hbA1cDisplayUnit) {
-            settings.hbA1cDisplayUnit = hbA1cDisplayUnit
+        if let eA1cDisplayUnit = try? container.decode(EstimatedA1cDisplayUnit.self, forKey: .eA1cDisplayUnit) {
+            settings.eA1cDisplayUnit = eA1cDisplayUnit
         }
 
         if let maxCarbs = try? container.decode(Decimal.self, forKey: .maxCarbs) {

+ 3 - 3
Trio/Sources/Modules/Home/HomeStateModel.swift

@@ -68,7 +68,7 @@ extension Home {
         var highGlucose: Decimal = 180
         var currentGlucoseTarget: Decimal = 100
         var glucoseColorScheme: GlucoseColorScheme = .staticColor
-        var hbA1cDisplayUnit: HbA1cDisplayUnit = .percent
+        var eA1cDisplayUnit: EstimatedA1cDisplayUnit = .percent
         var displayXgridLines: Bool = false
         var displayYgridLines: Bool = false
         var thresholdLines: Bool = false
@@ -375,7 +375,7 @@ extension Home {
             maxValue = settingsManager.preferences.autosensMax
             lowGlucose = settingsManager.settings.low
             highGlucose = settingsManager.settings.high
-            hbA1cDisplayUnit = settingsManager.settings.hbA1cDisplayUnit
+            eA1cDisplayUnit = settingsManager.settings.eA1cDisplayUnit
             displayXgridLines = settingsManager.settings.xGridLines
             displayYgridLines = settingsManager.settings.yGridLines
             thresholdLines = settingsManager.settings.rulerMarks
@@ -672,7 +672,7 @@ extension Home.StateModel:
             await getCurrentGlucoseTarget()
             await setupGlucoseTargets()
         }
-        hbA1cDisplayUnit = settingsManager.settings.hbA1cDisplayUnit
+        eA1cDisplayUnit = settingsManager.settings.eA1cDisplayUnit
         glucoseColorScheme = settingsManager.settings.glucoseColorScheme
         displayXgridLines = settingsManager.settings.xGridLines
         displayYgridLines = settingsManager.settings.yGridLines

+ 1 - 1
Trio/Sources/Modules/Settings/SettingItems.swift

@@ -208,7 +208,7 @@ enum SettingItems {
                 "Total Insulin Display Type",
                 "Total Daily Dose (TDD)",
                 "Total Insulin in Scope (TINS)",
-                "Override HbA1c Unit",
+                "Override eA1c Unit",
                 "Standing / Laying TIR Chart",
                 "Show Carbs Required Badge",
                 "Carbs Required Threshold",

+ 2 - 2
Trio/Sources/Modules/Stat/StatStateModel.swift

@@ -43,7 +43,7 @@ extension Stat {
         @ObservationIgnored @Injected() var settings: SettingsManager!
         var highLimit: Decimal = 180
         var lowLimit: Decimal = 70
-        var hbA1cDisplayUnit: HbA1cDisplayUnit = .percent
+        var eA1cDisplayUnit: EstimatedA1cDisplayUnit = .percent
         var timeInRangeChartStyle: TimeInRangeChartStyle = .vertical
         var units: GlucoseUnits = .mgdL
         var glucoseFromPersistence: [GlucoseStored] = []
@@ -172,7 +172,7 @@ extension Stat {
             highLimit = settingsManager.settings.high
             lowLimit = settingsManager.settings.low
             units = settingsManager.settings.units
-            hbA1cDisplayUnit = settingsManager.settings.hbA1cDisplayUnit
+            eA1cDisplayUnit = settingsManager.settings.eA1cDisplayUnit
             timeInRangeChartStyle = settingsManager.settings.timeInRangeChartStyle
         }
 

+ 3 - 22
Trio/Sources/Modules/Stat/View/StatRootView.swift

@@ -116,15 +116,6 @@ extension Stat {
                             glucoseRangeStats: state.glucoseRangeStats
                         )
                     }
-
-//                    Divider()
-//
-//                    SectorChart(
-//                        highLimit: state.highLimit,
-//                        lowLimit: state.lowLimit,
-//                        units: state.units,
-//                        glucose: state.glucoseFromPersistence
-//                    )
                 }
             }
         }
@@ -141,23 +132,13 @@ extension Stat {
 
                     Divider()
 
-                    BareStatisticsView.HbA1cView(
+                    BareStatisticsView.GlucoseMetricsView(
                         highLimit: state.highLimit,
                         lowLimit: state.lowLimit,
                         units: state.units,
-                        hbA1cDisplayUnit: state.hbA1cDisplayUnit,
+                        eA1cDisplayUnit: state.eA1cDisplayUnit,
                         glucose: state.glucoseFromPersistence
                     )
-
-//                    Divider()
-//
-//                    BareStatisticsView.BloodGlucoseView(
-//                        highLimit: state.highLimit,
-//                        lowLimit: state.lowLimit,
-//                        units: state.units,
-//                        hbA1cDisplayUnit: state.hbA1cDisplayUnit,
-//                        glucose: state.glucoseFromPersistence
-//                    )
                 }
             }
         }
@@ -285,7 +266,7 @@ extension Stat {
                         highLimit: state.highLimit,
                         lowLimit: state.lowLimit,
                         units: state.units,
-                        hbA1cDisplayUnit: state.hbA1cDisplayUnit,
+                        eA1cDisplayUnit: state.eA1cDisplayUnit,
                         loopStatRecords: state.loopStatRecords
                     )
                 }

+ 42 - 31
Trio/Sources/Modules/Stat/View/ViewElements/BareStatisticsView.swift

@@ -27,22 +27,18 @@ struct BareStatisticsView {
         return sorted[length / 2]
     }
 
-    struct HbA1cView: View {
+    struct GlucoseMetricsView: View {
         let highLimit: Decimal
         let lowLimit: Decimal
         let units: GlucoseUnits
-        let hbA1cDisplayUnit: HbA1cDisplayUnit
+        let eA1cDisplayUnit: EstimatedA1cDisplayUnit
         let glucose: [GlucoseStored]
 
         var body: some View {
-            hba1c
-        }
-
-        private var hba1c: some View {
             VStack(alignment: .leading) {
                 HStack(spacing: 40) {
                     let useUnit: GlucoseUnits = {
-                        if hbA1cDisplayUnit == .mmolMol { return .mmolL }
+                        if eA1cDisplayUnit == .mmolMol { return .mmolL }
                         else { return .mgdL }
                     }()
 
@@ -54,15 +50,15 @@ struct BareStatisticsView {
                     // Total time in days
                     let numberOfDays = (current - previous).timeInterval / 8.64E4
 
-                    let hba1cString = (
+                    let eA1cString = (
                         useUnit == .mmolL ? glucoseStats.ifcc
                             .formatted(.number.grouping(.never).rounded().precision(.fractionLength(1))) : glucoseStats.ngsp
                             .formatted(.number.grouping(.never).rounded().precision(.fractionLength(1)))
                             + " %"
                     )
                     VStack(spacing: 5) {
-                        Text("HbA1c").font(.subheadline).foregroundColor(.secondary)
-                        Text(hba1cString)
+                        Text("ebA1c").font(.subheadline).foregroundColor(.secondary)
+                        Text(eA1cString)
                     }
                     VStack(spacing: 5) {
                         Text("GMI").font(.subheadline).foregroundColor(.secondary)
@@ -102,57 +98,72 @@ struct BareStatisticsView {
                 readings: Double
             )
         {
-            // First date
+            // First recorded glucose date
             let previous = glucose.last?.date ?? Date()
-            // Last date (recent)
+            // Most recent glucose date
             let current = glucose.first?.date ?? Date()
-            // Total time in days
+            // Total duration in days
             let numberOfDays = (current - previous).timeInterval / 8.64E4
 
+            // Avoid division by zero, ensure at least 1 day
             let denominator = numberOfDays < 1 ? 1 : numberOfDays
 
+            // Extract glucose values as an array of integers
             let justGlucoseArray = glucose.compactMap({ each in Int(each.glucose as Int16) })
             let sumReadings = justGlucoseArray.reduce(0, +)
             let countReadings = justGlucoseArray.count
 
+            // Calculate the mean (average) glucose value
             let glucoseAverage = Double(sumReadings) / Double(countReadings)
+            // Calculate the median glucose value
             let medianGlucose = BareStatisticsView.medianCalculation(array: justGlucoseArray)
 
-            var NGSPa1CStatisticValue = 0.0
-            var IFCCa1CStatisticValue = 0.0
-            var GMIValue = 0.0
+            // Variables to store calculated values
+            var eA1cNGSP = 0.0 // eA1c in NGSP (%) standard (CGM-based)
+            var eA1cIFCC = 0.0 // eA1c in IFCC (mmol/mol) standard (CGM-based)
+            var GMIValue = 0.0 // Glucose Management Index
 
             if numberOfDays > 0 {
-                NGSPa1CStatisticValue = (glucoseAverage + 46.7) / 28.7
-                IFCCa1CStatisticValue = 10.929 * (NGSPa1CStatisticValue - 2.152)
-
-                // Calculate GMI using the standard formula
-                // GMI = 3.31 + 0.02392 * averageGlucose (mg/dL)
+                // **eA1c NGSP Calculation**: Estimated A1c in percentage (%)
+                // Based on CGM readings, using the DCCT-derived formula:
+                // eA1c NGSP (%) = (Average Glucose mg/dL + 46.7) / 28.7
+                eA1cNGSP = (glucoseAverage + 46.7) / 28.7
+
+                // **eA1c IFCC Calculation**: Conversion from eA1c NGSP to eA1c IFCC (mmol/mol)
+                // eA1c IFCC (mmol/mol) = 10.929 * (eA1c NGSP - 2.152)
+                // This conversion aligns with the IFCC standard.
+                eA1cIFCC = 10.929 * (eA1cNGSP - 2.152)
+
+                // **Glucose Management Index (GMI)**: Alternative eA1c estimate based on CGM data
+                // GMI = 3.31 + (0.02392 × Average Glucose mg/dL)
                 GMIValue = 3.31 + 0.02392 * glucoseAverage
             }
 
+            // Calculate Standard Deviation (SD) and Coefficient of Variation (CV)
             var sumOfSquares = 0.0
-            for array in justGlucoseArray {
-                sumOfSquares += pow(Double(array) - Double(glucoseAverage), 2)
+            for value in justGlucoseArray {
+                sumOfSquares += pow(Double(value) - glucoseAverage, 2)
             }
 
             var sd = 0.0
             var cv = 0.0
 
             if glucoseAverage > 0 {
+                // Standard deviation: Measure of glucose variability
                 sd = sqrt(sumOfSquares / Double(countReadings))
-                cv = sd / Double(glucoseAverage) * 100
+                // Coefficient of variation (CV %): Variability relative to mean glucose
+                cv = sd / glucoseAverage * 100
             }
 
             return (
-                ifcc: IFCCa1CStatisticValue,
-                ngsp: NGSPa1CStatisticValue,
-                gmi: GMIValue,
-                average: glucoseAverage * (units == .mmolL ? 0.0555 : 1),
+                ifcc: eA1cIFCC, // eA1c IFCC (mmol/mol)
+                ngsp: eA1cNGSP, // eA1c NGSP (%)
+                gmi: GMIValue, // Glucose Management Index
+                average: glucoseAverage * (units == .mmolL ? 0.0555 : 1), // Convert if needed
                 median: medianGlucose * (units == .mmolL ? 0.0555 : 1),
                 sd: sd * (units == .mmolL ? 0.0555 : 1),
                 cv: cv,
-                readings: Double(countReadings) / denominator
+                readings: Double(countReadings) / denominator // Readings per day
             )
         }
     }
@@ -161,7 +172,7 @@ struct BareStatisticsView {
         let highLimit: Decimal
         let lowLimit: Decimal
         let units: GlucoseUnits
-        let hbA1cDisplayUnit: HbA1cDisplayUnit
+        let eA1cDisplayUnit: EstimatedA1cDisplayUnit
         let glucose: [GlucoseStored]
 
         var body: some View {
@@ -263,7 +274,7 @@ struct BareStatisticsView {
         let highLimit: Decimal
         let lowLimit: Decimal
         let units: GlucoseUnits
-        let hbA1cDisplayUnit: HbA1cDisplayUnit
+        let eA1cDisplayUnit: EstimatedA1cDisplayUnit
         let loopStatRecords: [LoopStatRecord]
 
         var body: some View {

+ 2 - 2
Trio/Sources/Modules/UserInterfaceSettings/UserInterfaceSettingsStateModel.swift

@@ -12,7 +12,7 @@ extension UserInterfaceSettings {
         @Published var showCarbsRequiredBadge: Bool = true
         @Published var carbsRequiredThreshold: Decimal = 0
         @Published var glucoseColorScheme: GlucoseColorScheme = .staticColor
-        @Published var hbA1cDisplayUnit: HbA1cDisplayUnit = .percent
+        @Published var eA1cDisplayUnit: EstimatedA1cDisplayUnit = .percent
         @Published var timeInRangeChartStyle: TimeInRangeChartStyle = .vertical
 
         var units: GlucoseUnits = .mgdL
@@ -42,7 +42,7 @@ extension UserInterfaceSettings {
 
             subscribeSetting(\.glucoseColorScheme, on: $glucoseColorScheme) { glucoseColorScheme = $0 }
 
-            subscribeSetting(\.hbA1cDisplayUnit, on: $hbA1cDisplayUnit) { hbA1cDisplayUnit = $0 }
+            subscribeSetting(\.eA1cDisplayUnit, on: $eA1cDisplayUnit) { eA1cDisplayUnit = $0 }
 
             subscribeSetting(\.timeInRangeChartStyle, on: $timeInRangeChartStyle) { timeInRangeChartStyle = $0 }
         }

+ 6 - 6
Trio/Sources/Modules/UserInterfaceSettings/View/UserInterfaceSettingsRootView.swift

@@ -435,17 +435,17 @@ extension UserInterfaceSettings {
                     content: {
                         VStack {
                             Picker(
-                                selection: $state.hbA1cDisplayUnit,
-                                label: Text("HbA1c Display Unit")
+                                selection: $state.eA1cDisplayUnit,
+                                label: Text("eA1c Display Unit")
                             ) {
-                                ForEach(HbA1cDisplayUnit.allCases) { selection in
+                                ForEach(EstimatedA1cDisplayUnit.allCases) { selection in
                                     Text(selection.displayName).tag(selection)
                                 }
                             }.padding(.top)
 
                             HStack(alignment: .center) {
                                 Text(
-                                    "Choose to display HbA1c in percent or mmol/mol."
+                                    "Choose to display eA1c in percent or mmol/mol."
                                 )
                                 .font(.footnote)
                                 .foregroundColor(.secondary)
@@ -453,11 +453,11 @@ extension UserInterfaceSettings {
                                 Spacer()
                                 Button(
                                     action: {
-                                        hintLabel = String(localized: "HbA1c Display Unit")
+                                        hintLabel = String(localized: "eA1c Display Unit")
                                         selectedVerboseHint =
                                             AnyView(
                                                 Text(
-                                                    "Choose which format you'd prefer the HbA1c value in the statistics view as a percentage (Example: 6.5%) or mmol/mol (Example: 48 mmol/mol)."
+                                                    "Choose which format you'd prefer the eA1c (estimated A1c) value in the statistics view as a percentage (Example: 6.5%) or mmol/mol (Example: 48 mmol/mol)."
                                                 )
                                             )
                                         shouldDisplayHint.toggle()