This acts as a web-based CGM (Continuous Glucose Monitor) to allow multiple caregivers to remotely view a patient's glucose data in real time. The server reads a MongoDB which is intended to be data from a physical CGM, where it sends new SGV (sensor glucose values) as the data becomes available. The data is then displayed graphically and blood glucose values are predicted 0.5 hours ahead using an autoregressive second order model. Alarms are generated for high and low values, which can be cleared by any watcher of the data.
#WeAreNotWaiting and this is why.
Community maintained fork of the original cgm-remote-monitor.
Table of Contents
- Install
- Usage
Requirements:
Clone this repo then install dependencies into the root of the project:
$ npm install
#Usage
The data being uploaded from the server to the client is from a MongoDB server such as mongolab. In order to access the database, the appropriate credentials need to be filled into the JSON file in the root directory. SGV data from the database is assumed to have the following fields: date, sgv. Once all that is ready, just host your web app on your service of choice.
The easiest way to update your version of cgm-remote-monitor to our latest recommended version is to use the update my fork tool. It even gives out stars if you are up to date.
Try the what is my mongo string tool to get a good idea of your
mongo string. You can copy and paste the text in the gray box into your
MONGO_CONNECTION
environment variable.
Use the autoconfigure tool to sync an uploader to your config.
VARIABLE
(default) - description
MONGO_CONNECTION
- Your mongo uri, for example:mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout
DISPLAY_UNITS
(mg/dl
) - Choices:mg/dl
andmmol
. Setting tommol
puts the entire server intommol
mode by default, no further settings needed.
ENABLE
- Used to enable optional features, expects a space delimited list such as:careportal rawbg iob
, see plugins belowAPI_SECRET
- A secret passphrase that must be at least 12 characters long, required to enablePOST
andPUT
; also required for the Care PortalBG_HIGH
(260
) - must be set using mg/dl units; the high BG outside the target range that is considered urgentBG_TARGET_TOP
(180
) - must be set using mg/dl units; the top of the target range, also used to draw the line on the chartBG_TARGET_BOTTOM
(80
) - must be set using mg/dl units; the bottom of the target range, also used to draw the line on the chartBG_LOW
(55
) - must be set using mg/dl units; the low BG outside the target range that is considered urgentALARM_TYPES
(simple
if anyBG_
* ENV's are set, otherwisepredict
) - currently 2 alarm types are supported, and can be used independently or combined. Thesimple
alarm type only compares the current BG toBG_
thresholds above, thepredict
alarm type uses highly tuned formula that forecasts where the BG is going based on it's trend.predict
DOES NOT currently use any of theBG_
* ENV'sBASE_URL
- Used for building links to your sites api, ie pushover callbacks, usually the URL of your Nightscout site you may want https instead of http
MONGO_COLLECTION
(entries
) - The collection used to store SGV, MBG, and CAL records from your CGM deviceMONGO_TREATMENTS_COLLECTION
(treatments
) -The collection used to store treatments entered in the Care Portal, see theENABLE
env var aboveMONGO_DEVICESTATUS_COLLECTION
(devicestatus
) - The collection used to store device status information such as uploader batteryPORT
(1337
) - The port that the node.js application will listen on.SSL_KEY
- Path to your ssl key file, so that ssl(https) can be enabled directly in node.jsSSL_CERT
- Path to your ssl cert file, so that ssl(https) can be enabled directly in node.jsSSL_CA
- Path to your ssl ca file, so that ssl(https) can be enabled directly in node.js
TIME_FORMAT
(12
)- possible values12
or24
NIGHT_MODE
(off
) - possible valueson
oroff
SHOW_RAWBG
(never
) - possible valuesalways
,never
ornoise
CUSTOM_TITLE
(Nightscout
) - Usually name of T1THEME
(default
) - possible valuesdefault
orcolors
ALARM_URGENT_HIGH
(on
) - possible valueson
oroff
ALARM_HIGH
(on
) - possible valueson
oroff
ALARM_LOW
(on
) - possible valueson
oroff
ALARM_URGENT_LOW
(on
) - possible valueson
oroff
ALARM_TIMEAGO_WARN
(on
) - possible valueson
oroff
ALARM_TIMEAGO_WARN_MINS
(15
) - minutes since the last reading to trigger a warningALARM_TIMEAGO_URGENT
(on
) - possible valueson
oroff
ALARM_TIMEAGO_URGENT_MINS
(30
) - minutes since the last reading to trigger a urgent alarmSHOW_PLUGINS
- enabled plugins that should have their visualizations shown, defaults to all enabledLANGUAGE
(en
) - language of Nighscout. If not available english is used
Plugins are used extend the way information is displayed, how notifications are sent, alarms are triggered, and more.
The built-in/example plugins that are available by default are listed below. The plugins may still need to be enabled by adding to the ENABLE
environment variable.
Built-in/Example Plugins:
rawbg
(Raw BG) - Calculates BG using sensor and calibration records from and displays an alternate BG values and noise levels.iob
(Insulin-on-Board) - Adds the IOB pill visualization in the client and calculates values that used by other plugins. Uses treatments with insulin doses and thedia
andsens
fields from the treatment profile.cob
(Carbs-on-Board) - Adds the COB pill visualization in the client and calculates values that used by other plugins. Uses treatments with carb doses and thecarbs_hr
,carbratio
, andsens
fields from the treatment profile.bwp
(Bolus Wizard Preview) - This plugin in intended for the purpose of automatically snoozing alarms when the CGM indicates high blood sugar but there is also insulin on board (IOB) and secondly, alerting to user that it might be beneficial to measure the blood sugar using a glucometer and dosing insulin as calculated by the pump or instructed by trained medicare professionals. The values provided by the plugin are provided as a reference based on CGM data and insulin sensitivity you have configured, and are not intended to be used as a reference for bolus calculation. The plugin calculates the bolus amount when above your target, generates alarms when you should consider checking and bolusing, and snoozes alarms when there is enough IOB to cover a high BG. Uses the results of theiob
plugin andsens
,target_high
, andtarget_low
fields from the treatment profile. Defaults that can be adjusted with extended settingBWP_WARN
(0.50
) - IfBWP
is >BWP_WARN
a warning alarm will be triggered.BWP_URGENT
(1.00
) - IfBWP
is >BWP_URGENT
an urgent alarm will be triggered.BWP_SNOOZE_MINS
(10
) - minutes to snooze when there is enough IOB to cover a high BG.BWP_SNOOZE
- (0.10
) If BG is higher then thetarget_high
andBWP
<BWP_SNOOZE
alarms will be snoozed forBWP_SNOOZE_MINS
.
cage
(Cannula Age) - Calculates the number of hours since the lastSite Change
treatment that was recorded.CAGE_ENABLE_ALERTS
(false
) - Set totrue
to enable notifications to remind you of upcoming cannula change.CAGE_INFO
(44
) - If time since lastSite Change
matchesCAGE_INFO
, user will be warned of upcoming cannula changeCAGE_WARN
(48
) - If time since lastSite Change
matchesCAGE_WARN
, user will be alarmed to to change the cannulaCAGE_URGENT
(72
) - If time since lastSite Change
matchesCAGE_URGENT
, user will be issued a persistent warning of overdue change.
delta
(BG Delta) - Calculates and displays the change between the last 2 BG values. Enabled by default.direction
(BG Direction) - Displays the trend direction. Enabled by default.upbat
(Uploader Battery) - Displays the most recent battery status from the uploader phone. Enabled by default.ar2
(Forcasting using AR2 algorithm) - Generates alarms based on forecasted values. Enabled by default. Use extended settings to adjust AR2 behavior:AR2_USE_RAW
(false
) - to forecast usingrawbg
values when standard values don't trigger an alarm.AR2_CONE_FACTOR
(2
) - to adjust size of cone, use0
for a single line.
simplealarms
(Simple BG Alarms) - UsesBG_HIGH
,BG_TARGET_TOP
,BG_TARGET_BOTTOM
,BG_LOW
settings to generate alarms.errorcodes
(CGM Error Codes) - Generates alarms for CGM codes9
(hourglass) and10
(???). Enabled by default.treatmentnotify
(Treatment Notifications) - Generates notifications when a treatment has been entered and snoozes alarms minutes after a treatment. Default snooze is 10 minutes, and can be set using theTREATMENTNOTIFY_SNOOZE_MINS
extended setting.basal
(Basal Profile) - Adds the Basal pill visualization to display the basal rate for the current time. Also enables thebwp
plugin to calculate correction temp basal suggestions. Uses thebasal
field from the treatment profile.
Also see Pushover and IFTTT Maker.
Some plugins support additional configuration using extra environment variables. These are prefixed with the name of the plugin and a _
. For example setting MYPLUGIN_EXAMPLE_VALUE=1234
would make extendedSettings.exampleValue
available to the MYPLUGIN
plugin.
Plugins only have access to their own extended settings, all the extended settings of client plugins will be sent to the browser.
In addition to the normal web based alarms, there is also support for Pushover based alarms and notifications.
To get started install the Pushover application on your iOS or Android device and create an account.
Using that account login to Pushover, in the top left you’ll see your User Key, you’ll need this plus an application API Token/Key to complete this setup.
You’ll need to Create a Pushover Application. You only need to set the Application name, you can ignore all the other settings, but setting an Icon is a nice touch. Maybe you'd like to use this one?
Pushover is configured using the following Environment Variables:
* `ENABLE` - `pushover` should be added to the list of plugin, for example: `ENABLE="pushover"`.
* `PUSHOVER_API_TOKEN` - Used to enable pushover notifications, this token is specific to the application you create from in [Pushover](https://pushover.net/), ***[additional pushover information](#pushover)*** below.
* `PUSHOVER_USER_KEY` - Your Pushover user key, can be found in the top left of the [Pushover](https://pushover.net/) site, this can also be a pushover delivery group key to send to a group rather than just a single user. This also support a space delimited list of keys.
* `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys.
* `BASE_URL` - Used for pushover callbacks, usually the URL of your Nightscout site, use https when possible.
* `API_SECRET` - Used for signing the pushover callback request for acknowledgments.
For testing/development try [localtunnel](http://localtunnel.me/).
In addition to the normal web based alarms, and pushover, there is also integration for IFTTT Maker.
With Maker you are able to integrate with all the other IFTTT Channels. For example you can send a tweet when there is an alarm, change the color of hue light, send an email, send and sms, and so much more.
- Setup IFTTT account: login or create an account
- Find your secret key on the maker page
- Configure Nightscout by setting these environment variables:
ENABLE
-maker
should be added to the list of plugin, for example:ENABLE="maker"
.MAKER_KEY
- Set this to your secret key that you located in step 2, for example:MAKER_KEY="abcMyExampleabc123defjt1DeNSiftttmak-XQb69p"
This also support a space delimited list of keys.MAKER_ANNOUNCEMENT_KEY
- An optional Maker key, will be used for system wide user generated announcements. If not defined this will fallback toMAKER_KEY
. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys.
Plugins can create custom events, but all events sent to maker will be prefixed with ns-
. The core events are:
ns-event
- This event is sent to the maker service for all alarms and notifications. This is good catch all event for general logging.ns-allclear
- This event is sent to the maker service when an alarm has been ack'd or when the server starts up without triggering any alarms. For example, you could use this event to turn a light to green.ns-info
- Plugins that generate notifications at the info level will cause this event to also be triggered. It will be sent in addition tons-event
.ns-warning
- Alarms at the warning level with cause this event to also be triggered. It will be sent in addition tons-event
.ns-urgent
- Alarms at the urgent level with cause this event to also be triggered. It will be sent in addition tons-event
.- see the full list of events
Some of the plugins make use of a treatment profile that is stored in Mongo. To use those plugins there should only be a single doc in the profile
collection.
Example Profile (change it to fit you):
{
"dia": 3,
"carbs_hr": 20,
"carbratio": 30,
"sens": 100,
"basal": 0.125,
"target_low": 100,
"target_high": 120
}
Profile can also use time periods for any field, for example:
{
"carbratio": [
{
"time": "00:00",
"value": 30
},
{
"time": "06:00",
"value": 25
},
{
"time": "14:00",
"value": 28
}
],
"basal": [
{
"time": "00:00",
"value": 0.175
},
{
"time": "02:30",
"value": 0.125
},
{
"time": "05:00",
"value": 0.075
},
{
"time": "08:00",
"value": 0.100
},
{
"time": "14:00",
"value": 0.125
},
{
"time": "20:00",
"value": 0.175
},
{
"time": "22:00",
"value": 0.200
}
]
}
Treatment Profile Fields:
timezone
(Time Zone) - time zone local to the patient. Should be set.units
(Profile Units) - blood glucose units used in the profile, either "mgdl" or "mmol"dia
(Insulin duration) - value should be the duration of insulin action to use in calculating how much insulin is left active. Defaults to 3 hours.carbs_hr
(Carbs per Hour) - The number of carbs that are processed per hour, for more information see #DIYPS.carbratio
(Carb Ratio) - grams per unit of insulin.sens
(Insulin sensitivity) How much one unit of insulin will normally lower blood glucose.basal
The basal rate set on the pump.target_high
- Upper target for correction boluses.target_low
- Lower target for correction boluses.
Additional information can be found here.
Easy to emulate on the commandline:
echo 'MONGO_CONNECTION=mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout' >> my.env
echo 'MONGO_COLLECTION=entries' >> my.env
From now on you can run using
$ env $(cat my.env) PORT=1337 node server.js
Your hosting provider probably has a way to set these through their GUI.
Optionally, use Vagrant with the
included Vagrantfile
and setup.sh
to install OS and node packages to
a virtual machine.
host$ vagrant up
host$ vagrant ssh
vm$ setup.sh
The setup script will install OS packages then run npm install
.
The Vagrant VM serves to your host machine only on 192.168.33.10, you can access the web interface on http://192.168.33.10:1337
Feel free to post an issue, but read the wiki first.
cgm-remote-monitor - web app to broadcast cgm readings
Copyright (C) 2015 The Nightscout Foundation, http://www.nightscoutfoundation.org.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.