@peopl-health/nexus 5.71.21 → 5.71.22

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.
@@ -21,28 +21,31 @@ const MEDICAL_URGENCY_TO_SEVERITY = {
21
21
 
22
22
  const EMERGENCY_LEVELS = new Set(['stat', 'asap']);
23
23
 
24
- function pageNavigator({ severity, reason }) {
24
+ function pageNavigator({ severity, priority = null, reason }) {
25
25
  return {
26
26
  kind: 'page_navigator',
27
27
  severity,
28
+ priority,
28
29
  reason,
29
30
  requiresAck: severity === 'critical' || severity === 'high',
30
31
  };
31
32
  }
32
33
 
33
- function pageOncologist({ severity, reason }) {
34
+ function pageOncologist({ severity, priority = null, reason }) {
34
35
  return {
35
36
  kind: 'page_oncologist',
36
37
  severity,
38
+ priority,
37
39
  reason,
38
40
  requiresAck: true,
39
41
  };
40
42
  }
41
43
 
42
- function openTicket({ severity, title, reason }) {
44
+ function openTicket({ severity, priority = null, title, reason }) {
43
45
  return {
44
46
  kind: 'open_ticket',
45
47
  severity,
48
+ priority,
46
49
  title,
47
50
  reason,
48
51
  slaMinutes: SLA_MINUTES_BY_SEVERITY[severity] ?? null,
@@ -63,19 +66,21 @@ function planMedicalUrgent(signal) {
63
66
  const level = (signal?.urgencyLevel || 'urgent').toLowerCase();
64
67
  const indicators = Array.isArray(signal?.indicators) ? signal.indicators : [];
65
68
  const label = signal?.category || signal?.symptom || signal?.suspectedCondition || 'medical';
69
+ const priority = MEDICAL_URGENCY_TO_SEVERITY[level] ? level : null;
66
70
  if (EMERGENCY_LEVELS.has(level)) {
67
71
  const severity = MEDICAL_URGENCY_TO_SEVERITY[level];
68
72
  const reason = `emergency gate fired: ${indicators.join(', ') || 'unspecified'} (level=${level})`;
69
73
  return [
70
- pageOncologist({ severity, reason }),
71
- pageNavigator({ severity, reason }),
72
- openTicket({ severity, title: `EMERG: ${indicators.join(', ') || 'unspecified'}`, reason }),
74
+ pageOncologist({ severity, priority, reason }),
75
+ pageNavigator({ severity, priority, reason }),
76
+ openTicket({ severity, priority, title: `EMERG: ${indicators.join(', ') || 'unspecified'}`, reason }),
73
77
  ];
74
78
  }
75
79
  const severity = MEDICAL_URGENCY_TO_SEVERITY[level] || 'medium';
76
80
  return [
77
81
  openTicket({
78
82
  severity,
83
+ priority,
79
84
  title: `MED-${level.toUpperCase()}: ${String(label).slice(0, 60)}`,
80
85
  reason: signal?.urgencyJustification || null,
81
86
  }),
@@ -42,7 +42,7 @@ class CommunicationRequest {
42
42
  identifier: [identifier(ESCALATION_SLUG, notify.eventId)],
43
43
  status: NOTIFY_STATUS_TO_CR_STATUS[notify.status],
44
44
  intent: 'plan',
45
- priority: SEVERITY_TO_PRIORITY[notify.severity] || 'routine',
45
+ priority: notify.priority || SEVERITY_TO_PRIORITY[notify.severity] || 'routine',
46
46
  category: [codeableConcept(notify.kind, { code: notify.kind, system: codeSystemUrl(ESCALATION_KIND_SLUG) })],
47
47
  subject: patientReference(notify.patientId),
48
48
  authoredOn: toIso(notify.createdAt),
@@ -32,7 +32,7 @@ class Task {
32
32
  identifier: [identifier(ESCALATION_SLUG, ticket.eventId)],
33
33
  status: TICKET_STATUS_TO_TASK_STATUS[ticket.status],
34
34
  intent: 'order',
35
- priority: SEVERITY_TO_PRIORITY[ticket.severity] || 'routine',
35
+ priority: ticket.priority || SEVERITY_TO_PRIORITY[ticket.severity] || 'routine',
36
36
  code: codeableConcept(ticket.kind, { code: ticket.kind, system: codeSystemUrl(ESCALATION_KIND_SLUG) }),
37
37
  for: patientReference(ticket.patientId),
38
38
  authoredOn: toIso(ticket.createdAt),
@@ -9,6 +9,7 @@ const baseFields = {
9
9
  eventId: z.string(),
10
10
  patientId: z.string(),
11
11
  severity: z.enum(['critical', 'high', 'medium', 'low']),
12
+ priority: z.enum(['stat', 'asap', 'urgent', 'routine']).nullable().default(null),
12
13
  createdAt: dateTime,
13
14
  status: z.enum(['queued', 'sent', 'acknowledged', 'failed']).default('queued'),
14
15
  reason: z.string().nullable().default(null),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.71.21",
3
+ "version": "5.71.22",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",