@peopl-health/nexus 5.51.0-dev.7573 → 5.51.0-dev.7593

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 record = { ...recordUpdate, $set: { ...recordUpdate.$set, operationClaim: null } };
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
- record,
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 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');
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.51.0-dev.7573",
3
+ "version": "5.51.0-dev.7593",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",