From da11ae9745c4675dc01c0b9c0c92fca43091b96f Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Thu, 17 Aug 2023 16:02:04 -0500 Subject: [PATCH 1/6] StoredCarbEntry constructor signature change --- ...osingDecisionStore+SimulatedCoreData.swift | 12 ++++----- Loop/Views/SimpleBolusView.swift | 4 +-- .../ViewModels/BolusEntryViewModelTests.swift | 26 +++++++++++++++++-- .../SimpleBolusViewModelTests.swift | 4 +-- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift b/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift index 0e3dbe44fb..558d634539 100644 --- a/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift +++ b/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift @@ -103,23 +103,23 @@ fileprivate extension StoredDosingDecision { historicalGlucose.append(HistoricalGlucoseValue(startDate: date.addingTimeInterval(.minutes(minutes)), quantity: HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 125 + minutes / 5))) } - let originalCarbEntry = StoredCarbEntry(uuid: UUID(uuidString: "C86DEB61-68E9-464E-9DD5-96A9CB445FD3")!, + let originalCarbEntry = StoredCarbEntry(startDate: date.addingTimeInterval(-.minutes(15)), + quantity: HKQuantity(unit: .gram(), doubleValue: 15), + uuid: UUID(uuidString: "C86DEB61-68E9-464E-9DD5-96A9CB445FD3")!, provenanceIdentifier: Bundle.main.bundleIdentifier!, syncIdentifier: "2B03D96C-6F5D-4140-99CD-80C3E64D6010", syncVersion: 1, - startDate: date.addingTimeInterval(-.minutes(15)), - quantity: HKQuantity(unit: .gram(), doubleValue: 15), foodType: "Simulated", absorptionTime: .hours(3), createdByCurrentApp: true, userCreatedDate: date.addingTimeInterval(-.minutes(15)), userUpdatedDate: date.addingTimeInterval(-.minutes(1))) - let carbEntry = StoredCarbEntry(uuid: UUID(uuidString: "71B699D7-0E8F-4B13-B7A1-E7751EB78E74")!, + let carbEntry = StoredCarbEntry(startDate: date.addingTimeInterval(-.minutes(1)), + quantity: HKQuantity(unit: .gram(), doubleValue: 25), + uuid: UUID(uuidString: "71B699D7-0E8F-4B13-B7A1-E7751EB78E74")!, provenanceIdentifier: Bundle.main.bundleIdentifier!, syncIdentifier: "2B03D96C-6F5D-4140-99CD-80C3E64D6010", syncVersion: 2, - startDate: date.addingTimeInterval(-.minutes(1)), - quantity: HKQuantity(unit: .gram(), doubleValue: 25), foodType: "Simulated", absorptionTime: .hours(5), createdByCurrentApp: true, diff --git a/Loop/Views/SimpleBolusView.swift b/Loop/Views/SimpleBolusView.swift index af9098abb6..2a7fc3fe59 100644 --- a/Loop/Views/SimpleBolusView.swift +++ b/Loop/Views/SimpleBolusView.swift @@ -369,12 +369,12 @@ struct SimpleBolusCalculatorView_Previews: PreviewProvider { func addCarbEntry(_ carbEntry: NewCarbEntry, replacing replacingEntry: StoredCarbEntry?, completion: @escaping (Result) -> Void) { let storedCarbEntry = StoredCarbEntry( + startDate: carbEntry.startDate, + quantity: carbEntry.quantity, uuid: UUID(), provenanceIdentifier: UUID().uuidString, syncIdentifier: UUID().uuidString, syncVersion: 1, - startDate: carbEntry.startDate, - quantity: carbEntry.quantity, foodType: carbEntry.foodType, absorptionTime: carbEntry.absorptionTime, createdByCurrentApp: true, diff --git a/LoopTests/ViewModels/BolusEntryViewModelTests.swift b/LoopTests/ViewModels/BolusEntryViewModelTests.swift index 787deb1834..2877cb257b 100644 --- a/LoopTests/ViewModels/BolusEntryViewModelTests.swift +++ b/LoopTests/ViewModels/BolusEntryViewModelTests.swift @@ -58,9 +58,31 @@ class BolusEntryViewModelTests: XCTestCase { fileprivate var delegate: MockBolusEntryViewModelDelegate! var now: Date = BolusEntryViewModelTests.now - let mockOriginalCarbEntry = StoredCarbEntry(uuid: UUID(), provenanceIdentifier: "provenanceIdentifier", syncIdentifier: "syncIdentifier", syncVersion: 0, startDate: BolusEntryViewModelTests.exampleStartDate, quantity: BolusEntryViewModelTests.exampleCarbQuantity, foodType: "foodType", absorptionTime: 1, createdByCurrentApp: true, userCreatedDate: BolusEntryViewModelTests.now, userUpdatedDate: BolusEntryViewModelTests.now) + let mockOriginalCarbEntry = StoredCarbEntry( + startDate: BolusEntryViewModelTests.exampleStartDate, + quantity: BolusEntryViewModelTests.exampleCarbQuantity, + uuid: UUID(), + provenanceIdentifier: "provenanceIdentifier", + syncIdentifier: "syncIdentifier", + syncVersion: 0, + foodType: "foodType", + absorptionTime: 1, + createdByCurrentApp: true, + userCreatedDate: BolusEntryViewModelTests.now, + userUpdatedDate: BolusEntryViewModelTests.now) let mockPotentialCarbEntry = NewCarbEntry(quantity: BolusEntryViewModelTests.exampleCarbQuantity, startDate: BolusEntryViewModelTests.exampleStartDate, foodType: "foodType", absorptionTime: 1) - let mockFinalCarbEntry = StoredCarbEntry(uuid: UUID(), provenanceIdentifier: "provenanceIdentifier", syncIdentifier: "syncIdentifier", syncVersion: 1, startDate: BolusEntryViewModelTests.exampleStartDate, quantity: BolusEntryViewModelTests.exampleCarbQuantity, foodType: "foodType", absorptionTime: 1, createdByCurrentApp: true, userCreatedDate: BolusEntryViewModelTests.now, userUpdatedDate: BolusEntryViewModelTests.now) + let mockFinalCarbEntry = StoredCarbEntry( + startDate: BolusEntryViewModelTests.exampleStartDate, + quantity: BolusEntryViewModelTests.exampleCarbQuantity, + uuid: UUID(), + provenanceIdentifier: "provenanceIdentifier", + syncIdentifier: "syncIdentifier", + syncVersion: 1, + foodType: "foodType", + absorptionTime: 1, + createdByCurrentApp: true, + userCreatedDate: BolusEntryViewModelTests.now, + userUpdatedDate: BolusEntryViewModelTests.now) let mockUUID = BolusEntryViewModelTests.mockUUID.uuidString let queue = DispatchQueue(label: "BolusEntryViewModelTests") var saveAndDeliverSuccess = false diff --git a/LoopTests/ViewModels/SimpleBolusViewModelTests.swift b/LoopTests/ViewModels/SimpleBolusViewModelTests.swift index 7aab8112f4..94c1fd8661 100644 --- a/LoopTests/ViewModels/SimpleBolusViewModelTests.swift +++ b/LoopTests/ViewModels/SimpleBolusViewModelTests.swift @@ -294,12 +294,12 @@ extension SimpleBolusViewModelTests: SimpleBolusViewModelDelegate { addedCarbEntry = carbEntry let storedCarbEntry = StoredCarbEntry( + startDate: carbEntry.startDate, + quantity: carbEntry.quantity, uuid: UUID(), provenanceIdentifier: UUID().uuidString, syncIdentifier: UUID().uuidString, syncVersion: 1, - startDate: carbEntry.startDate, - quantity: carbEntry.quantity, foodType: carbEntry.foodType, absorptionTime: carbEntry.absorptionTime, createdByCurrentApp: true, From 599ba109ef2fc11df51a5f3fbf47a74102c5d81c Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Fri, 25 Aug 2023 13:35:32 -0500 Subject: [PATCH 2/6] Adding test for Loop functional algorithm --- Loop.xcodeproj/project.pbxproj | 4 + LoopTests/Managers/LoopAlgorithmTests.swift | 137 ++++++++++++++++++++ LoopTests/Mock Stores/MockCarbStore.swift | 1 - 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 LoopTests/Managers/LoopAlgorithmTests.swift diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index aaa0a470ac..512f50cdf4 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -470,6 +470,7 @@ C1D0B6302986D4D90098D215 /* LocalizedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1D0B62F2986D4D90098D215 /* LocalizedString.swift */; }; C1D0B6312986D4D90098D215 /* LocalizedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1D0B62F2986D4D90098D215 /* LocalizedString.swift */; }; C1D289B522F90A52003FFBD9 /* BasalDeliveryState.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1D289B422F90A52003FFBD9 /* BasalDeliveryState.swift */; }; + C1D476B42A8ED179002C1C87 /* LoopAlgorithmTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1D476B32A8ED179002C1C87 /* LoopAlgorithmTests.swift */; }; C1D6EEA02A06C7270047DE5C /* MKRingProgressView in Frameworks */ = {isa = PBXBuildFile; productRef = C1D6EE9F2A06C7270047DE5C /* MKRingProgressView */; }; C1DE5D23251BFC4D00439E49 /* SimpleBolusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1DE5D22251BFC4D00439E49 /* SimpleBolusView.swift */; }; C1E2773E224177C000354103 /* ClockKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1E2773D224177C000354103 /* ClockKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; @@ -1543,6 +1544,7 @@ C1D197FE232CF92D0096D646 /* capture-build-details.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "capture-build-details.sh"; sourceTree = ""; }; C1D289B422F90A52003FFBD9 /* BasalDeliveryState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasalDeliveryState.swift; sourceTree = ""; }; C1D70F7A2A914F71009FE129 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/InfoPlist.strings; sourceTree = ""; }; + C1D476B32A8ED179002C1C87 /* LoopAlgorithmTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopAlgorithmTests.swift; sourceTree = ""; }; C1DA986B2843B6F9001D04CC /* PersistedProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistedProperty.swift; sourceTree = ""; }; C1DE5D22251BFC4D00439E49 /* SimpleBolusView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleBolusView.swift; sourceTree = ""; }; C1E2773D224177C000354103 /* ClockKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ClockKit.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/ClockKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -1864,6 +1866,7 @@ E9B3552C293592B40076AB04 /* MealDetectionManagerTests.swift */, 1D70C40026EC0F9D00C62570 /* SupportManagerTests.swift */, A9F5F1F4251050EC00E7C8A4 /* ZipArchiveTests.swift */, + C1D476B32A8ED179002C1C87 /* LoopAlgorithmTests.swift */, ); path = Managers; sourceTree = ""; @@ -3991,6 +3994,7 @@ E93E86A824DDCC4400FF40C8 /* MockDoseStore.swift in Sources */, B4D4534128E5CA7900F1A8D9 /* AlertMuterTests.swift in Sources */, E98A55F124EDD85E0008715D /* MockDosingDecisionStore.swift in Sources */, + C1D476B42A8ED179002C1C87 /* LoopAlgorithmTests.swift in Sources */, 8968B114240C55F10074BB48 /* LoopSettingsTests.swift in Sources */, A9BD28E7272226B40071DF15 /* TestLocalizedError.swift in Sources */, A9F5F1F5251050EC00E7C8A4 /* ZipArchiveTests.swift in Sources */, diff --git a/LoopTests/Managers/LoopAlgorithmTests.swift b/LoopTests/Managers/LoopAlgorithmTests.swift new file mode 100644 index 0000000000..76745cb1dc --- /dev/null +++ b/LoopTests/Managers/LoopAlgorithmTests.swift @@ -0,0 +1,137 @@ +// +// LoopAlgorithmTests.swift +// LoopTests +// +// Created by Pete Schwamb on 8/17/23. +// Copyright © 2023 LoopKit Authors. All rights reserved. +// + +import XCTest +import LoopKit +import LoopCore +import HealthKit + +final class LoopAlgorithmTests: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + public var bundle: Bundle { + return Bundle(for: type(of: self)) + } + + public func loadFixture(_ resourceName: String) -> T { + let path = bundle.path(forResource: resourceName, ofType: "json")! + return try! JSONSerialization.jsonObject(with: Data(contentsOf: URL(fileURLWithPath: path)), options: []) as! T + } + + func loadBasalRateScheduleFixture(_ resourceName: String) -> BasalRateSchedule { + let fixture: [JSONDictionary] = loadFixture(resourceName) + + let items = fixture.map { + return RepeatingScheduleValue(startTime: TimeInterval(minutes: $0["minutes"] as! Double), value: $0["rate"] as! Double) + } + + return BasalRateSchedule(dailyItems: items, timeZone: .utcTimeZone)! + } + + func loadPredictedGlucoseFixture(_ name: String) -> [PredictedGlucoseValue] { + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .iso8601 + + let url = bundle.url(forResource: name, withExtension: "json")! + return try! decoder.decode([PredictedGlucoseValue].self, from: try! Data(contentsOf: url)) + } + + + func testLiveCaptureWithFunctionalAlgorithm() throws { + // This matches the "testForecastFromLiveCaptureInputData" test of LoopDataManagerDosingTests, + // Using the same input data, but generating the forecast using LoopPrediction + + let mockGlucoseStore = MockGlucoseStore(for: .liveCapture) + let historicGlucose = mockGlucoseStore.storedGlucose! + + let mockDoseStore = MockDoseStore(for: .liveCapture) + let doses = mockDoseStore.doseHistory! + + let mockCarbStore = MockCarbStore(for: .liveCapture) + let carbEntries = mockCarbStore.carbHistory! + + let baseTime = historicGlucose.last!.startDate + let treatmentInterval = LoopAlgorithm.treatmentHistoryDateInterval(for: baseTime) + + + let isfStart = min(treatmentInterval.start, doses.map { $0.startDate }.min() ?? .distantFuture) + let isfEnd = baseTime.addingTimeInterval(InsulinMath.defaultInsulinActivityDuration).dateCeiledToTimeInterval(GlucoseMath.defaultDelta) + + let basalRateSchedule = loadBasalRateScheduleFixture("basal_profile") + + let insulinSensitivitySchedule = InsulinSensitivitySchedule( + unit: .milligramsPerDeciliter, + dailyItems: [ + RepeatingScheduleValue(startTime: 0, value: 45), + RepeatingScheduleValue(startTime: 32400, value: 55) + ], + timeZone: .utcTimeZone + )! + let carbRatioSchedule = CarbRatioSchedule( + unit: .gram(), + dailyItems: [ + RepeatingScheduleValue(startTime: 0.0, value: 10.0), + ], + timeZone: .utcTimeZone + )! + + let glucoseTargetRangeSchedule = GlucoseRangeSchedule( + unit: HKUnit.milligramsPerDeciliter, + dailyItems: [ + RepeatingScheduleValue(startTime: TimeInterval(0), value: DoubleRange(minValue: 100, maxValue: 110)), + RepeatingScheduleValue(startTime: TimeInterval(28800), value: DoubleRange(minValue: 90, maxValue: 100)), + RepeatingScheduleValue(startTime: TimeInterval(75600), value: DoubleRange(minValue: 100, maxValue: 110)) + ], + timeZone: .utcTimeZone)! + + let settings = LoopAlgorithmSettings( + basal: basalRateSchedule.between(start: treatmentInterval.start, end: treatmentInterval.end), + sensitivity: insulinSensitivitySchedule.quantitiesBetween(start: isfStart, end: isfEnd), + carbRatio: carbRatioSchedule.between(start: treatmentInterval.start, end: treatmentInterval.end), + target: glucoseTargetRangeSchedule.quantityBetween(start: baseTime, end: isfEnd), + maximumBasalRatePerHour: 5.0, + maximumBolus: 10, + suspendThreshold: GlucoseThreshold(unit: HKUnit.milligramsPerDeciliter, value: 75)) + + let input = LoopPredictionInput( + glucoseHistory: historicGlucose, + doses: doses, + carbEntries: carbEntries, + settings: settings) + + let prediction = try LoopAlgorithm.generatePrediction(input: input) + + let expectedPredictedGlucose = loadPredictedGlucoseFixture("live_capture_predicted_glucose") + + XCTAssertEqual(expectedPredictedGlucose.count, prediction.glucose.count) + + let defaultAccuracy = 1.0 / 40.0 + + for (expected, calculated) in zip(expectedPredictedGlucose, prediction.glucose) { + XCTAssertEqual(expected.startDate, calculated.startDate) + XCTAssertEqual(expected.quantity.doubleValue(for: .milligramsPerDeciliter), calculated.quantity.doubleValue(for: .milligramsPerDeciliter), accuracy: defaultAccuracy) + } + + //XCTAssertEqual(1.99, recommendedBasal!.unitsPerHour, accuracy: defaultAccuracy) + } + + func testPerformanceExample() throws { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/LoopTests/Mock Stores/MockCarbStore.swift b/LoopTests/Mock Stores/MockCarbStore.swift index 25537d2267..2c8d7407e7 100644 --- a/LoopTests/Mock Stores/MockCarbStore.swift +++ b/LoopTests/Mock Stores/MockCarbStore.swift @@ -174,5 +174,4 @@ extension MockCarbStore { return nil } } - } From a6a057fb85f8ce7e057272faba6daf043790cebd Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Sat, 2 Sep 2023 14:15:36 -0500 Subject: [PATCH 3/6] Tests passing --- Loop.xcodeproj/project.pbxproj | 6 +- Loop/Managers/LoopDataManager.swift | 10 +- .../GlucoseStoreProtocol.swift | 2 +- Loop/Models/LoopConstants.swift | 3 - .../live_capture/live_capture_input.json | 1482 +++++++++++++++++ .../live_capture_predicted_glucose.json | 316 ++-- LoopTests/Managers/LoopAlgorithmTests.swift | 72 +- .../Managers/LoopDataManagerDosingTests.swift | 83 +- LoopTests/Mock Stores/MockDoseStore.swift | 8 +- LoopTests/Mock Stores/MockGlucoseStore.swift | 8 +- 10 files changed, 1775 insertions(+), 215 deletions(-) create mode 100644 LoopTests/Fixtures/live_capture/live_capture_input.json diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index 512f50cdf4..78f53ccf42 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -434,6 +434,7 @@ C16B983E26B4893300256B05 /* DoseEnactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16B983D26B4893300256B05 /* DoseEnactor.swift */; }; C16B984026B4898800256B05 /* DoseEnactorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16B983F26B4898800256B05 /* DoseEnactorTests.swift */; }; C16DA84222E8E112008624C2 /* PluginManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16DA84122E8E112008624C2 /* PluginManager.swift */; }; + C16FC0B02A99392F0025E239 /* live_capture_input.json in Resources */ = {isa = PBXBuildFile; fileRef = C16FC0AF2A99392F0025E239 /* live_capture_input.json */; }; C1735B1E2A0809830082BB8A /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = C1735B1D2A0809830082BB8A /* ZIPFoundation */; }; C1742332259BEADC00399C9D /* ManualEntryDoseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1742331259BEADC00399C9D /* ManualEntryDoseView.swift */; }; C174233C259BEB0F00399C9D /* ManualEntryDoseViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C174233B259BEB0F00399C9D /* ManualEntryDoseViewModel.swift */; }; @@ -1446,6 +1447,7 @@ C16B983D26B4893300256B05 /* DoseEnactor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoseEnactor.swift; sourceTree = ""; }; C16B983F26B4898800256B05 /* DoseEnactorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DoseEnactorTests.swift; sourceTree = ""; }; C16DA84122E8E112008624C2 /* PluginManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PluginManager.swift; sourceTree = ""; }; + C16FC0AF2A99392F0025E239 /* live_capture_input.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = live_capture_input.json; sourceTree = ""; }; C1742331259BEADC00399C9D /* ManualEntryDoseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManualEntryDoseView.swift; sourceTree = ""; }; C174233B259BEB0F00399C9D /* ManualEntryDoseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManualEntryDoseViewModel.swift; sourceTree = ""; }; C174571329830930009EFCF2 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = ""; }; @@ -1543,8 +1545,8 @@ C1D0B62F2986D4D90098D215 /* LocalizedString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedString.swift; sourceTree = ""; }; C1D197FE232CF92D0096D646 /* capture-build-details.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "capture-build-details.sh"; sourceTree = ""; }; C1D289B422F90A52003FFBD9 /* BasalDeliveryState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasalDeliveryState.swift; sourceTree = ""; }; - C1D70F7A2A914F71009FE129 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/InfoPlist.strings; sourceTree = ""; }; C1D476B32A8ED179002C1C87 /* LoopAlgorithmTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoopAlgorithmTests.swift; sourceTree = ""; }; + C1D70F7A2A914F71009FE129 /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/InfoPlist.strings; sourceTree = ""; }; C1DA986B2843B6F9001D04CC /* PersistedProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistedProperty.swift; sourceTree = ""; }; C1DE5D22251BFC4D00439E49 /* SimpleBolusView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SimpleBolusView.swift; sourceTree = ""; }; C1E2773D224177C000354103 /* ClockKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ClockKit.framework; path = Platforms/WatchOS.platform/Developer/SDKs/WatchOS.sdk/System/Library/Frameworks/ClockKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -2761,6 +2763,7 @@ C13072BD2A76AF97009A7C58 /* live_capture_doses.json */, C13072BF2A76B041009A7C58 /* live_capture_carb_entries.json */, C13072C32A76B0B1009A7C58 /* live_capture_historic_glucose.json */, + C16FC0AF2A99392F0025E239 /* live_capture_input.json */, ); path = live_capture; sourceTree = ""; @@ -3434,6 +3437,7 @@ E90909D124E34AC500F963D2 /* high_and_rising_with_cob_momentum_effect.json in Resources */, E9C58A8024DB529A00487A17 /* insulin_effect.json in Resources */, E90909DF24E34F1600F963D2 /* low_and_falling_insulin_effect.json in Resources */, + C16FC0B02A99392F0025E239 /* live_capture_input.json in Resources */, E93E86BE24E1FDC400FF40C8 /* flat_and_stable_carb_effect.json in Resources */, E90909E824E3530200F963D2 /* low_with_low_treatment_insulin_effect.json in Resources */, E9B3553B293706CB0076AB04 /* noisy_cgm_counteraction_effect.json in Resources */, diff --git a/Loop/Managers/LoopDataManager.swift b/Loop/Managers/LoopDataManager.swift index a97944e9ea..73b7e79abb 100644 --- a/Loop/Managers/LoopDataManager.swift +++ b/Loop/Managers/LoopDataManager.swift @@ -364,7 +364,7 @@ final class LoopDataManager { private var retrospectiveGlucoseDiscrepancies: [GlucoseEffect]? { didSet { - retrospectiveGlucoseDiscrepanciesSummed = retrospectiveGlucoseDiscrepancies?.combinedSums(of: LoopConstants.retrospectiveCorrectionGroupingInterval * retrospectiveCorrectionGroupingIntervalMultiplier) + retrospectiveGlucoseDiscrepanciesSummed = retrospectiveGlucoseDiscrepancies?.combinedSums(of: LoopMath.retrospectiveCorrectionGroupingInterval * retrospectiveCorrectionGroupingIntervalMultiplier) } } @@ -1005,7 +1005,7 @@ extension LoopDataManager { if glucoseMomentumEffect == nil { updateGroup.enter() - glucoseStore.getRecentMomentumEffect { (result) -> Void in + glucoseStore.getRecentMomentumEffect(for: now()) { (result) -> Void in switch result { case .failure(let error): self.logger.error("Failure getting recent momentum effect: %{public}@", String(describing: error)) @@ -1594,7 +1594,7 @@ extension LoopDataManager { insulinSensitivity: insulinSensitivity, basalRate: basalRate, correctionRange: correctionRange, - retrospectiveCorrectionGroupingInterval: LoopConstants.retrospectiveCorrectionGroupingInterval + retrospectiveCorrectionGroupingInterval: LoopMath.retrospectiveCorrectionGroupingInterval ) } @@ -1605,7 +1605,7 @@ extension LoopDataManager { let correctionRange = settings.glucoseTargetRangeSchedule!.quantityRange(at: glucose.startDate) let retrospectiveGlucoseDiscrepancies = insulinCounteractionEffects.subtracting(carbEffects, withUniformInterval: carbStore.delta) - let retrospectiveGlucoseDiscrepanciesSummed = retrospectiveGlucoseDiscrepancies.combinedSums(of: LoopConstants.retrospectiveCorrectionGroupingInterval * retrospectiveCorrectionGroupingIntervalMultiplier) + let retrospectiveGlucoseDiscrepanciesSummed = retrospectiveGlucoseDiscrepancies.combinedSums(of: LoopMath.retrospectiveCorrectionGroupingInterval * retrospectiveCorrectionGroupingIntervalMultiplier) return retrospectiveCorrection.computeEffect( startingAt: glucose, retrospectiveGlucoseDiscrepanciesSummed: retrospectiveGlucoseDiscrepanciesSummed, @@ -1613,7 +1613,7 @@ extension LoopDataManager { insulinSensitivity: insulinSensitivity, basalRate: basalRate, correctionRange: correctionRange, - retrospectiveCorrectionGroupingInterval: LoopConstants.retrospectiveCorrectionGroupingInterval + retrospectiveCorrectionGroupingInterval: LoopMath.retrospectiveCorrectionGroupingInterval ) } diff --git a/Loop/Managers/Store Protocols/GlucoseStoreProtocol.swift b/Loop/Managers/Store Protocols/GlucoseStoreProtocol.swift index b549d9b0df..adde73c4c7 100644 --- a/Loop/Managers/Store Protocols/GlucoseStoreProtocol.swift +++ b/Loop/Managers/Store Protocols/GlucoseStoreProtocol.swift @@ -29,7 +29,7 @@ protocol GlucoseStoreProtocol: AnyObject { func executeGlucoseQuery(fromQueryAnchor queryAnchor: GlucoseStore.QueryAnchor?, limit: Int, completion: @escaping (GlucoseStore.GlucoseQueryResult) -> Void) // MARK: Effect Calculation - func getRecentMomentumEffect(_ completion: @escaping (_ result: Result<[GlucoseEffect], Error>) -> Void) + func getRecentMomentumEffect(for date: Date?, _ completion: @escaping (_ result: Result<[GlucoseEffect], Error>) -> Void) func getCounteractionEffects(start: Date, end: Date?, to effects: [GlucoseEffect], _ completion: @escaping (_ effects: Result<[GlucoseEffectVelocity], Error>) -> Void) diff --git a/Loop/Models/LoopConstants.swift b/Loop/Models/LoopConstants.swift index a62fc13849..fb69c8275f 100644 --- a/Loop/Models/LoopConstants.swift +++ b/Loop/Models/LoopConstants.swift @@ -52,9 +52,6 @@ enum LoopConstants { // Percentage of recommended dose to apply as bolus when using automatic bolus dosing strategy static let bolusPartialApplicationFactor = 0.4 - /// The interval over which to aggregate changes in glucose for retrospective correction - static let retrospectiveCorrectionGroupingInterval = TimeInterval(minutes: 30) - /// Loop completion aging category limits static let completionFreshLimit = TimeInterval(minutes: 6) static let completionAgingLimit = TimeInterval(minutes: 16) diff --git a/LoopTests/Fixtures/live_capture/live_capture_input.json b/LoopTests/Fixtures/live_capture/live_capture_input.json new file mode 100644 index 0000000000..95c27a166b --- /dev/null +++ b/LoopTests/Fixtures/live_capture/live_capture_input.json @@ -0,0 +1,1482 @@ +{ + "carbEntries" : [ + { + "absorptionTime" : 10800, + "quantity" : 20, + "startDate" : "2023-08-17T20:05:47Z" + }, + { + "absorptionTime" : 10800, + "quantity" : 10, + "startDate" : "2023-08-18T18:01:14Z" + } + ], + "doses" : [ + { + "endDate" : "2023-08-17T18:21:55Z", + "startDate" : "2023-08-17T18:01:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T18:42:08Z", + "startDate" : "2023-08-17T18:21:55Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T18:47:09Z", + "startDate" : "2023-08-17T18:42:08Z", + "type" : "basal", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-17T19:07:04Z", + "startDate" : "2023-08-17T18:47:09Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T19:11:53Z", + "startDate" : "2023-08-17T19:07:04Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T19:26:55Z", + "startDate" : "2023-08-17T19:11:53Z", + "type" : "basal", + "unit" : "U", + "value" : 0.3 + }, + { + "endDate" : "2023-08-17T19:47:02Z", + "startDate" : "2023-08-17T19:26:55Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T20:06:54Z", + "startDate" : "2023-08-17T19:47:02Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T20:26:51Z", + "startDate" : "2023-08-17T20:06:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T20:46:53Z", + "startDate" : "2023-08-17T20:26:51Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T21:06:52Z", + "startDate" : "2023-08-17T20:46:53Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T21:46:54Z", + "startDate" : "2023-08-17T21:06:52Z", + "type" : "basal", + "unit" : "U", + "value" : 0.75 + }, + { + "endDate" : "2023-08-17T21:51:52Z", + "startDate" : "2023-08-17T21:46:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T21:56:54Z", + "startDate" : "2023-08-17T21:51:52Z", + "type" : "basal", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-17T22:11:51Z", + "startDate" : "2023-08-17T21:56:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T23:07:00Z", + "startDate" : "2023-08-17T22:11:51Z", + "type" : "basal", + "unit" : "U", + "value" : 1 + }, + { + "endDate" : "2023-08-17T23:11:53Z", + "startDate" : "2023-08-17T23:07:00Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-17T23:42:02Z", + "startDate" : "2023-08-17T23:11:53Z", + "type" : "basal", + "unit" : "U", + "value" : 0.55 + }, + { + "endDate" : "2023-08-18T00:02:07Z", + "startDate" : "2023-08-17T23:42:02Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T00:16:52Z", + "startDate" : "2023-08-18T00:02:07Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T01:26:52Z", + "startDate" : "2023-08-18T00:16:52Z", + "type" : "basal", + "unit" : "U", + "value" : 1.3 + }, + { + "endDate" : "2023-08-18T01:46:54Z", + "startDate" : "2023-08-18T01:26:52Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T01:56:52Z", + "startDate" : "2023-08-18T01:46:54Z", + "type" : "basal", + "unit" : "U", + "value" : 0.2 + }, + { + "endDate" : "2023-08-18T02:11:53Z", + "startDate" : "2023-08-18T01:56:52Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T02:41:53Z", + "startDate" : "2023-08-18T02:11:53Z", + "type" : "basal", + "unit" : "U", + "value" : 0.55 + }, + { + "endDate" : "2023-08-18T02:47:02Z", + "startDate" : "2023-08-18T02:41:53Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T03:01:55Z", + "startDate" : "2023-08-18T02:47:02Z", + "type" : "basal", + "unit" : "U", + "value" : 0.25 + }, + { + "endDate" : "2023-08-18T03:06:52Z", + "startDate" : "2023-08-18T03:01:55Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T04:06:54Z", + "startDate" : "2023-08-18T03:06:52Z", + "type" : "basal", + "unit" : "U", + "value" : 1.1 + }, + { + "endDate" : "2023-08-18T03:22:02Z", + "startDate" : "2023-08-18T03:21:50Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.3 + }, + { + "endDate" : "2023-08-18T03:27:09Z", + "startDate" : "2023-08-18T03:27:05Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T03:31:54Z", + "startDate" : "2023-08-18T03:31:50Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T03:41:53Z", + "startDate" : "2023-08-18T03:41:49Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T04:11:52Z", + "startDate" : "2023-08-18T04:06:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.75 + }, + { + "endDate" : "2023-08-18T04:21:54Z", + "startDate" : "2023-08-18T04:11:52Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.65 + }, + { + "endDate" : "2023-08-18T04:26:54Z", + "startDate" : "2023-08-18T04:21:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.45 + }, + { + "endDate" : "2023-08-18T04:41:56Z", + "startDate" : "2023-08-18T04:26:54Z", + "type" : "basal", + "unit" : "U", + "value" : 0.3 + }, + { + "endDate" : "2023-08-18T04:46:57Z", + "startDate" : "2023-08-18T04:41:56Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.4 + }, + { + "endDate" : "2023-08-18T04:51:52Z", + "startDate" : "2023-08-18T04:46:57Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T05:00:00Z", + "startDate" : "2023-08-18T04:51:52Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T05:01:54Z", + "startDate" : "2023-08-18T05:00:00Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T05:11:52Z", + "startDate" : "2023-08-18T05:01:54Z", + "type" : "basal", + "unit" : "U", + "value" : 0.2 + }, + { + "endDate" : "2023-08-18T05:16:57Z", + "startDate" : "2023-08-18T05:11:52Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T05:27:01Z", + "startDate" : "2023-08-18T05:16:57Z", + "type" : "basal", + "unit" : "U", + "value" : 0.2 + }, + { + "endDate" : "2023-08-18T05:46:52Z", + "startDate" : "2023-08-18T05:27:01Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T06:01:53Z", + "startDate" : "2023-08-18T05:46:52Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T06:06:56Z", + "startDate" : "2023-08-18T06:01:53Z", + "type" : "basal", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T06:22:05Z", + "startDate" : "2023-08-18T06:06:56Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T07:16:55Z", + "startDate" : "2023-08-18T06:22:05Z", + "type" : "basal", + "unit" : "U", + "value" : 1 + }, + { + "endDate" : "2023-08-18T07:26:58Z", + "startDate" : "2023-08-18T07:16:55Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T08:36:59Z", + "startDate" : "2023-08-18T07:26:58Z", + "type" : "basal", + "unit" : "U", + "value" : 1.3 + }, + { + "endDate" : "2023-08-18T08:41:52Z", + "startDate" : "2023-08-18T08:36:59Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T08:51:52Z", + "startDate" : "2023-08-18T08:41:52Z", + "type" : "basal", + "unit" : "U", + "value" : 0.2 + }, + { + "endDate" : "2023-08-18T08:56:58Z", + "startDate" : "2023-08-18T08:51:52Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T09:12:01Z", + "startDate" : "2023-08-18T08:56:58Z", + "type" : "basal", + "unit" : "U", + "value" : 0.3 + }, + { + "endDate" : "2023-08-18T09:42:01Z", + "startDate" : "2023-08-18T09:12:01Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T09:51:54Z", + "startDate" : "2023-08-18T09:42:01Z", + "type" : "basal", + "unit" : "U", + "value" : 0.2 + }, + { + "endDate" : "2023-08-18T09:56:52Z", + "startDate" : "2023-08-18T09:51:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T10:06:56Z", + "startDate" : "2023-08-18T09:56:52Z", + "type" : "basal", + "unit" : "U", + "value" : 0.2 + }, + { + "endDate" : "2023-08-18T10:11:54Z", + "startDate" : "2023-08-18T10:06:56Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T10:37:02Z", + "startDate" : "2023-08-18T10:11:54Z", + "type" : "basal", + "unit" : "U", + "value" : 0.45 + }, + { + "endDate" : "2023-08-18T10:41:54Z", + "startDate" : "2023-08-18T10:37:02Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T11:36:58Z", + "startDate" : "2023-08-18T10:41:54Z", + "type" : "basal", + "unit" : "U", + "value" : 1 + }, + { + "endDate" : "2023-08-18T11:51:54Z", + "startDate" : "2023-08-18T11:36:58Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T12:41:54Z", + "startDate" : "2023-08-18T11:51:54Z", + "type" : "basal", + "unit" : "U", + "value" : 0.9 + }, + { + "endDate" : "2023-08-18T12:57:00Z", + "startDate" : "2023-08-18T12:41:54Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T14:11:45Z", + "startDate" : "2023-08-18T12:57:00Z", + "type" : "basal", + "unit" : "U", + "value" : 1.35 + }, + { + "endDate" : "2023-08-18T14:17:00Z", + "startDate" : "2023-08-18T14:11:45Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T14:56:55Z", + "startDate" : "2023-08-18T14:17:00Z", + "type" : "basal", + "unit" : "U", + "value" : 0.75 + }, + { + "endDate" : "2023-08-18T15:17:08Z", + "startDate" : "2023-08-18T14:56:55Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 + }, + { + "endDate" : "2023-08-18T17:22:08Z", + "startDate" : "2023-08-18T15:17:08Z", + "type" : "basal", + "unit" : "U", + "value" : 2.3 + }, + { + "endDate" : "2023-08-18T16:12:07Z", + "startDate" : "2023-08-18T16:12:03Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T16:37:09Z", + "startDate" : "2023-08-18T16:37:05Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T16:42:09Z", + "startDate" : "2023-08-18T16:42:05Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T16:47:14Z", + "startDate" : "2023-08-18T16:47:10Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.1 + }, + { + "endDate" : "2023-08-18T17:22:10Z", + "startDate" : "2023-08-18T17:22:08Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.7 + }, + { + "endDate" : "2023-08-18T17:27:08Z", + "startDate" : "2023-08-18T17:22:10Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.75 + }, + { + "endDate" : "2023-08-18T17:57:10Z", + "startDate" : "2023-08-18T17:27:08Z", + "type" : "basal", + "unit" : "U", + "value" : 0.55 + }, + { + "endDate" : "2023-08-18T18:02:05Z", + "startDate" : "2023-08-18T17:57:10Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0.55 + }, + { + "endDate" : "2023-08-18T18:01:46Z", + "startDate" : "2023-08-18T18:01:30Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.4 + } + ], + "glucoseHistory" : [ + { + "quantity" : 81, + "startDate" : "2023-08-18T00:16:23Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T00:21:25Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T00:26:30Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T00:31:24Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T00:36:23Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T00:41:22Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T00:46:22Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T00:51:23Z" + }, + { + "quantity" : 91, + "startDate" : "2023-08-18T00:56:23Z" + }, + { + "quantity" : 91, + "startDate" : "2023-08-18T01:01:24Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T01:06:25Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T01:11:22Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T01:16:23Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T01:21:23Z" + }, + { + "quantity" : 78, + "startDate" : "2023-08-18T01:26:22Z" + }, + { + "quantity" : 80, + "startDate" : "2023-08-18T01:31:24Z" + }, + { + "quantity" : 79, + "startDate" : "2023-08-18T01:36:25Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T01:41:22Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T01:46:23Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T01:51:23Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T01:56:23Z" + }, + { + "quantity" : 80, + "startDate" : "2023-08-18T02:01:25Z" + }, + { + "quantity" : 79, + "startDate" : "2023-08-18T02:06:29Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T02:11:23Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T02:16:25Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T02:21:27Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T02:26:24Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T02:31:26Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T02:36:25Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T02:41:23Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T02:46:31Z" + }, + { + "quantity" : 99, + "startDate" : "2023-08-18T02:51:29Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T02:56:25Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T03:01:27Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T03:06:23Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T03:11:25Z" + }, + { + "quantity" : 94, + "startDate" : "2023-08-18T03:16:29Z" + }, + { + "quantity" : 101, + "startDate" : "2023-08-18T03:21:22Z" + }, + { + "quantity" : 103, + "startDate" : "2023-08-18T03:26:39Z" + }, + { + "quantity" : 104, + "startDate" : "2023-08-18T03:31:22Z" + }, + { + "quantity" : 106, + "startDate" : "2023-08-18T03:36:22Z" + }, + { + "quantity" : 108, + "startDate" : "2023-08-18T03:41:22Z" + }, + { + "quantity" : 108, + "startDate" : "2023-08-18T03:46:25Z" + }, + { + "quantity" : 109, + "startDate" : "2023-08-18T03:51:24Z" + }, + { + "quantity" : 110, + "startDate" : "2023-08-18T03:56:25Z" + }, + { + "quantity" : 110, + "startDate" : "2023-08-18T04:01:27Z" + }, + { + "quantity" : 109, + "startDate" : "2023-08-18T04:06:24Z" + }, + { + "quantity" : 108, + "startDate" : "2023-08-18T04:11:23Z" + }, + { + "quantity" : 106, + "startDate" : "2023-08-18T04:16:23Z" + }, + { + "quantity" : 105, + "startDate" : "2023-08-18T04:21:24Z" + }, + { + "quantity" : 105, + "startDate" : "2023-08-18T04:26:23Z" + }, + { + "quantity" : 106, + "startDate" : "2023-08-18T04:31:26Z" + }, + { + "quantity" : 106, + "startDate" : "2023-08-18T04:36:24Z" + }, + { + "quantity" : 102, + "startDate" : "2023-08-18T04:41:25Z" + }, + { + "quantity" : 99, + "startDate" : "2023-08-18T04:46:27Z" + }, + { + "quantity" : 99, + "startDate" : "2023-08-18T04:51:22Z" + }, + { + "quantity" : 97, + "startDate" : "2023-08-18T04:56:24Z" + }, + { + "quantity" : 96, + "startDate" : "2023-08-18T05:01:23Z" + }, + { + "quantity" : 97, + "startDate" : "2023-08-18T05:06:24Z" + }, + { + "quantity" : 95, + "startDate" : "2023-08-18T05:11:22Z" + }, + { + "quantity" : 93, + "startDate" : "2023-08-18T05:16:26Z" + }, + { + "quantity" : 92, + "startDate" : "2023-08-18T05:21:22Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T05:26:33Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T05:31:22Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T05:36:23Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T05:41:36Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T05:46:22Z" + }, + { + "quantity" : 78, + "startDate" : "2023-08-18T05:51:23Z" + }, + { + "quantity" : 79, + "startDate" : "2023-08-18T05:56:25Z" + }, + { + "quantity" : 80, + "startDate" : "2023-08-18T06:01:24Z" + }, + { + "quantity" : 79, + "startDate" : "2023-08-18T06:06:26Z" + }, + { + "quantity" : 78, + "startDate" : "2023-08-18T06:11:29Z" + }, + { + "quantity" : 79, + "startDate" : "2023-08-18T06:16:24Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T06:21:35Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T06:26:31Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T06:31:25Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T06:36:30Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T06:41:22Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T06:46:22Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T06:51:31Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T06:56:35Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T07:01:25Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T07:06:29Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T07:11:22Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T07:16:24Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T07:21:31Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T07:26:27Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T07:31:22Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T07:36:24Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T07:41:23Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T07:46:23Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T07:51:25Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T07:56:24Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T08:01:26Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T08:06:33Z" + }, + { + "quantity" : 91, + "startDate" : "2023-08-18T08:11:22Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T08:16:23Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T08:21:26Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T08:26:29Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T08:31:25Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T08:36:30Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T08:41:22Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T08:46:28Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T08:51:23Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T08:56:28Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T09:01:26Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T09:06:23Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T09:11:30Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T09:16:25Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T09:21:25Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T09:26:25Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T09:31:25Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T09:36:25Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T09:41:25Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T09:46:25Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T09:51:25Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T09:56:22Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T10:01:27Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T10:06:27Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T10:11:25Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T10:16:23Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T10:21:24Z" + }, + { + "quantity" : 83, + "startDate" : "2023-08-18T10:26:23Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T10:31:34Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T10:36:31Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T10:41:24Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T10:46:28Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T10:51:23Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T10:56:26Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T11:01:23Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T11:06:26Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T11:11:26Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T11:16:24Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T11:21:24Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T11:26:27Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T11:31:23Z" + }, + { + "quantity" : 82, + "startDate" : "2023-08-18T11:36:27Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T11:41:26Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T11:46:23Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T11:51:24Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T11:56:23Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T12:01:24Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T12:06:25Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T12:11:24Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T12:16:24Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T12:21:25Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T12:26:23Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T12:31:25Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T12:36:32Z" + }, + { + "quantity" : 81, + "startDate" : "2023-08-18T12:41:23Z" + }, + { + "quantity" : 78, + "startDate" : "2023-08-18T12:46:23Z" + }, + { + "quantity" : 77, + "startDate" : "2023-08-18T12:51:23Z" + }, + { + "quantity" : 84, + "startDate" : "2023-08-18T12:56:28Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T13:01:24Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T13:06:23Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T13:11:23Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T13:16:23Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T13:21:24Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T13:26:28Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T13:31:24Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T13:36:29Z" + }, + { + "quantity" : 90, + "startDate" : "2023-08-18T13:41:23Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T13:46:31Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T13:51:29Z" + }, + { + "quantity" : 92, + "startDate" : "2023-08-18T13:56:33Z" + }, + { + "quantity" : 95, + "startDate" : "2023-08-18T14:01:37Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T14:06:23Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T14:11:26Z" + }, + { + "quantity" : 92, + "startDate" : "2023-08-18T14:16:30Z" + }, + { + "quantity" : 94, + "startDate" : "2023-08-18T14:21:29Z" + }, + { + "quantity" : 96, + "startDate" : "2023-08-18T14:26:23Z" + }, + { + "quantity" : 96, + "startDate" : "2023-08-18T14:31:23Z" + }, + { + "quantity" : 98, + "startDate" : "2023-08-18T14:36:32Z" + }, + { + "quantity" : 98, + "startDate" : "2023-08-18T14:41:25Z" + }, + { + "quantity" : 99, + "startDate" : "2023-08-18T14:46:24Z" + }, + { + "quantity" : 98, + "startDate" : "2023-08-18T14:51:26Z" + }, + { + "quantity" : 94, + "startDate" : "2023-08-18T14:56:25Z" + }, + { + "quantity" : 87, + "startDate" : "2023-08-18T15:01:24Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T15:06:24Z" + }, + { + "quantity" : 85, + "startDate" : "2023-08-18T15:11:23Z" + }, + { + "quantity" : 86, + "startDate" : "2023-08-18T15:16:24Z" + }, + { + "quantity" : 88, + "startDate" : "2023-08-18T15:21:23Z" + }, + { + "quantity" : 89, + "startDate" : "2023-08-18T15:26:26Z" + }, + { + "quantity" : 91, + "startDate" : "2023-08-18T15:31:24Z" + }, + { + "quantity" : 92, + "startDate" : "2023-08-18T15:36:24Z" + }, + { + "quantity" : 94, + "startDate" : "2023-08-18T15:41:25Z" + }, + { + "quantity" : 96, + "startDate" : "2023-08-18T15:46:25Z" + }, + { + "quantity" : 96, + "startDate" : "2023-08-18T15:51:28Z" + }, + { + "quantity" : 98, + "startDate" : "2023-08-18T15:56:26Z" + }, + { + "quantity" : 97, + "startDate" : "2023-08-18T16:01:23Z" + }, + { + "quantity" : 99, + "startDate" : "2023-08-18T16:06:23Z" + }, + { + "quantity" : 101, + "startDate" : "2023-08-18T16:11:25Z" + }, + { + "quantity" : 102, + "startDate" : "2023-08-18T16:16:25Z" + }, + { + "quantity" : 103, + "startDate" : "2023-08-18T16:21:23Z" + }, + { + "quantity" : 98, + "startDate" : "2023-08-18T16:26:23Z" + }, + { + "quantity" : 102, + "startDate" : "2023-08-18T16:31:28Z" + }, + { + "quantity" : 105, + "startDate" : "2023-08-18T16:36:23Z" + }, + { + "quantity" : 112, + "startDate" : "2023-08-18T16:41:23Z" + }, + { + "quantity" : 112, + "startDate" : "2023-08-18T16:46:23Z" + }, + { + "quantity" : 111, + "startDate" : "2023-08-18T16:51:26Z" + }, + { + "quantity" : 111, + "startDate" : "2023-08-18T16:56:24Z" + }, + { + "quantity" : 111, + "startDate" : "2023-08-18T17:01:23Z" + }, + { + "quantity" : 109, + "startDate" : "2023-08-18T17:06:24Z" + }, + { + "quantity" : 111, + "startDate" : "2023-08-18T17:11:23Z" + }, + { + "quantity" : 111, + "startDate" : "2023-08-18T17:16:23Z" + }, + { + "quantity" : 110, + "startDate" : "2023-08-18T17:21:23Z" + }, + { + "quantity" : 111, + "startDate" : "2023-08-18T17:26:23Z" + }, + { + "quantity" : 110, + "startDate" : "2023-08-18T17:31:25Z" + }, + { + "quantity" : 110, + "startDate" : "2023-08-18T17:36:23Z" + }, + { + "quantity" : 110, + "startDate" : "2023-08-18T17:41:26Z" + }, + { + "quantity" : 110, + "startDate" : "2023-08-18T17:46:30Z" + }, + { + "quantity" : 111, + "startDate" : "2023-08-18T17:51:28Z" + }, + { + "quantity" : 106, + "startDate" : "2023-08-18T17:56:24Z" + }, + { + "quantity" : 102, + "startDate" : "2023-08-18T18:01:24Z" + } + ], + "settings" : { + "basal" : [ + { + "endDate" : "2023-08-18T05:00:00Z", + "startDate" : "2023-08-17T05:00:00Z", + "value" : 1.1 + }, + { + "endDate" : "2023-08-19T05:00:00Z", + "startDate" : "2023-08-18T05:00:00Z", + "value" : 1.1 + } + ], + "carbRatio" : [ + { + "endDate" : "2023-08-18T05:00:00Z", + "startDate" : "2023-08-17T05:00:00Z", + "value" : 15 + }, + { + "endDate" : "2023-08-19T05:00:00Z", + "startDate" : "2023-08-18T05:00:00Z", + "value" : 15 + } + ], + "sensitivity" : [ + { + "endDate" : "2023-08-18T05:00:00Z", + "startDate" : "2023-08-17T05:00:00Z", + "value" : 50 + }, + { + "endDate" : "2023-08-19T05:00:00Z", + "startDate" : "2023-08-18T05:00:00Z", + "value" : 50 + } + ], + "target" : [ + { + "endDate" : "2023-08-19T00:15:00Z", + "startDate" : "2023-08-18T11:50:00Z", + "value" : { + "maxValue" : 115, + "minValue" : 100 + } + } + ] + } +} diff --git a/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json b/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json index 8ec8f4688c..bb3a141d73 100644 --- a/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json +++ b/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json @@ -1,322 +1,382 @@ [ { + "quantity" : 102, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:20:54Z", - "quantity" : 170 + "startDate" : "2023-08-18T18:01:24Z" }, { + "quantity" : 99.896393318404151, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:25:00Z", - "quantity" : 174.50999999999999 + "startDate" : "2023-08-18T18:05:00Z" }, { + "quantity" : 97.327016523041976, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:30:00Z", - "quantity" : 177.56455527893289 + "startDate" : "2023-08-18T18:10:00Z" }, { + "quantity" : 95.324444788485806, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:35:00Z", - "quantity" : 177.67338252385397 + "startDate" : "2023-08-18T18:15:00Z" }, { + "quantity" : 93.992918445816656, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:40:00Z", - "quantity" : 174.91272423228034 + "startDate" : "2023-08-18T18:20:00Z" }, { + "quantity" : 92.98678930503138, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:45:00Z", - "quantity" : 171.75695070238604 + "startDate" : "2023-08-18T18:25:00Z" }, { + "quantity" : 92.153401829419991, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:50:00Z", - "quantity" : 168.76244616110549 + "startDate" : "2023-08-18T18:30:00Z" }, { + "quantity" : 91.502805972419452, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T19:55:00Z", - "quantity" : 165.95427643567874 + "startDate" : "2023-08-18T18:35:00Z" }, { + "quantity" : 91.044140230125493, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:00:00Z", - "quantity" : 163.35383111783804 + "startDate" : "2023-08-18T18:40:00Z" }, { + "quantity" : 90.785701374247225, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:05:00Z", - "quantity" : 160.97916167823055 + "startDate" : "2023-08-18T18:45:00Z" }, { + "quantity" : 90.735009333107385, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:10:00Z", - "quantity" : 158.84529353872236 + "startDate" : "2023-08-18T18:50:00Z" }, { + "quantity" : 90.87529571413188, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:15:00Z", - "quantity" : 156.96451392177406 + "startDate" : "2023-08-18T18:55:00Z" }, { + "quantity" : 91.131206561299791, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:20:00Z", - "quantity" : 155.34663717673348 + "startDate" : "2023-08-18T19:00:00Z" }, { + "quantity" : 91.369852449274902, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:25:00Z", - "quantity" : 153.99924917105037 + "startDate" : "2023-08-18T19:05:00Z" }, { + "quantity" : 91.596637899447671, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:30:00Z", - "quantity" : 152.92793222961055 + "startDate" : "2023-08-18T19:10:00Z" }, { + "quantity" : 91.815952582397927, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:35:00Z", - "quantity" : 152.13647200718029 + "startDate" : "2023-08-18T19:15:00Z" }, { + "quantity" : 92.031661009999482, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:40:00Z", - "quantity" : 151.62704758695727 + "startDate" : "2023-08-18T19:20:00Z" }, { + "quantity" : 92.24719829385748, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:45:00Z", - "quantity" : 151.36168828514261 + "startDate" : "2023-08-18T19:25:00Z" }, { + "quantity" : 92.465606922060431, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:50:00Z", - "quantity" : 151.16659478660213 + "startDate" : "2023-08-18T19:30:00Z" }, { + "quantity" : 92.689569938551358, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T20:55:00Z", - "quantity" : 151.01925161349905 + "startDate" : "2023-08-18T19:35:00Z" }, { + "quantity" : 92.921441679246016, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:00:00Z", - "quantity" : 150.9170176497727 + "startDate" : "2023-08-18T19:40:00Z" }, { + "quantity" : 93.163276230779218, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:05:00Z", - "quantity" : 150.85638361169495 + "startDate" : "2023-08-18T19:45:00Z" }, { + "quantity" : 93.416853767095574, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:10:00Z", - "quantity" : 150.83308419477353 + "startDate" : "2023-08-18T19:50:00Z" }, { + "quantity" : 93.683704909090238, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:15:00Z", - "quantity" : 150.84043373508726 + "startDate" : "2023-08-18T19:55:00Z" }, { + "quantity" : 93.965133243123091, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:20:00Z", - "quantity" : 150.86809756991411 + "startDate" : "2023-08-18T20:00:00Z" }, { + "quantity" : 94.262236125417473, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:25:00Z", - "quantity" : 150.9067680932084 + "startDate" : "2023-08-18T20:05:00Z" }, { + "quantity" : 94.575923891105845, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:30:00Z", - "quantity" : 150.94864870532584 + "startDate" : "2023-08-18T20:10:00Z" }, { + "quantity" : 94.906937578934446, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:35:00Z", - "quantity" : 150.98521164138711 + "startDate" : "2023-08-18T20:15:00Z" }, { + "quantity" : 95.255865275387578, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:40:00Z", - "quantity" : 151.00885216396446 + "startDate" : "2023-08-18T20:20:00Z" }, { + "quantity" : 95.623303645444025, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:45:00Z", - "quantity" : 151.01338818778473 + "startDate" : "2023-08-18T20:25:00Z" }, { + "quantity" : 96.000882373540378, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:50:00Z", - "quantity" : 150.99143437519743 + "startDate" : "2023-08-18T20:30:00Z" }, { + "quantity" : 96.365336203749791, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T21:55:00Z", - "quantity" : 150.93296955721272 + "startDate" : "2023-08-18T20:35:00Z" }, { + "quantity" : 96.715562621883805, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:00:00Z", - "quantity" : 150.82844495083614 + "startDate" : "2023-08-18T20:40:00Z" }, { + "quantity" : 97.051545329583519, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:05:00Z", - "quantity" : 150.67007248833207 + "startDate" : "2023-08-18T20:45:00Z" }, { + "quantity" : 97.373191168681046, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:10:00Z", - "quantity" : 150.44818289417267 + "startDate" : "2023-08-18T20:50:00Z" }, { + "quantity" : 97.68033912753441, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:15:00Z", - "quantity" : 150.15333032546724 + "startDate" : "2023-08-18T20:55:00Z" }, { + "quantity" : 97.972768583817071, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:20:00Z", - "quantity" : 149.77853346820271 + "startDate" : "2023-08-18T21:00:00Z" }, { + "quantity" : 98.250206839942507, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:25:00Z", - "quantity" : 149.31770786853204 + "startDate" : "2023-08-18T21:05:00Z" }, { + "quantity" : 98.512461657029007, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:30:00Z", - "quantity" : 148.76463863907512 + "startDate" : "2023-08-18T21:10:00Z" }, { + "quantity" : 98.759768446355963, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:35:00Z", - "quantity" : 148.11209303652518 + "startDate" : "2023-08-18T21:15:00Z" }, { + "quantity" : 98.992334190285419, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:40:00Z", - "quantity" : 147.3537767195518 + "startDate" : "2023-08-18T21:20:00Z" }, { + "quantity" : 99.210294956891744, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:45:00Z", - "quantity" : 146.48451003000551 + "startDate" : "2023-08-18T21:25:00Z" }, { + "quantity" : 99.413602382932424, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:50:00Z", - "quantity" : 145.49919962625873 + "startDate" : "2023-08-18T21:30:00Z" }, { + "quantity" : 99.601698280019434, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T22:55:00Z", - "quantity" : 144.39282841481932 + "startDate" : "2023-08-18T21:35:00Z" }, { + "quantity" : 99.773947375251453, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:00:00Z", - "quantity" : 143.1991839953188 + "startDate" : "2023-08-18T21:40:00Z" }, { + "quantity" : 99.929708236532747, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:05:00Z", - "quantity" : 142.08670682751759 + "startDate" : "2023-08-18T21:45:00Z" }, { + "quantity" : 100.06833834582778, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:10:00Z", - "quantity" : 141.07153230327131 + "startDate" : "2023-08-18T21:50:00Z" }, { + "quantity" : 100.18919669640144, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:15:00Z", - "quantity" : 140.14904110452417 + "startDate" : "2023-08-18T21:55:00Z" }, { + "quantity" : 100.29164609469677, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:20:00Z", - "quantity" : 139.31472998543964 + "startDate" : "2023-08-18T22:00:00Z" }, { + "quantity" : 100.3750551915391, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:25:00Z", - "quantity" : 138.56421620595611 + "startDate" : "2023-08-18T22:05:00Z" }, { + "quantity" : 100.43880026555911, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:30:00Z", - "quantity" : 137.8932410364304 + "startDate" : "2023-08-18T22:10:00Z" }, { + "quantity" : 100.48226678004278, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:35:00Z", - "quantity" : 137.29767242360586 + "startDate" : "2023-08-18T22:15:00Z" }, { + "quantity" : 100.50485073285557, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:40:00Z", - "quantity" : 136.77350690107906 + "startDate" : "2023-08-18T22:20:00Z" }, { + "quantity" : 100.50583426131806, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:45:00Z", - "quantity" : 136.3168708208772 + "startDate" : "2023-08-18T22:25:00Z" }, { + "quantity" : 100.48412374566237, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:50:00Z", - "quantity" : 135.92402097664686 + "startDate" : "2023-08-18T22:30:00Z" }, { + "quantity" : 100.4391400838507, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-29T23:55:00Z", - "quantity" : 135.59134468329685 + "startDate" : "2023-08-18T22:35:00Z" }, { + "quantity" : 100.3703782423454, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T00:00:00Z", - "quantity" : 135.31535937266145 + "startDate" : "2023-08-18T22:40:00Z" }, { + "quantity" : 100.28611412349363, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T00:05:00Z", - "quantity" : 135.09271175987229 + "startDate" : "2023-08-18T22:45:00Z" }, { + "quantity" : 100.20947967884376, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T00:10:00Z", - "quantity" : 134.92017663057632 + "startDate" : "2023-08-18T22:50:00Z" }, { + "quantity" : 100.14069735835136, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T00:15:00Z", - "quantity" : 134.79465529494851 + "startDate" : "2023-08-18T22:55:00Z" }, { + "quantity" : 100.07866920613634, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T00:20:00Z", - "quantity" : 134.71317375053073 + "startDate" : "2023-08-18T23:00:00Z" }, { + "quantity" : 100.02247162981837, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T00:25:00Z", - "quantity" : 134.67288059232183 + "startDate" : "2023-08-18T23:05:00Z" }, { + "quantity" : 99.971752267355782, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T00:30:00Z", - "quantity" : 134.66535701098488 + "startDate" : "2023-08-18T23:10:00Z" }, { + "quantity" : 99.926235939245828, "quantityUnit" : "mg\/dL", - "startDate" : "2023-07-30T01:20:54Z", - "quantity" : 134.66535701098488 + "startDate" : "2023-08-18T23:15:00Z" + }, + { + "quantity" : 99.88565546474166, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:20:00Z" + }, + { + "quantity" : 99.849751805109122, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:25:00Z" + }, + { + "quantity" : 99.81827416145336, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:30:00Z" + }, + { + "quantity" : 99.791028333933468, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:35:00Z" + }, + { + "quantity" : 99.767995772848735, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:40:00Z" + }, + { + "quantity" : 99.748959024064902, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:45:00Z" + }, + { + "quantity" : 99.733680926725469, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:50:00Z" + }, + { + "quantity" : 99.721933417247726, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-18T23:55:00Z" + }, + { + "quantity" : 99.713497415806842, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-19T00:00:00Z" + }, + { + "quantity" : 99.708162692555675, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-19T00:05:00Z" + }, + { + "quantity" : 99.705774231311352, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-19T00:10:00Z" + }, + { + "quantity" : 99.705641639222222, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-08-19T00:15:00Z" } ] diff --git a/LoopTests/Managers/LoopAlgorithmTests.swift b/LoopTests/Managers/LoopAlgorithmTests.swift index 76745cb1dc..3f6476c8c8 100644 --- a/LoopTests/Managers/LoopAlgorithmTests.swift +++ b/LoopTests/Managers/LoopAlgorithmTests.swift @@ -53,65 +53,12 @@ final class LoopAlgorithmTests: XCTestCase { // This matches the "testForecastFromLiveCaptureInputData" test of LoopDataManagerDosingTests, // Using the same input data, but generating the forecast using LoopPrediction - let mockGlucoseStore = MockGlucoseStore(for: .liveCapture) - let historicGlucose = mockGlucoseStore.storedGlucose! - - let mockDoseStore = MockDoseStore(for: .liveCapture) - let doses = mockDoseStore.doseHistory! - - let mockCarbStore = MockCarbStore(for: .liveCapture) - let carbEntries = mockCarbStore.carbHistory! - - let baseTime = historicGlucose.last!.startDate - let treatmentInterval = LoopAlgorithm.treatmentHistoryDateInterval(for: baseTime) - - - let isfStart = min(treatmentInterval.start, doses.map { $0.startDate }.min() ?? .distantFuture) - let isfEnd = baseTime.addingTimeInterval(InsulinMath.defaultInsulinActivityDuration).dateCeiledToTimeInterval(GlucoseMath.defaultDelta) - - let basalRateSchedule = loadBasalRateScheduleFixture("basal_profile") - - let insulinSensitivitySchedule = InsulinSensitivitySchedule( - unit: .milligramsPerDeciliter, - dailyItems: [ - RepeatingScheduleValue(startTime: 0, value: 45), - RepeatingScheduleValue(startTime: 32400, value: 55) - ], - timeZone: .utcTimeZone - )! - let carbRatioSchedule = CarbRatioSchedule( - unit: .gram(), - dailyItems: [ - RepeatingScheduleValue(startTime: 0.0, value: 10.0), - ], - timeZone: .utcTimeZone - )! - - let glucoseTargetRangeSchedule = GlucoseRangeSchedule( - unit: HKUnit.milligramsPerDeciliter, - dailyItems: [ - RepeatingScheduleValue(startTime: TimeInterval(0), value: DoubleRange(minValue: 100, maxValue: 110)), - RepeatingScheduleValue(startTime: TimeInterval(28800), value: DoubleRange(minValue: 90, maxValue: 100)), - RepeatingScheduleValue(startTime: TimeInterval(75600), value: DoubleRange(minValue: 100, maxValue: 110)) - ], - timeZone: .utcTimeZone)! - - let settings = LoopAlgorithmSettings( - basal: basalRateSchedule.between(start: treatmentInterval.start, end: treatmentInterval.end), - sensitivity: insulinSensitivitySchedule.quantitiesBetween(start: isfStart, end: isfEnd), - carbRatio: carbRatioSchedule.between(start: treatmentInterval.start, end: treatmentInterval.end), - target: glucoseTargetRangeSchedule.quantityBetween(start: baseTime, end: isfEnd), - maximumBasalRatePerHour: 5.0, - maximumBolus: 10, - suspendThreshold: GlucoseThreshold(unit: HKUnit.milligramsPerDeciliter, value: 75)) - - let input = LoopPredictionInput( - glucoseHistory: historicGlucose, - doses: doses, - carbEntries: carbEntries, - settings: settings) - - let prediction = try LoopAlgorithm.generatePrediction(input: input) + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .iso8601 + let url = bundle.url(forResource: "live_capture_input", withExtension: "json")! + let predictionInput = try! decoder.decode(LoopPredictionInput.self, from: try! Data(contentsOf: url)) + + let prediction = try LoopAlgorithm.generatePrediction(input: predictionInput) let expectedPredictedGlucose = loadPredictedGlucoseFixture("live_capture_predicted_glucose") @@ -127,11 +74,4 @@ final class LoopAlgorithmTests: XCTestCase { //XCTAssertEqual(1.99, recommendedBasal!.unitsPerHour, accuracy: defaultAccuracy) } - func testPerformanceExample() throws { - // This is an example of a performance test case. - self.measure { - // Put the code you want to measure the time of here. - } - } - } diff --git a/LoopTests/Managers/LoopDataManagerDosingTests.swift b/LoopTests/Managers/LoopDataManagerDosingTests.swift index 621aa348a5..a1f26a0e92 100644 --- a/LoopTests/Managers/LoopDataManagerDosingTests.swift +++ b/LoopTests/Managers/LoopDataManagerDosingTests.swift @@ -55,7 +55,83 @@ class LoopDataManagerDosingTests: LoopDataManagerTests { // MARK: Tests func testForecastFromLiveCaptureInputData() { - setUp(for: .liveCapture) + + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .iso8601 + let url = bundle.url(forResource: "live_capture_input", withExtension: "json")! + let predictionInput = try! decoder.decode(LoopPredictionInput.self, from: try! Data(contentsOf: url)) + + // Therapy settings in the "live capture" input only have one value, so we can fake some schedules + // from the first entry of each therapy setting's history. + let basalRateSchedule = BasalRateSchedule(dailyItems: [ + RepeatingScheduleValue(startTime: 0, value: predictionInput.settings.basal.first!.value) + ]) + let insulinSensitivitySchedule = InsulinSensitivitySchedule( + unit: .milligramsPerDeciliter, + dailyItems: [ + RepeatingScheduleValue(startTime: 0, value: predictionInput.settings.sensitivity.first!.value.doubleValue(for: .milligramsPerDeciliter)) + ], + timeZone: .utcTimeZone + )! + let carbRatioSchedule = CarbRatioSchedule( + unit: .gram(), + dailyItems: [ + RepeatingScheduleValue(startTime: 0.0, value: predictionInput.settings.carbRatio.first!.value) + ], + timeZone: .utcTimeZone + )! + + let settings = LoopSettings( + dosingEnabled: false, + glucoseTargetRangeSchedule: glucoseTargetRangeSchedule, + insulinSensitivitySchedule: insulinSensitivitySchedule, + basalRateSchedule: basalRateSchedule, + carbRatioSchedule: carbRatioSchedule, + maximumBasalRatePerHour: 10, + maximumBolus: 5, + suspendThreshold: predictionInput.settings.suspendThreshold, + automaticDosingStrategy: .automaticBolus + ) + + let glucoseStore = MockGlucoseStore() + glucoseStore.storedGlucose = predictionInput.glucoseHistory + + let currentDate = glucoseStore.latestGlucose!.startDate + now = currentDate + + let doseStore = MockDoseStore() + doseStore.basalProfile = basalRateSchedule + doseStore.basalProfileApplyingOverrideHistory = doseStore.basalProfile + doseStore.sensitivitySchedule = insulinSensitivitySchedule + doseStore.doseHistory = predictionInput.doses + doseStore.lastAddedPumpData = predictionInput.doses.last!.startDate + let carbStore = MockCarbStore() + carbStore.insulinSensitivityScheduleApplyingOverrideHistory = insulinSensitivitySchedule + carbStore.carbRatioSchedule = carbRatioSchedule + carbStore.carbRatioScheduleApplyingOverrideHistory = carbRatioSchedule + carbStore.carbHistory = predictionInput.carbEntries + + + dosingDecisionStore = MockDosingDecisionStore() + automaticDosingStatus = AutomaticDosingStatus(automaticDosingEnabled: true, isAutomaticDosingAllowed: true) + loopDataManager = LoopDataManager( + lastLoopCompleted: currentDate, + basalDeliveryState: .active(currentDate), + settings: settings, + overrideHistory: TemporaryScheduleOverrideHistory(), + analyticsServicesManager: AnalyticsServicesManager(), + localCacheDuration: .days(1), + doseStore: doseStore, + glucoseStore: glucoseStore, + carbStore: carbStore, + dosingDecisionStore: dosingDecisionStore, + latestStoredSettingsProvider: MockLatestStoredSettingsProvider(), + now: { currentDate }, + pumpInsulinType: .novolog, + automaticDosingStatus: automaticDosingStatus, + trustedTimeOffset: { 0 } + ) + let expectedPredictedGlucose = loadPredictedGlucoseFixture("live_capture_predicted_glucose") let updateGroup = DispatchGroup() @@ -63,7 +139,7 @@ class LoopDataManagerDosingTests: LoopDataManagerTests { var predictedGlucose: [PredictedGlucoseValue]? var recommendedBasal: TempBasalRecommendation? self.loopDataManager.getLoopState { _, state in - predictedGlucose = state.predictedGlucose + predictedGlucose = state.predictedGlucoseIncludingPendingInsulin recommendedBasal = state.recommendedAutomaticDose?.recommendation.basalAdjustment updateGroup.leave() } @@ -71,14 +147,13 @@ class LoopDataManagerDosingTests: LoopDataManagerTests { updateGroup.wait() XCTAssertNotNil(predictedGlucose) + XCTAssertEqual(expectedPredictedGlucose.count, predictedGlucose!.count) for (expected, calculated) in zip(expectedPredictedGlucose, predictedGlucose!) { XCTAssertEqual(expected.startDate, calculated.startDate) XCTAssertEqual(expected.quantity.doubleValue(for: .milligramsPerDeciliter), calculated.quantity.doubleValue(for: .milligramsPerDeciliter), accuracy: defaultAccuracy) } - - XCTAssertEqual(1.99, recommendedBasal!.unitsPerHour, accuracy: defaultAccuracy) } diff --git a/LoopTests/Mock Stores/MockDoseStore.swift b/LoopTests/Mock Stores/MockDoseStore.swift index a676fa9e74..dc358ec361 100644 --- a/LoopTests/Mock Stores/MockDoseStore.swift +++ b/LoopTests/Mock Stores/MockDoseStore.swift @@ -41,7 +41,7 @@ class MockDoseStore: DoseStoreProtocol { // Default to the adult exponential insulin model var insulinModelProvider: InsulinModelProvider = StaticInsulinModelProvider(ExponentialInsulinModelPreset.rapidActingAdult) - var longestEffectDuration: TimeInterval = ExponentialInsulinModelPreset.rapidActingAdult.actionDuration + var longestEffectDuration: TimeInterval = ExponentialInsulinModelPreset.rapidActingAdult.effectDuration var insulinSensitivitySchedule: InsulinSensitivitySchedule? @@ -92,7 +92,7 @@ class MockDoseStore: DoseStoreProtocol { } func getGlucoseEffects(start: Date, end: Date? = nil, basalDosingEnd: Date? = Date(), completion: @escaping (_ result: DoseStoreResult<[GlucoseEffect]>) -> Void) { - if let doseHistory, let sensitivitySchedule { + if let doseHistory, let sensitivitySchedule, let basalProfile = basalProfileApplyingOverrideHistory { // To properly know glucose effects at startDate, we need to go back another DIA hours let doseStart = start.addingTimeInterval(-longestEffectDuration) let doses = doseHistory.filterDateRange(doseStart, end) @@ -103,7 +103,9 @@ class MockDoseStore: DoseStoreProtocol { return dose.trimmed(to: basalDosingEnd) } - let glucoseEffects = trimmedDoses.glucoseEffects(insulinModelProvider: self.insulinModelProvider, longestEffectDuration: self.longestEffectDuration, insulinSensitivity: sensitivitySchedule, from: start, to: end) + let annotatedDoses = trimmedDoses.annotated(with: basalProfile) + + let glucoseEffects = annotatedDoses.glucoseEffects(insulinModelProvider: self.insulinModelProvider, longestEffectDuration: self.longestEffectDuration, insulinSensitivity: sensitivitySchedule, from: start, to: end) completion(.success(glucoseEffects.filterDateRange(start, end))) } else { return completion(.success(getCannedGlucoseEffects())) diff --git a/LoopTests/Mock Stores/MockGlucoseStore.swift b/LoopTests/Mock Stores/MockGlucoseStore.swift index 93b96f176b..19a6bc22e8 100644 --- a/LoopTests/Mock Stores/MockGlucoseStore.swift +++ b/LoopTests/Mock Stores/MockGlucoseStore.swift @@ -12,7 +12,7 @@ import LoopKit class MockGlucoseStore: GlucoseStoreProtocol { - init(for scenario: DosingTestScenario) { + init(for scenario: DosingTestScenario = .flatAndStable) { self.scenario = scenario // The store returns different effect values based on the scenario storedGlucose = loadHistoricGlucose(scenario: scenario) } @@ -80,12 +80,12 @@ class MockGlucoseStore: GlucoseStoreProtocol { } func counteractionEffects(for samples: [Sample], to effects: [GlucoseEffect]) -> [GlucoseEffectVelocity] where Sample : GlucoseSampleValue { - return [] // TODO: check if we'll ever want to test this + samples.counteractionEffects(to: effects) } - func getRecentMomentumEffect(_ completion: @escaping (_ effects: Result<[GlucoseEffect], Error>) -> Void) { + func getRecentMomentumEffect(for date: Date? = nil, _ completion: @escaping (_ effects: Result<[GlucoseEffect], Error>) -> Void) { if let storedGlucose { - let samples = storedGlucose.filterDateRange(scenario.currentDate.addingTimeInterval(-GlucoseMath.momentumDataInterval), nil) + let samples = storedGlucose.filterDateRange((date ?? Date()).addingTimeInterval(-GlucoseMath.momentumDataInterval), nil) completion(.success(samples.linearMomentumEffect())) } else { let fixture: [JSONDictionary] = loadFixture(momentumEffectToLoad) From a5f44a256ef1dba8ef4347706260eaf83396fe72 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Sat, 2 Sep 2023 14:24:01 -0500 Subject: [PATCH 4/6] Cleanup --- Loop.xcodeproj/project.pbxproj | 12 - .../live_capture_carb_entries.json | 6 - .../live_capture/live_capture_doses.json | 793 ---------------- .../live_capture_historic_glucose.json | 854 ------------------ LoopTests/Managers/LoopAlgorithmTests.swift | 2 - 5 files changed, 1667 deletions(-) delete mode 100644 LoopTests/Fixtures/live_capture/live_capture_carb_entries.json delete mode 100644 LoopTests/Fixtures/live_capture/live_capture_doses.json delete mode 100644 LoopTests/Fixtures/live_capture/live_capture_historic_glucose.json diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index 78f53ccf42..a5426f692c 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -414,9 +414,6 @@ C1201E2C23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */; }; C1201E2D23ECDF3D002DA84A /* WatchContextRequestUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */; }; C13072BA2A76AF31009A7C58 /* live_capture_predicted_glucose.json in Resources */ = {isa = PBXBuildFile; fileRef = C13072B92A76AF31009A7C58 /* live_capture_predicted_glucose.json */; }; - C13072BE2A76AF97009A7C58 /* live_capture_doses.json in Resources */ = {isa = PBXBuildFile; fileRef = C13072BD2A76AF97009A7C58 /* live_capture_doses.json */; }; - C13072C02A76B041009A7C58 /* live_capture_carb_entries.json in Resources */ = {isa = PBXBuildFile; fileRef = C13072BF2A76B041009A7C58 /* live_capture_carb_entries.json */; }; - C13072C42A76B0B1009A7C58 /* live_capture_historic_glucose.json in Resources */ = {isa = PBXBuildFile; fileRef = C13072C32A76B0B1009A7C58 /* live_capture_historic_glucose.json */; }; C13255D6223E7BE2008AF50C /* BolusProgressTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C1F8B1DB223862D500DD66CF /* BolusProgressTableViewCell.xib */; }; C13DA2B024F6C7690098BB29 /* UIViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C13DA2AF24F6C7690098BB29 /* UIViewController.swift */; }; C148CEE724FD91BD00711B3B /* DeliveryUncertaintyAlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C148CEE624FD91BD00711B3B /* DeliveryUncertaintyAlertManager.swift */; }; @@ -1422,9 +1419,6 @@ C12CB9B623106A6200F84978 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Intents.strings; sourceTree = ""; }; C12CB9B823106A6300F84978 /* pl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = pl; path = pl.lproj/Intents.strings; sourceTree = ""; }; C13072B92A76AF31009A7C58 /* live_capture_predicted_glucose.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = live_capture_predicted_glucose.json; sourceTree = ""; }; - C13072BD2A76AF97009A7C58 /* live_capture_doses.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = live_capture_doses.json; sourceTree = ""; }; - C13072BF2A76B041009A7C58 /* live_capture_carb_entries.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = live_capture_carb_entries.json; sourceTree = ""; }; - C13072C32A76B0B1009A7C58 /* live_capture_historic_glucose.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = live_capture_historic_glucose.json; sourceTree = ""; }; C13DA2AF24F6C7690098BB29 /* UIViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewController.swift; sourceTree = ""; }; C148CEE624FD91BD00711B3B /* DeliveryUncertaintyAlertManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeliveryUncertaintyAlertManager.swift; sourceTree = ""; }; C14952142995822A0095AA84 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -2760,9 +2754,6 @@ isa = PBXGroup; children = ( C13072B92A76AF31009A7C58 /* live_capture_predicted_glucose.json */, - C13072BD2A76AF97009A7C58 /* live_capture_doses.json */, - C13072BF2A76B041009A7C58 /* live_capture_carb_entries.json */, - C13072C32A76B0B1009A7C58 /* live_capture_historic_glucose.json */, C16FC0AF2A99392F0025E239 /* live_capture_input.json */, ); path = live_capture; @@ -3418,7 +3409,6 @@ E93E86CE24E2E02200FF40C8 /* high_and_stable_momentum_effect.json in Resources */, C13072BA2A76AF31009A7C58 /* live_capture_predicted_glucose.json in Resources */, E93E865424DB6CBA00FF40C8 /* retrospective_output.json in Resources */, - C13072BE2A76AF97009A7C58 /* live_capture_doses.json in Resources */, E9C58A7F24DB529A00487A17 /* counteraction_effect_falling_glucose.json in Resources */, E93E865624DB731900FF40C8 /* predicted_glucose_without_retrospective.json in Resources */, E9B3553D293706CB0076AB04 /* long_interval_counteraction_effect.json in Resources */, @@ -3431,7 +3421,6 @@ E90909D224E34AC500F963D2 /* high_and_rising_with_cob_insulin_effect.json in Resources */, E90909F224E35B4D00F963D2 /* high_and_falling_counteraction_effect.json in Resources */, E90909EE24E35B4000F963D2 /* high_and_falling_predicted_glucose.json in Resources */, - C13072C02A76B041009A7C58 /* live_capture_carb_entries.json in Resources */, E90909DD24E34F1600F963D2 /* low_and_falling_carb_effect.json in Resources */, E90909E924E3530200F963D2 /* low_with_low_treatment_predicted_glucose.json in Resources */, E90909D124E34AC500F963D2 /* high_and_rising_with_cob_momentum_effect.json in Resources */, @@ -3458,7 +3447,6 @@ E93E86C324E1FE6100FF40C8 /* flat_and_stable_counteraction_effect.json in Resources */, E9C58A7E24DB529A00487A17 /* dynamic_glucose_effect_partially_observed.json in Resources */, E90909F324E35B4D00F963D2 /* high_and_falling_carb_effect.json in Resources */, - C13072C42A76B0B1009A7C58 /* live_capture_historic_glucose.json in Resources */, E93E86CA24E2E02200FF40C8 /* high_and_stable_insulin_effect.json in Resources */, E93E86BB24E1FDC400FF40C8 /* flat_and_stable_momentum_effect.json in Resources */, E93E86CB24E2E02200FF40C8 /* high_and_stable_carb_effect.json in Resources */, diff --git a/LoopTests/Fixtures/live_capture/live_capture_carb_entries.json b/LoopTests/Fixtures/live_capture/live_capture_carb_entries.json deleted file mode 100644 index 6c5b77202e..0000000000 --- a/LoopTests/Fixtures/live_capture/live_capture_carb_entries.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "startDate": "2023-07-29T18:17:07Z", - "quantity": 50 - } -] diff --git a/LoopTests/Fixtures/live_capture/live_capture_doses.json b/LoopTests/Fixtures/live_capture/live_capture_doses.json deleted file mode 100644 index 452fce1d0a..0000000000 --- a/LoopTests/Fixtures/live_capture/live_capture_doses.json +++ /dev/null @@ -1,793 +0,0 @@ -[ - { - "value": 0, - "startDate": "2023-07-28T19:15:55Z", - "type": "tempBasal", - "endDate": "2023-07-28T19:15:55Z", - "unit": "U/hour" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-28T19:35:49Z", - "type": "tempBasal", - "endDate": "2023-07-28T19:35:49Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-28T19:40:49Z", - "type": "tempBasal", - "endDate": "2023-07-28T19:40:49Z", - "unit": "U/hour" - }, - { - "value": 0.25, - "startDate": "2023-07-28T20:00:49Z", - "type": "bolus", - "endDate": "2023-07-28T20:00:49Z", - "unit": "U" - }, - { - "value": 0.25, - "startDate": "2023-07-28T20:05:48Z", - "type": "bolus", - "endDate": "2023-07-28T20:05:48Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-28T20:10:51Z", - "type": "bolus", - "endDate": "2023-07-28T20:10:51Z", - "unit": "U" - }, - { - "value": 0.34999999999999998, - "startDate": "2023-07-28T20:15:49Z", - "type": "bolus", - "endDate": "2023-07-28T20:15:49Z", - "unit": "U" - }, - { - "value": 0.5, - "startDate": "2023-07-28T20:20:52Z", - "type": "bolus", - "endDate": "2023-07-28T20:20:52Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-28T20:30:48Z", - "type": "bolus", - "endDate": "2023-07-28T20:30:48Z", - "unit": "U" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-28T20:35:51Z", - "type": "bolus", - "endDate": "2023-07-28T20:35:51Z", - "unit": "U" - }, - { - "value": 0.25, - "startDate": "2023-07-28T20:40:51Z", - "type": "bolus", - "endDate": "2023-07-28T20:40:51Z", - "unit": "U" - }, - { - "value": 0.80000000000000004, - "startDate": "2023-07-28T20:45:56Z", - "type": "tempBasal", - "endDate": "2023-07-28T20:45:56Z", - "unit": "U/hour" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-28T20:55:48Z", - "type": "tempBasal", - "endDate": "2023-07-28T20:55:48Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-28T20:59:35Z", - "type": "suspend", - "endDate": "2023-07-28T20:59:35Z", - "unit": "U" - }, - { - "value": 3.0499999999999998, - "startDate": "2023-07-29T00:07:52Z", - "type": "bolus", - "endDate": "2023-07-29T00:07:52Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T00:10:54Z", - "type": "bolus", - "endDate": "2023-07-29T00:10:54Z", - "unit": "U" - }, - { - "value": 0.5, - "startDate": "2023-07-29T00:15:49Z", - "type": "bolus", - "endDate": "2023-07-29T00:15:49Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T00:20:50Z", - "type": "bolus", - "endDate": "2023-07-29T00:20:50Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T00:25:49Z", - "type": "bolus", - "endDate": "2023-07-29T00:25:49Z", - "unit": "U" - }, - { - "value": 0.55000000000000004, - "startDate": "2023-07-29T00:30:52Z", - "type": "bolus", - "endDate": "2023-07-29T00:30:52Z", - "unit": "U" - }, - { - "value": 0.59999999999999998, - "startDate": "2023-07-29T00:35:50Z", - "type": "bolus", - "endDate": "2023-07-29T00:35:50Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T00:40:50Z", - "type": "bolus", - "endDate": "2023-07-29T00:40:50Z", - "unit": "U" - }, - { - "value": 0.14999999999999999, - "startDate": "2023-07-29T00:45:49Z", - "type": "bolus", - "endDate": "2023-07-29T00:45:49Z", - "unit": "U" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T00:55:50Z", - "type": "tempBasal", - "endDate": "2023-07-29T00:55:50Z", - "unit": "U/hour" - }, - { - "value": 0.29999999999999999, - "startDate": "2023-07-29T01:00:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T01:00:49Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T01:05:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T01:05:49Z", - "unit": "U/hour" - }, - { - "value": 0.14999999999999999, - "startDate": "2023-07-29T01:15:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T01:15:49Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T01:20:50Z", - "type": "tempBasal", - "endDate": "2023-07-29T01:20:50Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T01:45:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T01:45:49Z", - "unit": "U/hour" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T01:50:50Z", - "type": "bolus", - "endDate": "2023-07-29T01:50:50Z", - "unit": "U" - }, - { - "value": 0.34999999999999998, - "startDate": "2023-07-29T02:00:58Z", - "type": "tempBasal", - "endDate": "2023-07-29T02:00:58Z", - "unit": "U/hour" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T02:00:59Z", - "type": "tempBasal", - "endDate": "2023-07-29T02:00:59Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T02:06:04Z", - "type": "tempBasal", - "endDate": "2023-07-29T02:06:04Z", - "unit": "U/hour" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T02:10:55Z", - "type": "bolus", - "endDate": "2023-07-29T02:10:55Z", - "unit": "U" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T02:15:49Z", - "type": "bolus", - "endDate": "2023-07-29T02:15:49Z", - "unit": "U" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T02:21:02Z", - "type": "bolus", - "endDate": "2023-07-29T02:21:02Z", - "unit": "U" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T02:30:49Z", - "type": "bolus", - "endDate": "2023-07-29T02:30:49Z", - "unit": "U" - }, - { - "value": 0.25, - "startDate": "2023-07-29T02:35:55Z", - "type": "bolus", - "endDate": "2023-07-29T02:35:55Z", - "unit": "U" - }, - { - "value": 0.5, - "startDate": "2023-07-29T02:45:58Z", - "type": "bolus", - "endDate": "2023-07-29T02:45:58Z", - "unit": "U" - }, - { - "value": 0.29999999999999999, - "startDate": "2023-07-29T02:50:54Z", - "type": "bolus", - "endDate": "2023-07-29T02:50:54Z", - "unit": "U" - }, - { - "value": 0.25, - "startDate": "2023-07-29T02:55:59Z", - "type": "bolus", - "endDate": "2023-07-29T02:55:59Z", - "unit": "U" - }, - { - "value": 0.14999999999999999, - "startDate": "2023-07-29T03:00:49Z", - "type": "bolus", - "endDate": "2023-07-29T03:00:49Z", - "unit": "U" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T03:05:51Z", - "type": "bolus", - "endDate": "2023-07-29T03:05:51Z", - "unit": "U" - }, - { - "value": 0.14999999999999999, - "startDate": "2023-07-29T03:10:58Z", - "type": "bolus", - "endDate": "2023-07-29T03:10:58Z", - "unit": "U" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T03:20:59Z", - "type": "bolus", - "endDate": "2023-07-29T03:20:59Z", - "unit": "U" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T03:30:50Z", - "type": "bolus", - "endDate": "2023-07-29T03:30:50Z", - "unit": "U" - }, - { - "value": 0.14999999999999999, - "startDate": "2023-07-29T03:35:51Z", - "type": "bolus", - "endDate": "2023-07-29T03:35:51Z", - "unit": "U" - }, - { - "value": 0.25, - "startDate": "2023-07-29T03:45:51Z", - "type": "tempBasal", - "endDate": "2023-07-29T03:45:51Z", - "unit": "U/hour" - }, - { - "value": 0.45000000000000001, - "startDate": "2023-07-29T03:50:50Z", - "type": "tempBasal", - "endDate": "2023-07-29T03:50:50Z", - "unit": "U/hour" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T03:55:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T03:55:49Z", - "unit": "U/hour" - }, - { - "value": 0.29999999999999999, - "startDate": "2023-07-29T04:00:50Z", - "type": "tempBasal", - "endDate": "2023-07-29T04:00:50Z", - "unit": "U/hour" - }, - { - "value": 0.14999999999999999, - "startDate": "2023-07-29T04:05:51Z", - "type": "tempBasal", - "endDate": "2023-07-29T04:05:51Z", - "unit": "U/hour" - }, - { - "value": 0.5, - "startDate": "2023-07-29T04:10:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T04:10:49Z", - "unit": "U/hour" - }, - { - "value": 0.34999999999999998, - "startDate": "2023-07-29T04:25:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T04:25:49Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T04:36:12Z", - "type": "tempBasal", - "endDate": "2023-07-29T04:36:12Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T05:00:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T05:00:49Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T05:20:53Z", - "type": "tempBasal", - "endDate": "2023-07-29T05:20:53Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T05:45:52Z", - "type": "tempBasal", - "endDate": "2023-07-29T05:45:52Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T06:10:49Z", - "type": "tempBasal", - "endDate": "2023-07-29T06:10:49Z", - "unit": "U/hour" - }, - { - "value": 1.05, - "startDate": "2023-07-29T06:40:50Z", - "type": "bolus", - "endDate": "2023-07-29T06:40:50Z", - "unit": "U" - }, - { - "value": 0.69999999999999996, - "startDate": "2023-07-29T06:45:49Z", - "type": "bolus", - "endDate": "2023-07-29T06:45:49Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T06:50:50Z", - "type": "bolus", - "endDate": "2023-07-29T06:50:50Z", - "unit": "U" - }, - { - "value": 0.59999999999999998, - "startDate": "2023-07-29T06:55:52Z", - "type": "bolus", - "endDate": "2023-07-29T06:55:52Z", - "unit": "U" - }, - { - "value": 0.5, - "startDate": "2023-07-29T07:00:49Z", - "type": "bolus", - "endDate": "2023-07-29T07:00:49Z", - "unit": "U" - }, - { - "value": 0.80000000000000004, - "startDate": "2023-07-29T07:05:52Z", - "type": "bolus", - "endDate": "2023-07-29T07:05:52Z", - "unit": "U" - }, - { - "value": 0.69999999999999996, - "startDate": "2023-07-29T07:10:51Z", - "type": "bolus", - "endDate": "2023-07-29T07:10:51Z", - "unit": "U" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T07:15:50Z", - "type": "bolus", - "endDate": "2023-07-29T07:15:50Z", - "unit": "U" - }, - { - "value": 0, - "startDate": "2023-07-29T07:20:50Z", - "type": "tempBasal", - "endDate": "2023-07-29T07:20:50Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T07:45:58Z", - "type": "tempBasal", - "endDate": "2023-07-29T07:45:58Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T08:10:53Z", - "type": "tempBasal", - "endDate": "2023-07-29T08:10:53Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T08:30:55Z", - "type": "tempBasal", - "endDate": "2023-07-29T08:30:55Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T08:55:56Z", - "type": "tempBasal", - "endDate": "2023-07-29T08:55:56Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T09:20:52Z", - "type": "tempBasal", - "endDate": "2023-07-29T09:20:52Z", - "unit": "U/hour" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T10:00:51Z", - "type": "bolus", - "endDate": "2023-07-29T10:00:51Z", - "unit": "U" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T10:05:58Z", - "type": "bolus", - "endDate": "2023-07-29T10:05:58Z", - "unit": "U" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T10:20:52Z", - "type": "bolus", - "endDate": "2023-07-29T10:20:52Z", - "unit": "U" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T10:25:50Z", - "type": "bolus", - "endDate": "2023-07-29T10:25:50Z", - "unit": "U" - }, - { - "value": 0.050000000000000003, - "startDate": "2023-07-29T10:30:53Z", - "type": "bolus", - "endDate": "2023-07-29T10:30:53Z", - "unit": "U" - }, - { - "value": 0, - "startDate": "2023-07-29T11:25:51Z", - "type": "tempBasal", - "endDate": "2023-07-29T11:25:51Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T12:50:53Z", - "type": "tempBasal", - "endDate": "2023-07-29T12:50:53Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T13:00:54Z", - "type": "tempBasal", - "endDate": "2023-07-29T13:00:54Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T13:25:52Z", - "type": "tempBasal", - "endDate": "2023-07-29T13:25:52Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T13:50:53Z", - "type": "tempBasal", - "endDate": "2023-07-29T13:50:53Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T14:15:53Z", - "type": "tempBasal", - "endDate": "2023-07-29T14:15:53Z", - "unit": "U/hour" - }, - { - "value": 0.65000000000000002, - "startDate": "2023-07-29T15:00:51Z", - "type": "bolus", - "endDate": "2023-07-29T15:00:51Z", - "unit": "U" - }, - { - "value": 0.65000000000000002, - "startDate": "2023-07-29T15:05:51Z", - "type": "bolus", - "endDate": "2023-07-29T15:05:51Z", - "unit": "U" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T15:10:53Z", - "type": "bolus", - "endDate": "2023-07-29T15:10:53Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T15:15:51Z", - "type": "bolus", - "endDate": "2023-07-29T15:15:51Z", - "unit": "U" - }, - { - "value": 0.29999999999999999, - "startDate": "2023-07-29T15:21:14Z", - "type": "bolus", - "endDate": "2023-07-29T15:21:14Z", - "unit": "U" - }, - { - "value": 0.69999999999999996, - "startDate": "2023-07-29T15:30:51Z", - "type": "tempBasal", - "endDate": "2023-07-29T15:30:51Z", - "unit": "U/hour" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T15:35:53Z", - "type": "bolus", - "endDate": "2023-07-29T15:35:53Z", - "unit": "U" - }, - { - "value": 0.59999999999999998, - "startDate": "2023-07-29T15:40:51Z", - "type": "bolus", - "endDate": "2023-07-29T15:40:51Z", - "unit": "U" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T15:45:52Z", - "type": "bolus", - "endDate": "2023-07-29T15:45:52Z", - "unit": "U" - }, - { - "value": 0.40000000000000002, - "startDate": "2023-07-29T15:50:50Z", - "type": "bolus", - "endDate": "2023-07-29T15:50:50Z", - "unit": "U" - }, - { - "value": 0.59999999999999998, - "startDate": "2023-07-29T15:55:53Z", - "type": "bolus", - "endDate": "2023-07-29T15:55:53Z", - "unit": "U" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T16:00:51Z", - "type": "bolus", - "endDate": "2023-07-29T16:00:51Z", - "unit": "U" - }, - { - "value": 0.10000000000000001, - "startDate": "2023-07-29T16:05:51Z", - "type": "bolus", - "endDate": "2023-07-29T16:05:51Z", - "unit": "U" - }, - { - "value": 0.25, - "startDate": "2023-07-29T16:15:51Z", - "type": "bolus", - "endDate": "2023-07-29T16:15:51Z", - "unit": "U" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T16:20:50Z", - "type": "bolus", - "endDate": "2023-07-29T16:20:50Z", - "unit": "U" - }, - { - "value": 0, - "startDate": "2023-07-29T16:25:54Z", - "type": "tempBasal", - "endDate": "2023-07-29T16:25:54Z", - "unit": "U/hour" - }, - { - "value": 0.29999999999999999, - "startDate": "2023-07-29T16:55:51Z", - "type": "tempBasal", - "endDate": "2023-07-29T16:55:51Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T17:00:51Z", - "type": "tempBasal", - "endDate": "2023-07-29T17:00:51Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T17:25:54Z", - "type": "tempBasal", - "endDate": "2023-07-29T17:25:54Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T17:45:56Z", - "type": "tempBasal", - "endDate": "2023-07-29T17:45:56Z", - "unit": "U/hour" - }, - { - "value": 0, - "startDate": "2023-07-29T18:10:56Z", - "type": "tempBasal", - "endDate": "2023-07-29T18:10:56Z", - "unit": "U/hour" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T18:15:56Z", - "type": "bolus", - "endDate": "2023-07-29T18:15:56Z", - "unit": "U" - }, - { - "value": 4.0999999999999996, - "startDate": "2023-07-29T18:17:11Z", - "type": "bolus", - "endDate": "2023-07-29T18:17:11Z", - "unit": "U" - }, - { - "value": 0.29999999999999999, - "startDate": "2023-07-29T18:25:55Z", - "type": "bolus", - "endDate": "2023-07-29T18:25:55Z", - "unit": "U" - }, - { - "value": 0, - "startDate": "2023-07-29T18:40:51Z", - "type": "tempBasal", - "endDate": "2023-07-29T18:40:51Z", - "unit": "U/hour" - }, - { - "value": 0.34999999999999998, - "startDate": "2023-07-29T18:51:05Z", - "type": "tempBasal", - "endDate": "2023-07-29T18:51:05Z", - "unit": "U/hour" - }, - { - "value": 0.55000000000000004, - "startDate": "2023-07-29T18:51:07Z", - "type": "tempBasal", - "endDate": "2023-07-29T18:51:07Z", - "unit": "U/hour" - }, - { - "value": 0.20000000000000001, - "startDate": "2023-07-29T18:55:55Z", - "type": "tempBasal", - "endDate": "2023-07-29T18:55:55Z", - "unit": "U/hour" - }, - { - "value": 0.5, - "startDate": "2023-07-29T19:00:57Z", - "type": "tempBasal", - "endDate": "2023-07-29T19:00:57Z", - "unit": "U/hour" - } -] diff --git a/LoopTests/Fixtures/live_capture/live_capture_historic_glucose.json b/LoopTests/Fixtures/live_capture/live_capture_historic_glucose.json deleted file mode 100644 index 0da74e48fc..0000000000 --- a/LoopTests/Fixtures/live_capture/live_capture_historic_glucose.json +++ /dev/null @@ -1,854 +0,0 @@ -[ - { - "startDate": "2023-07-29T01:40:51Z", - "quantity": 254 - }, - { - "startDate": "2023-07-29T01:45:52Z", - "quantity": 259 - }, - { - "startDate": "2023-07-29T01:50:51Z", - "quantity": 252 - }, - { - "startDate": "2023-07-29T01:55:52Z", - "quantity": 250 - }, - { - "startDate": "2023-07-29T02:00:52Z", - "quantity": 234 - }, - { - "startDate": "2023-07-29T02:05:51Z", - "quantity": 222 - }, - { - "startDate": "2023-07-29T02:10:51Z", - "quantity": 233 - }, - { - "startDate": "2023-07-29T02:15:52Z", - "quantity": 235 - }, - { - "startDate": "2023-07-29T02:20:52Z", - "quantity": 231 - }, - { - "startDate": "2023-07-29T02:25:52Z", - "quantity": 235 - }, - { - "startDate": "2023-07-29T02:30:51Z", - "quantity": 232 - }, - { - "startDate": "2023-07-29T02:35:51Z", - "quantity": 235 - }, - { - "startDate": "2023-07-29T02:40:52Z", - "quantity": 244 - }, - { - "startDate": "2023-07-29T02:45:51Z", - "quantity": 247 - }, - { - "startDate": "2023-07-29T02:50:52Z", - "quantity": 249 - }, - { - "startDate": "2023-07-29T02:55:52Z", - "quantity": 251 - }, - { - "startDate": "2023-07-29T03:00:52Z", - "quantity": 250 - }, - { - "startDate": "2023-07-29T03:05:52Z", - "quantity": 253 - }, - { - "startDate": "2023-07-29T03:10:52Z", - "quantity": 253 - }, - { - "startDate": "2023-07-29T03:15:52Z", - "quantity": 253 - }, - { - "startDate": "2023-07-29T03:20:52Z", - "quantity": 248 - }, - { - "startDate": "2023-07-29T03:25:51Z", - "quantity": 254 - }, - { - "startDate": "2023-07-29T03:30:52Z", - "quantity": 253 - }, - { - "startDate": "2023-07-29T03:35:51Z", - "quantity": 244 - }, - { - "startDate": "2023-07-29T03:40:52Z", - "quantity": 239 - }, - { - "startDate": "2023-07-29T03:45:51Z", - "quantity": 234 - }, - { - "startDate": "2023-07-29T03:50:52Z", - "quantity": 225 - }, - { - "startDate": "2023-07-29T03:55:52Z", - "quantity": 220 - }, - { - "startDate": "2023-07-29T04:00:51Z", - "quantity": 213 - }, - { - "startDate": "2023-07-29T04:05:52Z", - "quantity": 211 - }, - { - "startDate": "2023-07-29T04:10:52Z", - "quantity": 209 - }, - { - "startDate": "2023-07-29T04:15:52Z", - "quantity": 201 - }, - { - "startDate": "2023-07-29T04:20:52Z", - "quantity": 193 - }, - { - "startDate": "2023-07-29T04:25:52Z", - "quantity": 190 - }, - { - "startDate": "2023-07-29T04:30:51Z", - "quantity": 180 - }, - { - "startDate": "2023-07-29T04:35:51Z", - "quantity": 154 - }, - { - "startDate": "2023-07-29T04:40:52Z", - "quantity": 118 - }, - { - "startDate": "2023-07-29T04:45:52Z", - "quantity": 110 - }, - { - "startDate": "2023-07-29T04:50:51Z", - "quantity": 114 - }, - { - "startDate": "2023-07-29T04:55:51Z", - "quantity": 120 - }, - { - "startDate": "2023-07-29T05:00:51Z", - "quantity": 109 - }, - { - "startDate": "2023-07-29T05:05:51Z", - "quantity": 104 - }, - { - "startDate": "2023-07-29T05:10:51Z", - "quantity": 101 - }, - { - "startDate": "2023-07-29T05:15:52Z", - "quantity": 95 - }, - { - "startDate": "2023-07-29T05:20:52Z", - "quantity": 86 - }, - { - "startDate": "2023-07-29T05:25:51Z", - "quantity": 82 - }, - { - "startDate": "2023-07-29T05:30:52Z", - "quantity": 77 - }, - { - "startDate": "2023-07-29T05:35:52Z", - "quantity": 72 - }, - { - "startDate": "2023-07-29T05:40:51Z", - "quantity": 68 - }, - { - "startDate": "2023-07-29T05:45:52Z", - "quantity": 67 - }, - { - "startDate": "2023-07-29T05:50:52Z", - "quantity": 59 - }, - { - "startDate": "2023-07-29T05:55:52Z", - "quantity": 62 - }, - { - "startDate": "2023-07-29T06:00:52Z", - "quantity": 64 - }, - { - "startDate": "2023-07-29T06:05:52Z", - "quantity": 64 - }, - { - "startDate": "2023-07-29T06:10:52Z", - "quantity": 66 - }, - { - "startDate": "2023-07-29T06:15:52Z", - "quantity": 67 - }, - { - "startDate": "2023-07-29T06:20:52Z", - "quantity": 67 - }, - { - "startDate": "2023-07-29T06:25:52Z", - "quantity": 72 - }, - { - "startDate": "2023-07-29T06:30:52Z", - "quantity": 90 - }, - { - "startDate": "2023-07-29T06:35:52Z", - "quantity": 125 - }, - { - "startDate": "2023-07-29T06:40:52Z", - "quantity": 134 - }, - { - "startDate": "2023-07-29T06:45:52Z", - "quantity": 145 - }, - { - "startDate": "2023-07-29T06:50:52Z", - "quantity": 169 - }, - { - "startDate": "2023-07-29T06:55:52Z", - "quantity": 183 - }, - { - "startDate": "2023-07-29T07:00:52Z", - "quantity": 228 - }, - { - "startDate": "2023-07-29T07:05:53Z", - "quantity": 257 - }, - { - "startDate": "2023-07-29T07:10:52Z", - "quantity": 250 - }, - { - "startDate": "2023-07-29T07:15:52Z", - "quantity": 232 - }, - { - "startDate": "2023-07-29T07:20:52Z", - "quantity": 225 - }, - { - "startDate": "2023-07-29T07:25:52Z", - "quantity": 241 - }, - { - "startDate": "2023-07-29T07:30:52Z", - "quantity": 233 - }, - { - "startDate": "2023-07-29T07:35:53Z", - "quantity": 227 - }, - { - "startDate": "2023-07-29T07:40:52Z", - "quantity": 222 - }, - { - "startDate": "2023-07-29T07:45:52Z", - "quantity": 216 - }, - { - "startDate": "2023-07-29T07:50:52Z", - "quantity": 211 - }, - { - "startDate": "2023-07-29T07:55:52Z", - "quantity": 208 - }, - { - "startDate": "2023-07-29T08:00:52Z", - "quantity": 207 - }, - { - "startDate": "2023-07-29T08:05:52Z", - "quantity": 209 - }, - { - "startDate": "2023-07-29T08:10:52Z", - "quantity": 200 - }, - { - "startDate": "2023-07-29T08:15:52Z", - "quantity": 193 - }, - { - "startDate": "2023-07-29T08:20:52Z", - "quantity": 186 - }, - { - "startDate": "2023-07-29T08:25:52Z", - "quantity": 176 - }, - { - "startDate": "2023-07-29T08:30:52Z", - "quantity": 169 - }, - { - "startDate": "2023-07-29T08:35:52Z", - "quantity": 166 - }, - { - "startDate": "2023-07-29T08:40:52Z", - "quantity": 170 - }, - { - "startDate": "2023-07-29T08:45:52Z", - "quantity": 161 - }, - { - "startDate": "2023-07-29T08:50:53Z", - "quantity": 150 - }, - { - "startDate": "2023-07-29T08:55:53Z", - "quantity": 144 - }, - { - "startDate": "2023-07-29T09:00:53Z", - "quantity": 136 - }, - { - "startDate": "2023-07-29T09:05:53Z", - "quantity": 128 - }, - { - "startDate": "2023-07-29T09:10:52Z", - "quantity": 127 - }, - { - "startDate": "2023-07-29T09:15:53Z", - "quantity": 126 - }, - { - "startDate": "2023-07-29T09:20:53Z", - "quantity": 121 - }, - { - "startDate": "2023-07-29T09:25:52Z", - "quantity": 117 - }, - { - "startDate": "2023-07-29T09:30:52Z", - "quantity": 116 - }, - { - "startDate": "2023-07-29T09:35:53Z", - "quantity": 115 - }, - { - "startDate": "2023-07-29T09:40:52Z", - "quantity": 113 - }, - { - "startDate": "2023-07-29T09:45:52Z", - "quantity": 113 - }, - { - "startDate": "2023-07-29T09:50:52Z", - "quantity": 109 - }, - { - "startDate": "2023-07-29T09:55:53Z", - "quantity": 114 - }, - { - "startDate": "2023-07-29T10:00:52Z", - "quantity": 115 - }, - { - "startDate": "2023-07-29T10:05:52Z", - "quantity": 114 - }, - { - "startDate": "2023-07-29T10:10:53Z", - "quantity": 111 - }, - { - "startDate": "2023-07-29T10:15:52Z", - "quantity": 112 - }, - { - "startDate": "2023-07-29T10:20:52Z", - "quantity": 113 - }, - { - "startDate": "2023-07-29T10:25:53Z", - "quantity": 114 - }, - { - "startDate": "2023-07-29T10:30:52Z", - "quantity": 113 - }, - { - "startDate": "2023-07-29T10:35:52Z", - "quantity": 113 - }, - { - "startDate": "2023-07-29T10:40:53Z", - "quantity": 111 - }, - { - "startDate": "2023-07-29T10:45:53Z", - "quantity": 110 - }, - { - "startDate": "2023-07-29T10:50:53Z", - "quantity": 111 - }, - { - "startDate": "2023-07-29T10:55:52Z", - "quantity": 112 - }, - { - "startDate": "2023-07-29T11:00:53Z", - "quantity": 112 - }, - { - "startDate": "2023-07-29T11:05:52Z", - "quantity": 111 - }, - { - "startDate": "2023-07-29T11:10:52Z", - "quantity": 109 - }, - { - "startDate": "2023-07-29T11:15:52Z", - "quantity": 107 - }, - { - "startDate": "2023-07-29T11:20:52Z", - "quantity": 104 - }, - { - "startDate": "2023-07-29T11:25:53Z", - "quantity": 104 - }, - { - "startDate": "2023-07-29T11:30:53Z", - "quantity": 104 - }, - { - "startDate": "2023-07-29T11:35:53Z", - "quantity": 97 - }, - { - "startDate": "2023-07-29T11:40:53Z", - "quantity": 98 - }, - { - "startDate": "2023-07-29T11:45:52Z", - "quantity": 98 - }, - { - "startDate": "2023-07-29T11:50:53Z", - "quantity": 99 - }, - { - "startDate": "2023-07-29T11:55:52Z", - "quantity": 97 - }, - { - "startDate": "2023-07-29T12:00:53Z", - "quantity": 97 - }, - { - "startDate": "2023-07-29T12:05:53Z", - "quantity": 97 - }, - { - "startDate": "2023-07-29T12:10:53Z", - "quantity": 97 - }, - { - "startDate": "2023-07-29T12:15:52Z", - "quantity": 97 - }, - { - "startDate": "2023-07-29T12:20:53Z", - "quantity": 99 - }, - { - "startDate": "2023-07-29T12:25:53Z", - "quantity": 96 - }, - { - "startDate": "2023-07-29T12:30:53Z", - "quantity": 95 - }, - { - "startDate": "2023-07-29T12:35:53Z", - "quantity": 95 - }, - { - "startDate": "2023-07-29T12:40:53Z", - "quantity": 94 - }, - { - "startDate": "2023-07-29T12:45:53Z", - "quantity": 89 - }, - { - "startDate": "2023-07-29T12:50:53Z", - "quantity": 89 - }, - { - "startDate": "2023-07-29T12:55:53Z", - "quantity": 91 - }, - { - "startDate": "2023-07-29T13:00:52Z", - "quantity": 86 - }, - { - "startDate": "2023-07-29T13:05:53Z", - "quantity": 83 - }, - { - "startDate": "2023-07-29T13:10:53Z", - "quantity": 86 - }, - { - "startDate": "2023-07-29T13:15:53Z", - "quantity": 84 - }, - { - "startDate": "2023-07-29T13:20:53Z", - "quantity": 81 - }, - { - "startDate": "2023-07-29T13:25:53Z", - "quantity": 80 - }, - { - "startDate": "2023-07-29T13:30:53Z", - "quantity": 78 - }, - { - "startDate": "2023-07-29T13:35:53Z", - "quantity": 78 - }, - { - "startDate": "2023-07-29T13:40:53Z", - "quantity": 74 - }, - { - "startDate": "2023-07-29T13:45:53Z", - "quantity": 72 - }, - { - "startDate": "2023-07-29T13:50:52Z", - "quantity": 72 - }, - { - "startDate": "2023-07-29T13:55:53Z", - "quantity": 71 - }, - { - "startDate": "2023-07-29T14:00:53Z", - "quantity": 70 - }, - { - "startDate": "2023-07-29T14:05:53Z", - "quantity": 69 - }, - { - "startDate": "2023-07-29T14:10:53Z", - "quantity": 72 - }, - { - "startDate": "2023-07-29T14:15:53Z", - "quantity": 75 - }, - { - "startDate": "2023-07-29T14:20:53Z", - "quantity": 78 - }, - { - "startDate": "2023-07-29T14:25:53Z", - "quantity": 83 - }, - { - "startDate": "2023-07-29T14:30:53Z", - "quantity": 85 - }, - { - "startDate": "2023-07-29T14:35:53Z", - "quantity": 88 - }, - { - "startDate": "2023-07-29T14:40:53Z", - "quantity": 98 - }, - { - "startDate": "2023-07-29T14:45:53Z", - "quantity": 94 - }, - { - "startDate": "2023-07-29T14:50:53Z", - "quantity": 93 - }, - { - "startDate": "2023-07-29T14:55:53Z", - "quantity": 113 - }, - { - "startDate": "2023-07-29T15:00:53Z", - "quantity": 128 - }, - { - "startDate": "2023-07-29T15:05:53Z", - "quantity": 126 - }, - { - "startDate": "2023-07-29T15:10:54Z", - "quantity": 148 - }, - { - "startDate": "2023-07-29T15:15:54Z", - "quantity": 161 - }, - { - "startDate": "2023-07-29T15:20:54Z", - "quantity": 157 - }, - { - "startDate": "2023-07-29T15:25:53Z", - "quantity": 151 - }, - { - "startDate": "2023-07-29T15:30:53Z", - "quantity": 180 - }, - { - "startDate": "2023-07-29T15:35:53Z", - "quantity": 203 - }, - { - "startDate": "2023-07-29T15:40:54Z", - "quantity": 196 - }, - { - "startDate": "2023-07-29T15:45:54Z", - "quantity": 225 - }, - { - "startDate": "2023-07-29T15:50:53Z", - "quantity": 248 - }, - { - "startDate": "2023-07-29T15:55:53Z", - "quantity": 245 - }, - { - "startDate": "2023-07-29T16:00:53Z", - "quantity": 249 - }, - { - "startDate": "2023-07-29T16:05:53Z", - "quantity": 248 - }, - { - "startDate": "2023-07-29T16:10:54Z", - "quantity": 267 - }, - { - "startDate": "2023-07-29T16:15:53Z", - "quantity": 266 - }, - { - "startDate": "2023-07-29T16:20:54Z", - "quantity": 259 - }, - { - "startDate": "2023-07-29T16:25:54Z", - "quantity": 259 - }, - { - "startDate": "2023-07-29T16:30:53Z", - "quantity": 246 - }, - { - "startDate": "2023-07-29T16:35:54Z", - "quantity": 228 - }, - { - "startDate": "2023-07-29T16:40:53Z", - "quantity": 232 - }, - { - "startDate": "2023-07-29T16:45:53Z", - "quantity": 244 - }, - { - "startDate": "2023-07-29T16:50:53Z", - "quantity": 233 - }, - { - "startDate": "2023-07-29T16:55:53Z", - "quantity": 218 - }, - { - "startDate": "2023-07-29T17:00:53Z", - "quantity": 212 - }, - { - "startDate": "2023-07-29T17:05:53Z", - "quantity": 206 - }, - { - "startDate": "2023-07-29T17:10:53Z", - "quantity": 191 - }, - { - "startDate": "2023-07-29T17:15:54Z", - "quantity": 170 - }, - { - "startDate": "2023-07-29T17:20:54Z", - "quantity": 164 - }, - { - "startDate": "2023-07-29T17:25:53Z", - "quantity": 161 - }, - { - "startDate": "2023-07-29T17:30:53Z", - "quantity": 162 - }, - { - "startDate": "2023-07-29T17:35:53Z", - "quantity": 140 - }, - { - "startDate": "2023-07-29T17:40:54Z", - "quantity": 110 - }, - { - "startDate": "2023-07-29T17:45:54Z", - "quantity": 106 - }, - { - "startDate": "2023-07-29T17:50:53Z", - "quantity": 107 - }, - { - "startDate": "2023-07-29T17:55:53Z", - "quantity": 105 - }, - { - "startDate": "2023-07-29T18:00:53Z", - "quantity": 106 - }, - { - "startDate": "2023-07-29T18:05:54Z", - "quantity": 111 - }, - { - "startDate": "2023-07-29T18:10:53Z", - "quantity": 115 - }, - { - "startDate": "2023-07-29T18:15:53Z", - "quantity": 109 - }, - { - "startDate": "2023-07-29T18:20:54Z", - "quantity": 117 - }, - { - "startDate": "2023-07-29T18:25:54Z", - "quantity": 135 - }, - { - "startDate": "2023-07-29T18:30:53Z", - "quantity": 120 - }, - { - "startDate": "2023-07-29T18:35:53Z", - "quantity": 117 - }, - { - "startDate": "2023-07-29T18:40:53Z", - "quantity": 116 - }, - { - "startDate": "2023-07-29T18:45:53Z", - "quantity": 125 - }, - { - "startDate": "2023-07-29T18:50:53Z", - "quantity": 131 - }, - { - "startDate": "2023-07-29T18:55:53Z", - "quantity": 136 - }, - { - "startDate": "2023-07-29T19:00:53Z", - "quantity": 142 - }, - { - "startDate": "2023-07-29T19:05:53Z", - "quantity": 152 - }, - { - "startDate": "2023-07-29T19:10:54Z", - "quantity": 159 - }, - { - "startDate": "2023-07-29T19:15:54Z", - "quantity": 176 - }, - { - "startDate": "2023-07-29T19:20:54Z", - "quantity": 170 - } -] diff --git a/LoopTests/Managers/LoopAlgorithmTests.swift b/LoopTests/Managers/LoopAlgorithmTests.swift index 3f6476c8c8..92292a9569 100644 --- a/LoopTests/Managers/LoopAlgorithmTests.swift +++ b/LoopTests/Managers/LoopAlgorithmTests.swift @@ -70,8 +70,6 @@ final class LoopAlgorithmTests: XCTestCase { XCTAssertEqual(expected.startDate, calculated.startDate) XCTAssertEqual(expected.quantity.doubleValue(for: .milligramsPerDeciliter), calculated.quantity.doubleValue(for: .milligramsPerDeciliter), accuracy: defaultAccuracy) } - - //XCTAssertEqual(1.99, recommendedBasal!.unitsPerHour, accuracy: defaultAccuracy) } } From 687c055021d03d59e537b537ea977a0afe3d2803 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Tue, 5 Sep 2023 07:56:18 -0500 Subject: [PATCH 5/6] CarbValue struct update --- Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift | 2 +- Loop/Managers/LoopDataManager.swift | 2 +- LoopTests/Managers/LoopAlgorithmTests.swift | 1 - LoopTests/ViewModels/BolusEntryViewModelTests.swift | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift b/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift index 558d634539..53f81c5209 100644 --- a/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift +++ b/Loop/Extensions/DosingDecisionStore+SimulatedCoreData.swift @@ -147,7 +147,7 @@ fileprivate extension StoredDosingDecision { healthKitEligibleDate: nil) let carbsOnBoard = CarbValue(startDate: date, endDate: date.addingTimeInterval(.minutes(5)), - quantity: HKQuantity(unit: .gram(), doubleValue: 45.5)) + value: 45.5) let insulinOnBoard = InsulinValue(startDate: date, value: 1.5) let glucoseTargetRangeSchedule = GlucoseRangeSchedule(rangeSchedule: DailyQuantitySchedule(unit: .milligramsPerDeciliter, dailyItems: [RepeatingScheduleValue(startTime: .hours(0), value: DoubleRange(minValue: 100.0, maxValue: 110.0)), diff --git a/Loop/Managers/LoopDataManager.swift b/Loop/Managers/LoopDataManager.swift index 73b7e79abb..7927e5982e 100644 --- a/Loop/Managers/LoopDataManager.swift +++ b/Loop/Managers/LoopDataManager.swift @@ -1101,7 +1101,7 @@ extension LoopDataManager { switch error { case .noData: // when there is no data, carbs on board is set to 0 - self.carbsOnBoard = CarbValue(startDate: Date(), quantity: HKQuantity(unit: .gram(), doubleValue: 0)) + self.carbsOnBoard = CarbValue(startDate: Date(), value: 0) default: self.carbsOnBoard = nil warnings.append(.fetchDataWarning(.carbsOnBoard(error: error))) diff --git a/LoopTests/Managers/LoopAlgorithmTests.swift b/LoopTests/Managers/LoopAlgorithmTests.swift index 92292a9569..89831b4326 100644 --- a/LoopTests/Managers/LoopAlgorithmTests.swift +++ b/LoopTests/Managers/LoopAlgorithmTests.swift @@ -71,5 +71,4 @@ final class LoopAlgorithmTests: XCTestCase { XCTAssertEqual(expected.quantity.doubleValue(for: .milligramsPerDeciliter), calculated.quantity.doubleValue(for: .milligramsPerDeciliter), accuracy: defaultAccuracy) } } - } diff --git a/LoopTests/ViewModels/BolusEntryViewModelTests.swift b/LoopTests/ViewModels/BolusEntryViewModelTests.swift index 2877cb257b..c373b639b1 100644 --- a/LoopTests/ViewModels/BolusEntryViewModelTests.swift +++ b/LoopTests/ViewModels/BolusEntryViewModelTests.swift @@ -283,7 +283,7 @@ class BolusEntryViewModelTests: XCTestCase { } func testUpdateCarbsOnBoard() async throws { - delegate.carbsOnBoardResult = .success(CarbValue(startDate: Self.exampleStartDate, endDate: Self.exampleEndDate, quantity: Self.exampleCarbQuantity)) + delegate.carbsOnBoardResult = .success(CarbValue(startDate: Self.exampleStartDate, endDate: Self.exampleEndDate, value: Self.exampleCarbQuantity.doubleValue(for: .gram()))) XCTAssertNil(bolusEntryViewModel.activeCarbs) await bolusEntryViewModel.update() XCTAssertEqual(Self.exampleCarbQuantity, bolusEntryViewModel.activeCarbs) From d190fd5def92d56e707743c199fecf154d40ad34 Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Wed, 6 Sep 2023 10:59:08 -0500 Subject: [PATCH 6/6] Update live capture test with updated durations of input data, and streamline app startup when running app just for tests --- Loop/AppDelegate.swift | 12 +- Loop/Managers/LoopDataManager.swift | 4 +- Loop/Models/LoopSettings+Loop.swift | 5 +- .../live_capture/live_capture_input.json | 1465 ++++++----------- .../live_capture_predicted_glucose.json | 314 ++-- LoopTests/Managers/LoopAlgorithmTests.swift | 3 +- LoopTests/Mock Stores/MockCarbStore.swift | 4 +- 7 files changed, 674 insertions(+), 1133 deletions(-) diff --git a/Loop/AppDelegate.swift b/Loop/AppDelegate.swift index 5da6ce9cb6..41569632d3 100644 --- a/Loop/AppDelegate.swift +++ b/Loop/AppDelegate.swift @@ -22,8 +22,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, WindowProvider { setenv("CFNETWORK_DIAGNOSTICS", "3", 1) - loopAppManager.initialize(windowProvider: self, launchOptions: launchOptions) - loopAppManager.launch() + if ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] == nil { + // Code only executes when not running tests + loopAppManager.initialize(windowProvider: self, launchOptions: launchOptions) + loopAppManager.launch() + } return loopAppManager.isLaunchComplete } @@ -32,7 +35,10 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, WindowProvider { func applicationDidBecomeActive(_ application: UIApplication) { log.default(#function) - loopAppManager.didBecomeActive() + if ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] == nil { + // Code only executes when not running tests + loopAppManager.didBecomeActive() + } } func applicationWillResignActive(_ application: UIApplication) { diff --git a/Loop/Managers/LoopDataManager.swift b/Loop/Managers/LoopDataManager.swift index 7927e5982e..e532b42e54 100644 --- a/Loop/Managers/LoopDataManager.swift +++ b/Loop/Managers/LoopDataManager.swift @@ -441,9 +441,9 @@ final class LoopDataManager { if lastIntegralRetrospectiveCorrectionEnabled != currentIntegralRetrospectiveCorrectionEnabled || cachedRetrospectiveCorrection == nil { lastIntegralRetrospectiveCorrectionEnabled = currentIntegralRetrospectiveCorrectionEnabled if currentIntegralRetrospectiveCorrectionEnabled { - cachedRetrospectiveCorrection = IntegralRetrospectiveCorrection(effectDuration: LoopSettings.retrospectiveCorrectionEffectDuration) + cachedRetrospectiveCorrection = IntegralRetrospectiveCorrection(effectDuration: LoopMath.retrospectiveCorrectionEffectDuration) } else { - cachedRetrospectiveCorrection = StandardRetrospectiveCorrection(effectDuration: LoopSettings.retrospectiveCorrectionEffectDuration) + cachedRetrospectiveCorrection = StandardRetrospectiveCorrection(effectDuration: LoopMath.retrospectiveCorrectionEffectDuration) } } diff --git a/Loop/Models/LoopSettings+Loop.swift b/Loop/Models/LoopSettings+Loop.swift index fd35b6416b..e4952934cb 100644 --- a/Loop/Models/LoopSettings+Loop.swift +++ b/Loop/Models/LoopSettings+Loop.swift @@ -16,8 +16,5 @@ extension LoopSettings { inputs.remove(.retrospection) } return inputs - } - - static let retrospectiveCorrectionEffectDuration = TimeInterval(hours: 1) - + } } diff --git a/LoopTests/Fixtures/live_capture/live_capture_input.json b/LoopTests/Fixtures/live_capture/live_capture_input.json index 95c27a166b..f010194a63 100644 --- a/LoopTests/Fixtures/live_capture/live_capture_input.json +++ b/LoopTests/Fixtures/live_capture/live_capture_input.json @@ -2,1476 +2,1003 @@ "carbEntries" : [ { "absorptionTime" : 10800, - "quantity" : 20, - "startDate" : "2023-08-17T20:05:47Z" + "quantity" : 22, + "startDate" : "2023-06-22T19:20:53Z" }, { "absorptionTime" : 10800, - "quantity" : 10, - "startDate" : "2023-08-18T18:01:14Z" + "quantity" : 75, + "startDate" : "2023-06-22T21:04:45Z" + }, + { + "absorptionTime" : 10800, + "quantity" : 47, + "startDate" : "2023-06-23T02:10:13Z" } ], "doses" : [ { - "endDate" : "2023-08-17T18:21:55Z", - "startDate" : "2023-08-17T18:01:54Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 - }, - { - "endDate" : "2023-08-17T18:42:08Z", - "startDate" : "2023-08-17T18:21:55Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 - }, - { - "endDate" : "2023-08-17T18:47:09Z", - "startDate" : "2023-08-17T18:42:08Z", + "endDate" : "2023-06-22T16:22:40Z", + "startDate" : "2023-06-22T16:12:40Z", "type" : "basal", "unit" : "U", - "value" : 0.1 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-17T19:07:04Z", - "startDate" : "2023-08-17T18:47:09Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-22T16:17:54Z", + "startDate" : "2023-06-22T16:17:46Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.20000000000000001 }, { - "endDate" : "2023-08-17T19:11:53Z", - "startDate" : "2023-08-17T19:07:04Z", + "endDate" : "2023-06-22T16:32:40Z", + "startDate" : "2023-06-22T16:22:40Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-17T19:26:55Z", - "startDate" : "2023-08-17T19:11:53Z", + "endDate" : "2023-06-22T16:47:39Z", + "startDate" : "2023-06-22T16:32:40Z", "type" : "basal", "unit" : "U", - "value" : 0.3 - }, - { - "endDate" : "2023-08-17T19:47:02Z", - "startDate" : "2023-08-17T19:26:55Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 - }, - { - "endDate" : "2023-08-17T20:06:54Z", - "startDate" : "2023-08-17T19:47:02Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-17T20:26:51Z", - "startDate" : "2023-08-17T20:06:54Z", + "endDate" : "2023-06-22T16:57:41Z", + "startDate" : "2023-06-22T16:47:39Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-17T20:46:53Z", - "startDate" : "2023-08-17T20:26:51Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 - }, - { - "endDate" : "2023-08-17T21:06:52Z", - "startDate" : "2023-08-17T20:46:53Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 - }, - { - "endDate" : "2023-08-17T21:46:54Z", - "startDate" : "2023-08-17T21:06:52Z", + "endDate" : "2023-06-22T17:02:38Z", + "startDate" : "2023-06-22T16:57:41Z", "type" : "basal", "unit" : "U", - "value" : 0.75 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-17T21:51:52Z", - "startDate" : "2023-08-17T21:46:54Z", + "endDate" : "2023-06-22T17:07:38Z", + "startDate" : "2023-06-22T17:02:38Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-17T21:56:54Z", - "startDate" : "2023-08-17T21:51:52Z", + "endDate" : "2023-06-22T17:22:45Z", + "startDate" : "2023-06-22T17:07:38Z", "type" : "basal", "unit" : "U", - "value" : 0.1 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-17T22:11:51Z", - "startDate" : "2023-08-17T21:56:54Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 - }, - { - "endDate" : "2023-08-17T23:07:00Z", - "startDate" : "2023-08-17T22:11:51Z", - "type" : "basal", + "endDate" : "2023-06-22T17:12:46Z", + "startDate" : "2023-06-22T17:12:42Z", + "type" : "bolus", "unit" : "U", - "value" : 1 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-17T23:11:53Z", - "startDate" : "2023-08-17T23:07:00Z", + "endDate" : "2023-06-22T17:27:39Z", + "startDate" : "2023-06-22T17:22:45Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-17T23:42:02Z", - "startDate" : "2023-08-17T23:11:53Z", + "endDate" : "2023-06-22T17:27:39Z", + "startDate" : "2023-06-22T17:27:39Z", "type" : "basal", "unit" : "U", - "value" : 0.55 - }, - { - "endDate" : "2023-08-18T00:02:07Z", - "startDate" : "2023-08-17T23:42:02Z", - "type" : "tempBasal", - "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T00:16:52Z", - "startDate" : "2023-08-18T00:02:07Z", + "endDate" : "2023-06-22T17:32:39Z", + "startDate" : "2023-06-22T17:27:39Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T01:26:52Z", - "startDate" : "2023-08-18T00:16:52Z", + "endDate" : "2023-06-22T18:07:38Z", + "startDate" : "2023-06-22T17:32:39Z", "type" : "basal", "unit" : "U", - "value" : 1.3 - }, - { - "endDate" : "2023-08-18T01:46:54Z", - "startDate" : "2023-08-18T01:26:52Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "value" : 0.25 }, { - "endDate" : "2023-08-18T01:56:52Z", - "startDate" : "2023-08-18T01:46:54Z", - "type" : "basal", + "endDate" : "2023-06-22T17:32:45Z", + "startDate" : "2023-06-22T17:32:41Z", + "type" : "bolus", "unit" : "U", - "value" : 0.2 - }, - { - "endDate" : "2023-08-18T02:11:53Z", - "startDate" : "2023-08-18T01:56:52Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T02:41:53Z", - "startDate" : "2023-08-18T02:11:53Z", - "type" : "basal", + "endDate" : "2023-06-22T17:42:40Z", + "startDate" : "2023-06-22T17:42:38Z", + "type" : "bolus", "unit" : "U", - "value" : 0.55 - }, - { - "endDate" : "2023-08-18T02:47:02Z", - "startDate" : "2023-08-18T02:41:53Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T03:01:55Z", - "startDate" : "2023-08-18T02:47:02Z", - "type" : "basal", + "endDate" : "2023-06-22T17:47:43Z", + "startDate" : "2023-06-22T17:47:39Z", + "type" : "bolus", "unit" : "U", - "value" : 0.25 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T03:06:52Z", - "startDate" : "2023-08-18T03:01:55Z", + "endDate" : "2023-06-22T18:12:38Z", + "startDate" : "2023-06-22T18:07:38Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T04:06:54Z", - "startDate" : "2023-08-18T03:06:52Z", + "endDate" : "2023-06-22T19:17:40Z", + "startDate" : "2023-06-22T18:12:38Z", "type" : "basal", "unit" : "U", - "value" : 1.1 + "value" : 0.45000000000000001 }, { - "endDate" : "2023-08-18T03:22:02Z", - "startDate" : "2023-08-18T03:21:50Z", + "endDate" : "2023-06-22T19:02:43Z", + "startDate" : "2023-06-22T19:02:39Z", "type" : "bolus", "unit" : "U", - "value" : 0.3 + "value" : 0.10000000000000001 + }, + { + "endDate" : "2023-06-22T19:22:43Z", + "startDate" : "2023-06-22T19:17:40Z", + "type" : "tempBasal", + "unit" : "U\/hour", + "value" : 0 }, { - "endDate" : "2023-08-18T03:27:09Z", - "startDate" : "2023-08-18T03:27:05Z", + "endDate" : "2023-06-22T19:21:49Z", + "startDate" : "2023-06-22T19:21:01Z", "type" : "bolus", "unit" : "U", - "value" : 0.1 + "value" : 1.2 }, { - "endDate" : "2023-08-18T03:31:54Z", - "startDate" : "2023-08-18T03:31:50Z", - "type" : "bolus", + "endDate" : "2023-06-22T19:37:37Z", + "startDate" : "2023-06-22T19:22:43Z", + "type" : "basal", "unit" : "U", - "value" : 0.1 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T03:41:53Z", - "startDate" : "2023-08-18T03:41:49Z", + "endDate" : "2023-06-22T19:27:43Z", + "startDate" : "2023-06-22T19:27:39Z", "type" : "bolus", "unit" : "U", - "value" : 0.1 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T04:11:52Z", - "startDate" : "2023-08-18T04:06:54Z", + "endDate" : "2023-06-22T19:57:48Z", + "startDate" : "2023-06-22T19:37:37Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0.75 + "value" : 0 }, { - "endDate" : "2023-08-18T04:21:54Z", - "startDate" : "2023-08-18T04:11:52Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0.65 + "endDate" : "2023-06-22T19:57:48Z", + "startDate" : "2023-06-22T19:57:48Z", + "type" : "basal", + "unit" : "U", + "value" : 0 }, { - "endDate" : "2023-08-18T04:26:54Z", - "startDate" : "2023-08-18T04:21:54Z", + "endDate" : "2023-06-22T20:02:39Z", + "startDate" : "2023-06-22T19:57:48Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0.45 + "value" : 0 }, { - "endDate" : "2023-08-18T04:41:56Z", - "startDate" : "2023-08-18T04:26:54Z", + "endDate" : "2023-06-22T20:07:40Z", + "startDate" : "2023-06-22T20:02:39Z", "type" : "basal", "unit" : "U", - "value" : 0.3 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T04:46:57Z", - "startDate" : "2023-08-18T04:41:56Z", + "endDate" : "2023-06-22T20:12:40Z", + "startDate" : "2023-06-22T20:07:40Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0.4 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T04:51:52Z", - "startDate" : "2023-08-18T04:46:57Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0.1 + "endDate" : "2023-06-22T20:52:45Z", + "startDate" : "2023-06-22T20:12:40Z", + "type" : "basal", + "unit" : "U", + "value" : 0.25 }, { - "endDate" : "2023-08-18T05:00:00Z", - "startDate" : "2023-08-18T04:51:52Z", + "endDate" : "2023-06-22T21:07:43Z", + "startDate" : "2023-06-22T20:52:45Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T05:01:54Z", - "startDate" : "2023-08-18T05:00:00Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-22T21:07:49Z", + "startDate" : "2023-06-22T21:04:51Z", + "type" : "bolus", + "unit" : "U", + "value" : 4.4500000000000002 }, { - "endDate" : "2023-08-18T05:11:52Z", - "startDate" : "2023-08-18T05:01:54Z", + "endDate" : "2023-06-22T21:47:38Z", + "startDate" : "2023-06-22T21:07:43Z", "type" : "basal", "unit" : "U", - "value" : 0.2 - }, - { - "endDate" : "2023-08-18T05:16:57Z", - "startDate" : "2023-08-18T05:11:52Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "value" : 0.25 }, { - "endDate" : "2023-08-18T05:27:01Z", - "startDate" : "2023-08-18T05:16:57Z", - "type" : "basal", + "endDate" : "2023-06-22T21:12:42Z", + "startDate" : "2023-06-22T21:12:40Z", + "type" : "bolus", "unit" : "U", - "value" : 0.2 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T05:46:52Z", - "startDate" : "2023-08-18T05:27:01Z", + "endDate" : "2023-06-22T22:07:39Z", + "startDate" : "2023-06-22T21:47:38Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T06:01:53Z", - "startDate" : "2023-08-18T05:46:52Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-22T23:42:40Z", + "startDate" : "2023-06-22T22:07:39Z", + "type" : "basal", + "unit" : "U", + "value" : 0.65000000000000002 }, { - "endDate" : "2023-08-18T06:06:56Z", - "startDate" : "2023-08-18T06:01:53Z", - "type" : "basal", + "endDate" : "2023-06-22T22:27:46Z", + "startDate" : "2023-06-22T22:27:38Z", + "type" : "bolus", "unit" : "U", - "value" : 0.1 + "value" : 0.20000000000000001 }, { - "endDate" : "2023-08-18T06:22:05Z", - "startDate" : "2023-08-18T06:06:56Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-22T22:37:44Z", + "startDate" : "2023-06-22T22:37:40Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T07:16:55Z", - "startDate" : "2023-08-18T06:22:05Z", - "type" : "basal", + "endDate" : "2023-06-22T22:42:42Z", + "startDate" : "2023-06-22T22:42:40Z", + "type" : "bolus", "unit" : "U", - "value" : 1 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T07:26:58Z", - "startDate" : "2023-08-18T07:16:55Z", + "endDate" : "2023-06-22T23:52:44Z", + "startDate" : "2023-06-22T23:42:40Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T08:36:59Z", - "startDate" : "2023-08-18T07:26:58Z", + "endDate" : "2023-06-22T23:57:46Z", + "startDate" : "2023-06-22T23:52:44Z", "type" : "basal", "unit" : "U", - "value" : 1.3 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T08:41:52Z", - "startDate" : "2023-08-18T08:36:59Z", + "endDate" : "2023-06-23T00:02:37Z", + "startDate" : "2023-06-22T23:57:46Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T08:51:52Z", - "startDate" : "2023-08-18T08:41:52Z", + "endDate" : "2023-06-23T01:02:52Z", + "startDate" : "2023-06-23T00:02:37Z", "type" : "basal", "unit" : "U", - "value" : 0.2 - }, - { - "endDate" : "2023-08-18T08:56:58Z", - "startDate" : "2023-08-18T08:51:52Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "value" : 0.40000000000000002 }, { - "endDate" : "2023-08-18T09:12:01Z", - "startDate" : "2023-08-18T08:56:58Z", - "type" : "basal", + "endDate" : "2023-06-23T00:07:42Z", + "startDate" : "2023-06-23T00:07:40Z", + "type" : "bolus", "unit" : "U", - "value" : 0.3 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T09:42:01Z", - "startDate" : "2023-08-18T09:12:01Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-23T00:12:44Z", + "startDate" : "2023-06-23T00:12:38Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.14999999999999999 }, { - "endDate" : "2023-08-18T09:51:54Z", - "startDate" : "2023-08-18T09:42:01Z", - "type" : "basal", + "endDate" : "2023-06-23T00:22:43Z", + "startDate" : "2023-06-23T00:22:39Z", + "type" : "bolus", "unit" : "U", - "value" : 0.2 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T09:56:52Z", - "startDate" : "2023-08-18T09:51:54Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-23T00:27:49Z", + "startDate" : "2023-06-23T00:27:41Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.20000000000000001 }, { - "endDate" : "2023-08-18T10:06:56Z", - "startDate" : "2023-08-18T09:56:52Z", - "type" : "basal", + "endDate" : "2023-06-23T00:32:43Z", + "startDate" : "2023-06-23T00:32:39Z", + "type" : "bolus", "unit" : "U", - "value" : 0.2 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T10:11:54Z", - "startDate" : "2023-08-18T10:06:56Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-23T00:37:58Z", + "startDate" : "2023-06-23T00:37:48Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.25 }, { - "endDate" : "2023-08-18T10:37:02Z", - "startDate" : "2023-08-18T10:11:54Z", - "type" : "basal", + "endDate" : "2023-06-23T00:42:47Z", + "startDate" : "2023-06-23T00:42:39Z", + "type" : "bolus", "unit" : "U", - "value" : 0.45 + "value" : 0.20000000000000001 }, { - "endDate" : "2023-08-18T10:41:54Z", - "startDate" : "2023-08-18T10:37:02Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 + "endDate" : "2023-06-23T00:47:44Z", + "startDate" : "2023-06-23T00:47:40Z", + "type" : "bolus", + "unit" : "U", + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T11:36:58Z", - "startDate" : "2023-08-18T10:41:54Z", - "type" : "basal", + "endDate" : "2023-06-23T00:52:51Z", + "startDate" : "2023-06-23T00:52:45Z", + "type" : "bolus", "unit" : "U", - "value" : 1 + "value" : 0.14999999999999999 }, { - "endDate" : "2023-08-18T11:51:54Z", - "startDate" : "2023-08-18T11:36:58Z", + "endDate" : "2023-06-23T01:12:49Z", + "startDate" : "2023-06-23T01:02:52Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T12:41:54Z", - "startDate" : "2023-08-18T11:51:54Z", + "endDate" : "2023-06-23T01:17:41Z", + "startDate" : "2023-06-23T01:12:49Z", "type" : "basal", "unit" : "U", - "value" : 0.9 + "value" : 0.050000000000000003 }, { - "endDate" : "2023-08-18T12:57:00Z", - "startDate" : "2023-08-18T12:41:54Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0 - }, - { - "endDate" : "2023-08-18T14:11:45Z", - "startDate" : "2023-08-18T12:57:00Z", - "type" : "basal", + "endDate" : "2023-06-23T01:12:54Z", + "startDate" : "2023-06-23T01:12:50Z", + "type" : "bolus", "unit" : "U", - "value" : 1.35 + "value" : 0.10000000000000001 }, { - "endDate" : "2023-08-18T14:17:00Z", - "startDate" : "2023-08-18T14:11:45Z", + "endDate" : "2023-06-23T01:37:39Z", + "startDate" : "2023-06-23T01:17:41Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T14:56:55Z", - "startDate" : "2023-08-18T14:17:00Z", + "endDate" : "2023-06-23T01:37:39Z", + "startDate" : "2023-06-23T01:37:39Z", "type" : "basal", "unit" : "U", - "value" : 0.75 + "value" : 0 }, { - "endDate" : "2023-08-18T15:17:08Z", - "startDate" : "2023-08-18T14:56:55Z", + "endDate" : "2023-06-23T01:42:38Z", + "startDate" : "2023-06-23T01:37:39Z", "type" : "tempBasal", "unit" : "U\/hour", "value" : 0 }, { - "endDate" : "2023-08-18T17:22:08Z", - "startDate" : "2023-08-18T15:17:08Z", + "endDate" : "2023-06-23T02:07:42Z", + "startDate" : "2023-06-23T01:42:38Z", "type" : "basal", "unit" : "U", - "value" : 2.3 + "value" : 0.14999999999999999 }, { - "endDate" : "2023-08-18T16:12:07Z", - "startDate" : "2023-08-18T16:12:03Z", + "endDate" : "2023-06-23T01:47:46Z", + "startDate" : "2023-06-23T01:47:38Z", "type" : "bolus", "unit" : "U", - "value" : 0.1 + "value" : 0.20000000000000001 }, { - "endDate" : "2023-08-18T16:37:09Z", - "startDate" : "2023-08-18T16:37:05Z", + "endDate" : "2023-06-23T01:52:47Z", + "startDate" : "2023-06-23T01:52:39Z", "type" : "bolus", "unit" : "U", - "value" : 0.1 + "value" : 0.20000000000000001 }, { - "endDate" : "2023-08-18T16:42:09Z", - "startDate" : "2023-08-18T16:42:05Z", + "endDate" : "2023-06-23T01:57:50Z", + "startDate" : "2023-06-23T01:57:40Z", "type" : "bolus", "unit" : "U", - "value" : 0.1 + "value" : 0.25 }, { - "endDate" : "2023-08-18T16:47:14Z", - "startDate" : "2023-08-18T16:47:10Z", + "endDate" : "2023-06-23T02:02:49Z", + "startDate" : "2023-06-23T02:02:39Z", "type" : "bolus", "unit" : "U", - "value" : 0.1 + "value" : 0.25 }, { - "endDate" : "2023-08-18T17:22:10Z", - "startDate" : "2023-08-18T17:22:08Z", - "type" : "tempBasal", - "unit" : "U\/hour", - "value" : 0.7 + "endDate" : "2023-06-23T02:07:36Z", + "startDate" : "2023-06-23T02:04:30Z", + "type" : "bolus", + "unit" : "U", + "value" : 4.6500000000000004 }, { - "endDate" : "2023-08-18T17:27:08Z", - "startDate" : "2023-08-18T17:22:10Z", + "endDate" : "2023-06-23T02:27:44Z", + "startDate" : "2023-06-23T02:07:42Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0.75 + "value" : 0 }, { - "endDate" : "2023-08-18T17:57:10Z", - "startDate" : "2023-08-18T17:27:08Z", + "endDate" : "2023-06-23T02:27:44Z", + "startDate" : "2023-06-23T02:27:44Z", "type" : "basal", "unit" : "U", - "value" : 0.55 + "value" : 0 }, { - "endDate" : "2023-08-18T18:02:05Z", - "startDate" : "2023-08-18T17:57:10Z", + "endDate" : "2023-06-23T02:47:39Z", + "startDate" : "2023-06-23T02:27:44Z", "type" : "tempBasal", "unit" : "U\/hour", - "value" : 0.55 - }, - { - "endDate" : "2023-08-18T18:01:46Z", - "startDate" : "2023-08-18T18:01:30Z", - "type" : "bolus", - "unit" : "U", - "value" : 0.4 + "value" : 0 } ], "glucoseHistory" : [ { - "quantity" : 81, - "startDate" : "2023-08-18T00:16:23Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T00:21:25Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T00:26:30Z" - }, - { - "quantity" : 85, - "startDate" : "2023-08-18T00:31:24Z" - }, - { - "quantity" : 88, - "startDate" : "2023-08-18T00:36:23Z" - }, - { - "quantity" : 89, - "startDate" : "2023-08-18T00:41:22Z" - }, - { - "quantity" : 90, - "startDate" : "2023-08-18T00:46:22Z" - }, - { - "quantity" : 90, - "startDate" : "2023-08-18T00:51:23Z" + "quantity" : 120, + "startDate" : "2023-06-22T16:42:33Z" }, { - "quantity" : 91, - "startDate" : "2023-08-18T00:56:23Z" + "quantity" : 119, + "startDate" : "2023-06-22T16:47:33Z" }, { - "quantity" : 91, - "startDate" : "2023-08-18T01:01:24Z" + "quantity" : 120, + "startDate" : "2023-06-22T16:52:34Z" }, { - "quantity" : 89, - "startDate" : "2023-08-18T01:06:25Z" + "quantity" : 118, + "startDate" : "2023-06-22T16:57:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T01:11:22Z" + "quantity" : 115, + "startDate" : "2023-06-22T17:02:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T01:16:23Z" + "quantity" : 120, + "startDate" : "2023-06-22T17:07:34Z" }, { - "quantity" : 85, - "startDate" : "2023-08-18T01:21:23Z" + "quantity" : 121, + "startDate" : "2023-06-22T17:12:34Z" }, { - "quantity" : 78, - "startDate" : "2023-08-18T01:26:22Z" + "quantity" : 119, + "startDate" : "2023-06-22T17:17:34Z" }, { - "quantity" : 80, - "startDate" : "2023-08-18T01:31:24Z" + "quantity" : 116, + "startDate" : "2023-06-22T17:22:34Z" }, { - "quantity" : 79, - "startDate" : "2023-08-18T01:36:25Z" + "quantity" : 115, + "startDate" : "2023-06-22T17:27:34Z" }, { - "quantity" : 81, - "startDate" : "2023-08-18T01:41:22Z" + "quantity" : 124, + "startDate" : "2023-06-22T17:32:34Z" }, { - "quantity" : 82, - "startDate" : "2023-08-18T01:46:23Z" + "quantity" : 114, + "startDate" : "2023-06-22T17:37:34Z" }, { - "quantity" : 82, - "startDate" : "2023-08-18T01:51:23Z" + "quantity" : 124, + "startDate" : "2023-06-22T17:42:34Z" }, { - "quantity" : 81, - "startDate" : "2023-08-18T01:56:23Z" + "quantity" : 124, + "startDate" : "2023-06-22T17:47:33Z" }, { - "quantity" : 80, - "startDate" : "2023-08-18T02:01:25Z" + "quantity" : 124, + "startDate" : "2023-06-22T17:52:34Z" }, { - "quantity" : 79, - "startDate" : "2023-08-18T02:06:29Z" + "quantity" : 126, + "startDate" : "2023-06-22T17:57:33Z" }, { - "quantity" : 81, - "startDate" : "2023-08-18T02:11:23Z" + "quantity" : 125, + "startDate" : "2023-06-22T18:02:34Z" }, { - "quantity" : 84, - "startDate" : "2023-08-18T02:16:25Z" + "quantity" : 118, + "startDate" : "2023-06-22T18:07:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T02:21:27Z" + "quantity" : 122, + "startDate" : "2023-06-22T18:12:33Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T02:26:24Z" + "quantity" : 123, + "startDate" : "2023-06-22T18:17:34Z" }, { - "quantity" : 84, - "startDate" : "2023-08-18T02:31:26Z" + "quantity" : 123, + "startDate" : "2023-06-22T18:22:34Z" }, { - "quantity" : 84, - "startDate" : "2023-08-18T02:36:25Z" + "quantity" : 121, + "startDate" : "2023-06-22T18:27:34Z" }, { - "quantity" : 82, - "startDate" : "2023-08-18T02:41:23Z" + "quantity" : 118, + "startDate" : "2023-06-22T18:32:34Z" }, { - "quantity" : 82, - "startDate" : "2023-08-18T02:46:31Z" + "quantity" : 116, + "startDate" : "2023-06-22T18:37:34Z" }, { - "quantity" : 99, - "startDate" : "2023-08-18T02:51:29Z" + "quantity" : 118, + "startDate" : "2023-06-22T18:42:34Z" }, { - "quantity" : 83, - "startDate" : "2023-08-18T02:56:25Z" + "quantity" : 115, + "startDate" : "2023-06-22T18:47:34Z" }, { - "quantity" : 83, - "startDate" : "2023-08-18T03:01:27Z" + "quantity" : 117, + "startDate" : "2023-06-22T18:52:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T03:06:23Z" + "quantity" : 125, + "startDate" : "2023-06-22T18:57:34Z" }, { - "quantity" : 90, - "startDate" : "2023-08-18T03:11:25Z" + "quantity" : 122, + "startDate" : "2023-06-22T19:02:34Z" }, { - "quantity" : 94, - "startDate" : "2023-08-18T03:16:29Z" + "quantity" : 119, + "startDate" : "2023-06-22T19:07:34Z" }, { - "quantity" : 101, - "startDate" : "2023-08-18T03:21:22Z" + "quantity" : 120, + "startDate" : "2023-06-22T19:12:34Z" }, { - "quantity" : 103, - "startDate" : "2023-08-18T03:26:39Z" - }, - { - "quantity" : 104, - "startDate" : "2023-08-18T03:31:22Z" + "quantity" : 112, + "startDate" : "2023-06-22T19:17:34Z" }, { - "quantity" : 106, - "startDate" : "2023-08-18T03:36:22Z" + "quantity" : 111, + "startDate" : "2023-06-22T19:22:34Z" }, { - "quantity" : 108, - "startDate" : "2023-08-18T03:41:22Z" + "quantity" : 114, + "startDate" : "2023-06-22T19:27:34Z" }, { - "quantity" : 108, - "startDate" : "2023-08-18T03:46:25Z" + "quantity" : 117, + "startDate" : "2023-06-22T19:32:34Z" }, { - "quantity" : 109, - "startDate" : "2023-08-18T03:51:24Z" + "quantity" : 107, + "startDate" : "2023-06-22T19:37:34Z" }, { - "quantity" : 110, - "startDate" : "2023-08-18T03:56:25Z" + "quantity" : 113, + "startDate" : "2023-06-22T19:42:34Z" }, { - "quantity" : 110, - "startDate" : "2023-08-18T04:01:27Z" + "quantity" : 117, + "startDate" : "2023-06-22T19:47:34Z" }, { "quantity" : 109, - "startDate" : "2023-08-18T04:06:24Z" - }, - { - "quantity" : 108, - "startDate" : "2023-08-18T04:11:23Z" - }, - { - "quantity" : 106, - "startDate" : "2023-08-18T04:16:23Z" - }, - { - "quantity" : 105, - "startDate" : "2023-08-18T04:21:24Z" - }, - { - "quantity" : 105, - "startDate" : "2023-08-18T04:26:23Z" - }, - { - "quantity" : 106, - "startDate" : "2023-08-18T04:31:26Z" - }, - { - "quantity" : 106, - "startDate" : "2023-08-18T04:36:24Z" - }, - { - "quantity" : 102, - "startDate" : "2023-08-18T04:41:25Z" - }, - { - "quantity" : 99, - "startDate" : "2023-08-18T04:46:27Z" - }, - { - "quantity" : 99, - "startDate" : "2023-08-18T04:51:22Z" - }, - { - "quantity" : 97, - "startDate" : "2023-08-18T04:56:24Z" - }, - { - "quantity" : 96, - "startDate" : "2023-08-18T05:01:23Z" - }, - { - "quantity" : 97, - "startDate" : "2023-08-18T05:06:24Z" - }, - { - "quantity" : 95, - "startDate" : "2023-08-18T05:11:22Z" - }, - { - "quantity" : 93, - "startDate" : "2023-08-18T05:16:26Z" - }, - { - "quantity" : 92, - "startDate" : "2023-08-18T05:21:22Z" - }, - { - "quantity" : 90, - "startDate" : "2023-08-18T05:26:33Z" - }, - { - "quantity" : 87, - "startDate" : "2023-08-18T05:31:22Z" - }, - { - "quantity" : 85, - "startDate" : "2023-08-18T05:36:23Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T05:41:36Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T05:46:22Z" - }, - { - "quantity" : 78, - "startDate" : "2023-08-18T05:51:23Z" - }, - { - "quantity" : 79, - "startDate" : "2023-08-18T05:56:25Z" - }, - { - "quantity" : 80, - "startDate" : "2023-08-18T06:01:24Z" - }, - { - "quantity" : 79, - "startDate" : "2023-08-18T06:06:26Z" - }, - { - "quantity" : 78, - "startDate" : "2023-08-18T06:11:29Z" - }, - { - "quantity" : 79, - "startDate" : "2023-08-18T06:16:24Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T06:21:35Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T06:26:31Z" - }, - { - "quantity" : 86, - "startDate" : "2023-08-18T06:31:25Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T06:36:30Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T06:41:22Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T06:46:22Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T06:51:31Z" - }, - { - "quantity" : 85, - "startDate" : "2023-08-18T06:56:35Z" - }, - { - "quantity" : 85, - "startDate" : "2023-08-18T07:01:25Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T07:06:29Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T07:11:22Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T07:16:24Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T07:21:31Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T07:26:27Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T07:31:22Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T07:36:24Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T07:41:23Z" + "startDate" : "2023-06-22T19:52:34Z" }, { - "quantity" : 85, - "startDate" : "2023-08-18T07:46:23Z" + "quantity" : 117, + "startDate" : "2023-06-22T19:57:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T07:51:25Z" + "quantity" : 121, + "startDate" : "2023-06-22T20:02:34Z" }, { - "quantity" : 89, - "startDate" : "2023-08-18T07:56:24Z" - }, - { - "quantity" : 90, - "startDate" : "2023-08-18T08:01:26Z" + "quantity" : 121, + "startDate" : "2023-06-22T20:07:34Z" }, { - "quantity" : 90, - "startDate" : "2023-08-18T08:06:33Z" + "quantity" : 127, + "startDate" : "2023-06-22T20:12:34Z" }, { - "quantity" : 91, - "startDate" : "2023-08-18T08:11:22Z" + "quantity" : 133, + "startDate" : "2023-06-22T20:17:34Z" }, { - "quantity" : 90, - "startDate" : "2023-08-18T08:16:23Z" + "quantity" : 131, + "startDate" : "2023-06-22T20:22:34Z" }, { - "quantity" : 89, - "startDate" : "2023-08-18T08:21:26Z" - }, - { - "quantity" : 89, - "startDate" : "2023-08-18T08:26:29Z" + "quantity" : 132, + "startDate" : "2023-06-22T20:27:34Z" }, { - "quantity" : 88, - "startDate" : "2023-08-18T08:31:25Z" + "quantity" : 134, + "startDate" : "2023-06-22T20:32:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T08:36:30Z" + "quantity" : 134, + "startDate" : "2023-06-22T20:37:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T08:41:22Z" + "quantity" : 139, + "startDate" : "2023-06-22T20:42:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T08:46:28Z" + "quantity" : 139, + "startDate" : "2023-06-22T20:47:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T08:51:23Z" + "quantity" : 132, + "startDate" : "2023-06-22T20:52:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T08:56:28Z" + "quantity" : 118, + "startDate" : "2023-06-22T20:57:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T09:01:26Z" + "quantity" : 123, + "startDate" : "2023-06-22T21:02:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T09:06:23Z" + "quantity" : 122, + "startDate" : "2023-06-22T21:07:34Z" }, { - "quantity" : 85, - "startDate" : "2023-08-18T09:11:30Z" + "quantity" : 119, + "startDate" : "2023-06-22T21:12:34Z" }, { - "quantity" : 85, - "startDate" : "2023-08-18T09:16:25Z" + "quantity" : 116, + "startDate" : "2023-06-22T21:17:34Z" }, { - "quantity" : 84, - "startDate" : "2023-08-18T09:21:25Z" + "quantity" : 113, + "startDate" : "2023-06-22T21:22:34Z" }, { - "quantity" : 84, - "startDate" : "2023-08-18T09:26:25Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T09:31:25Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T09:36:25Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T09:41:25Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T09:46:25Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T09:51:25Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T09:56:22Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T10:01:27Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T10:06:27Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T10:11:25Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T10:16:23Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T10:21:24Z" - }, - { - "quantity" : 83, - "startDate" : "2023-08-18T10:26:23Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T10:31:34Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T10:36:31Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T10:41:24Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T10:46:28Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T10:51:23Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T10:56:26Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T11:01:23Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T11:06:26Z" - }, - { - "quantity" : 85, - "startDate" : "2023-08-18T11:11:26Z" - }, - { - "quantity" : 87, - "startDate" : "2023-08-18T11:16:24Z" - }, - { - "quantity" : 88, - "startDate" : "2023-08-18T11:21:24Z" - }, - { - "quantity" : 88, - "startDate" : "2023-08-18T11:26:27Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T11:31:23Z" - }, - { - "quantity" : 82, - "startDate" : "2023-08-18T11:36:27Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T11:41:26Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T11:46:23Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T11:51:24Z" - }, - { - "quantity" : 84, - "startDate" : "2023-08-18T11:56:23Z" - }, - { - "quantity" : 86, - "startDate" : "2023-08-18T12:01:24Z" - }, - { - "quantity" : 86, - "startDate" : "2023-08-18T12:06:25Z" - }, - { - "quantity" : 86, - "startDate" : "2023-08-18T12:11:24Z" - }, - { - "quantity" : 86, - "startDate" : "2023-08-18T12:16:24Z" - }, - { - "quantity" : 86, - "startDate" : "2023-08-18T12:21:25Z" - }, - { - "quantity" : 87, - "startDate" : "2023-08-18T12:26:23Z" - }, - { - "quantity" : 87, - "startDate" : "2023-08-18T12:31:25Z" - }, - { - "quantity" : 88, - "startDate" : "2023-08-18T12:36:32Z" - }, - { - "quantity" : 81, - "startDate" : "2023-08-18T12:41:23Z" - }, - { - "quantity" : 78, - "startDate" : "2023-08-18T12:46:23Z" - }, - { - "quantity" : 77, - "startDate" : "2023-08-18T12:51:23Z" + "quantity" : 111, + "startDate" : "2023-06-22T21:27:34Z" }, { - "quantity" : 84, - "startDate" : "2023-08-18T12:56:28Z" + "quantity" : 112, + "startDate" : "2023-06-22T21:32:34Z" }, { - "quantity" : 88, - "startDate" : "2023-08-18T13:01:24Z" + "quantity" : 107, + "startDate" : "2023-06-22T21:37:34Z" }, { - "quantity" : 90, - "startDate" : "2023-08-18T13:06:23Z" + "quantity" : 102, + "startDate" : "2023-06-22T21:42:34Z" }, { - "quantity" : 85, - "startDate" : "2023-08-18T13:11:23Z" + "quantity" : 95, + "startDate" : "2023-06-22T21:47:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T13:16:23Z" + "quantity" : 96, + "startDate" : "2023-06-22T21:52:34Z" }, { "quantity" : 89, - "startDate" : "2023-08-18T13:21:24Z" + "startDate" : "2023-06-22T21:57:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T13:26:28Z" + "quantity" : 95, + "startDate" : "2023-06-22T22:02:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T13:31:24Z" + "quantity" : 95, + "startDate" : "2023-06-22T22:07:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T13:36:29Z" + "quantity" : 93, + "startDate" : "2023-06-22T22:12:34Z" }, { - "quantity" : 90, - "startDate" : "2023-08-18T13:41:23Z" + "quantity" : 98, + "startDate" : "2023-06-22T22:17:35Z" }, { - "quantity" : 89, - "startDate" : "2023-08-18T13:46:31Z" + "quantity" : 95, + "startDate" : "2023-06-22T22:22:35Z" }, { - "quantity" : 88, - "startDate" : "2023-08-18T13:51:29Z" + "quantity" : 101, + "startDate" : "2023-06-22T22:27:34Z" }, { - "quantity" : 92, - "startDate" : "2023-08-18T13:56:33Z" + "quantity" : 97, + "startDate" : "2023-06-22T22:32:34Z" }, { - "quantity" : 95, - "startDate" : "2023-08-18T14:01:37Z" + "quantity" : 108, + "startDate" : "2023-06-22T22:37:35Z" }, { - "quantity" : 88, - "startDate" : "2023-08-18T14:06:23Z" + "quantity" : 109, + "startDate" : "2023-06-22T22:42:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T14:11:26Z" + "quantity" : 109, + "startDate" : "2023-06-22T22:47:34Z" }, { - "quantity" : 92, - "startDate" : "2023-08-18T14:16:30Z" + "quantity" : 114, + "startDate" : "2023-06-22T22:52:34Z" }, { - "quantity" : 94, - "startDate" : "2023-08-18T14:21:29Z" + "quantity" : 115, + "startDate" : "2023-06-22T22:57:34Z" }, { - "quantity" : 96, - "startDate" : "2023-08-18T14:26:23Z" + "quantity" : 114, + "startDate" : "2023-06-22T23:02:34Z" }, { - "quantity" : 96, - "startDate" : "2023-08-18T14:31:23Z" + "quantity" : 121, + "startDate" : "2023-06-22T23:07:34Z" }, { - "quantity" : 98, - "startDate" : "2023-08-18T14:36:32Z" + "quantity" : 119, + "startDate" : "2023-06-22T23:12:34Z" }, { - "quantity" : 98, - "startDate" : "2023-08-18T14:41:25Z" + "quantity" : 117, + "startDate" : "2023-06-22T23:17:34Z" }, { - "quantity" : 99, - "startDate" : "2023-08-18T14:46:24Z" + "quantity" : 120, + "startDate" : "2023-06-22T23:22:35Z" }, { - "quantity" : 98, - "startDate" : "2023-08-18T14:51:26Z" + "quantity" : 122, + "startDate" : "2023-06-22T23:27:34Z" }, { - "quantity" : 94, - "startDate" : "2023-08-18T14:56:25Z" + "quantity" : 123, + "startDate" : "2023-06-22T23:32:34Z" }, { - "quantity" : 87, - "startDate" : "2023-08-18T15:01:24Z" + "quantity" : 127, + "startDate" : "2023-06-22T23:37:34Z" }, { - "quantity" : 85, - "startDate" : "2023-08-18T15:06:24Z" + "quantity" : 118, + "startDate" : "2023-06-22T23:42:35Z" }, { - "quantity" : 85, - "startDate" : "2023-08-18T15:11:23Z" + "quantity" : 120, + "startDate" : "2023-06-22T23:47:34Z" }, { - "quantity" : 86, - "startDate" : "2023-08-18T15:16:24Z" + "quantity" : 119, + "startDate" : "2023-06-22T23:52:35Z" }, { - "quantity" : 88, - "startDate" : "2023-08-18T15:21:23Z" + "quantity" : 115, + "startDate" : "2023-06-22T23:57:34Z" }, { - "quantity" : 89, - "startDate" : "2023-08-18T15:26:26Z" + "quantity" : 116, + "startDate" : "2023-06-23T00:02:34Z" }, { - "quantity" : 91, - "startDate" : "2023-08-18T15:31:24Z" + "quantity" : 133, + "startDate" : "2023-06-23T00:07:34Z" }, { - "quantity" : 92, - "startDate" : "2023-08-18T15:36:24Z" + "quantity" : 145, + "startDate" : "2023-06-23T00:12:34Z" }, { - "quantity" : 94, - "startDate" : "2023-08-18T15:41:25Z" + "quantity" : 140, + "startDate" : "2023-06-23T00:17:34Z" }, { - "quantity" : 96, - "startDate" : "2023-08-18T15:46:25Z" + "quantity" : 161, + "startDate" : "2023-06-23T00:22:35Z" }, { - "quantity" : 96, - "startDate" : "2023-08-18T15:51:28Z" + "quantity" : 166, + "startDate" : "2023-06-23T00:27:34Z" }, { - "quantity" : 98, - "startDate" : "2023-08-18T15:56:26Z" + "quantity" : 172, + "startDate" : "2023-06-23T00:32:35Z" }, { - "quantity" : 97, - "startDate" : "2023-08-18T16:01:23Z" + "quantity" : 182, + "startDate" : "2023-06-23T00:37:35Z" }, { - "quantity" : 99, - "startDate" : "2023-08-18T16:06:23Z" + "quantity" : 184, + "startDate" : "2023-06-23T00:42:35Z" }, { - "quantity" : 101, - "startDate" : "2023-08-18T16:11:25Z" + "quantity" : 185, + "startDate" : "2023-06-23T00:47:34Z" }, { - "quantity" : 102, - "startDate" : "2023-08-18T16:16:25Z" + "quantity" : 190, + "startDate" : "2023-06-23T00:52:35Z" }, { - "quantity" : 103, - "startDate" : "2023-08-18T16:21:23Z" + "quantity" : 182, + "startDate" : "2023-06-23T00:57:34Z" }, { - "quantity" : 98, - "startDate" : "2023-08-18T16:26:23Z" + "quantity" : 166, + "startDate" : "2023-06-23T01:02:35Z" }, { - "quantity" : 102, - "startDate" : "2023-08-18T16:31:28Z" + "quantity" : 174, + "startDate" : "2023-06-23T01:07:34Z" }, { - "quantity" : 105, - "startDate" : "2023-08-18T16:36:23Z" + "quantity" : 179, + "startDate" : "2023-06-23T01:12:34Z" }, { - "quantity" : 112, - "startDate" : "2023-08-18T16:41:23Z" + "quantity" : 166, + "startDate" : "2023-06-23T01:17:35Z" }, { - "quantity" : 112, - "startDate" : "2023-08-18T16:46:23Z" + "quantity" : 134, + "startDate" : "2023-06-23T01:22:34Z" }, { - "quantity" : 111, - "startDate" : "2023-08-18T16:51:26Z" + "quantity" : 131, + "startDate" : "2023-06-23T01:27:35Z" }, { - "quantity" : 111, - "startDate" : "2023-08-18T16:56:24Z" + "quantity" : 129, + "startDate" : "2023-06-23T01:32:34Z" }, { - "quantity" : 111, - "startDate" : "2023-08-18T17:01:23Z" + "quantity" : 136, + "startDate" : "2023-06-23T01:37:34Z" }, { - "quantity" : 109, - "startDate" : "2023-08-18T17:06:24Z" + "quantity" : 152, + "startDate" : "2023-06-23T01:42:34Z" }, { - "quantity" : 111, - "startDate" : "2023-08-18T17:11:23Z" + "quantity" : 162, + "startDate" : "2023-06-23T01:47:35Z" }, { - "quantity" : 111, - "startDate" : "2023-08-18T17:16:23Z" + "quantity" : 165, + "startDate" : "2023-06-23T01:52:34Z" }, { - "quantity" : 110, - "startDate" : "2023-08-18T17:21:23Z" + "quantity" : 172, + "startDate" : "2023-06-23T01:57:34Z" }, { - "quantity" : 111, - "startDate" : "2023-08-18T17:26:23Z" + "quantity" : 176, + "startDate" : "2023-06-23T02:02:35Z" }, { - "quantity" : 110, - "startDate" : "2023-08-18T17:31:25Z" + "quantity" : 165, + "startDate" : "2023-06-23T02:07:35Z" }, { - "quantity" : 110, - "startDate" : "2023-08-18T17:36:23Z" + "quantity" : 172, + "startDate" : "2023-06-23T02:12:34Z" }, { - "quantity" : 110, - "startDate" : "2023-08-18T17:41:26Z" + "quantity" : 170, + "startDate" : "2023-06-23T02:17:35Z" }, { - "quantity" : 110, - "startDate" : "2023-08-18T17:46:30Z" + "quantity" : 177, + "startDate" : "2023-06-23T02:22:35Z" }, { - "quantity" : 111, - "startDate" : "2023-08-18T17:51:28Z" + "quantity" : 176, + "startDate" : "2023-06-23T02:27:35Z" }, { - "quantity" : 106, - "startDate" : "2023-08-18T17:56:24Z" + "quantity" : 173, + "startDate" : "2023-06-23T02:32:34Z" }, { - "quantity" : 102, - "startDate" : "2023-08-18T18:01:24Z" + "quantity" : 180, + "startDate" : "2023-06-23T02:37:35Z" } ], "settings" : { "basal" : [ { - "endDate" : "2023-08-18T05:00:00Z", - "startDate" : "2023-08-17T05:00:00Z", - "value" : 1.1 - }, - { - "endDate" : "2023-08-19T05:00:00Z", - "startDate" : "2023-08-18T05:00:00Z", - "value" : 1.1 + "endDate" : "2023-06-23T05:00:00Z", + "startDate" : "2023-06-22T10:00:00Z", + "value" : 0.45000000000000001 } ], "carbRatio" : [ { - "endDate" : "2023-08-18T05:00:00Z", - "startDate" : "2023-08-17T05:00:00Z", - "value" : 15 - }, - { - "endDate" : "2023-08-19T05:00:00Z", - "startDate" : "2023-08-18T05:00:00Z", - "value" : 15 + "endDate" : "2023-06-23T07:00:00Z", + "startDate" : "2023-06-22T07:00:00Z", + "value" : 11 } ], + "maximumBasalRatePerHour" : null, + "maximumBolus" : null, "sensitivity" : [ { - "endDate" : "2023-08-18T05:00:00Z", - "startDate" : "2023-08-17T05:00:00Z", - "value" : 50 - }, - { - "endDate" : "2023-08-19T05:00:00Z", - "startDate" : "2023-08-18T05:00:00Z", - "value" : 50 + "endDate" : "2023-06-23T05:00:00Z", + "startDate" : "2023-06-22T10:00:00Z", + "value" : 60 } ], + "suspendThreshold" : null, "target" : [ { - "endDate" : "2023-08-19T00:15:00Z", - "startDate" : "2023-08-18T11:50:00Z", + "endDate" : "2023-06-23T07:00:00Z", + "startDate" : "2023-06-22T20:25:00Z", + "value" : { + "maxValue" : 115, + "minValue" : 100 + } + }, + { + "endDate" : "2023-06-23T08:50:00Z", + "startDate" : "2023-06-23T07:00:00Z", "value" : { "maxValue" : 115, "minValue" : 100 diff --git a/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json b/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json index bb3a141d73..a98fbaccb7 100644 --- a/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json +++ b/LoopTests/Fixtures/live_capture/live_capture_predicted_glucose.json @@ -1,382 +1,392 @@ [ { - "quantity" : 102, + "quantity" : 180, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:01:24Z" + "startDate" : "2023-06-23T02:37:35Z" }, { - "quantity" : 99.896393318404151, + "quantity" : 180.29132150657966, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:05:00Z" + "startDate" : "2023-06-23T02:40:00Z" }, { - "quantity" : 97.327016523041976, + "quantity" : 180.51458820506667, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:10:00Z" + "startDate" : "2023-06-23T02:45:00Z" }, { - "quantity" : 95.324444788485806, + "quantity" : 179.7158986124237, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:15:00Z" + "startDate" : "2023-06-23T02:50:00Z" }, { - "quantity" : 93.992918445816656, + "quantity" : 177.66868460973922, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:20:00Z" + "startDate" : "2023-06-23T02:55:00Z" }, { - "quantity" : 92.98678930503138, + "quantity" : 174.80252509117634, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:25:00Z" + "startDate" : "2023-06-23T03:00:00Z" }, { - "quantity" : 92.153401829419991, + "quantity" : 171.74984493231631, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:30:00Z" + "startDate" : "2023-06-23T03:05:00Z" }, { - "quantity" : 91.502805972419452, + "quantity" : 168.58187755437024, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:35:00Z" + "startDate" : "2023-06-23T03:10:00Z" }, { - "quantity" : 91.044140230125493, + "quantity" : 165.36216340804185, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:40:00Z" + "startDate" : "2023-06-23T03:15:00Z" }, { - "quantity" : 90.785701374247225, + "quantity" : 162.12697210734922, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:45:00Z" + "startDate" : "2023-06-23T03:20:00Z" }, { - "quantity" : 90.735009333107385, + "quantity" : 158.90986429144345, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:50:00Z" + "startDate" : "2023-06-23T03:25:00Z" }, { - "quantity" : 90.87529571413188, + "quantity" : 155.75684851046043, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T18:55:00Z" + "startDate" : "2023-06-23T03:30:00Z" }, { - "quantity" : 91.131206561299791, + "quantity" : 152.70869296700107, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:00:00Z" + "startDate" : "2023-06-23T03:35:00Z" }, { - "quantity" : 91.369852449274902, + "quantity" : 149.78068888956841, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:05:00Z" + "startDate" : "2023-06-23T03:40:00Z" }, { - "quantity" : 91.596637899447671, + "quantity" : 147.00401242102828, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:10:00Z" + "startDate" : "2023-06-23T03:45:00Z" }, { - "quantity" : 91.815952582397927, + "quantity" : 144.40563853768242, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:15:00Z" + "startDate" : "2023-06-23T03:50:00Z" }, { - "quantity" : 92.031661009999482, + "quantity" : 142.0087170601098, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:20:00Z" + "startDate" : "2023-06-23T03:55:00Z" }, { - "quantity" : 92.24719829385748, + "quantity" : 139.83295658233396, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:25:00Z" + "startDate" : "2023-06-23T04:00:00Z" }, { - "quantity" : 92.465606922060431, + "quantity" : 137.89511837124121, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:30:00Z" + "startDate" : "2023-06-23T04:05:00Z" }, { - "quantity" : 92.689569938551358, + "quantity" : 136.07526338088792, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:35:00Z" + "startDate" : "2023-06-23T04:10:00Z" }, { - "quantity" : 92.921441679246016, + "quantity" : 134.25815754225141, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:40:00Z" + "startDate" : "2023-06-23T04:15:00Z" }, { - "quantity" : 93.163276230779218, + "quantity" : 132.45275084533137, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:45:00Z" + "startDate" : "2023-06-23T04:20:00Z" }, { - "quantity" : 93.416853767095574, + "quantity" : 130.66563522056958, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:50:00Z" + "startDate" : "2023-06-23T04:25:00Z" }, { - "quantity" : 93.683704909090238, + "quantity" : 128.90146920949769, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T19:55:00Z" + "startDate" : "2023-06-23T04:30:00Z" }, { - "quantity" : 93.965133243123091, + "quantity" : 127.16322092092855, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:00:00Z" + "startDate" : "2023-06-23T04:35:00Z" }, { - "quantity" : 94.262236125417473, + "quantity" : 125.45215396105368, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:05:00Z" + "startDate" : "2023-06-23T04:40:00Z" }, { - "quantity" : 94.575923891105845, + "quantity" : 123.76712483433676, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:10:00Z" + "startDate" : "2023-06-23T04:45:00Z" }, { - "quantity" : 94.906937578934446, + "quantity" : 122.10683165409341, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:15:00Z" + "startDate" : "2023-06-23T04:50:00Z" }, { - "quantity" : 95.255865275387578, + "quantity" : 120.46857875163471, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:20:00Z" + "startDate" : "2023-06-23T04:55:00Z" }, { - "quantity" : 95.623303645444025, + "quantity" : 118.84903308222181, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:25:00Z" + "startDate" : "2023-06-23T05:00:00Z" }, { - "quantity" : 96.000882373540378, + "quantity" : 117.24445077397047, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:30:00Z" + "startDate" : "2023-06-23T05:05:00Z" }, { - "quantity" : 96.365336203749791, + "quantity" : 115.65043839655846, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:35:00Z" + "startDate" : "2023-06-23T05:10:00Z" }, { - "quantity" : 96.715562621883805, + "quantity" : 114.06198688414838, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:40:00Z" + "startDate" : "2023-06-23T05:15:00Z" }, { - "quantity" : 97.051545329583519, + "quantity" : 112.47356001340279, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:45:00Z" + "startDate" : "2023-06-23T05:20:00Z" }, { - "quantity" : 97.373191168681046, + "quantity" : 110.87917488553444, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:50:00Z" + "startDate" : "2023-06-23T05:25:00Z" }, { - "quantity" : 97.68033912753441, + "quantity" : 109.27247502015473, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T20:55:00Z" + "startDate" : "2023-06-23T05:30:00Z" }, { - "quantity" : 97.972768583817071, + "quantity" : 107.64679662666447, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:00:00Z" + "startDate" : "2023-06-23T05:35:00Z" }, { - "quantity" : 98.250206839942507, + "quantity" : 105.99522857963143, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:05:00Z" + "startDate" : "2023-06-23T05:40:00Z" }, { - "quantity" : 98.512461657029007, + "quantity" : 104.31066658787131, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:10:00Z" + "startDate" : "2023-06-23T05:45:00Z" }, { - "quantity" : 98.759768446355963, + "quantity" : 102.58586201263279, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:15:00Z" + "startDate" : "2023-06-23T05:50:00Z" }, { - "quantity" : 98.992334190285419, + "quantity" : 100.81350120847731, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:20:00Z" + "startDate" : "2023-06-23T05:55:00Z" }, { - "quantity" : 99.210294956891744, + "quantity" : 98.986445102805988, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:25:00Z" + "startDate" : "2023-06-23T06:00:00Z" }, { - "quantity" : 99.413602382932424, + "quantity" : 97.097518927124952, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:30:00Z" + "startDate" : "2023-06-23T06:05:00Z" }, { - "quantity" : 99.601698280019434, + "quantity" : 95.139330662672023, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:35:00Z" + "startDate" : "2023-06-23T06:10:00Z" }, { - "quantity" : 99.773947375251453, + "quantity" : 93.104670202578632, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:40:00Z" + "startDate" : "2023-06-23T06:15:00Z" }, { - "quantity" : 99.929708236532747, + "quantity" : 90.986165185301502, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:45:00Z" + "startDate" : "2023-06-23T06:20:00Z" }, { - "quantity" : 100.06833834582778, + "quantity" : 88.909927040807588, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:50:00Z" + "startDate" : "2023-06-23T06:25:00Z" }, { - "quantity" : 100.18919669640144, + "quantity" : 86.994338611676767, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T21:55:00Z" + "startDate" : "2023-06-23T06:30:00Z" }, { - "quantity" : 100.29164609469677, + "quantity" : 85.232136877351081, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:00:00Z" + "startDate" : "2023-06-23T06:35:00Z" }, { - "quantity" : 100.3750551915391, + "quantity" : 83.615651290380811, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:05:00Z" + "startDate" : "2023-06-23T06:40:00Z" }, { - "quantity" : 100.43880026555911, + "quantity" : 82.136746744082188, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:10:00Z" + "startDate" : "2023-06-23T06:45:00Z" }, { - "quantity" : 100.48226678004278, + "quantity" : 80.787935960558002, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:15:00Z" + "startDate" : "2023-06-23T06:50:00Z" }, { - "quantity" : 100.50485073285557, + "quantity" : 79.561150334091622, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:20:00Z" + "startDate" : "2023-06-23T06:55:00Z" }, { - "quantity" : 100.50583426131806, + "quantity" : 78.448809315519384, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:25:00Z" + "startDate" : "2023-06-23T07:00:00Z" }, { - "quantity" : 100.48412374566237, + "quantity" : 77.444295000376087, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:30:00Z" + "startDate" : "2023-06-23T07:05:00Z" }, { - "quantity" : 100.4391400838507, + "quantity" : 76.541144021775267, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:35:00Z" + "startDate" : "2023-06-23T07:10:00Z" }, { - "quantity" : 100.3703782423454, + "quantity" : 75.734033247701291, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:40:00Z" + "startDate" : "2023-06-23T07:15:00Z" }, { - "quantity" : 100.28611412349363, + "quantity" : 75.018229944400559, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:45:00Z" + "startDate" : "2023-06-23T07:20:00Z" }, { - "quantity" : 100.20947967884376, + "quantity" : 74.389076912965834, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:50:00Z" + "startDate" : "2023-06-23T07:25:00Z" }, { - "quantity" : 100.14069735835136, + "quantity" : 73.841309919727451, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T22:55:00Z" + "startDate" : "2023-06-23T07:30:00Z" }, { - "quantity" : 100.07866920613634, + "quantity" : 73.370549918316215, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:00:00Z" + "startDate" : "2023-06-23T07:35:00Z" }, { - "quantity" : 100.02247162981837, + "quantity" : 72.972744055408953, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:05:00Z" + "startDate" : "2023-06-23T07:40:00Z" }, { - "quantity" : 99.971752267355782, + "quantity" : 72.643975082565134, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:10:00Z" + "startDate" : "2023-06-23T07:45:00Z" }, { - "quantity" : 99.926235939245828, + "quantity" : 72.380461060355856, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:15:00Z" + "startDate" : "2023-06-23T07:50:00Z" }, { - "quantity" : 99.88565546474166, + "quantity" : 72.178520063294286, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:20:00Z" + "startDate" : "2023-06-23T07:55:00Z" }, { - "quantity" : 99.849751805109122, + "quantity" : 72.034174053629386, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:25:00Z" + "startDate" : "2023-06-23T08:00:00Z" }, { - "quantity" : 99.81827416145336, + "quantity" : 71.942299096190823, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:30:00Z" + "startDate" : "2023-06-23T08:05:00Z" }, { - "quantity" : 99.791028333933468, + "quantity" : 71.897751011456421, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:35:00Z" + "startDate" : "2023-06-23T08:10:00Z" }, { - "quantity" : 99.767995772848735, + "quantity" : 71.895123880236383, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:40:00Z" + "startDate" : "2023-06-23T08:15:00Z" }, { - "quantity" : 99.748959024064902, + "quantity" : 71.906254842464136, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:45:00Z" + "startDate" : "2023-06-23T08:20:00Z" }, { - "quantity" : 99.733680926725469, + "quantity" : 71.914434937142801, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:50:00Z" + "startDate" : "2023-06-23T08:25:00Z" }, { - "quantity" : 99.721933417247726, + "quantity" : 71.920167940771535, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-18T23:55:00Z" + "startDate" : "2023-06-23T08:30:00Z" }, { - "quantity" : 99.713497415806842, + "quantity" : 71.923927819981145, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-19T00:00:00Z" + "startDate" : "2023-06-23T08:35:00Z" }, { - "quantity" : 99.708162692555675, + "quantity" : 71.926159114246957, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-19T00:05:00Z" + "startDate" : "2023-06-23T08:40:00Z" }, { - "quantity" : 99.705774231311352, + "quantity" : 71.927280081079402, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-19T00:10:00Z" + "startDate" : "2023-06-23T08:45:00Z" }, { - "quantity" : 99.705641639222222, + "quantity" : 71.927682355083221, "quantityUnit" : "mg\/dL", - "startDate" : "2023-08-19T00:15:00Z" + "startDate" : "2023-06-23T08:50:00Z" + }, + { + "quantity" : 71.927731342958282, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-06-23T08:55:00Z" + }, + { + "quantity" : 71.927731342958282, + "quantityUnit" : "mg\/dL", + "startDate" : "2023-06-23T09:00:00Z" } ] diff --git a/LoopTests/Managers/LoopAlgorithmTests.swift b/LoopTests/Managers/LoopAlgorithmTests.swift index 89831b4326..6c51283872 100644 --- a/LoopTests/Managers/LoopAlgorithmTests.swift +++ b/LoopTests/Managers/LoopAlgorithmTests.swift @@ -51,7 +51,8 @@ final class LoopAlgorithmTests: XCTestCase { func testLiveCaptureWithFunctionalAlgorithm() throws { // This matches the "testForecastFromLiveCaptureInputData" test of LoopDataManagerDosingTests, - // Using the same input data, but generating the forecast using LoopPrediction + // Using the same input data, but generating the forecast using the LoopAlgorithm.generatePrediction() + // function. let decoder = JSONDecoder() decoder.dateDecodingStrategy = .iso8601 diff --git a/LoopTests/Mock Stores/MockCarbStore.swift b/LoopTests/Mock Stores/MockCarbStore.swift index 2c8d7407e7..4a5c016eb5 100644 --- a/LoopTests/Mock Stores/MockCarbStore.swift +++ b/LoopTests/Mock Stores/MockCarbStore.swift @@ -108,8 +108,8 @@ class MockCarbStore: CarbStoreProtocol { let carbDates = samples.map { $0.startDate } let maxCarbDate = carbDates.max()! let minCarbDate = carbDates.min()! - let carbRatio = carbRatioScheduleApplyingOverrideHistory.between(start: maxCarbDate, end: minCarbDate) - let insulinSensitivity = insulinSensitivityScheduleApplyingOverrideHistory.quantitiesBetween(start: maxCarbDate, end: minCarbDate) + let carbRatio = carbRatioScheduleApplyingOverrideHistory.between(start: minCarbDate, end: maxCarbDate) + let insulinSensitivity = insulinSensitivityScheduleApplyingOverrideHistory.quantitiesBetween(start: minCarbDate, end: maxCarbDate) let effects = samples.map( to: effectVelocities, carbRatio: carbRatio,