Merge pull request #607 from Philoul/NewUelLog

New UserEntries
This commit is contained in:
Milos Kozak 2021-09-22 18:20:06 +02:00 committed by GitHub
commit b40428c986
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 26 deletions

View file

@ -4,12 +4,17 @@ import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
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.InsertTherapyEventAnnouncementTransaction import info.nightscout.androidaps.database.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
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.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
@ -38,7 +43,8 @@ class LocalAlertUtils @Inject constructor(
private val smsCommunicatorPlugin: SmsCommunicatorPlugin, private val smsCommunicatorPlugin: SmsCommunicatorPlugin,
private val config: Config, private val config: Config,
private val repository: AppRepository, private val repository: AppRepository,
private val dateUtil: DateUtil private val dateUtil: DateUtil,
private val uel: UserEntryLogger
) { ) {
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -59,6 +65,7 @@ class LocalAlertUtils @Inject constructor(
aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated) aapsLogger.debug(LTag.CORE, "Generating pump unreachable alarm. lastConnection: " + dateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated)
sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold()) sp.putLong("nextPumpDisconnectedAlarm", System.currentTimeMillis() + pumpUnreachableThreshold())
rxBus.send(EventNewNotification(Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT).also { it.soundId = R.raw.alarm })) rxBus.send(EventNewNotification(Notification(Notification.PUMP_UNREACHABLE, resourceHelper.gs(R.string.pump_unreachable), Notification.URGENT).also { it.soundId = R.raw.alarm }))
uel.log(Action.CAREPORTAL, Sources.Aaps, resourceHelper.gs(R.string.pump_unreachable), ValueWithUnit.TherapyEventType(TherapyEvent.Type.ANNOUNCEMENT))
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true))
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(resourceHelper.gs(R.string.pump_unreachable))).subscribe() disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(resourceHelper.gs(R.string.pump_unreachable))).subscribe()
} }
@ -117,6 +124,7 @@ class LocalAlertUtils @Inject constructor(
n.soundId = R.raw.alarm n.soundId = R.raw.alarm
sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold()) sp.putLong("nextMissedReadingsAlarm", System.currentTimeMillis() + missedReadingsThreshold())
rxBus.send(EventNewNotification(n)) rxBus.send(EventNewNotification(n))
uel.log(Action.CAREPORTAL, Sources.Aaps, resourceHelper.gs(R.string.missed_bg_readings), ValueWithUnit.TherapyEventType(TherapyEvent.Type.ANNOUNCEMENT))
if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) { if (sp.getBoolean(R.string.key_ns_create_announcements_from_errors, true)) {
n.text?.let { disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(it)).subscribe() } n.text?.let { disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(it)).subscribe() }
} }

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
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.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
@ -30,7 +31,8 @@ class PumpSyncImplementation @Inject constructor(
private val rxBus: RxBusWrapper, private val rxBus: RxBusWrapper,
private val resourceHelper: ResourceHelper, private val resourceHelper: ResourceHelper,
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val repository: AppRepository private val repository: AppRepository,
private val uel: UserEntryLogger
) : PumpSync { ) : PumpSync {
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -213,6 +215,7 @@ class PumpSyncImplementation @Inject constructor(
pumpType = pumpType.toDbPumpType(), pumpType = pumpType.toDbPumpType(),
pumpSerial = pumpSerial) pumpSerial = pumpSerial)
) )
uel.log(UserEntry.Action.CAREPORTAL, pumpType.source, note, ValueWithUnit.Timestamp(timestamp), ValueWithUnit.TherapyEventType(type.toDBbEventType()))
repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(therapyEvent)) repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(therapyEvent))
.doOnError { .doOnError {
aapsLogger.error(LTag.DATABASE, "Error while saving TherapyEvent", it) aapsLogger.error(LTag.DATABASE, "Error while saving TherapyEvent", it)

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.common.defs
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.embedments.InterfaceIDs import info.nightscout.androidaps.database.embedments.InterfaceIDs
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.plugins.common.ManufacturerType import info.nightscout.androidaps.plugins.common.ManufacturerType
import info.nightscout.androidaps.utils.Round import info.nightscout.androidaps.utils.Round
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -50,7 +51,8 @@ enum class PumpType {
baseBasalMinValue = 0.01, baseBasalMinValue = 0.01,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = DoseStepSize.ComboBasal, baseBasalSpecialSteps = DoseStepSize.ComboBasal,
pumpCapability = PumpCapability.ComboCapabilities), pumpCapability = PumpCapability.ComboCapabilities,
source = Sources.Combo),
ACCU_CHEK_SPIRIT(description = "Accu-Chek Spirit", ACCU_CHEK_SPIRIT(description = "Accu-Chek Spirit",
manufacturer = ManufacturerType.Roche, manufacturer = ManufacturerType.Roche,
model = "Spirit", model = "Spirit",
@ -90,7 +92,8 @@ enum class PumpType {
baseBasalMaxValue = null, baseBasalMaxValue = null,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = DoseStepSize.InsightBasal, baseBasalSpecialSteps = DoseStepSize.InsightBasal,
pumpCapability = PumpCapability.InsightCapabilities), pumpCapability = PumpCapability.InsightCapabilities,
source = Sources.Insight),
ACCU_CHEK_SOLO(description = "Accu-Chek Solo", ACCU_CHEK_SOLO(description = "Accu-Chek Solo",
manufacturer = ManufacturerType.Roche, manufacturer = ManufacturerType.Roche,
model = "Solo", model = "Solo",
@ -133,7 +136,8 @@ enum class PumpType {
baseBasalMinValue = 0.04, baseBasalMinValue = 0.04,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaCapabilities), pumpCapability = PumpCapability.DanaCapabilities,
source = Sources.DanaR),
DANA_R_KOREAN(description = "DanaR Korean", DANA_R_KOREAN(description = "DanaR Korean",
manufacturer = ManufacturerType.Sooil, manufacturer = ManufacturerType.Sooil,
model = "DanaRKorean", model = "DanaRKorean",
@ -146,7 +150,8 @@ enum class PumpType {
baseBasalMinValue = 0.1, baseBasalMinValue = 0.1,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaCapabilities), pumpCapability = PumpCapability.DanaCapabilities,
source = Sources.DanaRC),
DANA_RS(description = "DanaRS", DANA_RS(description = "DanaRS",
manufacturer = ManufacturerType.Sooil, manufacturer = ManufacturerType.Sooil,
model = "DanaRS", model = "DanaRS",
@ -159,10 +164,11 @@ enum class PumpType {
baseBasalMinValue = 0.04, baseBasalMinValue = 0.04,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaWithHistoryCapabilities), pumpCapability = PumpCapability.DanaWithHistoryCapabilities,
source = Sources.DanaRS),
DANA_RS_KOREAN(description = "DanaRSKorean", model = "DanaRSKorean", parent = DANA_RS), DANA_RS_KOREAN(description = "DanaRSKorean", model = "DanaRSKorean", parent = DANA_RS),
DANA_I(description = "DanaI", model = "DanaI", parent = DANA_RS), DANA_I(description = "DanaI", model = "DanaI", parent = DANA_RS, source = Sources.DanaI),
DANA_RV2(description = "DanaRv2", model = "DanaRv2", parent = DANA_RS), DANA_RV2(description = "DanaRv2", model = "DanaRv2", parent = DANA_RS, source = Sources.DanaRv2),
OMNIPOD_EROS(description = "Omnipod Eros", OMNIPOD_EROS(description = "Omnipod Eros",
manufacturer = ManufacturerType.Insulet, manufacturer = ManufacturerType.Insulet,
model = "Eros", model = "Eros",
@ -177,7 +183,8 @@ enum class PumpType {
baseBasalStep = 0.05, baseBasalStep = 0.05,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.OmnipodCapabilities, pumpCapability = PumpCapability.OmnipodCapabilities,
hasCustomUnreachableAlertCheck = true), hasCustomUnreachableAlertCheck = true,
source = Sources.OmnipodEros),
OMNIPOD_DASH(description = "Omnipod Dash", OMNIPOD_DASH(description = "Omnipod Dash",
manufacturer = ManufacturerType.Insulet, manufacturer = ManufacturerType.Insulet,
model = "Dash", model = "Dash",
@ -205,7 +212,8 @@ enum class PumpType {
baseBasalMinValue = 0.05, baseBasalMinValue = 0.05,
baseBasalStep = 0.05, baseBasalStep = 0.05,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.MedtronicCapabilities), pumpCapability = PumpCapability.MedtronicCapabilities,
source = Sources.Medtronic),
MEDTRONIC_515_715(description = "Medtronic 515/715", MEDTRONIC_515_715(description = "Medtronic 515/715",
model = "515/715", model = "515/715",
parent = MEDTRONIC_512_712), parent = MEDTRONIC_512_712),
@ -224,7 +232,8 @@ enum class PumpType {
baseBasalMinValue = 0.025, baseBasalMinValue = 0.025,
baseBasalStep = 0.025, baseBasalStep = 0.025,
baseBasalSpecialSteps = DoseStepSize.MedtronicVeoBasal, baseBasalSpecialSteps = DoseStepSize.MedtronicVeoBasal,
pumpCapability = PumpCapability.MedtronicCapabilities), pumpCapability = PumpCapability.MedtronicCapabilities,
source = Sources.Medtronic),
MEDTRONIC_554_754_VEO(description = "Medtronic 554/754 (Veo)", model = "554/754 (Veo)", parent = MEDTRONIC_523_723_REVEL), MEDTRONIC_554_754_VEO(description = "Medtronic 554/754 (Veo)", model = "554/754 (Veo)", parent = MEDTRONIC_523_723_REVEL),
MEDTRONIC_640G(description = "Medtronic 640G", MEDTRONIC_640G(description = "Medtronic 640G",
manufacturer = ManufacturerType.Medtronic, manufacturer = ManufacturerType.Medtronic,
@ -284,7 +293,8 @@ enum class PumpType {
model = "USER", model = "USER",
tbrSettings = DoseSettings(1.0, 15, 24 * 60, 0.0, 500.0), tbrSettings = DoseSettings(1.0, 15, 24 * 60, 0.0, 500.0),
extendedBolusSettings = DoseSettings(0.1, 15, 12 * 60, 0.1), extendedBolusSettings = DoseSettings(0.1, 15, 12 * 60, 0.1),
pumpCapability = PumpCapability.MDI), pumpCapability = PumpCapability.MDI,
source = Sources.MDI),
//Diaconn Pump //Diaconn Pump
DIACONN_G8(description = "DiaconnG8", DIACONN_G8(description = "DiaconnG8",
@ -300,7 +310,8 @@ enum class PumpType {
baseBasalMaxValue = 3.0, baseBasalMaxValue = 3.0,
baseBasalStep = 0.01, baseBasalStep = 0.01,
baseBasalSpecialSteps = null, baseBasalSpecialSteps = null,
pumpCapability = PumpCapability.DanaWithHistoryCapabilities); pumpCapability = PumpCapability.DanaWithHistoryCapabilities,
source = Sources.DiaconnG8);
val description: String val description: String
var manufacturer: ManufacturerType? = null var manufacturer: ManufacturerType? = null
@ -342,6 +353,7 @@ enum class PumpType {
var hasCustomUnreachableAlertCheck = false var hasCustomUnreachableAlertCheck = false
private set private set
private var parent: PumpType? = null private var parent: PumpType? = null
val source: Sources
companion object { companion object {
@ -349,9 +361,10 @@ enum class PumpType {
values().firstOrNull { it.description == desc } ?: GENERIC_AAPS values().firstOrNull { it.description == desc } ?: GENERIC_AAPS
} }
constructor(description: String, model: String, parent: PumpType, pumpCapability: PumpCapability? = null) { constructor(description: String, model: String, parent: PumpType, pumpCapability: PumpCapability? = null, source: Sources? = null) {
this.description = description this.description = description
this.parent = parent this.parent = parent
this.source = source ?: parent.source
this.pumpCapability = pumpCapability this.pumpCapability = pumpCapability
parent.model = model parent.model = model
} }
@ -370,7 +383,8 @@ enum class PumpType {
baseBasalStep: Double = 1.0, baseBasalStep: Double = 1.0,
baseBasalSpecialSteps: DoseStepSize? = null, baseBasalSpecialSteps: DoseStepSize? = null,
pumpCapability: PumpCapability, pumpCapability: PumpCapability,
hasCustomUnreachableAlertCheck: Boolean = false) { hasCustomUnreachableAlertCheck: Boolean = false,
source: Sources = Sources.VirtualPump) {
this.description = description this.description = description
this.manufacturer = manufacturer this.manufacturer = manufacturer
this.model = model this.model = model
@ -386,6 +400,7 @@ enum class PumpType {
this.baseBasalSpecialSteps = baseBasalSpecialSteps this.baseBasalSpecialSteps = baseBasalSpecialSteps
this.pumpCapability = pumpCapability this.pumpCapability = pumpCapability
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck
this.source = source
} }
fun getFullDescription(i18nTemplate: String, hasExtendedBasals: Boolean, resourceHelper: ResourceHelper): String { fun getFullDescription(i18nTemplate: String, hasExtendedBasals: Boolean, resourceHelper: ResourceHelper): String {

View file

@ -264,6 +264,8 @@ class Translator @Inject internal constructor(
Sources.DanaRC -> TODO() Sources.DanaRC -> TODO()
Sources.DanaRv2 -> TODO() Sources.DanaRv2 -> TODO()
Sources.DanaRS -> TODO() Sources.DanaRS -> TODO()
Sources.DanaI -> TODO()
Sources.DiaconnG8 -> TODO()
Sources.Insight -> TODO() Sources.Insight -> TODO()
Sources.Combo -> TODO() Sources.Combo -> TODO()
Sources.Medtronic -> TODO() Sources.Medtronic -> TODO()

View file

@ -129,6 +129,8 @@ class UserEntryMapper {
DanaRC (UserEntry.Sources.DanaRC), DanaRC (UserEntry.Sources.DanaRC),
DanaRv2 (UserEntry.Sources.DanaRv2), DanaRv2 (UserEntry.Sources.DanaRv2),
DanaRS (UserEntry.Sources.DanaRS), DanaRS (UserEntry.Sources.DanaRS),
DanaI (UserEntry.Sources.DanaI),
DiaconnG8 (UserEntry.Sources.DiaconnG8),
Insight (UserEntry.Sources.Insight), Insight (UserEntry.Sources.Insight),
Combo (UserEntry.Sources.Combo), Combo (UserEntry.Sources.Combo),
Medtronic (UserEntry.Sources.Medtronic), Medtronic (UserEntry.Sources.Medtronic),

View file

@ -83,6 +83,8 @@ class UserEntryPresentationHelper @Inject constructor(
Sources.DanaRC -> R.drawable.ic_danars_128 Sources.DanaRC -> R.drawable.ic_danars_128
Sources.DanaRv2 -> R.drawable.ic_danars_128 Sources.DanaRv2 -> R.drawable.ic_danars_128
Sources.DanaRS -> R.drawable.ic_danars_128 Sources.DanaRS -> R.drawable.ic_danars_128
Sources.DanaI -> R.drawable.ic_danai_128
Sources.DiaconnG8 -> R.drawable.ic_diaconn_g8
Sources.Insight -> R.drawable.ic_insight_128 Sources.Insight -> R.drawable.ic_insight_128
Sources.Combo -> R.drawable.ic_combo_128 Sources.Combo -> R.drawable.ic_combo_128
Sources.Medtronic -> R.drawable.ic_veo_128 Sources.Medtronic -> R.drawable.ic_veo_128

View file

@ -153,18 +153,20 @@ data class UserEntry(
Objectives, //From Objectives plugin Objectives, //From Objectives plugin
Pump, //To update with one Source per pump Pump, //To update with one Source per pump
Dana, //Only one UserEntry in Common module Dana Dana, //Only one UserEntry in Common module Dana
DanaR, //No entry currently DanaR,
DanaRC, //No entry currently DanaRC,
DanaRv2, //No entry currently DanaRv2,
DanaRS, //No entry currently DanaRS,
Insight, //No entry currently DanaI,
Combo, //No entry currently DiaconnG8,
Medtronic, //No entry currently Insight,
Combo,
Medtronic,
Omnipod, //No entry currently Omnipod, //No entry currently
OmnipodEros, //No entry currently OmnipodEros,
OmnipodDash, //No entry currently OmnipodDash, //No entry currently
MDI, //No entry currently MDI,
VirtualPump, //No entry currently VirtualPump,
SMS, //From SMS plugin SMS, //From SMS plugin
Treatments, //From Treatments plugin Treatments, //From Treatments plugin
Wear, //From Wear plugin Wear, //From Wear plugin