Merge pull request #1961 from andyrozman/bug1724_tbr_iob

Bug1724 tbr iob
This commit is contained in:
Milos Kozak 2022-07-30 22:47:29 +02:00 committed by GitHub
commit d4ed32dd6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -797,24 +797,68 @@ class MedtronicHistoryData @Inject constructor(
}
}
// see if rewind items, need to fix any of current tempBasalProcessDTO items (bug 1724)
if (rewindList.isNotEmpty()) {
for (rewindEntry in rewindList) {
for (tempBasalProcessDTO in processList) {
if (tempBasalProcessDTO.itemTwo==null) {
val endTime: Long = DateTimeUtil.getATDWithAddedMinutes(tempBasalProcessDTO.itemOne.atechDateTime, tempBasalProcessDTO.itemOneTbr!!.durationMinutes)
// TODO this solution needs to be overworked, commenting out for now
// val suspendList = getFilteredItems(newHistory, //
// setOf(PumpHistoryEntryType.SuspendPump))
//
// val stopList : MutableList<PumpHistoryEntry> = mutableListOf()
// stopList.addAll(suspendList);
// stopList.addAll(rewindList);
//
// // TODO remove see if rewind items, need to fix any of current tempBasalProcessDTO items (bug 1724)
// if (rewindList.isNotEmpty()) {
// for (rewindEntry in rewindList) {
// for (tempBasalProcessDTO in processList) {
// if (tempBasalProcessDTO.itemTwo==null) {
// val endTime: Long = DateTimeUtil.getATDWithAddedMinutes(tempBasalProcessDTO.itemOne.atechDateTime, tempBasalProcessDTO.itemOneTbr!!.durationMinutes)
//
// if ((rewindEntry.atechDateTime > tempBasalProcessDTO.itemOne.atechDateTime) &&
// (rewindEntry.atechDateTime < endTime)) {
// tempBasalProcessDTO.itemTwo = rewindEntry
// continue
// }
// }
// }
// }
// }
//
// // see if have rewind/stop items that need to fix any of current tempBasalProcessDTO items (bug 1724)
// if (stopList.isNotEmpty()) {
// for (tempBasalProcessDTO in processList) {
// if (tempBasalProcessDTO.itemTwo==null) {
// val endTime: Long = DateTimeUtil.getATDWithAddedMinutes(tempBasalProcessDTO.itemOne.atechDateTime, tempBasalProcessDTO.itemOneTbr!!.durationMinutes)
//
// val findNearestEntry = findNearestEntry(tempBasalProcessDTO.itemOne.atechDateTime, endTime, stopList);
//
// if (findNearestEntry!=null) {
// tempBasalProcessDTO.itemTwo = findNearestEntry
// stopList.remove(findNearestEntry)
// }
// }
// }
// }
if ((rewindEntry.atechDateTime > tempBasalProcessDTO.itemOne.atechDateTime) &&
(rewindEntry.atechDateTime < endTime)) {
tempBasalProcessDTO.itemTwo = rewindEntry
continue
}
}
}
return processList
}
fun findNearestEntry(startTime: Long, endTime: Long, list: MutableList<PumpHistoryEntry>) : PumpHistoryEntry? {
val outList: MutableList<PumpHistoryEntry> = mutableListOf()
for (pumpHistoryEntry in list) {
if ((pumpHistoryEntry.atechDateTime > startTime) &&
(pumpHistoryEntry.atechDateTime < endTime)) {
outList.add(pumpHistoryEntry)
}
}
return processList
if (outList.size == 0) {
return null
} else if (outList.size==1) {
return outList[0]
} else {
// TODO
return null
}
}
fun isTBRActive(dbEntry: PumpDbEntryTBR): Boolean {