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 -> activity?.let { activity ->
val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits()) val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits())
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
//uel.log(Action.BG_REMOVED, XXXValueWithUnit.Timestamp(glucoseValue.timestamp)) val source = Sources.BG //Todo Replace Sources.BG by Active BG Source plugin
uel.log(Action.BG_REMOVED, Sources.BG, uel.log(Action.BG_REMOVED, source,
ValueWithUnit.Timestamp(glucoseValue.timestamp)) ValueWithUnit.Timestamp(glucoseValue.timestamp))
disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe() 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.AppRepository
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.entities.TherapyEvent 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.database.transactions.CgmSourceTransaction
import info.nightscout.androidaps.interfaces.BgSourceInterface import info.nightscout.androidaps.interfaces.BgSourceInterface
import info.nightscout.androidaps.interfaces.PluginBase 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.interfaces.PluginType
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.receivers.DataWorker import info.nightscout.androidaps.receivers.DataWorker
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
@ -83,6 +87,7 @@ class DexcomPlugin @Inject constructor(
@Inject lateinit var dataWorker: DataWorker @Inject lateinit var dataWorker: DataWorker
@Inject lateinit var broadcastToXDrip: XDripBroadcast @Inject lateinit var broadcastToXDrip: XDripBroadcast
@Inject lateinit var repository: AppRepository @Inject lateinit var repository: AppRepository
@Inject lateinit var uel: UserEntryLogger
init { init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this) (context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
@ -150,8 +155,20 @@ class DexcomPlugin @Inject constructor(
broadcastToXDrip(it) broadcastToXDrip(it)
aapsLogger.debug(LTag.DATABASE, "Updated bg $it") aapsLogger.debug(LTag.DATABASE, "Updated bg $it")
} }
result.sensorInsertionsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted sensor insertion $it") } result.sensorInsertionsInserted.forEach {
result.calibrationsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted calibration $it") } 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) { } catch (e: Exception) {
aapsLogger.error("Error while processing intent from Dexcom App", e) 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.Announcement -> TODO()
Sources.Actions -> TODO() Sources.Actions -> TODO()
Sources.BG -> 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.LocalProfile -> TODO()
Sources.Maintenance -> TODO() Sources.Maintenance -> TODO()
Sources.NSProfile -> TODO() Sources.NSProfile -> TODO()

View file

@ -106,6 +106,14 @@ class UserEntryMapper {
Actions (UserEntry.Sources.Actions), Actions (UserEntry.Sources.Actions),
Automation (UserEntry.Sources.Automation), Automation (UserEntry.Sources.Automation),
BG (UserEntry.Sources.BG), 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), LocalProfile (UserEntry.Sources.LocalProfile),
Loop (UserEntry.Sources.Loop), Loop (UserEntry.Sources.Loop),
Maintenance (UserEntry.Sources.Maintenance), Maintenance (UserEntry.Sources.Maintenance),

View file

@ -39,35 +39,43 @@ class UserEntryPresentationHelper @Inject constructor(
} }
fun iconId(source: Sources): Int = when (source) { fun iconId(source: Sources): Int = when (source) {
Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs
Sources.InsulinDialog -> R.drawable.ic_bolus Sources.InsulinDialog -> R.drawable.ic_bolus
Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs
Sources.WizardDialog -> R.drawable.ic_calculator Sources.WizardDialog -> R.drawable.ic_calculator
Sources.QuickWizard -> R.drawable.ic_quick_wizard Sources.QuickWizard -> R.drawable.ic_quick_wizard
Sources.ExtendedBolusDialog -> R.drawable.ic_actions_startextbolus Sources.ExtendedBolusDialog -> R.drawable.ic_actions_startextbolus
Sources.TTDialog -> R.drawable.ic_temptarget_high Sources.TTDialog -> R.drawable.ic_temptarget_high
Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch
Sources.LoopDialog -> R.drawable.ic_loop_closed Sources.LoopDialog -> R.drawable.ic_loop_closed
Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
Sources.CalibrationDialog -> R.drawable.ic_calibration Sources.CalibrationDialog -> R.drawable.ic_calibration
Sources.FillDialog -> R.drawable.ic_cp_pump_canula Sources.FillDialog -> R.drawable.ic_cp_pump_canula
Sources.BgCheck -> R.drawable.ic_cp_bgcheck Sources.BgCheck -> R.drawable.ic_cp_bgcheck
Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
Sources.BatteryChange -> R.drawable.ic_cp_pump_battery Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
Sources.Note -> R.drawable.ic_cp_note Sources.Note -> R.drawable.ic_cp_note
Sources.Exercise -> R.drawable.ic_cp_exercise Sources.Exercise -> R.drawable.ic_cp_exercise
Sources.Question -> R.drawable.ic_cp_question Sources.Question -> R.drawable.ic_cp_question
Sources.Announcement -> R.drawable.ic_cp_announcement Sources.Announcement -> R.drawable.ic_cp_announcement
Sources.Actions -> R.drawable.ic_action Sources.Actions -> R.drawable.ic_action
Sources.Automation -> R.drawable.ic_automation Sources.Automation -> R.drawable.ic_automation
Sources.BG -> R.drawable.ic_generic_cgm Sources.BG -> R.drawable.ic_generic_cgm
Sources.LocalProfile -> R.drawable.ic_local_profile Sources.Dexcom -> R.drawable.ic_dexcom_g6
Sources.Loop -> R.drawable.ic_loop_closed_white Sources.Eversense -> R.drawable.ic_eversense
Sources.Maintenance -> R.drawable.ic_maintenance Sources.Glimp -> R.drawable.ic_glimp
Sources.NSClient -> R.drawable.ic_nightscout_syncs Sources.MM640g -> R.drawable.ic_generic_cgm
Sources.NSProfile -> R.drawable.ic_nightscout_profile Sources.NSClientSource -> R.drawable.ic_nsclient_bg
Sources.Objectives -> R.drawable.ic_graduation Sources.PocTech -> R.drawable.ic_poctech
Sources.Pump -> R.drawable.ic_generic_icon 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
Sources.NSClient -> R.drawable.ic_nightscout_syncs
Sources.NSProfile -> R.drawable.ic_nightscout_profile
Sources.Objectives -> R.drawable.ic_graduation
Sources.Pump -> R.drawable.ic_generic_icon
Sources.Dana -> R.drawable.ic_danars_128 Sources.Dana -> R.drawable.ic_danars_128
Sources.DanaR -> R.drawable.ic_danars_128 Sources.DanaR -> R.drawable.ic_danars_128
Sources.DanaRC -> R.drawable.ic_danars_128 Sources.DanaRC -> R.drawable.ic_danars_128

View file

@ -125,6 +125,14 @@ data class UserEntry(
Actions, //From Actions plugin Actions, //From Actions plugin
Automation, //From Automation plugin Automation, //From Automation plugin
BG, //From BG plugin => Add One Source per BG Source for Calibration or Sensor Change 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 LocalProfile, //From LocalProfile plugin
Loop, //From Loop plugin Loop, //From Loop plugin
Maintenance, //From Maintenance plugin Maintenance, //From Maintenance plugin