Browse Source

Fix again...

(cherry picked from commit cb54dc9d298dcf4e0af6e73273f41151a4ef6aaf)
Jon Mårtensson 3 years ago
parent
commit
313c5dd1bc
1 changed files with 9 additions and 1 deletions
  1. 9 1
      FreeAPS/Sources/APS/APSManager.swift

+ 9 - 1
FreeAPS/Sources/APS/APSManager.swift

@@ -972,6 +972,14 @@ final class BaseAPSManager: APSManager, Injectable {
         if nr_bgs > 0 {
             // Up to 91 days
             bg_total = bg / nr_bgs
+
+            // If less then 24 hours of glucose data, use total instead
+            if bg_1 == 0 {
+                bg_1 = bg_total
+                bgArray_1 = bgArrayForTIR
+                end1 = true
+                nr_bgs_1 = nr_bgs
+            }
         }
 
         // Total median
@@ -1036,7 +1044,7 @@ final class BaseAPSManager: APSManager, Injectable {
         // HbA1c estimation (%, mmol/mol) 1 day
         var NGSPa1CStatisticValue: Decimal = 0.0
         var IFCCa1CStatisticValue: Decimal = 0.0
-        if end1 {
+        if end1, bg_1 > 0 {
             NGSPa1CStatisticValue = (46.7 + bg_1) / 28.7 // NGSP (%)
             IFCCa1CStatisticValue = 10.929 *
                 (NGSPa1CStatisticValue - 2.152) // IFCC (mmol/mol)  A1C(mmol/mol) = 10.929 * (A1C(%) - 2.15)