From 9f6a2fcc4ed51be7a734ea825ff049c727c9ea80 Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 30 Nov 2021 21:55:24 +0100 Subject: [PATCH] Add BG value in CarePortal events --- .../nsclient/NSClientAddUpdateWorker.kt | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt index 04845c27b5..2765eb8e39 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt @@ -266,21 +266,23 @@ class NSClientAddUpdateWorker( TherapyEvent.Type.INSULIN_CHANGE.text -> Action.RESERVOIR_CHANGE else -> Action.CAREPORTAL } - result.inserted.forEach { + result.inserted.forEach { therapyEvent -> uel.log(action, Sources.NSClient, - it.note ?: "", - ValueWithUnit.Timestamp(it.timestamp), - ValueWithUnit.TherapyEventType(it.type) + therapyEvent.note ?: "", + ValueWithUnit.Timestamp(therapyEvent.timestamp), + ValueWithUnit.TherapyEventType(therapyEvent.type), + ValueWithUnit.fromGlucoseUnit(therapyEvent.glucose ?:0.0,therapyEvent.glucoseUnit.toString).takeIf { therapyEvent.glucose != null } ) - aapsLogger.debug(LTag.DATABASE, "Inserted TherapyEvent $it") + aapsLogger.debug(LTag.DATABASE, "Inserted TherapyEvent $therapyEvent") } - result.invalidated.forEach { + result.invalidated.forEach { therapyEvent -> uel.log(Action.CAREPORTAL_REMOVED, Sources.NSClient, - it.note ?: "", - ValueWithUnit.Timestamp(it.timestamp), - ValueWithUnit.TherapyEventType(it.type) + therapyEvent.note ?: "", + ValueWithUnit.Timestamp(therapyEvent.timestamp), + ValueWithUnit.TherapyEventType(therapyEvent.type), + ValueWithUnit.fromGlucoseUnit(therapyEvent.glucose ?:0.0, therapyEvent.glucoseUnit.toString).takeIf { therapyEvent.glucose != null } ) - aapsLogger.debug(LTag.DATABASE, "Invalidated TherapyEvent $it") + aapsLogger.debug(LTag.DATABASE, "Invalidated TherapyEvent $therapyEvent") } result.updatedNsId.forEach { aapsLogger.debug(LTag.DATABASE, "Updated nsId TherapyEvent $it")