@peopl-health/nexus 5.71.15 → 5.71.17

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.
@@ -94,6 +94,19 @@ const DIMENSION_ES = {
94
94
  amount: 'cantidad',
95
95
  };
96
96
 
97
+ const ADHERENCE_ES = {
98
+ full: 'la siguió',
99
+ partial: 'la siguió en parte',
100
+ none: 'no la siguió',
101
+ };
102
+
103
+ const CHANGE_ES = {
104
+ improved: 'mejoró',
105
+ unchanged: 'sigue igual',
106
+ worsened: 'empeoró',
107
+ mixed: 'mixto',
108
+ };
109
+
97
110
  const GRADE_BASIS_ES = {
98
111
  composite: 'la tabla compuesta del PRO-CTCAE resolvió el grado con las respuestas de arriba',
99
112
  presence: 'sólo se preguntó si el síntoma estaba presente; el grado no sale de una escala de severidad',
@@ -272,9 +285,9 @@ function buildAdherenceBlock(priorResolutions = []) {
272
285
  .map((row) => {
273
286
  const symptom = row.symptoms_patient_facing || row.element_name_short || 'sin síntoma registrado';
274
287
  const recommendation = row.patient_main_recommendation || 'sin texto registrado';
275
- const adherence = row.adherence_level || 'sin respuesta';
276
- const change = row.symptom_change || 'sin respuesta';
277
- return `- Síntoma(s): ${symptom} · Recomendación previa: ${recommendation} · Adherencia reportada: ${adherence} · Cambio del síntoma: ${change}`;
288
+ const adherence = ADHERENCE_ES[row.adherence_level] || row.adherence_level || 'sin respuesta';
289
+ const change = CHANGE_ES[row.symptom_change] || row.symptom_change || 'sin respuesta';
290
+ return `- Síntoma(s): ${symptom} · Recomendación previa: ${recommendation} · Adherencia reportada: ${adherence} · Cambio que reportó después de esa recomendación: ${change}`;
278
291
  })
279
292
  .join('\n');
280
293
  }
@@ -31,7 +31,7 @@ function trendReadings(catalog, gradeByKey, priorResolutions, openCases) {
31
31
  readings.push({
32
32
  keys: String(row?.ctcae_terms ?? '').split(',').flatMap((term) => aliasClosure(catalog, term)),
33
33
  trend: CHANGE_TREND[change],
34
- reading: `${change} (cambio reportado de la tarjeta previa)`,
34
+ reading: `${change} (cambio reportado después de la tarjeta previa)`,
35
35
  });
36
36
  }
37
37
  for (const managed of openCases) {
@@ -50,16 +50,21 @@ function nextLight(current, { service, color, source }) {
50
50
 
51
51
  const WEEKLY_COLLECTIVE_LIMIT = Object.freeze({ psychology: 1 });
52
52
 
53
+ // A patient in individual psycho-oncology therapy may join a group only when her psycho-oncology light is green, set by
54
+ // the AI or a specialist: the risk level decides, and no colour yet does not count as green.
53
55
  function collectiveOffer({
54
56
  service, color = 'unknown', isInvitationPaused = false, hasInvitationThisWeek = false,
55
- collectivesThisWeek = 0, hasCapacity = false,
57
+ collectivesThisWeek = 0, hasCapacity = false, isInIndividualTherapy = false,
58
+ psychologyColor = service === 'psychology' ? color : 'unknown',
56
59
  }) {
57
60
  assertLight(service, color);
61
+ assertLight('psychology', psychologyColor);
58
62
  const refuse = (reason) => ({ allowed: false, reason });
59
63
  if (color === 'red') return refuse('light_red');
60
64
  if (service === 'psychology' && color === 'orange') return refuse('light_orange');
61
65
  if (service === 'psychology' && color === 'unknown') return refuse('light_unconfirmed');
62
66
  if (isInvitationPaused) return refuse('invitation_paused');
67
+ if (isInIndividualTherapy && psychologyColor !== 'green') return refuse('individual_therapy');
63
68
  if (hasInvitationThisWeek) return refuse('already_invited_this_week');
64
69
  const limit = WEEKLY_COLLECTIVE_LIMIT[service];
65
70
  if (limit != null && collectivesThisWeek >= limit) return refuse('weekly_limit');
package/lib/index.d.ts CHANGED
@@ -942,7 +942,7 @@ declare module '@peopl-health/nexus' {
942
942
  export type SupportLightColor = 'green' | 'yellow' | 'orange' | 'red' | 'unknown';
943
943
  export type SupportLightSource = 'ai' | 'human';
944
944
  export type SupportLightOutcome = 'applied' | 'pending' | 'withdrawn' | 'unchanged';
945
- export type CollectiveRefusal = 'light_red' | 'light_orange' | 'light_unconfirmed' | 'invitation_paused'
945
+ export type CollectiveRefusal = 'light_red' | 'light_orange' | 'light_unconfirmed' | 'invitation_paused' | 'individual_therapy'
946
946
  | 'already_invited_this_week' | 'weekly_limit' | 'no_capacity';
947
947
 
948
948
  export interface SupportLightEvidence {
@@ -1044,6 +1044,8 @@ declare module '@peopl-health/nexus' {
1044
1044
  hasInvitationThisWeek?: boolean;
1045
1045
  collectivesThisWeek?: number;
1046
1046
  hasCapacity?: boolean;
1047
+ isInIndividualTherapy?: boolean;
1048
+ psychologyColor?: SupportLightColor;
1047
1049
  }): { allowed: boolean; reason: CollectiveRefusal | null };
1048
1050
  supportWeek(date: Date | string): string | null;
1049
1051
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.71.15",
3
+ "version": "5.71.17",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",