Skip to content
This repository has been archived by the owner on Oct 26, 2020. It is now read-only.

Fix US server #13

Merged
merged 2 commits into from
Aug 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var CARELINK_TREND_TO_NIGHTSCOUT_TREND = {
}
};

function parsePumpTime(pumpTimeString, offset) {
if (process.env['MMCONNECT_SERVER'] === 'EU') {
function parsePumpTime(pumpTimeString, offset, medicalDeviceFamily) {
if (process.env['MMCONNECT_SERVER'] === 'EU' || medicalDeviceFamily === 'GUARDIAN') {
return Date.parse(pumpTimeString);
} else {
return Date.parse(pumpTimeString + ' ' + offset);
Expand Down Expand Up @@ -109,7 +109,7 @@ function deviceStatusEntry(data, offset) {
'timestamp': timestampAsString(data['lastMedicalDeviceDataUpdateServerTime']),
'bolusiob': _.get(data, 'activeInsulin.amount') >= 0 ? _.get(data, 'activeInsulin.amount') : undefined,
},
'clock': timestampAsString(parsePumpTime(data['sMedicalDeviceTime'], offset)),
'clock': timestampAsString(parsePumpTime(data['sMedicalDeviceTime'], offset, data['medicalDeviceFamily'])),
// TODO: add last alarm from data['lastAlarm']['code'] and data['lastAlarm']['datetime']
// https://gist.github.com/mddub/a95dc120d9d1414a433d#file-minimed-connect-codes-js-L79
},
Expand All @@ -136,7 +136,7 @@ function sgvEntries(data, offset) {
var sgvs = data['sgs'].filter(function (entry) {
return entry['kind'] === 'SG' && entry['sg'] !== 0;
}).map(function (sgv) {
var timestamp = parsePumpTime(sgv['datetime'], offset);
var timestamp = parsePumpTime(sgv['datetime'], offset, data['medicalDeviceFamily']);
return {
'type': SENSOR_GLUCOSE_ENTRY_TYPE,
'sgv': sgv['sg'],
Expand Down