NSC: fix sync of recordonly boluses

This commit is contained in:
Milos Kozak 2023-09-14 18:16:58 +02:00
parent de3f24a8fb
commit d302e6eb55

View file

@ -5,6 +5,7 @@ import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.Carbs import info.nightscout.database.entities.Carbs
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
class DetailedBolusInfo { class DetailedBolusInfo {
@ -97,6 +98,9 @@ class DetailedBolusInfo {
glucoseType = glucoseType?.toDbMeterType() glucoseType = glucoseType?.toDbMeterType()
) )
/**
* Used for create record going directly to db (record only)
*/
fun createBolus(): Bolus = fun createBolus(): Bolus =
if (insulin != 0.0) if (insulin != 0.0)
Bolus( Bolus(
@ -104,6 +108,7 @@ class DetailedBolusInfo {
amount = insulin, amount = insulin,
type = bolusType.toDBbBolusType(), type = bolusType.toDBbBolusType(),
notes = notes, notes = notes,
interfaceIDs_backing = InterfaceIDs(pumpId = timestamp)
) )
else throw IllegalStateException("insulin == 0.0") else throw IllegalStateException("insulin == 0.0")
@ -113,7 +118,7 @@ class DetailedBolusInfo {
timestamp = carbsTimestamp ?: timestamp, timestamp = carbsTimestamp ?: timestamp,
amount = carbs, amount = carbs,
duration = carbsDuration, duration = carbsDuration,
notes = notes, notes = notes
) )
else throw IllegalStateException("carbs == 0.0") else throw IllegalStateException("carbs == 0.0")