@peopl-health/nexus 5.61.0-dev.11233 → 5.61.0-dev.11234

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.
@@ -796,11 +796,16 @@ async function suggestDraft({ id, requestedBy, requestId = null } = {}) {
796
796
  return { ...draft, doctorText: withIdentity({ identity, review, doctorText: draft.doctorText }) };
797
797
  }
798
798
 
799
- // The most urgent level the doctor was actually alerted about; a failed attempt told them nothing.
799
+ // The most urgent level the doctor was actually alerted about since the last decision: a failed attempt
800
+ // told them nothing, and a review reopened after a decision is a new question for them.
800
801
  // Scheduling and sending gate on the same one.
801
- const alertedRankOf = (review) => Math.max(0, ...(review.doctorAlerts ?? [])
802
- .filter((sent) => sent.kind === 'initial' && !sent.error)
803
- .map((sent) => URGENCY_RANK[sent.urgencyLevel] || 0));
802
+ const alertedRankOf = (review) => {
803
+ const decidedAt = (review.decisions ?? []).at(-1)?.createdAt;
804
+ const sinceMs = decidedAt ? new Date(decidedAt).getTime() : -Infinity;
805
+ return Math.max(0, ...(review.doctorAlerts ?? [])
806
+ .filter((sent) => sent.kind === 'initial' && !sent.error && new Date(sent.sentAt).getTime() > sinceMs)
807
+ .map((sent) => URGENCY_RANK[sent.urgencyLevel] || 0));
808
+ };
804
809
 
805
810
  // A stat or asap alarm more urgent than anything the doctor was already told about is due now.
806
811
  async function scheduleDoctorAlert(review, alarm, now) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.61.0-dev.11233",
3
+ "version": "5.61.0-dev.11234",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",