forked from nightscout/minimed-connect-to-nightscout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "minimed-connect-to-nightscout", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Send Medtronic pump and CGM data to Nightscout.", | ||
"author": "Mark Wilson <[email protected]>", | ||
"repository": { | ||
|
@@ -12,13 +12,21 @@ | |
}, | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node run.js" | ||
"start": "node run.js", | ||
"test": "mocha" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": "0.10.x" | ||
}, | ||
"dependencies": { | ||
"common": "0.2.5", | ||
"extend": "3.0.0", | ||
"request": "2.64.0" | ||
"common": "0.2.x", | ||
"extend": "3.0.x", | ||
"request": "2.64.x" | ||
}, | ||
"devDependencies": { | ||
"expect.js": "0.3.x", | ||
"mocha": "2.3.x" | ||
}, | ||
"keywords": [ | ||
"medtronic", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
var extend = require('extend'); | ||
|
||
var makeSG = module.exports.makeSG = function(sg, time) { | ||
time = time || "Oct 20, 2015 11:09:00"; | ||
return { | ||
"sg" : sg, | ||
"datetime" : time, | ||
"version" : 1, | ||
"timeChange" : false, | ||
"kind" : "SG" | ||
}; | ||
}; | ||
|
||
var makeSGs = module.exports.makeSGs = function(count) { | ||
var out = []; | ||
for(var i = 0; i < count; i++) { | ||
out.push(makeSG(100 + i)); | ||
} | ||
return out; | ||
}; | ||
|
||
var data = module.exports.data = function(overrides) { | ||
overrides = overrides || {}; | ||
return extend(true, { | ||
"sgs" : makeSGs(300), | ||
"conduitSerialNumber" : "0", | ||
"conduitMedicalDeviceInRange" : true, | ||
"version" : 1, | ||
"calibStatus" : "LESS_THAN_TWELVE_HRS", | ||
"medicalDeviceFamily" : "PARADIGM", | ||
"kind" : "Main", | ||
"medicalDeviceTime" : 0, | ||
"lastAlarm" : { | ||
"type" : "ALARM", | ||
"version" : 1, | ||
"flash" : false, | ||
"datetime" : "Oct 12, 2015 03:12:10", | ||
"kind" : "Alarm", | ||
"code" : 102 | ||
}, | ||
"currentServerTime" : 1445091119507, | ||
"sMedicalDeviceTime" : "Oct 17, 2015 09:09:14", | ||
"conduitInRange" : true, | ||
"limits" : [ | ||
{ | ||
"index" : 0, | ||
"lowLimit" : 80, | ||
"kind" : "Limits", | ||
"highLimit" : 300, | ||
"version" : 1 | ||
} | ||
], | ||
"reservoirAmount" : 52, | ||
"timeFormat" : "HR_24", | ||
"sensorState" : "NORMAL", | ||
"lastConduitTime" : 0, | ||
"medicalDeviceBatteryLevelPercent" : 100, | ||
"reservoirLevelPercent" : 50, | ||
// We don't look at this; otherwise it should match "sgs" | ||
"lastSG" : { | ||
"kind" : "SG", | ||
"datetime" : "Oct 17, 2015 09:08:00", | ||
"version" : 1, | ||
"timeChange" : false, | ||
"sg" : 180 | ||
}, | ||
"lastSensorTSAsString" : "Oct 17, 2015 09:08:00", | ||
"lastName" : "<redacted>", | ||
"activeInsulin" : { | ||
"datetime" : "Oct 17, 2015 09:09:14", | ||
"version" : 1, | ||
"amount" : 1.275, | ||
"kind" : "Insulin" | ||
}, | ||
"conduitBatteryLevel" : 100, | ||
"conduitBatteryStatus" : "FULL", | ||
"conduitSensorInRange" : true, | ||
"medicalDeviceSerialNumber" : "<redacted>", | ||
"timeToNextCalibHours" : 11, | ||
"sensorDurationHours" : 91, | ||
"firstName" : "<redacted>", | ||
"lastConduitUpdateServerTime" : 1445091101422, | ||
"lastMedicalDeviceDataUpdateServerTime" : 1445091101422, | ||
"medicalDeviceSuspended" : false, | ||
"bgunits" : "MGDL", | ||
"bgUnits" : "MGDL", | ||
"sLastSensorTime" : "Oct 17, 2015 09:08:00", | ||
"lastSensorTS" : 0, | ||
"medicalDeviceTimeAsString" : "Oct 17, 2015 09:09:14", | ||
"lastSGTrend" : "UP_DOUBLE", | ||
"lastSensorTime" : 0 | ||
}, overrides); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* jshint node: true */ | ||
/* globals describe, it */ | ||
"use strict"; | ||
|
||
var expect = require('expect.js'); | ||
|
||
var f = require('./fixtures.js'), | ||
transform = require('../transform.js'); | ||
|
||
describe('transform()', function() { | ||
it('should obey sgvLimit', function() { | ||
var data = f.data(); | ||
|
||
expect( | ||
transform(data) | ||
.filter(function(e) { return e['type'] === 'sgv'; }) | ||
.length | ||
).to.eql(data['sgs'].length); | ||
|
||
expect( | ||
transform(data, 4) | ||
.filter(function(e) { return e['type'] === 'sgv'; }) | ||
.length | ||
).to.be(4); | ||
}); | ||
|
||
it('should include pump device family', function() { | ||
expect( | ||
transform( | ||
f.data({'medicalDeviceFamily': 'foo'}) | ||
)[0]['device'] | ||
).to.be('connect://foo'); | ||
}); | ||
|
||
it('should discard data more than 20 minutes old', function() { | ||
var now = Date.now(); | ||
var THRESHOLD = 20; | ||
var boundary = now - THRESHOLD * 60 * 1000; | ||
expect( | ||
transform( | ||
f.data({'currentServerTime': now, 'lastMedicalDeviceDataUpdateServerTime': boundary}) | ||
).length | ||
).to.be.greaterThan(0); | ||
|
||
expect( | ||
transform( | ||
f.data({'currentServerTime': now, 'lastMedicalDeviceDataUpdateServerTime': boundary - 1}) | ||
).length | ||
).to.be(0); | ||
}); | ||
}); |