Add BG sources for uel (Calibration and Sensor Change)

This commit is contained in:
Philoul 2021-04-08 10:06:00 +02:00
parent ec9efefb93
commit 6114effb22
10 changed files with 80 additions and 31 deletions

View file

@ -131,8 +131,8 @@ class BGSourceFragment : DaggerFragment() {
activity?.let { activity ->
val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits())
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
//uel.log(Action.BG_REMOVED, XXXValueWithUnit.Timestamp(glucoseValue.timestamp))
uel.log(Action.BG_REMOVED, Sources.BG,
val source = Sources.BG //Todo Replace Sources.BG by Active BG Source plugin
uel.log(Action.BG_REMOVED, source,
ValueWithUnit.Timestamp(glucoseValue.timestamp))
disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe()
})

View file

@ -14,6 +14,9 @@ import info.nightscout.androidaps.activities.RequestDexcomPermissionActivity
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.transactions.CgmSourceTransaction
import info.nightscout.androidaps.interfaces.BgSourceInterface
import info.nightscout.androidaps.interfaces.PluginBase
@ -21,6 +24,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.receivers.DataWorker
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.T
@ -83,6 +87,7 @@ class DexcomPlugin @Inject constructor(
@Inject lateinit var dataWorker: DataWorker
@Inject lateinit var broadcastToXDrip: XDripBroadcast
@Inject lateinit var repository: AppRepository
@Inject lateinit var uel: UserEntryLogger
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
@ -150,8 +155,20 @@ class DexcomPlugin @Inject constructor(
broadcastToXDrip(it)
aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
}
result.sensorInsertionsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted sensor insertion $it") }
result.calibrationsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted calibration $it") }
result.sensorInsertionsInserted.forEach {
uel.log(Action.CAREPORTAL,
Sources.BG,
ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.TherapyEventType(it.type))
aapsLogger.debug(LTag.DATABASE, "Inserted sensor insertion $it")
}
result.calibrationsInserted.forEach {
uel.log(Action.CAREPORTAL,
Sources.BG,
ValueWithUnit.Timestamp(it.timestamp),
ValueWithUnit.TherapyEventType(it.type))
aapsLogger.debug(LTag.DATABASE, "Inserted calibration $it")
}
}
} catch (e: Exception) {
aapsLogger.error("Error while processing intent from Dexcom App", e)

View file

@ -233,6 +233,14 @@ class Translator @Inject internal constructor(
Sources.Announcement -> TODO()
Sources.Actions -> TODO()
Sources.BG -> TODO()
Sources.Dexcom -> TODO()
Sources.Eversense -> TODO()
Sources.Glimp -> TODO()
Sources.MM640g -> TODO()
Sources.NSClientSource -> TODO()
Sources.PocTech -> TODO()
Sources.Tomato -> TODO()
Sources.Xdrip -> TODO()
Sources.LocalProfile -> TODO()
Sources.Maintenance -> TODO()
Sources.NSProfile -> TODO()

View file

@ -106,6 +106,14 @@ class UserEntryMapper {
Actions (UserEntry.Sources.Actions),
Automation (UserEntry.Sources.Automation),
BG (UserEntry.Sources.BG),
Dexcom (UserEntry.Sources.Dexcom),
Eversense (UserEntry.Sources.Eversense),
Glimp (UserEntry.Sources.Glimp),
MM640g (UserEntry.Sources.MM640g),
NSClientSource (UserEntry.Sources.BG),
PocTech (UserEntry.Sources.PocTech),
Tomato (UserEntry.Sources.Tomato),
Xdrip (UserEntry.Sources.Xdrip),
LocalProfile (UserEntry.Sources.LocalProfile),
Loop (UserEntry.Sources.Loop),
Maintenance (UserEntry.Sources.Maintenance),

View file

@ -61,6 +61,14 @@ class UserEntryPresentationHelper @Inject constructor(
Sources.Actions -> R.drawable.ic_action
Sources.Automation -> R.drawable.ic_automation
Sources.BG -> R.drawable.ic_generic_cgm
Sources.Dexcom -> R.drawable.ic_dexcom_g6
Sources.Eversense -> R.drawable.ic_eversense
Sources.Glimp -> R.drawable.ic_glimp
Sources.MM640g -> R.drawable.ic_generic_cgm
Sources.NSClientSource -> R.drawable.ic_nsclient_bg
Sources.PocTech -> R.drawable.ic_poctech
Sources.Tomato -> R.drawable.ic_sensor
Sources.Xdrip -> R.drawable.ic_blooddrop_48
Sources.LocalProfile -> R.drawable.ic_local_profile
Sources.Loop -> R.drawable.ic_loop_closed_white
Sources.Maintenance -> R.drawable.ic_maintenance

View file

@ -125,6 +125,14 @@ data class UserEntry(
Actions, //From Actions plugin
Automation, //From Automation plugin
BG, //From BG plugin => Add One Source per BG Source for Calibration or Sensor Change
Dexcom,
Eversense,
Glimp,
MM640g,
NSClientSource,
PocTech,
Tomato,
Xdrip,
LocalProfile, //From LocalProfile plugin
Loop, //From Loop plugin
Maintenance, //From Maintenance plugin