mirror of
https://github.com/bckelley/tconnectsync.git
synced 2026-08-24 11:44:12 -05:00
add basal therapy event type, now that Tandem is storing it along with bolus/cgm/bgs
This commit is contained in:
@@ -429,3 +429,52 @@ class BolusTherapyEvent(TherapyEvent):
|
||||
'type': 'BG',
|
||||
'uploadId': 0}
|
||||
"""
|
||||
|
||||
class BasalTherapyEvent(TherapyEvent):
|
||||
"""
|
||||
{
|
||||
'basalRate': {
|
||||
'duration': 0,
|
||||
'percent': 0,
|
||||
'value': 0.0
|
||||
},
|
||||
'displayInHistory': 0,
|
||||
'eventDateTime': '2022-12-02T00:00:00',
|
||||
'note': {
|
||||
'id': 0,
|
||||
'indexId': '16403',
|
||||
'eventTypeId': 90,
|
||||
'sourceRecordId': 0,
|
||||
'eventId': 0,
|
||||
'active': False
|
||||
},
|
||||
'noteDate': {},
|
||||
'requestDateTime': '0001-01-01T00:00:00',
|
||||
'type': 'Basal',
|
||||
'description': 'NDE',
|
||||
'sourceRecId': xxx,
|
||||
'eventTypeId': 0,
|
||||
'indexId': 0,
|
||||
'uploadId': 0,
|
||||
'interactive': 1,
|
||||
'tempRateId': 0,
|
||||
'tempRateCompleted': 0,
|
||||
'tempRateActivated': 0
|
||||
}
|
||||
"""
|
||||
basalRateValue = None
|
||||
basalRatePercent = None
|
||||
basalRateDuration = None
|
||||
eventTime = None
|
||||
|
||||
|
||||
@classmethod
|
||||
def parse(_, json):
|
||||
self = CGMTherapyEvent()
|
||||
TherapyEvent.parse(self, json)
|
||||
if 'basalRate' in json:
|
||||
self.basalRateValue = json['basalRate']['value']
|
||||
self.basalRatePercent = json['basalRate']['percent']
|
||||
self.basalRateDuration = json['basalRate']['duration']
|
||||
self.eventTime = json['eventDateTime']
|
||||
return self
|
||||
@@ -1,4 +1,4 @@
|
||||
from tconnectsync.domain.therapy_event import BolusTherapyEvent, CGMTherapyEvent, BGTherapyEvent
|
||||
from tconnectsync.domain.therapy_event import BolusTherapyEvent, CGMTherapyEvent, BGTherapyEvent, BasalTherapyEvent
|
||||
from tconnectsync.parser.tconnect import TConnectEntry
|
||||
|
||||
import logging
|
||||
@@ -9,6 +9,7 @@ def split_therapy_events(ciqTherapyEvents):
|
||||
bolusEvents = []
|
||||
cgmEvents = []
|
||||
bgEvents = []
|
||||
basalEvents = []
|
||||
for e in ciqTherapyEvents['event']:
|
||||
event = TConnectEntry.parse_therapy_event(e)
|
||||
if isinstance(event, BolusTherapyEvent):
|
||||
@@ -17,7 +18,10 @@ def split_therapy_events(ciqTherapyEvents):
|
||||
cgmEvents.append(event)
|
||||
elif isinstance(event, BGTherapyEvent):
|
||||
bgEvents.append(event)
|
||||
elif isinstance(event, BasalTherapyEvent):
|
||||
basalEvents.append(event)
|
||||
|
||||
|
||||
logger.debug("split_therapy_events: %d bolus, %d CGM, %d BG" % (len(bolusEvents), len(cgmEvents), len(bgEvents)))
|
||||
logger.debug("split_therapy_events: %d bolus, %d CGM, %d BG, %d basal" % (len(bolusEvents), len(cgmEvents), len(bgEvents), len(basalEvents)))
|
||||
# TODO: BG events (CGM Calibration) values are not currently returned from ciq_therapy_events.py
|
||||
return bolusEvents, cgmEvents
|
||||
|
||||
@@ -3,7 +3,7 @@ import sys
|
||||
import arrow
|
||||
from tconnectsync.domain.bolus import Bolus
|
||||
|
||||
from tconnectsync.domain.therapy_event import BolusTherapyEvent, CGMTherapyEvent, BGTherapyEvent
|
||||
from tconnectsync.domain.therapy_event import BolusTherapyEvent, CGMTherapyEvent, BGTherapyEvent, BasalTherapyEvent
|
||||
|
||||
try:
|
||||
from ..secret import TIMEZONE_NAME
|
||||
@@ -202,6 +202,8 @@ class TConnectEntry:
|
||||
return CGMTherapyEvent.parse(data)
|
||||
elif data["type"] == "BG":
|
||||
return BGTherapyEvent.parse(data)
|
||||
elif data["type"] == "Basal":
|
||||
return BasalTherapyEvent.parse(data)
|
||||
|
||||
raise UnknownTherapyEventException(data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user