diff --git a/lib/drivers/insulet/insuletDriver.js b/lib/drivers/insulet/insuletDriver.js index 081871e315..9cf98dd431 100644 --- a/lib/drivers/insulet/insuletDriver.js +++ b/lib/drivers/insulet/insuletDriver.js @@ -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) {