@peopl-health/nexus 5.59.0-dev.10731 → 5.59.0
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.
|
@@ -57,6 +57,7 @@ const doctorHandoffSchema = new mongoose.Schema({
|
|
|
57
57
|
transport: { type: String, enum: [null, 'text', 'template'], default: null },
|
|
58
58
|
messageId: { type: String, default: null },
|
|
59
59
|
message: { type: String, default: null },
|
|
60
|
+
alarmCount: { type: Number, default: null },
|
|
60
61
|
sentBy: { type: String, required: true },
|
|
61
62
|
}, { timestamps: { createdAt: true, updatedAt: false } });
|
|
62
63
|
|
|
@@ -929,7 +929,7 @@ async function handOffToDoctor({ id, mode, physicianEmail = null, sentBy, reques
|
|
|
929
929
|
if (approver) delivery = { physicianEmail: approver.email, ...(await sendDoctorAlert({ message, approver, operator })) };
|
|
930
930
|
const sent = delivery.transport === 'template' ? Object.values(message.template).join('\n') : message.body;
|
|
931
931
|
const handoff = {
|
|
932
|
-
$push: { doctorHandoffs: { mode, draftNumber, ...delivery, message: sent, sentBy: operator } },
|
|
932
|
+
$push: { doctorHandoffs: { mode, draftNumber, ...delivery, message: sent, alarmCount: (review.alarms ?? []).length, sentBy: operator } },
|
|
933
933
|
$addToSet: { patientCaseRecordIds: { $each: patientCaseRecordIds } },
|
|
934
934
|
$unset: { identityBlock: '' },
|
|
935
935
|
};
|
|
@@ -1077,10 +1077,10 @@ async function sendApprovedIndications({ id, outsideWindowRoute = null, sentBy,
|
|
|
1077
1077
|
await audit(review, operator, requestId, { action: status, decisionNumber, transport: delivery.transport });
|
|
1078
1078
|
const sent = await syncCase(review, operator, requestId);
|
|
1079
1079
|
if (review.status !== 'indications_sent' || decision === 'needs_intervention') return sent;
|
|
1080
|
-
const
|
|
1081
|
-
const
|
|
1082
|
-
if ((review.alarms ?? []).
|
|
1083
|
-
logger.warn('[EscalationReview]
|
|
1080
|
+
const decidedDraft = review.decisions[decisionNumber - 1]?.draftNumber;
|
|
1081
|
+
const handoff = (review.doctorHandoffs ?? []).findLast((entry) => entry.draftNumber === decidedDraft);
|
|
1082
|
+
if (handoff?.alarmCount == null || (review.alarms ?? []).length > handoff.alarmCount) {
|
|
1083
|
+
logger.warn('[EscalationReview] The doctor did not see every alarm on this review; it stays open for them', {
|
|
1084
1084
|
escalationReviewId: String(review._id),
|
|
1085
1085
|
});
|
|
1086
1086
|
return sent;
|