@peopl-health/nexus 6.0.0-dev.16339 → 6.0.0-dev.16502
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.
|
@@ -14,6 +14,9 @@ const NEGATION = /\b(sin|niega|no|ninguna?)\b/;
|
|
|
14
14
|
|
|
15
15
|
const isDay = (value) => typeof value === 'string' && ISO_DAY.test(value) && !Number.isNaN(Date.parse(`${value}T00:00:00Z`));
|
|
16
16
|
const dmy = (iso) => `${iso.slice(8, 10)}/${iso.slice(5, 7)}/${iso.slice(0, 4)}`;
|
|
17
|
+
// a weekday with the date: the model miscounts the day of the week from a bare date ("el viernes" for a Saturday)
|
|
18
|
+
const WEEKDAYS = ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'];
|
|
19
|
+
const weekdayDmy = (iso) => `${WEEKDAYS[new Date(`${iso}T00:00:00Z`).getUTCDay()]} ${dmy(iso)}`;
|
|
17
20
|
const addDays = (iso, days) => new Date(Date.parse(`${iso}T00:00:00Z`) + days * 86400000).toISOString().slice(0, 10);
|
|
18
21
|
const fold = (value) => foldAccents(String(value || '')).toLowerCase().trim();
|
|
19
22
|
const text = (value) => (typeof value === 'string' ? value.trim() : '');
|
|
@@ -132,13 +135,13 @@ function chemoLines(context, today) {
|
|
|
132
135
|
}
|
|
133
136
|
if (context.proximaSesion && context.proximaSesion.fecha >= today) {
|
|
134
137
|
lines.push(context.proximaSesion.tipo === 'agendada'
|
|
135
|
-
? `Próxima sesión de quimioterapia: ${
|
|
136
|
-
: `Próxima sesión de quimioterapia: ${
|
|
138
|
+
? `Próxima sesión de quimioterapia: ${weekdayDmy(context.proximaSesion.fecha)}${CLOCK.test(context.proximaSesion.hora) ? ` a las ${context.proximaSesion.hora}` : ''} (${['agendada', confirmation(context.proximaSesion)].filter(Boolean).join('; ')})`
|
|
139
|
+
: `Próxima sesión de quimioterapia: ${weekdayDmy(context.proximaSesion.fecha)} (estimada; no la confirmes como cita)`);
|
|
137
140
|
}
|
|
138
141
|
const support = context.proximaVisitaSoporte;
|
|
139
142
|
if (support && support.fecha >= today) {
|
|
140
143
|
const care = texts(support.detalle);
|
|
141
|
-
lines.push(`Próxima visita a la unidad sin quimioterapia: ${
|
|
144
|
+
lines.push(`Próxima visita a la unidad sin quimioterapia: ${weekdayDmy(support.fecha)} (${[care.join(', '), confirmation(support)].filter(Boolean).join('; ')})`);
|
|
142
145
|
}
|
|
143
146
|
if (context.noAplicadas.length) lines.push(`Sesiones no aplicadas en los últimos 90 días: ${context.noAplicadas.map(dmy).join(', ')}`);
|
|
144
147
|
if (text(context.reaccionInfusion?.texto)) lines.push(`Reacción durante la infusión registrada: ${text(context.reaccionInfusion.texto)} (${dmy(context.reaccionInfusion.fecha)})`);
|
|
@@ -880,6 +880,13 @@ function issuePaths(issues) {
|
|
|
880
880
|
return [...new Set(issues.map((issue) => String(issue.path || '').replace(/\[[^\]]*\]/g, '[]')).filter(Boolean))];
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
+
// Zod issue paths in dotted form with indices collapsed; keys are the DTO's camelCase, not the model's snake_case.
|
|
884
|
+
function dtoIssues(err) {
|
|
885
|
+
const issues = Array.isArray(err?.issues) ? err.issues : [];
|
|
886
|
+
const paths = issues.map((issue) => ({ path: arr(issue.path).map((key) => (typeof key === 'number' ? '[]' : `.${String(key)}`)).join('').replace(/^\./, '') }));
|
|
887
|
+
return paths.some((issue) => issue.path) ? paths : null;
|
|
888
|
+
}
|
|
889
|
+
|
|
883
890
|
function truncateToCardLimit(elements, repairs) {
|
|
884
891
|
const excess = elements.length - MAX_TRIAGE_CARDS;
|
|
885
892
|
if (excess <= 0) return 0;
|
|
@@ -992,7 +999,7 @@ async function runPlan({ provider, presetId, casoBase, gate, boundary = null, ra
|
|
|
992
999
|
plan = buildPlan(takeaways, elements);
|
|
993
1000
|
} catch (err) {
|
|
994
1001
|
lastIssues = [{ path: 'plan', problem: err?.message || 'DTO inválido' }];
|
|
995
|
-
if (attempt < PLAN_MAX_ATTEMPTS) { retried(attempt, 'plan_dto_invalid'); continue; }
|
|
1002
|
+
if (attempt < PLAN_MAX_ATTEMPTS) { retried(attempt, 'plan_dto_invalid', dtoIssues(err)); continue; }
|
|
996
1003
|
return outcome({ attempts: attempt, repairs, failure: { status: 'failed', stage: 'validate', reason: 'plan_invalid', hardRejectIssues: lastIssues } });
|
|
997
1004
|
}
|
|
998
1005
|
return outcome({
|
|
@@ -6,7 +6,7 @@ const RESPONSE_MINUTES = { stat: 15, asap: 60, urgent: 240, routine: 720 };
|
|
|
6
6
|
const MAX_RESPONSE_MINUTES = 7 * 24 * 60;
|
|
7
7
|
const BUSINESS_HOURS_LEVELS = ['urgent', 'routine'];
|
|
8
8
|
const TEAM_TIMEZONE = 'America/Mexico_City';
|
|
9
|
-
const DEFAULT_TEAM_HOURS = { days: [1, 2, 3, 4, 5], startHour:
|
|
9
|
+
const DEFAULT_TEAM_HOURS = { days: [1, 2, 3, 4, 5, 6, 7], startHour: 9, endHour: 22 };
|
|
10
10
|
const UNTAKEN_STAGES = { stat: ['deadline'], asap: ['early', 'half', 'deadline'], urgent: ['half', 'deadline'] };
|
|
11
11
|
const DEFAULT_PATIENT_TIMER_MINUTES = { stat: 15, asap: 20 };
|
|
12
12
|
const PATIENT_TIMER_KEYS = { stat: 'ESCALATION_PATIENT_TIMER_MINUTES', asap: 'ESCALATION_ASAP_PATIENT_TIMER_MINUTES' };
|