PumpHistoryEvent.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Foundation
  2. struct PumpHistoryEvent: JSON, Equatable {
  3. let id: String
  4. let type: EventType
  5. let timestamp: Date
  6. let amount: Decimal?
  7. let duration: Int?
  8. let durationMin: Int?
  9. let rate: Decimal?
  10. let temp: TempType?
  11. let carbInput: Int?
  12. var note: String? = nil
  13. }
  14. enum EventType: String, JSON {
  15. case bolus = "Bolus"
  16. case mealBulus = "Meal Bolus"
  17. case correctionBolus = "Correction Bolus"
  18. case snackBolus = "Snack Bolus"
  19. case bolusWizard = "BolusWizard"
  20. case tempBasal = "TempBasal"
  21. case tempBasalDuration = "TempBasalDuration"
  22. case pumpSuspend = "PumpSuspend"
  23. case pumpResume = "PumpResume"
  24. case rewind = "Rewind"
  25. case prime = "Prime"
  26. case journalCarbs = "JournalEntryMealMarker"
  27. case nsTempBasal = "Temp Basal"
  28. case nsCarbCorrection = "Carb Correction"
  29. case nsTempTarget = "Temporary Target"
  30. case nsSensorChange = "Sensor Start"
  31. }
  32. enum TempType: String, JSON {
  33. case absolute
  34. case percent
  35. }
  36. extension PumpHistoryEvent {
  37. private enum CodingKeys: String, CodingKey {
  38. case id
  39. case type = "_type"
  40. case timestamp
  41. case amount
  42. case duration
  43. case durationMin = "duration (min)"
  44. case rate
  45. case temp
  46. case carbInput = "carb_input"
  47. case note
  48. }
  49. }