@peopl-health/nexus 6.0.0-dev.16614 → 6.0.0-dev.16615
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -179,16 +179,29 @@ async function sweepUntakenAlerts({ now = new Date() } = {}) {
|
|
|
179
179
|
.lean();
|
|
180
180
|
const policy = responseDeadlinePolicy();
|
|
181
181
|
let sent = 0;
|
|
182
|
+
const failed = (message, review, error) => logger.error(message, {
|
|
183
|
+
escalationReviewId: String(review._id), error: redactDirectIdentifiers(String(error?.message || error)),
|
|
184
|
+
});
|
|
182
185
|
for (const review of reviews) {
|
|
186
|
+
let clock;
|
|
187
|
+
try {
|
|
188
|
+
clock = untakenClockOf(review, policy);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
failed('[UntakenAlert] Could not check a review for an untaken alert', review, error);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
// A failed team alert must not keep the case from the doctor, so each step fails on its own.
|
|
183
194
|
try {
|
|
184
|
-
const clock = untakenClockOf(review, policy);
|
|
185
195
|
const stage = alerts && clock && dueStageOf(review, clock, now);
|
|
186
196
|
if (stage && await alertIfUntaken(review, clock, stage, now)) sent += 1;
|
|
187
|
-
if (autoHandoff) await settleCharacterization(review, clock, now);
|
|
188
197
|
} catch (error) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
198
|
+
failed('[UntakenAlert] Could not check a review for an untaken alert', review, error);
|
|
199
|
+
}
|
|
200
|
+
if (!autoHandoff) continue;
|
|
201
|
+
try {
|
|
202
|
+
await settleCharacterization(review, clock, now);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
failed('[UntakenAlert] Could not settle the characterization of a review', review, error);
|
|
192
205
|
}
|
|
193
206
|
}
|
|
194
207
|
return sent;
|