@peopl-health/nexus 5.48.0-dev.7344 → 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
|
|
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: `${
|
|
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
|
|
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:
|
|
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 =
|
|
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
|
|
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,
|
|
54
|
+
const threadFilter = buildThreadFilter(filter, { triageIds, pendingTaskCodes });
|
|
66
55
|
|
|
67
56
|
logger.info('[fetchConversationData] Applying filter', { filter });
|
|
68
57
|
const startTime = Date.now();
|
|
@@ -159,7 +159,6 @@ async function getPatientTasks(code) {
|
|
|
159
159
|
cases: cases.tasks,
|
|
160
160
|
openCount: requests.openCount + cases.openCount,
|
|
161
161
|
attentionCount: requests.attentionCount + cases.attentionCount,
|
|
162
|
-
attention: { cases: cases.attentionCount, requests: requests.attentionCount },
|
|
163
162
|
options: { requestStatus: REQUEST_STATUSES, caseStatus: CASE_STATUSES, operationsStatus: OPERATIONS_STATUSES },
|
|
164
163
|
};
|
|
165
164
|
}
|