@peopl-health/nexus 6.6.0-dev.21352 → 6.6.1
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.
|
@@ -1567,6 +1567,11 @@ function updatesDoctor(review) {
|
|
|
1567
1567
|
return botHandoffs.length <= MAX_DOCTOR_UPDATES;
|
|
1568
1568
|
}
|
|
1569
1569
|
|
|
1570
|
+
async function markDraftFailed(review, lease, reason) {
|
|
1571
|
+
const marked = await getEscalationReview().updateOne({ _id: review._id, closedAt: null, draftDueAt: lease }, { $set: { draftFailedAt: new Date() } }, BOOKKEEPING);
|
|
1572
|
+
if (marked.modifiedCount) await audit(review, DRAFT_OPERATOR, null, { action: 'draft_generation_failed', reason });
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1570
1575
|
async function generateBotDraft({ id, lease = null } = {}) {
|
|
1571
1576
|
const startedAt = new Date();
|
|
1572
1577
|
const review = await loadReview(reviewIdOf(id));
|
|
@@ -1579,6 +1584,7 @@ async function generateBotDraft({ id, lease = null } = {}) {
|
|
|
1579
1584
|
const identity = await readDoctorIdentity(review);
|
|
1580
1585
|
if (identity.missing.length) {
|
|
1581
1586
|
if (!review.identityBlock && !refreshing) await blockForMissingIdentity({ review, missing: identity.missing, operator: DRAFT_OPERATOR });
|
|
1587
|
+
if (lease && refreshing) await markDraftFailed(review, lease, 'missing_doctor_identity');
|
|
1582
1588
|
return { review: null, retry: false };
|
|
1583
1589
|
}
|
|
1584
1590
|
|
|
@@ -1598,6 +1604,7 @@ async function generateBotDraft({ id, lease = null } = {}) {
|
|
|
1598
1604
|
}
|
|
1599
1605
|
if (!draft.completed) {
|
|
1600
1606
|
logger.warn('[EscalationReview] The automatic draft was not written', { escalationReviewId: String(review._id), reason: draft.reason });
|
|
1607
|
+
if (draft.configured === false && lease) await markDraftFailed(review, lease, 'not_configured');
|
|
1601
1608
|
return { review: null, retry: draft.configured !== false, rejected: draft.rejected === true };
|
|
1602
1609
|
}
|
|
1603
1610
|
|