@peopl-health/nexus 5.51.0-dev.7573 → 5.51.0-dev.7592
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.
|
@@ -109,9 +109,10 @@ const releaseReview = (id, from, to, claim = null) => getEscalationReview().upda
|
|
|
109
109
|
// The record of a message that really went out is never gated on status: the operator may have
|
|
110
110
|
// adjudicated the review while the send was still running. Only the status transition is gated,
|
|
111
111
|
// so a closed review keeps its handoff or delivery without being resurrected.
|
|
112
|
-
async function completeOperation(id, claim, fromStatus, recordUpdate, nextStatus) {
|
|
112
|
+
async function completeOperation(id, claim, fromStatus, recordUpdate, nextStatus, lateUpdate = recordUpdate) {
|
|
113
113
|
const EscalationReview = getEscalationReview();
|
|
114
|
-
const
|
|
114
|
+
const claimCleared = (update) => ({ ...update, $set: { ...update.$set, operationClaim: null } });
|
|
115
|
+
const record = claimCleared(recordUpdate);
|
|
115
116
|
const settled = await EscalationReview.findOneAndUpdate(
|
|
116
117
|
{ _id: id, status: fromStatus, operationClaim: claim },
|
|
117
118
|
{ ...record, $set: { ...record.$set, status: nextStatus } },
|
|
@@ -121,7 +122,7 @@ async function completeOperation(id, claim, fromStatus, recordUpdate, nextStatus
|
|
|
121
122
|
|
|
122
123
|
const recorded = await EscalationReview.findOneAndUpdate(
|
|
123
124
|
{ _id: id, operationClaim: claim },
|
|
124
|
-
|
|
125
|
+
claimCleared(lateUpdate),
|
|
125
126
|
{ new: true },
|
|
126
127
|
).lean();
|
|
127
128
|
if (recorded) {
|
|
@@ -373,10 +374,9 @@ async function handOffToDoctor({ id, mode, physicianEmail = null, sentBy, reques
|
|
|
373
374
|
let updated;
|
|
374
375
|
try {
|
|
375
376
|
if (approver) delivery = { physicianEmail: approver.email, ...(await sendDoctorAlert({ review, draft, approver, operator })) };
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
updated = await completeOperation(reviewId, claim, 'handing_off', recordUpdate, 'awaiting_doctor');
|
|
377
|
+
const handoff = { $push: { doctorHandoffs: { mode, draftNumber, ...delivery, sentBy: operator } } };
|
|
378
|
+
const recordUpdate = withCaseMirror(review, handoff, { status: 'en revision_medica' });
|
|
379
|
+
updated = await completeOperation(reviewId, claim, 'handing_off', recordUpdate, 'awaiting_doctor', handoff);
|
|
380
380
|
} catch (error) {
|
|
381
381
|
await releaseReview(reviewId, 'handing_off', review.status, claim);
|
|
382
382
|
throw error;
|