@peopl-health/nexus 5.71.16 → 5.71.18
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.
|
@@ -4,7 +4,7 @@ const { safeParse, isPlainObject } = require('../../utils/jsonUtils');
|
|
|
4
4
|
const { logger } = require('../../utils/logger');
|
|
5
5
|
|
|
6
6
|
const ACTIVE_DAYS = 35;
|
|
7
|
-
const HEADER = 'Quimioterapia (registro de la unidad de quimioterapia; úsalo para contextualizar y priorizar síntomas, nunca para bajar la urgencia; no comuniques dosis ni ajustes de tratamiento; si el paciente dice
|
|
7
|
+
const HEADER = 'Quimioterapia (registro de la unidad de quimioterapia; úsalo para contextualizar y priorizar síntomas, nunca para bajar la urgencia; no comuniques dosis ni ajustes de tratamiento; si el paciente dice algo distinto, créele: si es otra fecha de cita, que el paciente la confirme con el área de tratamiento, sin avisar al equipo; si es un dato clínico, o una sesión suspendida o cambiada por un motivo clínico, avisa al equipo)';
|
|
8
8
|
const ISO_DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
9
9
|
const NO_ALLERGY = /^(ninguna?s?|no|negadas?|desconocidas?|(niega|no refiere|sin|no tiene|no presenta) alergias?( conocidas| a medicamentos)?)$/;
|
|
10
10
|
const NEGATION = /\b(sin|niega|no|ninguna?)\b/;
|
|
@@ -42,6 +42,7 @@ function normalize(raw) {
|
|
|
42
42
|
ajusteProximoCiclo: dated(raw.ajusteProximoCiclo, ['valor']),
|
|
43
43
|
esquemaPrevio: isPlainObject(raw.esquemaPrevio) && isDay(raw.esquemaPrevio.hasta) ? { farmacos: texts(raw.esquemaPrevio.farmacos), hasta: raw.esquemaPrevio.hasta } : null,
|
|
44
44
|
visitaSoporte: dated(raw.visitaSoporte, ['farmacos']),
|
|
45
|
+
proximaVisitaSoporte: dated(raw.proximaVisitaSoporte, ['detalle']),
|
|
45
46
|
antecedentes: dated(raw.antecedentes, []),
|
|
46
47
|
};
|
|
47
48
|
}
|
|
@@ -64,6 +65,12 @@ function chemoStatus(context, today) {
|
|
|
64
65
|
return { active: days <= ACTIVE_DAYS || Boolean(scheduled), days };
|
|
65
66
|
}
|
|
66
67
|
|
|
68
|
+
// the unit confirms an appointment the day before: unconfirmed is the normal state of a later one
|
|
69
|
+
function confirmation(appointment) {
|
|
70
|
+
if (typeof appointment.confirmada !== 'boolean') return '';
|
|
71
|
+
return appointment.confirmada ? 'confirmada por la unidad' : 'la unidad aún no la confirma';
|
|
72
|
+
}
|
|
73
|
+
|
|
67
74
|
function regimenText(context) {
|
|
68
75
|
return context.esquema.map((e) => [e.farmaco, e.via, e.tiempo].map(text).filter(Boolean).join(' ')).join('; ');
|
|
69
76
|
}
|
|
@@ -99,10 +106,15 @@ function chemoLines(context, today) {
|
|
|
99
106
|
? `Inicio de este esquema: antes del ${dmy(context.inicioEsquema.fecha)} (inicio del registro)`
|
|
100
107
|
: `Inicio de este esquema: ${dmy(context.inicioEsquema.fecha)}`);
|
|
101
108
|
}
|
|
102
|
-
if (context.proximaSesion) {
|
|
109
|
+
if (context.proximaSesion && context.proximaSesion.fecha >= today) {
|
|
103
110
|
lines.push(context.proximaSesion.tipo === 'agendada'
|
|
104
|
-
? `Próxima sesión: ${dmy(context.proximaSesion.fecha)} (agendada)`
|
|
105
|
-
: `Próxima sesión: ${dmy(context.proximaSesion.fecha)} (estimada; no la confirmes como cita)`);
|
|
111
|
+
? `Próxima sesión de quimioterapia: ${dmy(context.proximaSesion.fecha)} (${['agendada', confirmation(context.proximaSesion)].filter(Boolean).join('; ')})`
|
|
112
|
+
: `Próxima sesión de quimioterapia: ${dmy(context.proximaSesion.fecha)} (estimada; no la confirmes como cita)`);
|
|
113
|
+
}
|
|
114
|
+
const support = context.proximaVisitaSoporte;
|
|
115
|
+
if (support && support.fecha >= today) {
|
|
116
|
+
const care = texts(support.detalle);
|
|
117
|
+
lines.push(`Próxima visita a la unidad sin quimioterapia: ${dmy(support.fecha)} (${[care.join(', '), confirmation(support)].filter(Boolean).join('; ')})`);
|
|
106
118
|
}
|
|
107
119
|
if (context.noAplicadas.length) lines.push(`Sesiones no aplicadas en los últimos 90 días: ${context.noAplicadas.map(dmy).join(', ')}`);
|
|
108
120
|
if (text(context.reaccionInfusion?.texto)) lines.push(`Reacción durante la infusión registrada: ${text(context.reaccionInfusion.texto)} (${dmy(context.reaccionInfusion.fecha)})`);
|
|
@@ -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
|
};
|