@peopl-health/nexus 5.48.0-dev.7343 → 5.48.0-dev.7346

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.
@@ -68,11 +68,6 @@ function validateGateInheritance(elements, gate) {
68
68
  path: 'elements[].escalation.routes',
69
69
  problem: 'gate equipo_tratante_hoy ⇒ un elemento heredado debe incluir equipo_medico_tratante',
70
70
  });
71
- } else if (!sameDayTeamElements.some((element) => /\bhoy\b/i.test(element.recommendation.patient.mainRecommendation))) {
72
- issues.push({
73
- path: 'elements[].recommendation.patient.main_recommendation',
74
- problem: 'gate equipo_tratante_hoy ⇒ la recomendación heredada debe indicar explícitamente contactar al equipo hoy',
75
- });
76
71
  }
77
72
  }
78
73
  return issues;
@@ -97,17 +92,13 @@ function validate(elements, options = {}) {
97
92
  }
98
93
  }
99
94
  const count = patient.mainRecommendation ? sentenceCount(patient.mainRecommendation) : 0;
100
- const inheritsSameDayTeamGate = inheritsUrgentGate(element, options.gate)
101
- && options.gate.escalationRoute === 'equipo_tratante_hoy'
102
- && element.escalation.routes.includes('equipo_medico_tratante');
103
- const minSentences = isTriagePlan ? (inheritsSameDayTeamGate ? 4 : 3) : 2;
95
+ const minSentences = isTriagePlan ? 3 : 2;
104
96
  if (patient.mainRecommendation && !(count >= minSentences && count <= 4)) {
105
- const expected = minSentences === 4 ? 'exactamente 4 oraciones' : `${minSentences}-4 oraciones`;
106
97
  issues.push({
107
98
  path: `${path}.recommendation.patient.main_recommendation`,
108
99
  code: SENTENCE_COUNT_CODE,
109
100
  warning: true,
110
- problem: `${expected}; detectadas: ${count}`,
101
+ problem: `${minSentences}-4 oraciones; detectadas: ${count}`,
111
102
  });
112
103
  }
113
104
  if (element.escalation.urgentUnder24h && !patient.whenToEscalate) {
@@ -15,9 +15,7 @@ const toMap = (arr, keyFn, valFn) => arr.reduce((m, item) => {
15
15
  return key ? { ...m, [key]: valFn(item) } : m;
16
16
  }, {});
17
17
 
18
- const PENDING_TASK_FILTERS = ['pending-tasks', 'pending-cases', 'pending-requests'];
19
-
20
- const buildThreadFilter = (filter, { triageIds, taskCodes }) => {
18
+ const buildThreadFilter = (filter, { triageIds, pendingTaskCodes }) => {
21
19
  const base = { lastMessageAt: { $ne: null } };
22
20
  switch (filter) {
23
21
  case 'unread':
@@ -31,11 +29,7 @@ const buildThreadFilter = (filter, { triageIds, taskCodes }) => {
31
29
  case 'triage-last-month':
32
30
  return { ...base, code: { $in: triageIds } };
33
31
  case 'pending-tasks':
34
- return { ...base, code: { $in: taskCodes.all } };
35
- case 'pending-cases':
36
- return { ...base, code: { $in: taskCodes.cases } };
37
- case 'pending-requests':
38
- return { ...base, code: { $in: taskCodes.requests } };
32
+ return { ...base, code: { $in: pendingTaskCodes } };
39
33
  case 'all':
40
34
  default:
41
35
  return base;
@@ -49,20 +43,15 @@ const fetchConversationData = async (filter, skip, limit) => {
49
43
  triageIds = (triageRecords || []).map(r => r.whatsapp_id).filter(Boolean);
50
44
  }
51
45
 
52
- const openTaskMap = PENDING_TASK_FILTERS.includes(filter)
46
+ const openTaskMap = filter === 'pending-tasks'
53
47
  ? await getOpenTaskSummary()
54
48
  : await getOpenTaskSummary().catch((error) => {
55
49
  logger.warn('[fetchConversationData] Open task summary unavailable', { error: error.message });
56
50
  return null;
57
51
  });
58
- const taskEntries = [...(openTaskMap?.entries() || [])];
59
- const taskCodes = {
60
- all: taskEntries.map(([code]) => code),
61
- cases: taskEntries.filter(([, entry]) => entry.cases > 0).map(([code]) => code),
62
- requests: taskEntries.filter(([, entry]) => entry.requests > 0).map(([code]) => code),
63
- };
52
+ const pendingTaskCodes = [...(openTaskMap?.keys() || [])];
64
53
 
65
- const threadFilter = buildThreadFilter(filter, { triageIds, taskCodes });
54
+ const threadFilter = buildThreadFilter(filter, { triageIds, pendingTaskCodes });
66
55
 
67
56
  logger.info('[fetchConversationData] Applying filter', { filter });
68
57
  const startTime = Date.now();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "5.48.0-dev.7343",
3
+ "version": "5.48.0-dev.7346",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",