@peopl-health/nexus 5.47.1 → 5.48.0-dev.7343
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,6 +68,11 @@ 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
|
+
});
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
return issues;
|
|
@@ -92,13 +97,17 @@ function validate(elements, options = {}) {
|
|
|
92
97
|
}
|
|
93
98
|
}
|
|
94
99
|
const count = patient.mainRecommendation ? sentenceCount(patient.mainRecommendation) : 0;
|
|
95
|
-
const
|
|
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;
|
|
96
104
|
if (patient.mainRecommendation && !(count >= minSentences && count <= 4)) {
|
|
105
|
+
const expected = minSentences === 4 ? 'exactamente 4 oraciones' : `${minSentences}-4 oraciones`;
|
|
97
106
|
issues.push({
|
|
98
107
|
path: `${path}.recommendation.patient.main_recommendation`,
|
|
99
108
|
code: SENTENCE_COUNT_CODE,
|
|
100
109
|
warning: true,
|
|
101
|
-
problem: `${
|
|
110
|
+
problem: `${expected}; detectadas: ${count}`,
|
|
102
111
|
});
|
|
103
112
|
}
|
|
104
113
|
if (element.escalation.urgentUnder24h && !patient.whenToEscalate) {
|
|
@@ -15,7 +15,9 @@ const toMap = (arr, keyFn, valFn) => arr.reduce((m, item) => {
|
|
|
15
15
|
return key ? { ...m, [key]: valFn(item) } : m;
|
|
16
16
|
}, {});
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const PENDING_TASK_FILTERS = ['pending-tasks', 'pending-cases', 'pending-requests'];
|
|
19
|
+
|
|
20
|
+
const buildThreadFilter = (filter, { triageIds, taskCodes }) => {
|
|
19
21
|
const base = { lastMessageAt: { $ne: null } };
|
|
20
22
|
switch (filter) {
|
|
21
23
|
case 'unread':
|
|
@@ -29,7 +31,11 @@ const buildThreadFilter = (filter, { triageIds, pendingTaskCodes }) => {
|
|
|
29
31
|
case 'triage-last-month':
|
|
30
32
|
return { ...base, code: { $in: triageIds } };
|
|
31
33
|
case 'pending-tasks':
|
|
32
|
-
return { ...base, code: { $in:
|
|
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 } };
|
|
33
39
|
case 'all':
|
|
34
40
|
default:
|
|
35
41
|
return base;
|
|
@@ -43,15 +49,20 @@ const fetchConversationData = async (filter, skip, limit) => {
|
|
|
43
49
|
triageIds = (triageRecords || []).map(r => r.whatsapp_id).filter(Boolean);
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
const openTaskMap = filter
|
|
52
|
+
const openTaskMap = PENDING_TASK_FILTERS.includes(filter)
|
|
47
53
|
? await getOpenTaskSummary()
|
|
48
54
|
: await getOpenTaskSummary().catch((error) => {
|
|
49
55
|
logger.warn('[fetchConversationData] Open task summary unavailable', { error: error.message });
|
|
50
56
|
return null;
|
|
51
57
|
});
|
|
52
|
-
const
|
|
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
|
+
};
|
|
53
64
|
|
|
54
|
-
const threadFilter = buildThreadFilter(filter, { triageIds,
|
|
65
|
+
const threadFilter = buildThreadFilter(filter, { triageIds, taskCodes });
|
|
55
66
|
|
|
56
67
|
logger.info('[fetchConversationData] Applying filter', { filter });
|
|
57
68
|
const startTime = Date.now();
|