Skip to content

Commit 649ecba

Browse files
author
Jason Calabrese
committed
Merge branch 'release/0.6.0'
2 parents ba84cfd + 1055a59 commit 649ecba

File tree

21 files changed

+1250
-684
lines changed

21 files changed

+1250
-684
lines changed

COPYRIGHT

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
2-
We track contributions on a per-patch basis using git.
3-
Please see our published git log:
4-
* https://github.com/nightscout/cgm-remote-monitor/commits/master
5-
1+
Copyright (C) 2015 The Nightscout Foundation, http://www.nightscoutfoundation.org

README.md

Lines changed: 80 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
cgm-remote-monitor (a.k.a. NightScout)
1+
cgm-remote-monitor (a.k.a. Nightscout)
22
======================================
3-
3+
44
[![Build Status](https://travis-ci.org/nightscout/cgm-remote-monitor.png)](https://travis-ci.org/nightscout/cgm-remote-monitor)
55
[![Dependency Status](https://david-dm.org/nightscout/cgm-remote-monitor.png)](https://david-dm.org/nightscout/cgm-remote-monitor)
66
[![Gitter chat](https://badges.gitter.im/nightscout.png)](https://gitter.im/nightscout/public)
7+
[![Stories in Ready](https://badge.waffle.io/nightscout/cgm-remote-monitor.png?label=ready&title=Ready)](https://waffle.io/nightscout/cgm-remote-monitor)
8+
[![Stories in Progress](https://badge.waffle.io/nightscout/cgm-remote-monitor.png?label=in+progress&title=In+Progress)](https://waffle.io/nightscout/cgm-remote-monitor)
79

810
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
911

10-
This acts as a web-based CGM (Continuous Glucose Montinor) to allow
11-
multiple caregivers to remotely view a patients glucose data in
12-
realtime. The server reads a MongoDB which is intended to be data
12+
This acts as a web-based CGM (Continuous Glucose Monitor) to allow
13+
multiple caregivers to remotely view a patient's glucose data in
14+
real time. The server reads a MongoDB which is intended to be data
1315
from a physical CGM, where it sends new SGV (sensor glucose values) as
1416
the data becomes available. The data is then displayed graphically
15-
and blood glucose values are predicted 0.5 hours ahead using a
17+
and blood glucose values are predicted 0.5 hours ahead using an
1618
autoregressive second order model. Alarms are generated for high and
1719
low values, which can be cleared by any watcher of the data.
1820

@@ -32,23 +34,6 @@ Clone this repo then install dependencies into the root of the project:
3234
$ npm install
3335
```
3436

35-
### Vagrant install
36-
37-
Optionally, use [Vagrant](https://www.vagrantup.com/) with the
38-
included `Vagrantfile` and `setup.sh` to install OS and node packages to
39-
a virtual machine.
40-
41-
```bash
42-
host$ vagrant up
43-
host$ vagrant ssh
44-
vm$ setup.sh
45-
```
46-
47-
The setup script will install OS packages then run `npm install`.
48-
49-
The Vagrant VM serves to your host machine only on 192.168.33.10, you can access
50-
the web interface on [http://192.168.33.10:1337](http://192.168.33.10:1337)
51-
5237
Usage
5338
---------------
5439

@@ -61,50 +46,104 @@ ready, just host your web app on your service of choice.
6146

6247
[mongodb]: https://mongolab.com
6348
[json]: https://github.com/rnpenguin/cgm-remote-monitor/blob/master/database_configuration.json
49+
[autoconfigure]: http://nightscout.github.io/pages/configure/
50+
[mongostring]: http://nightscout.github.io/pages/mongostring/
51+
[update-fork]: http://nightscout.github.io/pages/update-fork/
52+
53+
### Updating my version?
54+
The easiest way to update your version of cgm-remote-monitor to our latest
55+
recommended version is to use the [update my fork tool][update-fork]. It even
56+
gives out stars if you are up to date.
57+
58+
### What is my mongo string?
59+
60+
Try the [what is my mongo string tool][mongostring] to get a good idea of your
61+
mongo string. You can copy and paste the text in the gray box into your
62+
`MONGO_CONNECTION` environment variable.
63+
64+
### Configure my uploader to match
65+
66+
Use the [autoconfigure tool][autoconfigure] to sync an uploader to your config.
67+
6468

6569
### Environment
66-
You can use the default null `database_configuration.json`
67-
config if you set the following environment variables instead.
68-
(Hosting providers often make this easy, and this allows you to avoid
69-
editing anything.)
7070

71-
* `CUSTOMCONNSTR_mongo` - the mongo connection string, corresponds to
72-
`DB.url`.
73-
* `CUSTOMCONNSTR_mongo_collection` - the mongo collection to use,
74-
corresponds to `DB.collection`.
71+
`VARIABLE` (default) - description
72+
73+
#### Required
7574

75+
* `MONGO_CONNECTION` - Your mongo uri, for example: `mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout`
76+
77+
#### Features/Labs
78+
79+
* `ENABLE` - Used to enable optional features, currently supports: `careportal`
80+
* `API_SECRET` - A secret passphrase that must be at least 12 characters long, required to enable `POST` and `PUT`; also required for the Care Portal
81+
* `BG_HIGH` (`260`) - must be set using mg/dl units; the high BG outside the target range that is considered urgent
82+
* `BG_TARGET_TOP` (`180`) - must be set using mg/dl units; the top of the target range, also used to draw the line on the chart
83+
* `BG_TARGET_BOTTOM` (`80`) - must be set using mg/dl units; the bottom of the target range, also used to draw the line on the chart
84+
* `BG_LOW` (`55`) - must be set using mg/dl units; the low BG outside the target range that is considered urgent
85+
* `ALARM_TYPES` (`simple` if any `BG_`* ENV's are set, otherwise `predict`) - currently 2 alarm types are supported, and can be used independently or combined. The `simple` alarm type only compares the current BG to `BG_` thresholds above, the `predict` 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 the `BG_`* ENV's
86+
* `PUSHOVER_API_TOKEN` - Used to enable pushover notifications for Care Portal treatments, this token is specific to the application you create from in [Pushover](https://pushover.net/)
87+
* `PUSHOVER_USER_KEY` - Your Pushover user key, can be found in the top left of the [Pushover](https://pushover.net/) site
88+
89+
90+
#### Core
91+
92+
* `DISPLAY_UNITS` (`mg/dl`) - Choices: `mg/dl` and `mmol`. Setting to `mmol` puts the entire server into `mmol` mode by default, no further settings needed.
93+
* `MONGO_COLLECTION` (`entries`) - The collection used to store SGV, MBG, and CAL records from your CGM device
94+
* `MONGO_TREATMENTS_COLLECTION` (`treatments`) -The collection used to store treatments entered in the Care Portal, see the `ENABLE` env var above
95+
* `MONGO_DEVICESTATUS_COLLECTION`(`devicestatus`) - The collection used to store device status information such as uploader battery
96+
* `PORT` (`1337`) - The port that the node.js application will listen on.
97+
* `SSL_KEY` - Path to your ssl key file, so that ssl(https) can be enabled directly in node.js
98+
* `SSL_CERT` - Path to your ssl cert file, so that ssl(https) can be enabled directly in node.js
99+
* `SSL_CA` - Path to your ssl ca file, so that ssl(https) can be enabled directly in node.js
100+
101+
## Setting environment variables
76102
Easy to emulate on the commandline:
77103

78104
```bash
79-
echo 'CUSTOMCONNSTR_mongo="mongodb://sally:sallypass@mymongohost.com/db"' >> my.env
80-
echo 'CUSTOMCONNSTR_mongo_collection="sallyCGMCollection"' >> my.env
105+
echo 'MONGO_CONNECTION="mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout"' >> my.env
81106
```
82107

83108
From now on you can run using
84109
```bash
85-
$ env $(cat my.env) PORT=1337 node server.js
110+
$ env $(cat my.env) PORT=1337 node server.js
86111
```
87112

88-
Your hosting provider probably has a way to set these through their
89-
GUI.
113+
Your hosting provider probably has a way to set these through their GUI.
114+
115+
### Vagrant install
116+
117+
Optionally, use [Vagrant](https://www.vagrantup.com/) with the
118+
included `Vagrantfile` and `setup.sh` to install OS and node packages to
119+
a virtual machine.
120+
121+
```bash
122+
host$ vagrant up
123+
host$ vagrant ssh
124+
vm$ setup.sh
125+
```
126+
127+
The setup script will install OS packages then run `npm install`.
128+
129+
The Vagrant VM serves to your host machine only on 192.168.33.10, you can access
130+
the web interface on [http://192.168.33.10:1337](http://192.168.33.10:1337)
90131

91132
More questions?
92133
---------------
93134

94135
Feel free to [post an issue][issues], but read the [wiki][wiki] first.
95136

96-
[issues]: https://github.com/rnpenguin/cgm-remote-monitor/issues
97-
[wiki]: https://github.com/rnpenguin/cgm-remote-monitor/wiki
137+
[issues]: https://github.com/nightscout/cgm-remote-monitor/issues
138+
[wiki]: https://github.com/nightscout/cgm-remote-monitor/wiki
98139

99140
License
100141
---------------
101142

102143
[agpl-3]: http://www.gnu.org/licenses/agpl-3.0.txt
103144

104145
cgm-remote-monitor - web app to broadcast cgm readings
105-
Copyright (C) 2014 Nightscout contributors. See the COPYRIGHT file
106-
at the root directory of this distribution and at
107-
https://github.com/nightscout/cgm-remote-monitor/blob/master/COPYRIGHT
146+
Copyright (C) 2015 The Nightscout Foundation, http://www.nightscoutfoundation.org.
108147

109148
This program is free software: you can redistribute it and/or modify
110149
it under the terms of the GNU Affero General Public License as published
@@ -118,5 +157,3 @@ License
118157

119158
You should have received a copy of the GNU Affero General Public License
120159
along with this program. If not, see <http://www.gnu.org/licenses/>.
121-
122-

app.json

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,32 @@
33
"repository": "https://github.com/nightscout/cgm-remote-monitor",
44
"env": {
55
"MONGO_COLLECTION": {
6-
"description": "The mongo collection to connect to.",
7-
"value": "nightscout"
6+
"description": "The mongo collection for CGM data. Most users should leave this as default.",
7+
"value": "entries",
8+
"required": true
9+
},
10+
"API_SECRET": {
11+
"description": "User generated password required for REST API and other features (12 character minimum).",
12+
"value": "",
13+
"required": true
14+
},
15+
"ENABLE": {
16+
"description": "Space delimited list of optional features to enable. Leave blank for a default site.",
17+
"value": "",
18+
"required": false
19+
},
20+
"PUSHOVER_API_TOKEN": {
21+
"description": "Pushover API token, required for Pushover notifications. Leave blank for a default site.",
22+
"value": "",
23+
"required": false
24+
},
25+
"PUSHOVER_USER_KEY": {
26+
"description": "Pushover user key, required for Pushover notifications. Leave blank for a default site.",
27+
"value": "",
28+
"required": false
829
}
930
},
1031
"addons": [
11-
"mongolab"
32+
"mongolab:sandbox"
1233
]
1334
}

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nightscout",
3-
"version": "0.5.1",
3+
"version": "0.6.0",
44
"dependencies": {
55
"angularjs": "1.3.0-beta.19",
66
"bootstrap": "~3.2.0",

env.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var env = { };
44
var crypto = require('crypto');
55
var consts = require('./lib/constants');
6+
var fs = require('fs');
67
// Module to constrain all config and environment parsing to one spot.
78
function config ( ) {
89

@@ -43,6 +44,19 @@ function config ( ) {
4344
env.devicestatus_collection = readENV('MONGO_DEVICESTATUS_COLLECTION', 'devicestatus');
4445

4546
env.enable = readENV('ENABLE');
47+
env.SSL_KEY = readENV('SSL_KEY');
48+
env.SSL_CERT = readENV('SSL_CERT');
49+
env.SSL_CA = readENV('SSL_CA');
50+
env.ssl = false;
51+
if (env.SSL_KEY && env.SSL_CERT) {
52+
env.ssl = {
53+
key: fs.readFileSync(env.SSL_KEY)
54+
, cert: fs.readFileSync(env.SSL_CERT)
55+
};
56+
if (env.SSL_CA) {
57+
env.ca = fs.readFileSync(env.SSL_CA);
58+
}
59+
}
4660

4761
var shasum = crypto.createHash('sha1');
4862

@@ -64,6 +78,43 @@ function config ( ) {
6478
env.api_secret = shasum.digest('hex');
6579
}
6680

81+
env.thresholds = {
82+
bg_high: readIntENV('BG_HIGH', 260)
83+
, bg_target_top: readIntENV('BG_TARGET_TOP', 180)
84+
, bg_target_bottom: readIntENV('BG_TARGET_BOTTOM', 80)
85+
, bg_low: readIntENV('BG_LOW', 55)
86+
};
87+
88+
//NOTE: using +/- 1 here to make the thresholds look visibly wrong in the UI
89+
// if all thresholds were set to the same value you should see 4 lines stacked right on top of each other
90+
if (env.thresholds.bg_target_bottom >= env.thresholds.bg_target_top) {
91+
console.warn('BG_TARGET_BOTTOM(' + env.thresholds.bg_target_bottom + ') was >= BG_TARGET_TOP(' + env.thresholds.bg_target_top + ')');
92+
env.thresholds.bg_target_bottom = env.thresholds.bg_target_top - 1;
93+
console.warn('BG_TARGET_BOTTOM is now ' + env.thresholds.bg_target_bottom);
94+
}
95+
96+
if (env.thresholds.bg_target_top <= env.thresholds.bg_target_bottom) {
97+
console.warn('BG_TARGET_TOP(' + env.thresholds.bg_target_top + ') was <= BG_TARGET_BOTTOM(' + env.thresholds.bg_target_bottom + ')');
98+
env.thresholds.bg_target_top = env.thresholds.bg_target_bottom + 1;
99+
console.warn('BG_TARGET_TOP is now ' + env.thresholds.bg_target_top);
100+
}
101+
102+
if (env.thresholds.bg_low >= env.thresholds.bg_target_bottom) {
103+
console.warn('BG_LOW(' + env.thresholds.bg_low + ') was >= BG_TARGET_BOTTOM(' + env.thresholds.bg_target_bottom + ')');
104+
env.thresholds.bg_low = env.thresholds.bg_target_bottom - 1;
105+
console.warn('BG_LOW is now ' + env.thresholds.bg_low);
106+
}
107+
108+
if (env.thresholds.bg_high <= env.thresholds.bg_target_top) {
109+
console.warn('BG_HIGH(' + env.thresholds.bg_high + ') was <= BG_TARGET_TOP(' + env.thresholds.bg_target_top + ')');
110+
env.thresholds.bg_high = env.thresholds.bg_target_top + 1;
111+
console.warn('BG_HIGH is now ' + env.thresholds.bg_high);
112+
}
113+
114+
//if any of the BG_* thresholds are set, default to "simple" otherwise default to "predict" to preserve current behavior
115+
var thresholdsSet = readIntENV('BG_HIGH') || readIntENV('BG_TARGET_TOP') || readIntENV('BG_TARGET_BOTTOM') || readIntENV('BG_LOW');
116+
env.alarm_types = readENV('ALARM_TYPES') || (thresholdsSet ? "simple" : "predict");
117+
67118
// For pushing notifications to Pushover.
68119
env.pushover_api_token = readENV('PUSHOVER_API_TOKEN');
69120
env.pushover_user_key = readENV('PUSHOVER_USER_KEY') || readENV('PUSHOVER_GROUP_KEY');
@@ -83,6 +134,10 @@ function config ( ) {
83134
return env;
84135
}
85136

137+
function readIntENV(varName, defaultValue) {
138+
return parseInt(readENV(varName)) || defaultValue;
139+
}
140+
86141
function readENV(varName, defaultValue) {
87142
//for some reason Azure uses this prefix, maybe there is a good reason
88143
var value = process.env['CUSTOMCONNSTR_' + varName]

lib/api/entries/middleware.js

Whitespace-only changes.

lib/api/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ function create (env, entries, settings, treatments, devicestatus) {
3333

3434
app.set('title', [app.get('name'), 'API', app.get('version')].join(' '));
3535

36+
app.thresholds = env.thresholds;
37+
app.alarm_types = env.alarm_types;
38+
3639
// Start setting up routes
3740
if (app.enabled('api')) {
3841
// experiments

lib/api/status.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ function configure (app, wares) {
1616
, units: app.get('units')
1717
, head: wares.get_head( )
1818
, version: app.get('version')
19+
, thresholds: app.thresholds
20+
, alarm_types: app.alarm_types
1921
, name: app.get('name')};
2022
var badge = 'http://img.shields.io/badge/Nightscout-OK-green';
2123
return res.format({

lib/api/treatments/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function configure (app, wares, treatments) {
1717

1818
// List settings available
1919
api.get('/treatments/', function(req, res) {
20-
treatments.list(function (err, profiles) {
20+
treatments.list({}, function (err, profiles) {
2121
return res.json(profiles);
2222
});
2323
});

0 commit comments

Comments
 (0)