Last active
August 29, 2015 14:22
-
-
Save jasoncalabrese/67e19600c773341f493a to your computer and use it in GitHub Desktop.
Insurance Export
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
var start = new ISODate("2015-05-01T00:00:00.001-07").toISOString(); | |
var end = new ISODate("2015-05-31T00:00:00.001-07").toISOString(); | |
var min = 60; | |
var max = 220; | |
var bgChecks = db.treatments.find({$and: [ | |
{created_at: {$gt: start}} | |
, {created_at: {$lt: end}} | |
, {glucose: {$exists: true}} | |
, {glucoseType: 'Finger'} | |
]}); | |
bgChecks.forEach(function(doc) { | |
var bg = Number(doc.glucose); | |
if (bg >= min && bg <= max) { | |
print(new Date(doc.created_at).getTime() + '\t' +new Date(doc.created_at).toLocaleString() + '\t' + doc.glucose); | |
} | |
}); |
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
var start = new ISODate("2015-05-01T00:00:00.001-07").getTime(); | |
var end = new ISODate("2015-05-31T00:00:00.001-07").getTime(); | |
var min = 60; | |
var max = 220; | |
var mbgs = db.entries.find({$and: [ | |
{date: {$gt: NumberLong(start)}} | |
, {date: {$lt: NumberLong(end)}} | |
, {type: "mbg"} | |
, {mbg: {$gte: min}} | |
, {mbg: {$lte: max}} | |
]}); | |
mbgs.forEach(function(doc) { | |
print(doc.date + '\t' + new Date(doc.date).toLocaleString() + '\t' + doc.mbg); | |
}); |
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
#!/bin/sh | |
PATH="ds012345.mongolab.com:12345/nightscout" | |
USER="nightscout" | |
PASSWORD="secret" | |
mongo $PATH -u $USER -p $PASSWORD export-mbgs.js > mbgs.tsv | |
mongo $PATH -u $USER -p $PASSWORD export-bgchecks.js > bgchecks.tsv | |
tail -n +3 mbgs.tsv > combined.tsv | |
tail -n +3 bgchecks.tsv >> combined.tsv | |
sort combined.tsv > sorted.tsv | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment