Pages

Tuesday 24 November 2015

Nightscout on the 640g: Real-Time Pump Monitor

Nightscout was originally designed to display CGM data, those Sensor Glucose (SG) values that come from the Dexcom or Enlite system every five minutes.
But why stop there? 

Real-time* 640g CGM and Pump data up on Nightscout:

All of the data shown is automatically transferred from the 640g to Nightscout

*delayed by around 5 minutes due to the current bounce via CareLink

In addition to the core Nightscout code, developers** have added the Care Portal plugin for Nightscout's CGM Remote Monitor.

This currently gives you the option to enter 16 different types of T1D-related event, from a meal or correction bolus, a question to/from a carer, to inserting a new sensor or infusion set.
What a great idea to keep even more of your T1D data together and accessible.

No more text messages or Post-It Notes left at 2am to say "sensor tracking 3 units higher than BG" in case your other half gets the next alarm... 

**Jason Calabrese and Milos Kozak I think, but please correct me if I have it wrong

But I'm busy and so is everyone managing T1D. (Also I'm rubbish at typing on my touchscreen phone) I really don't want to enter data via the Nightscout CGM Remote Monitor app or browser, especially if I already have that data in the pump.

So after getting the first 640g SG and BG data up into Nightscout (see here and here for details, relying in part on Ben West's modified CSV parsing routines) the next step was to extract as much information as possible from pump. Automatically. Here's my first attempt.



All Pump Alarms
All alarms on the 640g are automatically passed to Nightscout as Announcements, recorded on the SG plot (e.g. the Basal Delivery Resumed announcement in the screen-shot above). These can be configured as per standard Nightscout Announcements to issue an alert on your device e.g. let you know SmartGuard has been triggered.

Cannula Age
Enable the CAGE plugin on Nightscout and let the pump + Nightscout automatically tell you how old the infusion set is:

Alerts can be set as per the manual site change entry, e.g. at 66 and 72 hrs

SmartGuard (Predicted Low Glucose Management)
All SmartGuard PLGM (Predicted Low Glucose Management) triggers are automatically shown, set initially at zero basal (0U) for 2 hours (the maximum time PLGM is on in one event). This time is then amended when the Basal Delivery Resumed trigger is found:
PLGM action on a school day.
Note: most other notifications turned off on this display

Temporary Basal Rates
Temporary basal rates, set manually on the pump, are automatically passed to Nightscout. They are displayed as set on the pump (e.g. in absolute units or a percentage change):
190% (+90%) basal set to try to coax down a stubborn high without putting all insulin eggs in one basket

Bolus Events, including Dual / Square Wave Cancellations
Details from the 640g's Bolus Wizard are automatically sent to Nightscout, including
  • Carbs (g)
  • Insulin delivered (units) now (Normal), shown at the time of delivery
  • Insulin delivered (units) as Square-wave (usually as component of Dual-wave), shown at the end of delivery.

We've posted before on the potential hazard of not putting back in dual-wave bolus insulin that has been interrupted by the pump initiating PLGM. The pump does not remind you about the missing bolus insulin when basal is resumed.

Therefore, any cancelled insulin is marked on a truncated square-wave bolus delivery. In the example below, a 0.5 unit, 2 hour (120 minute) square-wave component was requested at around 18:00 when Janki ate. At 19:32, PLGM kicked in and suspended the pump. Nightscout then automatically records and displays 0.35 units of the dual component delivered over the proceeding 87 minutes, but that, crucially, 0.15 units were cancelled:
Smartguard (PLGM) fires, 0.15 units of bolus is cancelled...

Could be useful for example, when checking-in on the fate of a lunchtime dual bolus at school? You'd want to double-check the bolus history on the pump before actioning of course.

Predicted SG Values
[Note: Currently disabled this on the GitHub script due to stability issues]
Along each SG value, Medtronic also include a "Predicted SG" value for use with its SmartGuard algorithm. I think this is the system's best estimate of where we - Janki - will be in 30 minutes time. Nightscout puts up a lovely range of likely predicted SG values (those open cyan/blue dots on the right). Details of this algorithm are also discussed here.  I find them very useful, but I also automatically pop the Medtronic prediction under the corresponding future time point.

These are parsed as "Notes" and appear as row of numbers under each SG value, the string of small, brown boxes in the view above. At any current time-point, it's the last number on the right (6.4 mmol/L in this case) which is of most interest.

At the moment they're there for no more than idle curiosity but may, in future, be useful when contemplating how much of a correction bolus or how many carbs to give. The rationale being that your fast acting insulin will not start to work for ~20 minutes and so it's potentially more important to know where you glucose will be at that time. At present, we guestimate or use a small Google Sheet on my phone to achieve that 'look ahead'.

How I did it
As this is not officially part of NS, I was careful to work within the existing NS infrastructure. Therefore, I haven't made any changes to my fork (version) of CGM Remote Monitor and its plugins. I've routed all the pump data through the Care Portal API using a number of additional parsers, based on the methodology originally laid down by Ben West.

I'll put these up on Github shortly, whilst also working on a number of further extensions (there's more data in each CSV). I hope others will find these ideas useful too.

This work is completely reliant on being able to build on the (open-source, open-standards) work of Nightscout developers over the years. A vast amount of work has gone into building up this application and its plugins thanks to clever people giving up their spare time to build this amazing platform. Thank-you.

A Reminder
As with previous posts on getting 640g data on to Nightscout, this is a "Proof of Principle", "First Step", "Alpha Release". You get the picture. It's clunky and it wobbles every now and then (it does rely on CareLink after all ;-) ). Therefore, I am certainly not recommending you go ahead and try this at home. 

As ever, feel free to post a comment below, on Facebook or on Twitter :-)

Update: If you've landed here looking for Nightscout on your 600-series pump, thanks for stopping by :) The simplest way to get your pump on to Nightscout is to use the 600-series Android Uploader. Enjoy!

2 comments:

  1. Replies
    1. Thanks Kev - on the shoulders of a lot of effort by the core NS developer team, but it's been great to see all that data pushed up there automatically. Take care.

      Delete