From 1954758ca99a45ce9c3a37a60978207f20540aa4 Mon Sep 17 00:00:00 2001 From: Foxy7 <37312469+Foxy7@users.noreply.github.com> Date: Sat, 11 Dec 2021 03:14:17 +0000 Subject: [PATCH] rewind, prime and battery indicates change (#1409) * rewind, prime and battery indicates change * rewind, prime and battery indicates change * "fixed" prime only added filter for "fixed" primes only to count as site change. therefore manual primes will be ignored. --- bin/mm-format-ns-treatments.sh | 10 +++++++++- examples/profile.json | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/mm-format-ns-treatments.sh b/bin/mm-format-ns-treatments.sh index 8fac046c5..d104254dd 100755 --- a/bin/mm-format-ns-treatments.sh +++ b/bin/mm-format-ns-treatments.sh @@ -18,6 +18,11 @@ EOT # | json -e "this.type = 'mm://openaps/$self'" \ model=$(jq -r . $MODEL) +#load ns event preferences +PREF=${4-preferences.json} +rewind_indicates_cartridge_change=$(jq -r .rewind_indicates_cartridge_change $PREF) +prime_indicates_pump_site_change=$(jq -r .prime_indicates_pump_site_change $PREF) +battery_indicates_battery_change=$(jq -r .battery_indicates_battery_change $PREF) run_remote_command "oref0-normalize-temps $HISTORY" \ | jq '[ .[] @@ -25,10 +30,13 @@ run_remote_command "oref0-normalize-temps $HISTORY" \ | .created_at = if .created_at then .created_at else .timestamp end | .enteredBy = "openaps://medtronic/'$model'" | if .glucose and (.glucoseType | not) and .glucose > 0 then .glucoseType = .enteredBy else . end + | if ._type == "Rewind" and "'$rewind_indicates_cartridge_change'" == "true" then .eventType = "Insulin Change" else . end + | if ._type == "Prime" and .type == "fixed" and "'$prime_indicates_pump_site_change'" == "true" then .eventType = "Site Change" else . end + | if ._type == "Battery" and "'$battery_indicates_battery_change'" == "true" then .eventType = "Pump Battery Change" else . end | .eventType = if .eventType then .eventType else "Note" end | if ._type == "AlarmSensor" and .alarm_description then .notes = .alarm_description else . end | ( if .notes then .notes else "" end ) as $note - | if ( .eventType == "Note" ) and ( .alarm_description | not ) then .notes = ( [ ._type, "'" $model "'", $note ] | join("") ) else . end + | if ( .eventType == "Note" or .eventType == "Insulin Change" or .eventType == "Site Change" or .eventType == "Pump Battery Change" ) and ( .alarm_description | not ) then .notes = ( [ ._type, "'" $model "'", $note ] | join("") ) else . end ]' \ > $OUTPUT diff --git a/examples/profile.json b/examples/profile.json index a79a4119d..125c7e96f 100644 --- a/examples/profile.json +++ b/examples/profile.json @@ -63,6 +63,9 @@ "enableSMB_with_COB": true, "enableSMB_with_temptarget": false, "enableSMB_after_carbs": true, + "prime_indicates_pump_site_change": false, + "rewind_indicates_cartridge_change": false, + "battery_indicates_battery_change": false, "maxSMBBasalMinutes": 75, "curve": "rapid-acting", "useCustomPeakTime": false,