TreatmentDialog (fix missing uel.log if only carbs), BolusWizard, and TempTargetDialog
This commit is contained in:
parent
bb3effcda3
commit
1a1d718fa2
3 changed files with 37 additions and 44 deletions
|
@ -183,16 +183,11 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||
val units = profileFunction.getUnits()
|
||||
when(reason) {
|
||||
//resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
//resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
//resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
//resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.CUSTOM), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
//resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
|
||||
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
||||
resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
||||
resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
||||
resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.CUSTOM.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
||||
resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
|
||||
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, Sources.TTDialog, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, Sources.TTDialog, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, Sources.TTDialog, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, Sources.TTDialog, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.CUSTOM), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
||||
resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, Sources.TTDialog, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
|
||||
}
|
||||
if (target == 0.0 || duration == 0) {
|
||||
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))
|
||||
|
@ -209,7 +204,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
resourceHelper.gs(R.string.eatingsoon) -> TemporaryTarget.Reason.EATING_SOON
|
||||
resourceHelper.gs(R.string.activity) -> TemporaryTarget.Reason.ACTIVITY
|
||||
resourceHelper.gs(R.string.hypo) -> TemporaryTarget.Reason.HYPOGLYCEMIA
|
||||
else -> TemporaryTarget.Reason.CUSTOM
|
||||
else -> TemporaryTarget.Reason.CUSTOM
|
||||
},
|
||||
lowTarget = Profile.toMgdl(target, profileFunction.getUnits()),
|
||||
highTarget = Profile.toMgdl(target, profileFunction.getUnits())
|
||||
|
|
|
@ -141,7 +141,6 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) {
|
||||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||
//uel.log(Action.TREATMENT, XXXValueWithUnit.Insulin(insulin ).takeIf { insulin != 0.0 }, XXXValueWithUnit.Gram(carbs).takeIf { carbs != 0 })
|
||||
val action = when {
|
||||
insulinAfterConstraints.equals(0.0) -> Action.CARBS
|
||||
carbsAfterConstraints.equals(0) -> Action.BOLUS
|
||||
|
@ -154,12 +153,11 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
detailedBolusInfo.carbs = carbsAfterConstraints.toDouble()
|
||||
detailedBolusInfo.context = context
|
||||
if (recordOnlyChecked) {
|
||||
uel.log(action,
|
||||
ValueWithUnit(Sources.TreatmentDialog),
|
||||
ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp, eventTimeChanged),
|
||||
ValueWithUnit(R.string.record, Units.R_String, insulin != 0.0),
|
||||
ValueWithUnit(insulinAfterConstraints, Units.U, insulin != 0.0),
|
||||
ValueWithUnit(carbsAfterConstraints, Units.G, carbs != 0))
|
||||
uel.log(action, Sources.TreatmentDialog,
|
||||
XXXValueWithUnit.Timestamp(detailedBolusInfo.timestamp).takeIf { eventTimeChanged },
|
||||
XXXValueWithUnit.StringResource(R.string.record).takeIf { insulinAfterConstraints != 0.0 },
|
||||
XXXValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 },
|
||||
XXXValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
||||
if (detailedBolusInfo.insulin > 0)
|
||||
disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction())
|
||||
.subscribe(
|
||||
|
@ -173,17 +171,20 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
|||
{ aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) }
|
||||
)
|
||||
} else {
|
||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
|
||||
} else
|
||||
uel.log(action,
|
||||
ValueWithUnit(Sources.TreatmentDialog),
|
||||
ValueWithUnit(insulin, Units.U, insulin != 0.0),
|
||||
ValueWithUnit(carbs, Units.G, carbs != 0))
|
||||
}
|
||||
})
|
||||
if (detailedBolusInfo.insulin > 0)
|
||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
|
||||
} else
|
||||
uel.log(action, Sources.TreatmentDialog,
|
||||
XXXValueWithUnit.Insulin(insulinAfterConstraints),
|
||||
XXXValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
|
||||
}
|
||||
})
|
||||
else
|
||||
uel.log(action, Sources.TreatmentDialog,
|
||||
XXXValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbs != 0 })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -350,11 +350,10 @@ class BolusWizard @Inject constructor(
|
|||
carbTime = 0
|
||||
bolusCalculatorResult = createBolusCalculatorResult()
|
||||
notes = this@BolusWizard.notes
|
||||
//uel.log(Action.BOLUS_ADVISOR, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints))
|
||||
uel.log(Action.BOLUS_ADVISOR, notes,
|
||||
ValueWithUnit(if (quickWizard) Sources.QuickWizard else Sources.WizardDialog),
|
||||
ValueWithUnit(eventType.toDBbEventType().text, Units.TherapyEvent),
|
||||
ValueWithUnit(insulinAfterConstraints, Units.U))
|
||||
uel.log(Action.BOLUS_ADVISOR, if (quickWizard) Sources.QuickWizard else Sources.WizardDialog,
|
||||
notes,
|
||||
XXXValueWithUnit.TherapyEventType(eventType.toDBbEventType()),
|
||||
XXXValueWithUnit.Insulin(insulinAfterConstraints))
|
||||
if (insulin > 0) {
|
||||
commandQueue.bolus(this, object : Callback() {
|
||||
override fun run() {
|
||||
|
@ -377,7 +376,7 @@ class BolusWizard @Inject constructor(
|
|||
OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, {
|
||||
if (insulinAfterConstraints > 0 || carbs > 0) {
|
||||
if (useSuperBolus) {
|
||||
uel.log(Action.SUPERBOLUS_TBR, ValueWithUnit(Sources.WizardDialog))
|
||||
uel.log(Action.SUPERBOLUS_TBR, Sources.WizardDialog)
|
||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
|
||||
rxBus.send(EventRefreshOverview("WizardDialog"))
|
||||
|
@ -392,7 +391,6 @@ class BolusWizard @Inject constructor(
|
|||
}
|
||||
})
|
||||
} else {
|
||||
|
||||
commandQueue.tempBasalPercent(0, 120, true, profile, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
|
@ -418,18 +416,17 @@ class BolusWizard @Inject constructor(
|
|||
bolusCalculatorResult = createBolusCalculatorResult()
|
||||
notes = this@BolusWizard.notes
|
||||
if (insulin > 0 || carbs > 0) {
|
||||
//uel.log(Action.BOLUS, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Gram(this@BolusWizard.carbs).takeIf { this@BolusWizard.carbs != 0 }, XXXValueWithUnit.Minute(carbTime).takeIf { carbTime != 0 })
|
||||
val action = when {
|
||||
val action = when {
|
||||
insulinAfterConstraints.equals(0.0) -> Action.CARBS
|
||||
carbs.equals(0.0) -> Action.BOLUS
|
||||
else -> Action.TREATMENT
|
||||
}
|
||||
uel.log(action, notes,
|
||||
ValueWithUnit(if (quickWizard) Sources.QuickWizard else Sources.WizardDialog),
|
||||
ValueWithUnit(eventType.toDBbEventType().text, Units.TherapyEvent),
|
||||
ValueWithUnit(insulinAfterConstraints, Units.U, insulinAfterConstraints != 0.0),
|
||||
ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0),
|
||||
ValueWithUnit(carbTime, Units.M, carbTime != 0))
|
||||
uel.log(action, if (quickWizard) Sources.QuickWizard else Sources.WizardDialog,
|
||||
notes,
|
||||
XXXValueWithUnit.TherapyEventType(eventType.toDBbEventType()),
|
||||
XXXValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 },
|
||||
XXXValueWithUnit.Gram(this@BolusWizard.carbs).takeIf { this@BolusWizard.carbs != 0 },
|
||||
XXXValueWithUnit.Minute(carbTime).takeIf { carbTime != 0 })
|
||||
commandQueue.bolus(this, object : Callback() {
|
||||
override fun run() {
|
||||
if (!result.success) {
|
||||
|
|
Loading…
Reference in a new issue