Time threshold for 100% percentage in bolus wizard 16 min, configurable

This commit is contained in:
Milos Kozak 2023-08-03 12:37:33 +02:00
parent 4406b60ecf
commit cb9935d880
6 changed files with 27 additions and 3 deletions

View file

@ -483,6 +483,7 @@
<string name="cobvsiob">COB vs IOB</string>
<string name="slowabsorptiondetected"><![CDATA[<font color=\'%1$s\'>!!!!! Slow carbs absorption detected: %2$d%% of time. Double check your calculation. COB can be overestimated thus more insulin could be given !!!!!</font>]]></string>
<string name="partialboluswizard">Deliver this part of bolus wizard result [%]</string>
<string name="partialboluswizard_reset_time">Old glycemia time threshold [min]</string>
<string name="bolus_constraint_applied_warn">Bolus constraint applied: %1$.2f U to %2$.2f U</string>
<string name="bolus_recorded_only">Bolus will be recorded only (not delivered by pump)</string>
<string name="advisoralarm">Run alarm when is time to eat</string>

View file

@ -97,6 +97,7 @@
<string name="key_objectiveusereconnect" translatable="false">ObjectivesReconnectUsed</string>
<string name="key_aps_mode" translatable="false">aps_mode</string>
<string name="key_boluswizard_percentage" translatable="false">boluswizard_percentage</string>
<string name="key_reset_boluswizard_percentage_time" translatable="false">key_reset_boluswizard_percentage_time</string>
<string name="key_usesuperbolus" translatable="false">key_usersuperbolus</string>
<string name="key_treatmentssafety_maxbolus" translatable="false">treatmentssafety_maxbolus</string>
<string name="key_patient_name" translatable="false">patient_name</string>

View file

@ -16,6 +16,7 @@ import info.nightscout.core.utils.extensions.storeDouble
import info.nightscout.core.utils.extensions.storeInt
import info.nightscout.core.utils.extensions.storeString
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.validators.ValidatingEditTextPreference
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Overview
import info.nightscout.interfaces.overview.OverviewMenus
@ -150,6 +151,11 @@ class OverviewPlugin @Inject constructor(
it.isEnabled = false
}
}
if (!config.isEngineeringMode())
(preferenceFragment.findPreference(rh.gs(info.nightscout.core.utils.R.string.key_reset_boluswizard_percentage_time)) as ValidatingEditTextPreference?)?.let {
it.isVisible = false
it.isEnabled = false
}
}
override fun configuration(): JSONObject =

View file

@ -278,6 +278,7 @@
<string name="short_tabtitles">Shorten tab titles</string>
<string name="overview_show_notes_field_in_dialogs_title">Show notes field in treatment dialogs</string>
<string name="deliverpartofboluswizard">Bolus wizard performs calculation but only this part of calculated insulin is delivered. Useful with SMB algorithm.</string>
<string name="deliver_part_of_boluswizard_reset_time">Deliver full bolus (100%) if glycemia is older than</string>
<string name="enable_bolus_advisor">Enable bolus advisor</string>
<string name="enable_bolus_advisor_summary">Use reminder to start eating later instead of wizard result during high glycemia ("pre-bolus")</string>
<string name="enablesuperbolus">Enable superbolus in wizard</string>

View file

@ -482,6 +482,19 @@
validate:minNumber="10"
validate:testType="numericRange" />
<info.nightscout.core.validators.ValidatingEditTextPreference
android:defaultValue="16"
android:dialogMessage="@string/deliver_part_of_boluswizard_reset_time"
android:inputType="number"
android:key="@string/key_reset_boluswizard_percentage_time"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/partialboluswizard_reset_time"
validate:maxNumber="120"
validate:minNumber="6"
validate:testType="numericRange" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_usebolusadvisor"

View file

@ -175,11 +175,13 @@ class WizardDialog : DaggerDialogFragment() {
// If there is no BG using % lower that 100% leads to high BGs
// because loop doesn't add missing insulin
var percentage = sp.getInt(info.nightscout.core.utils.R.string.key_boluswizard_percentage, 100).toDouble()
val time = sp.getLong(info.nightscout.core.utils.R.string.key_reset_boluswizard_percentage_time, 16)
repository.getLastGlucoseValueWrapped().blockingGet().let {
// if last value is older than 6 min or there is no bg
if (it is ValueWrapper.Existing)
if (it.value.timestamp < dateUtil.now() - T.mins(6).msecs())
// if last value is older or there is no bg
if (it is ValueWrapper.Existing) {
if (it.value.timestamp < dateUtil.now() - T.mins(time).msecs())
percentage = 100.0
} else percentage = 100.0
}
if (usePercentage) {