TherapySetting.swift 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // TherapySetting.swift
  3. // LoopKit
  4. //
  5. // Created by Rick Pasetto on 7/14/20.
  6. // Copyright © 2020 LoopKit Authors. All rights reserved.
  7. //
  8. public enum TherapySetting: String {
  9. case glucoseTargetRange
  10. case preMealCorrectionRangeOverride
  11. case workoutCorrectionRangeOverride
  12. case suspendThreshold
  13. case basalRate
  14. case deliveryLimits
  15. case insulinModel
  16. case carbRatio
  17. case insulinSensitivity
  18. case none
  19. }
  20. public extension TherapySetting {
  21. // The following comes from https://tidepool.atlassian.net/browse/IFU-24
  22. var title: String {
  23. switch self {
  24. case .glucoseTargetRange:
  25. return LocalizedString("Correction Range", comment: "Title text for glucose target range")
  26. case .preMealCorrectionRangeOverride:
  27. return String(format: LocalizedString("%@ Range", comment: "Format for correction range override therapy setting card"), CorrectionRangeOverrides.Preset.preMeal.title)
  28. case .workoutCorrectionRangeOverride:
  29. return String(format: LocalizedString("%@ Range", comment: "Format for correction range override therapy setting card"), CorrectionRangeOverrides.Preset.workout.title)
  30. case .suspendThreshold:
  31. return LocalizedString("Glucose Safety Limit", comment: "Title text for glucose safety limit")
  32. case .basalRate:
  33. return LocalizedString("Basal Rates", comment: "Title text for basal rates")
  34. case .deliveryLimits:
  35. return LocalizedString("Delivery Limits", comment: "Title text for delivery limits")
  36. case .insulinModel:
  37. return LocalizedString("Insulin Model", comment: "Title text for fast acting insulin model")
  38. case .carbRatio:
  39. return LocalizedString("Carb Ratios", comment: "Title text for carb ratios")
  40. case .insulinSensitivity:
  41. return LocalizedString("Insulin Sensitivities", comment: "Title text for insulin sensitivity")
  42. case .none:
  43. return ""
  44. }
  45. }
  46. var smallTitle: String {
  47. switch self {
  48. default:
  49. return title
  50. }
  51. }
  52. func descriptiveText(appName: String) -> String {
  53. switch self {
  54. case .glucoseTargetRange:
  55. return String(format: LocalizedString("Correction Range is the glucose value (or range of values) that you want %1$@ to aim for in adjusting your basal insulin and helping you calculate your boluses.", comment: "Descriptive text for glucose target range (1: app name)"), appName)
  56. case .preMealCorrectionRangeOverride:
  57. return LocalizedString("Temporarily lower your glucose target before a meal to impact post-meal glucose spikes.", comment: "Descriptive text for pre-meal correction range override")
  58. case .workoutCorrectionRangeOverride:
  59. return LocalizedString("Temporarily raise your glucose target before, during, or after physical activity to reduce the risk of low glucose events.", comment: "Descriptive text for workout correction range override")
  60. case .suspendThreshold:
  61. return String(format: LocalizedString("%1$@ will deliver basal and recommend bolus insulin only if your glucose is predicted to be above this limit for the next three hours.", comment: "Descriptive format string for glucose safety limit (1: app name)"), appName)
  62. case .basalRate:
  63. return LocalizedString("Your Basal Rate of insulin is the number of units per hour that you want to use to cover your background insulin needs.", comment: "Descriptive text for basal rate")
  64. case .deliveryLimits:
  65. return "\(DeliveryLimits.Setting.maximumBasalRate.localizedDescriptiveText(appName: appName))\n\n\(DeliveryLimits.Setting.maximumBolus.localizedDescriptiveText(appName: appName))"
  66. case .insulinModel:
  67. return String(format: LocalizedString("For fast acting insulin, %1$@ assumes it is actively working for 6 hours. You can choose from different models for the peak activity.", comment: "Descriptive text for fast acting insulin model (1: app name)"), appName)
  68. case .carbRatio:
  69. return LocalizedString("Your Carb Ratio is the number of grams of carbohydrates covered by one unit of insulin.", comment: "Descriptive text for carb ratio")
  70. case .insulinSensitivity:
  71. return LocalizedString("Your Insulin Sensitivities refer to the drop in glucose expected from one unit of insulin.", comment: "Descriptive text for insulin sensitivity")
  72. case .none:
  73. return ""
  74. }
  75. }
  76. }
  77. // MARK: Guardrails
  78. public extension TherapySetting {
  79. var guardrailCaptionForLowValue: String {
  80. switch self {
  81. // For schedules & ranges where it's possible for more than 1 to be outside of guardrails
  82. case .glucoseTargetRange:
  83. return LocalizedString("A value you have entered is lower than what is typically recommended for most people.", comment: "Descriptive text for guardrail low value warning for schedule interface")
  84. default:
  85. return LocalizedString("The value you have entered is lower than what is typically recommended for most people.", comment: "Descriptive text for guardrail low value warning")
  86. }
  87. }
  88. var guardrailCaptionForHighValue: String {
  89. switch self {
  90. // For schedules & ranges where it's possible for more than 1 to be outside of guardrails
  91. case .glucoseTargetRange:
  92. return LocalizedString("A value you have entered is higher than what is typically recommended for most people.", comment: "Descriptive text for guardrail high value warning for schedule interface")
  93. default:
  94. return LocalizedString("The value you have entered is higher than what is typically recommended for most people.", comment: "Descriptive text for guardrail high value warning")
  95. }
  96. }
  97. var guardrailCaptionForOutsideValues: String {
  98. switch self {
  99. case .deliveryLimits:
  100. return LocalizedString("The values you have entered are outside of what is typically recommended for most people.", comment: "Descriptive text for guardrail high value warning")
  101. default:
  102. return LocalizedString("Some of the values you have entered are outside of what is typically recommended for most people.", comment: "Descriptive text for guardrail high value warning for schedule interface")
  103. }
  104. }
  105. var guardrailSaveWarningCaption: String {
  106. switch self {
  107. default:
  108. return LocalizedString("One or more of the values you have entered is outside of what is typically recommended for most people.", comment: "Descriptive text for saving settings outside the recommended range")
  109. }
  110. }
  111. }