Skip to content

Commit

Permalink
rewind, prime and battery indicates change (#1409)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Foxy7 authored Dec 11, 2021
1 parent 7157ef4 commit 1954758
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/mm-format-ns-treatments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@ 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 '[ .[]
| .medtronic = ( [ "mm://openaps/'$self'/", ( . | if ._type then ._type else .eventType end ) ] | join("") )
| .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

3 changes: 3 additions & 0 deletions examples/profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1954758

Please sign in to comment.