@peopl-health/nexus 5.72.18 → 5.72.19
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.
|
@@ -52,11 +52,13 @@ function drugOf(symptom, item) {
|
|
|
52
52
|
|
|
53
53
|
const proposedDrugs = ({ proposal }) => (proposal?.items ?? []).map((item) => drugOf(proposal.symptom, item)).filter(Boolean);
|
|
54
54
|
|
|
55
|
-
function proposalLine({ proposal,
|
|
55
|
+
function proposalLine({ proposal, conduct, sections }) {
|
|
56
56
|
const drugs = proposedDrugs({ proposal });
|
|
57
57
|
if (!drugs.length) {
|
|
58
|
-
const
|
|
59
|
-
return
|
|
58
|
+
const modifiers = (Array.isArray(sections?.treatmentModifiers) ? sections.treatmentModifiers : []).map((key) => inlineOf(key)?.replace(/_/g, ' ')).filter(Boolean);
|
|
59
|
+
return modifiers.length
|
|
60
|
+
? `→ Sin propuesta de tratamiento: condición que cambia el algoritmo (${modifiers.join(', ')}).`
|
|
61
|
+
: '→ Sin propuesta de tratamiento.';
|
|
60
62
|
}
|
|
61
63
|
const declared = [...(proposal.conditions ?? []), ...(proposal.ruledOut ?? []).map((key) => `descartado ${key}`)]
|
|
62
64
|
.map((key) => inlineOf(key)?.replace(/_/g, ' ')).filter(Boolean);
|
|
@@ -70,7 +72,7 @@ function proposalLine({ proposal, withheldReason, conduct, sections }) {
|
|
|
70
72
|
const armedConduct = urgent.length ? inlineOf(conduct) : null;
|
|
71
73
|
return [
|
|
72
74
|
`${lead}: ${sentence(drugs.join('; '))}`,
|
|
73
|
-
armedConduct ? sentence(armedConduct) :
|
|
75
|
+
armedConduct ? sentence(armedConduct) : gate.length && 'Si algo de lo pendiente es positivo: valoración presencial.',
|
|
74
76
|
declared.length && `Verificar: ${sentence(declared.join(', '))}`,
|
|
75
77
|
].filter(Boolean).join(' ');
|
|
76
78
|
}
|
|
@@ -79,14 +81,11 @@ function symptomParagraph(entry, fallbackSymptom) {
|
|
|
79
81
|
const sections = entry.sections ?? {};
|
|
80
82
|
const grade = [1, 2, 3].includes(sections.grade) ? `G${sections.grade}` : 'grado no establecido';
|
|
81
83
|
const { present, absent, unassessed } = flagsByStatus(sections);
|
|
82
|
-
const isUndocumented = !present.length && !absent.length && !unassessed.length;
|
|
83
84
|
const summary = inlineOf(sections.characterizationSummary);
|
|
84
85
|
return [
|
|
85
86
|
`${inlineOf(sections.symptom) || fallbackSymptom || 'Síntoma no especificado'} (${grade}):`,
|
|
86
87
|
summary && sentence(summary),
|
|
87
88
|
present.length && `${present.length > 1 ? 'Banderas rojas presentes' : 'Bandera roja presente'}: ${sentence(present.join(', '))}`,
|
|
88
|
-
unassessed.length && `Falta confirmar: ${sentence(unassessed.join(', '))}`,
|
|
89
|
-
isUndocumented && 'Banderas rojas no documentadas.',
|
|
90
89
|
!present.length && !unassessed.length && absent.length && 'Sin banderas rojas.',
|
|
91
90
|
proposalLine(entry),
|
|
92
91
|
].filter(Boolean).join(' ');
|
|
@@ -23,31 +23,24 @@ const TECHNICAL_TOKEN = /\b(urgentIfPositive|blocksDrug|null)\b|\b[a-z]+_\w+|\\n
|
|
|
23
23
|
|
|
24
24
|
const trimmed = (value) => String(value ?? '').trim();
|
|
25
25
|
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const reasons = [];
|
|
30
|
-
if (present.length) reasons.push(present.length === 1 ? 'hay una bandera roja presente' : 'hay banderas rojas presentes');
|
|
31
|
-
if (modifiers.length) reasons.push(`condición que cambia el algoritmo (${modifiers.join(', ')})`);
|
|
32
|
-
return reasons.join('; ') || null;
|
|
26
|
+
function withholds(sections) {
|
|
27
|
+
const modifiers = (Array.isArray(sections?.treatmentModifiers) ? sections.treatmentModifiers : []).map(trimmed).filter(Boolean);
|
|
28
|
+
return flagsByStatus(sections).present.length > 0 || modifiers.length > 0;
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
function settleProposal(parsed) {
|
|
36
|
-
const withheld = withholdReason(parsed);
|
|
37
32
|
const raw = parsed?.treatmentProposal;
|
|
38
33
|
const items = Array.isArray(raw?.items) ? raw.items : [];
|
|
39
34
|
const stated = trimmed(parsed?.proposalWithheldReason);
|
|
40
35
|
const conduct = stated && !drugsNamedIn(stated).length ? stated : null;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (withheld) return { proposal: null, withheldReason: [withheld, callFirst].filter(Boolean).join('; '), conduct, strippedItems: items.length };
|
|
44
|
-
if (!items.length) return { proposal: null, withheldReason: callFirst, conduct, strippedItems: 0 };
|
|
36
|
+
if (withholds(parsed)) return { proposal: null, conduct, strippedItems: items.length };
|
|
37
|
+
if (!items.length) return { proposal: null, conduct, strippedItems: 0 };
|
|
45
38
|
|
|
46
39
|
const conditions = Array.isArray(raw.conditions) ? raw.conditions : [];
|
|
47
40
|
const ruledOut = Array.isArray(raw.ruledOut) ? raw.ruledOut : [];
|
|
48
41
|
const proposal = { symptom: raw.symptom, items, conditions, ruledOut };
|
|
49
42
|
const { valid, issues } = validateProposal(proposal, { conditions, ruledOut });
|
|
50
|
-
return valid ? { proposal,
|
|
43
|
+
return valid ? { proposal, conduct, strippedItems: 0 } : { invalid: issues };
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
const textList = (value) => (Array.isArray(value) ? value.map(trimmed).filter(Boolean) : []);
|
|
@@ -178,7 +171,7 @@ async function generateEscalationDraft({
|
|
|
178
171
|
|
|
179
172
|
const draft = {
|
|
180
173
|
shared: parsed,
|
|
181
|
-
symptoms: settled.map(({ block, proposal,
|
|
174
|
+
symptoms: settled.map(({ block, proposal, conduct }) => ({ sections: block, proposal, conduct })),
|
|
182
175
|
};
|
|
183
176
|
const doctorText = composeDoctorBody({ ...draft, alarm: alarms[alarms.length - 1] ?? null });
|
|
184
177
|
|