Merge pull request #1961 from andyrozman/bug1724_tbr_iob
Bug1724 tbr iob
This commit is contained in:
commit
d4ed32dd6c
|
@ -797,26 +797,70 @@ class MedtronicHistoryData @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if rewind items, need to fix any of current tempBasalProcessDTO items (bug 1724)
|
// TODO this solution needs to be overworked, commenting out for now
|
||||||
if (rewindList.isNotEmpty()) {
|
// val suspendList = getFilteredItems(newHistory, //
|
||||||
for (rewindEntry in rewindList) {
|
// setOf(PumpHistoryEntryType.SuspendPump))
|
||||||
for (tempBasalProcessDTO in processList) {
|
//
|
||||||
if (tempBasalProcessDTO.itemTwo==null) {
|
// val stopList : MutableList<PumpHistoryEntry> = mutableListOf()
|
||||||
val endTime: Long = DateTimeUtil.getATDWithAddedMinutes(tempBasalProcessDTO.itemOne.atechDateTime, tempBasalProcessDTO.itemOneTbr!!.durationMinutes)
|
// stopList.addAll(suspendList);
|
||||||
|
// stopList.addAll(rewindList);
|
||||||
if ((rewindEntry.atechDateTime > tempBasalProcessDTO.itemOne.atechDateTime) &&
|
//
|
||||||
(rewindEntry.atechDateTime < endTime)) {
|
// // TODO remove see if rewind items, need to fix any of current tempBasalProcessDTO items (bug 1724)
|
||||||
tempBasalProcessDTO.itemTwo = rewindEntry
|
// if (rewindList.isNotEmpty()) {
|
||||||
continue
|
// 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)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
return processList
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outList.size == 0) {
|
||||||
|
return null
|
||||||
|
} else if (outList.size==1) {
|
||||||
|
return outList[0]
|
||||||
|
} else {
|
||||||
|
// TODO
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun isTBRActive(dbEntry: PumpDbEntryTBR): Boolean {
|
fun isTBRActive(dbEntry: PumpDbEntryTBR): Boolean {
|
||||||
return isTBRActive(
|
return isTBRActive(
|
||||||
startTimestamp = dbEntry.date,
|
startTimestamp = dbEntry.date,
|
||||||
|
|
Loading…
Reference in a new issue