MDT TBR fix

This commit is contained in:
Milos Kozak 2021-12-06 13:46:44 +01:00
parent a2c7f2a6d9
commit 0b102376c6

View file

@ -631,18 +631,25 @@ class MedtronicHistoryData @Inject constructor(
"pumpId=${tempBasalProcessDTO.pumpId}, pumpType=${medtronicPumpStatus.pumpType}, " +
"pumpSerial=${medtronicPumpStatus.serialNumber}]")
val result = pumpSync.syncTemporaryBasalWithTempId(
tryToGetByLocalTime(tempBasalProcessDTO.atechDateTime),
tbrEntry.insulinRate,
tempBasalProcessDTO.durationAsSeconds * 1000L,
isAbsolute = !tbrEntry.isPercent,
entryWithTempId.temporaryId,
PumpSync.TemporaryBasalType.NORMAL,
tempBasalProcessDTO.pumpId,
medtronicPumpStatus.pumpType,
medtronicPumpStatus.serialNumber)
aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithTempId - Result: $result")
if (tempBasalProcessDTO.durationAsSeconds == 0) {
rxBus.send(EventNewNotification(Notification(Notification.MDT_INVALID_HISTORY_DATA, rh.gs(R.string.invalid_history_data), Notification.URGENT)))
aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithPumpId - Skipped")
} else {
val result = pumpSync.syncTemporaryBasalWithTempId(
tryToGetByLocalTime(tempBasalProcessDTO.atechDateTime),
tbrEntry.insulinRate,
tempBasalProcessDTO.durationAsSeconds * 1000L,
isAbsolute = !tbrEntry.isPercent,
entryWithTempId.temporaryId,
PumpSync.TemporaryBasalType.NORMAL,
tempBasalProcessDTO.pumpId,
medtronicPumpStatus.pumpType,
medtronicPumpStatus.serialNumber
)
aapsLogger.debug(LTag.PUMP, "syncTemporaryBasalWithTempId - Result: $result")
}
pumpSyncStorage.removeTemporaryBasalWithTemporaryId(entryWithTempId.temporaryId)
tbrRecords.remove(entryWithTempId)