Skip to content

Commit

Permalink
Merge pull request #1255 from tidepool-org/alarmtype-null
Browse files Browse the repository at this point in the history
Bug fix for TypeError: Cannot read property 'with_alarmType' of null (UPLOAD-363)
  • Loading branch information
gniezen authored Jul 29, 2020
2 parents 81cc117 + f7288a2 commit d778c69
Showing 1 changed file with 105 additions and 105 deletions.
210 changes: 105 additions & 105 deletions lib/drivers/insulet/insuletDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,113 +999,113 @@ module.exports = (config) => {
postalarm = null;
}
const alarmText = getNameForValue(ALARM_TYPES, alarmValue);
switch (alarmValue) {
// alarmType `other`
// History - ALARM
case ALARM_TYPES.AlrmADV_KEY.value:
case ALARM_TYPES.AlrmEXP_WARNING.value:
case ALARM_TYPES.AlrmSYSTEM_ERROR10.value:
case ALARM_TYPES.AlrmSYSTEM_ERROR12.value:
case ALARM_TYPES.AlrmSYSTEM_ERROR28.value:
case ALARM_TYPES.AlrmPDM_ERROR0.value:
case ALARM_TYPES.AlrmPDM_ERROR1.value:
case ALARM_TYPES.AlrmPDM_ERROR2.value:
case ALARM_TYPES.AlrmPDM_ERROR3.value:
case ALARM_TYPES.AlrmPDM_ERROR4.value:
case ALARM_TYPES.AlrmPDM_ERROR5.value:
case ALARM_TYPES.AlrmPDM_ERROR6.value:
case ALARM_TYPES.AlrmPDM_ERROR7.value:
case ALARM_TYPES.AlrmPDM_ERROR8.value:
case ALARM_TYPES.AlrmPDM_ERROR9.value: // History - REMOTE HAZ
case ALARM_TYPES.AlrmHAZ_REMOTE.value:
case ALARM_TYPES.AlrmHAZ_PUMP_ACTIVATE.value:
case ALARM_TYPES.AlrmADV_PUMP_AUTO_OFF.value:
case ALARM_TYPES.AlrmADV_PUMP_SUSPEND.value:
case ALARM_TYPES.AlrmADV_PUMP_EXP1.value:
case ALARM_TYPES.AlrmADV_PUMP_EXP2.value:
postalarm = postalarm.with_alarmType('other')
.with_payload({
alarmText,
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.done();
break;
// Pump advisory and hazard alarm (non-History)
// alarmType `low_insulin`
case ALARM_TYPES.AlrmADV_PUMP_VOL.value:
postalarm = postalarm.with_alarmType('low_insulin')
.with_payload({
alarmText,
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.done();
break;
// alarmType `no_insulin`
case ALARM_TYPES.AlrmHAZ_PUMP_VOL.value:
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('no_insulin')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// alarmType `occlusion`
case ALARM_TYPES.AlrmHAZ_PUMP_OCCL.value:
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('occlusion')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// alarmType `no_delivery`
case ALARM_TYPES.AlrmHAZ_PUMP_EXPIRED.value:
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('no_delivery')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// alarmType `auto_off`
case ALARM_TYPES.AlrmHAZ_PDM_AUTO_OFF.value:
case ALARM_TYPES.AlrmHAZ_PUMP_AUTO_OFF.value:
// TODO: clarify with Insulet or get data to figure out whether this (below) is
// a warning or the actual auto-off; the spec is confused
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('auto_off')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// for alarm codes not documented in the spec
default:
if (postalarm) {
if (postalarm != null) {
switch (alarmValue) {
// alarmType `other`
// History - ALARM
case ALARM_TYPES.AlrmADV_KEY.value:
case ALARM_TYPES.AlrmEXP_WARNING.value:
case ALARM_TYPES.AlrmSYSTEM_ERROR10.value:
case ALARM_TYPES.AlrmSYSTEM_ERROR12.value:
case ALARM_TYPES.AlrmSYSTEM_ERROR28.value:
case ALARM_TYPES.AlrmPDM_ERROR0.value:
case ALARM_TYPES.AlrmPDM_ERROR1.value:
case ALARM_TYPES.AlrmPDM_ERROR2.value:
case ALARM_TYPES.AlrmPDM_ERROR3.value:
case ALARM_TYPES.AlrmPDM_ERROR4.value:
case ALARM_TYPES.AlrmPDM_ERROR5.value:
case ALARM_TYPES.AlrmPDM_ERROR6.value:
case ALARM_TYPES.AlrmPDM_ERROR7.value:
case ALARM_TYPES.AlrmPDM_ERROR8.value:
case ALARM_TYPES.AlrmPDM_ERROR9.value: // History - REMOTE HAZ
case ALARM_TYPES.AlrmHAZ_REMOTE.value:
case ALARM_TYPES.AlrmHAZ_PUMP_ACTIVATE.value:
case ALARM_TYPES.AlrmADV_PUMP_AUTO_OFF.value:
case ALARM_TYPES.AlrmADV_PUMP_SUSPEND.value:
case ALARM_TYPES.AlrmADV_PUMP_EXP1.value:
case ALARM_TYPES.AlrmADV_PUMP_EXP2.value:
postalarm = postalarm.with_alarmType('other')
.with_payload({
alarmText,
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.done();
}
break;
}
if (postalarm != null) {
break;
// Pump advisory and hazard alarm (non-History)
// alarmType `low_insulin`
case ALARM_TYPES.AlrmADV_PUMP_VOL.value:
postalarm = postalarm.with_alarmType('low_insulin')
.with_payload({
alarmText,
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.done();
break;
// alarmType `no_insulin`
case ALARM_TYPES.AlrmHAZ_PUMP_VOL.value:
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('no_insulin')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// alarmType `occlusion`
case ALARM_TYPES.AlrmHAZ_PUMP_OCCL.value:
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('occlusion')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// alarmType `no_delivery`
case ALARM_TYPES.AlrmHAZ_PUMP_EXPIRED.value:
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('no_delivery')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// alarmType `auto_off`
case ALARM_TYPES.AlrmHAZ_PDM_AUTO_OFF.value:
case ALARM_TYPES.AlrmHAZ_PUMP_AUTO_OFF.value:
// TODO: clarify with Insulet or get data to figure out whether this (below) is
// a warning or the actual auto-off; the spec is confused
postsuspend = makeSuspended(alarm);
postbasal = makeSuspendBasal(alarm);
postalarm = postalarm.with_alarmType('auto_off')
.with_payload({
alarmText: getNameForValue(ALARM_TYPES, alarmValue),
explanation: ALARM_TYPES[alarmText].explanation,
stopsDelivery: ALARM_TYPES[alarmText].stopsDelivery,
})
.with_status(postsuspend)
.done();
break;
// for alarm codes not documented in the spec
default:
if (postalarm) {
postalarm = postalarm.with_alarmType('other')
.done();
}
break;
}
postrecords.push(postalarm);
}
if (postsuspend != null) {
Expand Down

0 comments on commit d778c69

Please sign in to comment.