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

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.
@@ -851,8 +851,15 @@ async function prepareDoctorAlert(review, kind, urgencyLevel) {
851
851
  return { approver, message };
852
852
  }
853
853
 
854
- const topUrgencyOf = (review) => (review.alarms ?? [])
855
- .reduce((top, alarm) => (URGENCY_RANK[alarm.urgencyLevel] > (URGENCY_RANK[top] || 0) ? alarm.urgencyLevel : top), null);
854
+ // The urgency the doctor is asked about now: alarms a decision already answered do not raise it, so a
855
+ // review reopened by an asap alarm after a decided stat is an asap alert.
856
+ const topUrgencyOf = (review) => {
857
+ const alarms = review.alarms ?? [];
858
+ const decidedAt = (review.decisions ?? []).at(-1)?.createdAt;
859
+ const open = decidedAt ? alarms.filter((alarm) => new Date(alarm.raisedAt) > new Date(decidedAt)) : alarms;
860
+ return (open.length ? open : alarms)
861
+ .reduce((top, alarm) => (URGENCY_RANK[alarm.urgencyLevel] > (URGENCY_RANK[top] || 0) ? alarm.urgencyLevel : top), null);
862
+ };
856
863
 
857
864
  const realertStillDue = (review, initial) => !review.closedAt && Boolean(initial) && !answeredSince(review, initial.sentAt);
858
865
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.61.0-dev.11234",
3
+ "version": "5.61.0-dev.11235",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",