@peopl-health/nexus 5.50.2 → 5.51.0-dev.7558
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,10 +109,9 @@ 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) {
|
|
113
113
|
const EscalationReview = getEscalationReview();
|
|
114
|
-
const
|
|
115
|
-
const record = claimCleared(recordUpdate);
|
|
114
|
+
const record = { ...recordUpdate, $set: { ...recordUpdate.$set, operationClaim: null } };
|
|
116
115
|
const settled = await EscalationReview.findOneAndUpdate(
|
|
117
116
|
{ _id: id, status: fromStatus, operationClaim: claim },
|
|
118
117
|
{ ...record, $set: { ...record.$set, status: nextStatus } },
|
|
@@ -122,7 +121,7 @@ async function completeOperation(id, claim, fromStatus, recordUpdate, nextStatus
|
|
|
122
121
|
|
|
123
122
|
const recorded = await EscalationReview.findOneAndUpdate(
|
|
124
123
|
{ _id: id, operationClaim: claim },
|
|
125
|
-
|
|
124
|
+
record,
|
|
126
125
|
{ new: true },
|
|
127
126
|
).lean();
|
|
128
127
|
if (recorded) {
|
|
@@ -374,9 +373,10 @@ async function handOffToDoctor({ id, mode, physicianEmail = null, sentBy, reques
|
|
|
374
373
|
let updated;
|
|
375
374
|
try {
|
|
376
375
|
if (approver) delivery = { physicianEmail: approver.email, ...(await sendDoctorAlert({ review, draft, approver, operator })) };
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
376
|
+
const recordUpdate = withCaseMirror(review, {
|
|
377
|
+
$push: { doctorHandoffs: { mode, draftNumber, ...delivery, sentBy: operator } },
|
|
378
|
+
}, { status: 'en revision_medica' });
|
|
379
|
+
updated = await completeOperation(reviewId, claim, 'handing_off', recordUpdate, 'awaiting_doctor');
|
|
380
380
|
} catch (error) {
|
|
381
381
|
await releaseReview(reviewId, 'handing_off', review.status, claim);
|
|
382
382
|
throw error;
|