Add BG sources for uel (Calibration and Sensor Change)
This commit is contained in:
parent
ec9efefb93
commit
6114effb22
10 changed files with 80 additions and 31 deletions
|
@ -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()
|
||||
})
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -39,35 +39,43 @@ class UserEntryPresentationHelper @Inject constructor(
|
|||
}
|
||||
|
||||
fun iconId(source: Sources): Int = when (source) {
|
||||
Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs
|
||||
Sources.InsulinDialog -> R.drawable.ic_bolus
|
||||
Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs
|
||||
Sources.WizardDialog -> R.drawable.ic_calculator
|
||||
Sources.QuickWizard -> R.drawable.ic_quick_wizard
|
||||
Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs
|
||||
Sources.InsulinDialog -> R.drawable.ic_bolus
|
||||
Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs
|
||||
Sources.WizardDialog -> R.drawable.ic_calculator
|
||||
Sources.QuickWizard -> R.drawable.ic_quick_wizard
|
||||
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.LoopDialog -> R.drawable.ic_loop_closed
|
||||
Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
|
||||
Sources.CalibrationDialog -> R.drawable.ic_calibration
|
||||
Sources.FillDialog -> R.drawable.ic_cp_pump_canula
|
||||
Sources.BgCheck -> R.drawable.ic_cp_bgcheck
|
||||
Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
|
||||
Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
|
||||
Sources.Note -> R.drawable.ic_cp_note
|
||||
Sources.Exercise -> R.drawable.ic_cp_exercise
|
||||
Sources.Question -> R.drawable.ic_cp_question
|
||||
Sources.Announcement -> R.drawable.ic_cp_announcement
|
||||
Sources.Actions -> R.drawable.ic_action
|
||||
Sources.Automation -> R.drawable.ic_automation
|
||||
Sources.BG -> R.drawable.ic_generic_cgm
|
||||
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.LoopDialog -> R.drawable.ic_loop_closed
|
||||
Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
|
||||
Sources.CalibrationDialog -> R.drawable.ic_calibration
|
||||
Sources.FillDialog -> R.drawable.ic_cp_pump_canula
|
||||
Sources.BgCheck -> R.drawable.ic_cp_bgcheck
|
||||
Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
|
||||
Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
|
||||
Sources.Note -> R.drawable.ic_cp_note
|
||||
Sources.Exercise -> R.drawable.ic_cp_exercise
|
||||
Sources.Question -> R.drawable.ic_cp_question
|
||||
Sources.Announcement -> R.drawable.ic_cp_announcement
|
||||
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
|
||||
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.DanaR -> R.drawable.ic_danars_128
|
||||
Sources.DanaRC -> R.drawable.ic_danars_128
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue