Skip to content

Instantly share code, notes, and snippets.

@thebookins
Last active August 18, 2016 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebookins/3a8f624f496e7aad80381b7a98c129ad to your computer and use it in GitHub Desktop.
Save thebookins/3a8f624f496e7aad80381b7a98c129ad to your computer and use it in GitHub Desktop.
mmhistorytools integration with openaps

Getting started

Install mmistorytools and add to your openaps project by following the instructions at mmhistorytools

  $ sudo easy_install openapscontrib.mmhistorytools
  $ openaps vendor add openapscontrib.mmhistorytools
  $ openaps device add history mmhistorytools

Add a report for the prepare command shortcut, using the raw pump history and basal profile as inputs

  $ openaps report add raw-pump/pump-history-prepared.json JSON history prepare raw-pump/pump-history-raw.json --basal-profile raw-pump/selected-basal-profile.json

Change the definition of the monitor/pump-history.json report to take the prepared pump history as input [TODO add command here prob openaps report remove, followed by openaps report add ...]

  • Change oref0 calculate-iob to accept new format of input file pump-history.json
  • Change the report nightscout/recent-treatments.json to accept new format of input file pump-history.json (or keep the old one if this makes more sense)
  • Change alias monitor-pump-history to invoke the new report raw-pump/pump-history-prepared.json
  • Consider whether it makes sense to edit the openaps templates (for use with oref0-mint)
  • Think about the integral method to calculate iob based on square wave:

Alternate method to calculate iob contribution from square wave (or net temp basal):

If there is an insulin bolus of 1U at time zero, the iob contribution from this bolus at time t is given by the funtion f(t). If there is a square wave delivery of 1U/hr for T hours, ending at time zero, the iob contribution from thie bolus at time t is given by the function g(t) We can show that g(t) = I(t)(t+T) f(tau)dtau In other words, if a square wave delivery ended a time of t hours ago, to get its IOB contribution, integrate the normal insulin decay curve from t to t + T, where T is the width of the square wave

Other considerations

It is important that integrating mmhistorytools doesn't break anyone's rig. For this reason, it probably makes sense to have some kind of setting (prefences.json?) to indicate that we want to use the mmhistorytools versions of the oref0 code. Alternatievly, we can probably interrogate pump-history.json to find out what kind it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment