@peopl-health/nexus 6.5.22 → 6.5.23

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.
@@ -13,6 +13,8 @@ const { URGENCY_RANK } = require('../../models/escalationReviewModel');
13
13
  const { objectArg, safeParse, isPlainObject } = require('../../utils/jsonUtils');
14
14
  const { logger } = require('../../utils/logger');
15
15
 
16
+ const ABSENT_ONLY_IF_DENIED = 'Escribe como ausente solo lo que el paciente negó cuando se le preguntó por eso en este episodio; lo que nadie preguntó va como «no preguntado» ("debilidad en piernas: no preguntado"), nunca como «sin debilidad» ni «descartado». Los equipos y los borradores leen tu texto como dato del paciente. ';
17
+
16
18
  const FEVER_RUBRIC_STAT = 'fiebre en la ventana de quimioterapia con una bandera roja confirmada (regla de fiebre),';
17
19
 
18
20
  const FEVER_RUBRIC_ASAP = 'fiebre ≥38.0 °C, o temperatura baja (menos de 36.0 °C) confirmada al volver a medir con malestar o escalofríos, o ≤35.0 °C confirmado, en la ventana de quimioterapia sin bandera roja (regla de fiebre),';
@@ -64,7 +66,7 @@ const definition = {
64
66
  'urgency_justification': {
65
67
  'type': 'string',
66
68
  'description': 'Por qué ESTE nivel — y explícitamente por qué no el inmediato superior ni el inferior (qué dato objetivo define el tier). Es el registro auditable de la decisión. Una o dos frases. INTERNO; el paciente nunca lo ve. '
67
- + MEDICATION_NAMING_RULE
69
+ + ABSENT_ONLY_IF_DENIED + MEDICATION_NAMING_RULE
68
70
  },
69
71
  'details': {
70
72
  'type': 'object',
@@ -116,7 +118,7 @@ const definition = {
116
118
  'anyOf': [
117
119
  {
118
120
  'type': 'string',
119
- 'description': 'Sospecha operativa interna para triage. NUNCA se menciona al paciente.'
121
+ 'description': 'Sospecha operativa interna para triage. NUNCA se menciona al paciente. ' + ABSENT_ONLY_IF_DENIED
120
122
  },
121
123
  {
122
124
  'type': 'null'
@@ -22,7 +22,8 @@ const LEVEL_LABELS = { asap: 'ASAP', urgent: 'URGENT' };
22
22
  const HANDOFF_RETRY_MS = 10 * 60 * 1000;
23
23
  const MAX_HANDOFF_ATTEMPTS = 4;
24
24
  const MAX_NOTE_LENGTH = 200;
25
- const UPDATE_NOTE = 'Actualización: la paciente contestó';
25
+ // A redraft also follows a call note or the agent's own update, so the note does not say the patient answered.
26
+ const UPDATE_NOTE = 'Actualización del caso';
26
27
  const GRAVE_RETRY_MS = 5 * 60 * 1000;
27
28
  const GRAVE_REASONS = { unobtainable: 'no lo puede dar', unanswered: 'no contestó', not_said: 'no lo ha dicho' };
28
29
  const QUIET_REMINDER_TEXT = '¿Pudiste ver lo que te pregunté? Cuando puedas, respóndeme por aquí.';
@@ -63,8 +64,8 @@ function teamGraveOf(review, clock, grave, now) {
63
64
  .filter((ask) => timeOf(ask.draftAt) >= timeOf(firstSeenAt) && (ask.flags ?? []).map(normalizedKeyOf).includes(flag))
64
65
  .map((ask) => timeOf(ask.sentAt)),
65
66
  );
66
- const dueAt = (entry) => (entry.reason === 'unobtainable' ? -Infinity : askedAt(entry) + waitMs);
67
- // A datum the bot never asked about calls no one: it reaches the doctor in the note.
67
+ const dueAt = (entry) => (entry.reason === 'unobtainable' ? Infinity : askedAt(entry) + waitMs);
68
+ // A datum the bot never asked about, or one the patient cannot give, calls no one: it reaches the doctor in the note.
68
69
  const asked = grave.filter((entry) => dueAt(entry) < Infinity);
69
70
  if (asked.some((entry) => dueAt(entry) <= now.getTime())) return { due: asked, waiting: [] };
70
71
  return { due: [], waiting: asked };
@@ -112,7 +113,7 @@ function outcomeOf(review, clock, now) {
112
113
  const teamFirst = !update && !present.length && grave.length + waiting.length > 0;
113
114
  const held = teamFirst && (waiting.length > 0 || grave.some(({ flag }) => now.getTime() < graveDueAt(review, clock, flag) + wait * 60000));
114
115
  if (graveFlags.length || present.length) {
115
- const lacking = graveFlags.length && `Falta dato grave: ${graveFlags.map(({ flag }) => flag).join(', ')}${teamFirst && !held ? ' (no se consiguió)' : ''}`;
116
+ const lacking = graveFlags.length && `Falta dato grave: ${graveFlags.map(({ flag, reason }) => (reason === 'unobtainable' ? `${flag} (${GRAVE_REASONS.unobtainable})` : flag)).join(', ')}${teamFirst && !held ? ' (no se consiguió)' : ''}`;
116
117
  // A grave datum still inside its wait goes in the note too, so the doctor knows it is still open.
117
118
  const pending = pendingFlagsOf(review, clock.since).flags.map(({ flag }) => flag).filter((flag) => !graveFlags.some((entry) => entry.flag === flag));
118
119
  const note = [present.length && `Bandera grave presente: ${present.join(', ')}`, lacking, pending.length && `Pendiente: ${pending.join(', ')}`];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "6.5.22",
3
+ "version": "6.5.23",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",