-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LOOP-1479: Implement first 2 screens of prescription flow + mock mana…
…ger (#11) Create Prescription data model Create a mock prescription manager Create a UICoordinator to navigate between views in the flow Add button to TidepoolService setup view controller to trigger the onboarding flow Create assets folder with Dexcom/Dash images Create view model for initial part of flow Create the first 2 screens of the onboarding flow (prescription code entry & device review)
- Loading branch information
Showing
18 changed files
with
902 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// TimeInterval.swift | ||
// TidepoolServiceKit | ||
// | ||
// Created by Anna Quinlan on 6/26/20. | ||
// Copyright © 2020 Tidepool Project. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension TimeInterval { | ||
public static func minutes(_ minutes: Double) -> TimeInterval { | ||
return TimeInterval(minutes * 60 /* seconds in minute */) | ||
} | ||
|
||
public static func hours(_ hours: Double) -> TimeInterval { | ||
return TimeInterval(hours * 60 /* minutes in hr */ * 60 /* seconds in minute */) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// | ||
// Prescription.swift | ||
// TidepoolServiceKit | ||
// | ||
// Created by Anna Quinlan on 6/18/20. | ||
// Copyright © 2020 Tidepool Project. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import HealthKit | ||
import LoopKit | ||
|
||
|
||
public enum CGMType: String, Codable { | ||
case g6 | ||
} | ||
|
||
public enum PumpType: String, Codable { | ||
case dash | ||
} | ||
|
||
public enum TrainingType: String, Codable { | ||
case inPerson // Patient must have hands-on training with clinician/CDE | ||
case inModule // Patient can train in-app | ||
|
||
} | ||
|
||
public enum BGUnit: String, Codable { | ||
case mgdl | ||
case mmol | ||
|
||
var hkUnit: HKUnit { | ||
switch self { | ||
case .mgdl: | ||
return .milligramsPerDeciliter | ||
case .mmol: | ||
return .millimolesPerLiter | ||
} | ||
} | ||
} | ||
|
||
public struct MockPrescription: Codable { | ||
public let datePrescribed: Date // Date prescription was prescribed | ||
public let providerName: String // Name of clinician prescribing | ||
public let cgm: CGMType // CGM type (manufacturer & model) | ||
public let pump: PumpType // Pump type (manufacturer & model) | ||
public let bloodGlucoseUnit: BGUnit | ||
public let basalRateSchedule: BasalRateSchedule | ||
public let glucoseTargetRangeSchedule: GlucoseRangeSchedule | ||
public let carbRatioSchedule: CarbRatioSchedule | ||
public let insulinSensitivitySchedule: InsulinSensitivitySchedule | ||
public let maximumBasalRatePerHour: Double | ||
public let maximumBolus: Double | ||
public let suspendThreshold: GlucoseThreshold | ||
public let insulinModel: InsulinModel | ||
public let preMealTargetRange: DoubleRange | ||
public let workoutTargetRange: DoubleRange | ||
|
||
public init(datePrescribed: Date, | ||
providerName: String, | ||
cgmType: CGMType, | ||
pumpType: PumpType, | ||
bloodGlucoseUnit: BGUnit, | ||
basalRateSchedule: BasalRateSchedule, | ||
glucoseTargetRangeSchedule: GlucoseRangeSchedule, | ||
carbRatioSchedule: CarbRatioSchedule, | ||
insulinSensitivitySchedule: InsulinSensitivitySchedule, | ||
maximumBasalRatePerHour: Double, | ||
maximumBolus: Double, | ||
suspendThreshold: GlucoseThreshold, | ||
insulinModel: InsulinModel, | ||
preMealTargetRange: DoubleRange, | ||
workoutTargetRange: DoubleRange) { | ||
self.datePrescribed = datePrescribed | ||
self.providerName = providerName | ||
self.cgm = cgmType | ||
self.pump = pumpType | ||
self.bloodGlucoseUnit = bloodGlucoseUnit | ||
self.basalRateSchedule = basalRateSchedule | ||
self.glucoseTargetRangeSchedule = glucoseTargetRangeSchedule | ||
self.carbRatioSchedule = carbRatioSchedule | ||
self.insulinSensitivitySchedule = insulinSensitivitySchedule | ||
self.maximumBasalRatePerHour = maximumBasalRatePerHour | ||
self.maximumBolus = maximumBolus | ||
self.suspendThreshold = suspendThreshold | ||
self.insulinModel = insulinModel | ||
self.preMealTargetRange = preMealTargetRange | ||
self.workoutTargetRange = workoutTargetRange | ||
} | ||
|
||
public struct InsulinModel: Codable, Equatable { | ||
public enum ModelType: String, Codable { | ||
case fiasp | ||
case rapidAdult | ||
case rapidChild | ||
case walsh | ||
} | ||
|
||
public let modelType: ModelType | ||
public let actionDuration: TimeInterval | ||
public let peakActivity: TimeInterval? | ||
|
||
public init(modelType: ModelType, actionDuration: TimeInterval, peakActivity: TimeInterval? = nil) { | ||
self.modelType = modelType | ||
self.actionDuration = actionDuration | ||
self.peakActivity = peakActivity | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// MockPrescriptionManager.swift | ||
// TidepoolServiceKit | ||
// | ||
// Created by Anna Quinlan on 6/18/20. | ||
// Copyright © 2020 Tidepool Project. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import LoopKit | ||
|
||
public class MockPrescriptionManager { | ||
private var prescription: MockPrescription | ||
|
||
public init(prescription: MockPrescription? = nil) { | ||
if let prescription = prescription { | ||
self.prescription = prescription | ||
} else { | ||
let timeZone = TimeZone(identifier: "America/Los_Angeles")! | ||
let glucoseTargetRangeSchedule = GlucoseRangeSchedule( | ||
rangeSchedule: DailyQuantitySchedule(unit: .milligramsPerDeciliter, | ||
dailyItems: [RepeatingScheduleValue(startTime: .hours(0), value: DoubleRange(minValue: 100.0, maxValue: 110.0)), | ||
RepeatingScheduleValue(startTime: .hours(8), value: DoubleRange(minValue: 95.0, maxValue: 105.0)), | ||
RepeatingScheduleValue(startTime: .hours(14), value: DoubleRange(minValue: 95.0, maxValue: 105.0)), | ||
RepeatingScheduleValue(startTime: .hours(16), value: DoubleRange(minValue: 100.0, maxValue: 110.0)), | ||
RepeatingScheduleValue(startTime: .hours(18), value: DoubleRange(minValue: 90.0, maxValue: 100.0)), | ||
RepeatingScheduleValue(startTime: .hours(21), value: DoubleRange(minValue: 110.0, maxValue: 120.0))], | ||
timeZone: timeZone)!, | ||
override: GlucoseRangeSchedule.Override(value: DoubleRange(minValue: 80.0, maxValue: 90.0), | ||
start: Date().addingTimeInterval(.minutes(-30)), | ||
end: Date().addingTimeInterval(.minutes(30))) | ||
) | ||
let basalRateSchedule = BasalRateSchedule( | ||
dailyItems: [RepeatingScheduleValue(startTime: .hours(0), value: 1.0), | ||
RepeatingScheduleValue(startTime: .hours(8), value: 1.125), | ||
RepeatingScheduleValue(startTime: .hours(10), value: 1.25), | ||
RepeatingScheduleValue(startTime: .hours(12), value: 1.5), | ||
RepeatingScheduleValue(startTime: .hours(14), value: 1.25), | ||
RepeatingScheduleValue(startTime: .hours(16), value: 1.5), | ||
RepeatingScheduleValue(startTime: .hours(18), value: 1.25), | ||
RepeatingScheduleValue(startTime: .hours(21), value: 1.0)], | ||
timeZone: timeZone)! | ||
let insulinSensitivitySchedule = InsulinSensitivitySchedule( | ||
unit: .milligramsPerDeciliter, | ||
dailyItems: [RepeatingScheduleValue(startTime: .hours(0), value: 45.0), | ||
RepeatingScheduleValue(startTime: .hours(8), value: 40.0), | ||
RepeatingScheduleValue(startTime: .hours(10), value: 35.0), | ||
RepeatingScheduleValue(startTime: .hours(12), value: 30.0), | ||
RepeatingScheduleValue(startTime: .hours(14), value: 35.0), | ||
RepeatingScheduleValue(startTime: .hours(16), value: 40.0)], | ||
timeZone: timeZone)! | ||
let carbRatioSchedule = CarbRatioSchedule( | ||
unit: .gram(), | ||
|
||
dailyItems: [RepeatingScheduleValue(startTime: .hours(0), value: 10.0), | ||
RepeatingScheduleValue(startTime: .hours(8), value: 12.0), | ||
RepeatingScheduleValue(startTime: .hours(10), value: 9.0), | ||
RepeatingScheduleValue(startTime: .hours(12), value: 10.0), | ||
RepeatingScheduleValue(startTime: .hours(14), value: 11.0), | ||
RepeatingScheduleValue(startTime: .hours(16), value: 12.0), | ||
RepeatingScheduleValue(startTime: .hours(18), value: 8.0), | ||
RepeatingScheduleValue(startTime: .hours(21), value: 10.0)], | ||
timeZone: timeZone)! | ||
|
||
self.prescription = MockPrescription( | ||
datePrescribed: Date(), | ||
providerName: "Sally Seastar", | ||
cgmType: CGMType.g6, | ||
pumpType: PumpType.dash, | ||
bloodGlucoseUnit: .mgdl, | ||
basalRateSchedule: basalRateSchedule, | ||
glucoseTargetRangeSchedule: glucoseTargetRangeSchedule, | ||
carbRatioSchedule: carbRatioSchedule, | ||
insulinSensitivitySchedule: insulinSensitivitySchedule, | ||
maximumBasalRatePerHour: 3.0, | ||
maximumBolus: 5.0, | ||
suspendThreshold: GlucoseThreshold(unit: .milligramsPerDeciliter, value: 70), | ||
insulinModel: MockPrescription.InsulinModel(modelType: .rapidAdult, actionDuration: .hours(6), peakActivity: .hours(3)), | ||
preMealTargetRange: DoubleRange(minValue: 80.0, maxValue: 90.0), | ||
workoutTargetRange: DoubleRange(minValue: 80.0, maxValue: 90.0)) | ||
} | ||
} | ||
|
||
public func getPrescriptionData(completion: @escaping (Result<MockPrescription, Error>) -> Void) { | ||
completion(.success(self.prescription)) | ||
} | ||
} |
Oops, something went wrong.