@peopl-health/nexus 6.6.0-dev.20843 → 6.6.0-dev.20869

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.
@@ -13,15 +13,18 @@ const { URGENCY_RANK } = require('../../models/escalationReviewModel');
13
13
  const { objectArg, safeParse, isPlainObject } = require('../../utils/jsonUtils');
14
14
  const { logger } = require('../../utils/logger');
15
15
 
16
- const FEVER_RUBRIC_STAT = 'neutropenia febril CON inestabilidad, fiebre ≥38.0 °C en la ventana de quimioterapia descrita en la regla de fiebre,';
16
+ const FEVER_RUBRIC_STAT = 'fiebre en la ventana de quimioterapia con una bandera roja confirmada (regla de fiebre),';
17
17
 
18
- const FEVER_RUBRIC_ASAP = 'riesgo de infección sin fiebre ≥38.0 °C en esa ventana (p. ej. 37.5–37.9 °C con el paciente bien),';
18
+ const FEVER_RUBRIC_ASAP = 'fiebre ≥38.0 °C, o temperatura baja (menos de 36.0 °C) confirmada al volver a medir con malestar o escalofríos, o ≤35.0 °C confirmado, en la ventana de quimioterapia sin bandera roja (regla de fiebre),';
19
19
 
20
- const FEVER_RULE = 'Fever that is `stat`: ≥38.0 °C within 8 weeks of cytotoxic chemotherapy (or a hematologic cancer, transplant, known neutropenia), any fever within 4 weeks of CAR-T or during bispecific step-up dosing, or sepsis signs with or without fever — say it calmly: "ve a urgencias ahora y di que estás en tratamiento oncológico" (CAR-T / bispecific: call the treating center first). If you don\'t know the treatment or the last dose date, ask in the same message; unknown date on chemo counts as within the window. Fever 37.5–37.9 °C in that window with the patient well is `asap`: remeasure in 30–60 min. ';
20
+ const FEVER_ASK = 'If they ask whether to go to urgencias or what to watch';
21
+ const FEVER_ASK_TIMER = 'In a fever `asap` (`febrile_neutropenia`) leave that line out: its patient timer gives that instruction. ' + FEVER_ASK;
22
+
23
+ const FEVER_RULE = 'Fever within 6 weeks (42 days) of cytotoxic chemotherapy (or with a hematologic cancer, transplant, known neutropenia) — ≥38.0 °C, feeling feverish or chills with no thermometer, or malaise while on an antipyretic or steroid — is `asap` with `category: febrile_neutropenia`. A low reading means below 36.0 °C only; 36.0 °C is normal. A low reading is not fever and is never called fever, neither to the patient nor in `details`: before escalating, ask for a re-measure and how they feel right now. Still below 36.0 °C with current malaise, chills or shivering, or a confirmed ≤35.0 °C, is `asap`; still below 36.0 °C with no other symptom is `urgent`. Chills or rigors, even strong, are `asap`. It is `stat` only with a very obvious, confirmed red flag (clear shortness of breath at rest, clear confusion, fainting or unable to stand with the fever, mottled or cold skin, bleeding that does not stop), or any fever within 4 weeks of CAR-T or during bispecific step-up dosing — say it calmly: "ve a urgencias ahora y di que estás en tratamiento oncológico" (CAR-T / bispecific: call the treating center first). If you don\'t know the treatment or the last dose date, ask in the same message. 37.5–37.9 °C in that window is `urgent`: remeasure in 30–60 min. ';
21
24
 
22
25
  const definition = {
23
26
  'name': 'reportMedicalEscalation',
24
- 'description': '**Does:** Escalates a MEDICAL situation to the oncology care team at a chosen urgency, with an explicit justification for the level. Covers the full medical-urgency spectrum — immediate emergencies through asynchronous team review. One-way commit; the payload is INTERNAL — the patient never sees it.\n\n**Required inputs:** `urgency_level` — the FHIR request-priority code (`stat` | `asap` | `urgent` | `routine`), `urgency_justification` (one or two sentences: why this level AND why not the tier above/below — the auditable decision record), `details` (object — `symptom` + `evidence_quote` required; pass `null` when unknown for `category`, `indicators`, `suspected_condition`, `recommended_action`).\n\n**Urgency levels:** FHIR request-priority, a RELATIVE order `routine` < `urgent` < `asap` < `stat` (priority/speed, not a fixed clock). The full per-tier rubric with clinical examples lives on the `urgency_level` input enum — read it there. Out-of-enum values are coerced to `urgent` and disclosed via `coerced_urgency` on the result.\n\n**Neurological constellation override:** TWO OR MORE of — visual change, dizziness/vertigo/loss of balance, inability to walk/stand, focal weakness/numbness, acute confusion, sudden severe headache — reported this turn or across the last 2–3 turns → escalate now, with no question that invites a downgrade: `asap` by default, `stat` if there is an acute deficit (new, sudden weakness of an arm, a leg or one side, numbness of the face or a whole side, a drooping face or new trouble speaking — even if they can still move it —; new loss of bladder or bowel control; new or worsening leg weakness with back or neck pain, known spine disease or bone metastases (or, with bone status unknown, a cancer that often spreads to the spine), or groin numbness, or sudden weakness of both legs → possible cord compression) or any instability; an acute deficit is must-go and asks nothing, except the one onset question when it is not yet known whether it came on suddenly. In `asap`, ask the short neuro checklist in the same message as ONE question on one line, not a numbered list (\'¿Sabes dónde estás y qué día es, puedes hablar bien, ves bien, sientes debilidad de un lado, has vomitado o convulsionado?\'), keeping the message ≤60 words — the one exception to asking about a single sign and to no lists.\n\n**When NOT to call:**\n- An open case in `turn_focus.team_cases` already covers this symptom at this level or higher. Read it before calling (load `getRouterContextBundle` first if you have not this turn). Call again, as an update, only for a new symptom, a higher grade, a new red flag, a detail that makes something more serious plausible, or a symptom that persists or worsens while the team has not answered; a characterization detail that changes none of these needs no call. Otherwise tell the patient where the case stands.\n- Unconfirmed/unspecific symptom — ask ONE characterization question via `DeliverPatientMessage` first.\n- Active mental-health crisis — use `reportCrisis`.\n- Patient shared lab/imaging/values/files — use `reportResultsReceived`.\n- Administrative / operative matter (appointments, insurance, authorizations, letters, transport, scheduling, out-of-scope request) or a non-clinical referral (psico-oncología, paliativos, non-oncology medical) — use `reportUnresolvedRequestv2`.\n- Twice in the same turn for the same episode — already committed; a later datum belongs to the same open escalation.\n\n**After the commit:** the escalation does not end the conversation.\n- **Patient message** (`DeliverPatientMessage`, calm, ≤60 words): acknowledge what they told you → \'Ya avisé al equipo médico\' → ONE concrete next step (a `stat` that is not must-go has none) → availability: \'si algo cambia o te preocupa, escríbeme por aquí\'. Outside a must-go `stat` and the fever rule, no warning signs by default: naming a sign the patient did not mention makes them watch for it and feel it. If one is truly needed, give at most ONE per episode, about the symptom they already reported getting worse or not easing (\'si el dolor no cede con lo que tomas, escríbeme y lo vemos\') — never another body part or symptom, never a list (not even of related symptoms), never the last line. Outside a must-go `stat` never write \'de inmediato\', \'con urgencia\', \'máxima urgencia\', \'no esperes\', \'por si acaso\' or \'es poco probable, pero\' — not in \'escríbeme de inmediato\' nor in \'ya avisé con urgencia\': the priority travels to the team, not to the patient. Explain the purpose only in general words (\'para revisar qué está pasando y ver si necesitas algo más\'): never name an organ, a complication, a mechanism or what is being ruled out (\'descartar que sea del corazón\', \'una presión en la columna\') — to an oncology patient that reads as a diagnosis. Reassure with the plan (\'ya le avisé al equipo médico para que lo revise\', \'vamos a darle seguimiento contigo\'), never with promises (\'no es nada\', \'no te preocupes\'). No diagnosis names, no lists of alarming symptoms, no \'grave/peligroso\', no timed fallback (\'si en 15 minutos…\'), and no promised contact time — not even \'te contactan hoy en las próximas horas\'; say what the team was asked to do (\'le pedí al equipo médico que lo revise\'), never that someone is already reviewing it, and not when they will reach out.\n- **By level:** `stat` asks no characterization question (the fever rule keeps its question about the treatment and the last dose; who can take them is part of the urgencias instruction), and it is the ONLY level that may send the patient now — only for fever (the fever rule below) or when it cannot wait for the team (must-go): bleeding that does not stop, or vomiting blood or black, tarry stool together with dizziness or near-fainting on standing (even without the skin signs of shock); fainting or loss of consciousness; INTENSE shortness of breath at rest (mild breathlessness at rest is not must-go, except with the checkpoint-inhibitor signs below); chest pain with CLEAR shortness of breath, cold sweat, or spreading to the arm or jaw; sudden confusion or a seizure; NEW, SUDDEN weakness of one arm, one leg or one side, numbness of the face or of a whole side (face, arm and leg), a drooping face or new trouble speaking, even if they can still move it (a known, long-standing limitation is not sudden; general weakness or tiredness, or not getting up from fatigue, is not must-go: `asap`, or `urgent` if it is gradual and they are eating, drinking and passing urine; if they cannot stand because they feel faint, check it against fainting and shock); possible cord compression — NEW or WORSENING weakness in the legs TOGETHER WITH back or neck pain, known spine disease or bone metastases (or, with bone status unknown, a cancer that often spreads to the spine: breast, prostate, lung, kidney, myeloma), or numbness in the groin or buttocks, even if it came on over hours or days; or SUDDEN weakness of both legs (it came on within hours), even without back pain; or new loss of bladder or bowel control on its own (not feeling or not holding urine or stool, or not being able to pass urine; urgency from diarrhea is not this) — tingling or numbness in hands and feet from neuropathy, or long-standing leg weakness without back pain, is not must-go, and new back pain with no neurologic sign is `asap`; on active or recent checkpoint-inhibitor immunotherapy, drooping eyelids, double vision, new trouble swallowing or leg weakness getting worse over days is at least `asap`, and must-go with shortness of breath at rest or when they cannot swallow; anaphylaxis, only once it is well characterized — the patient confirms swelling of the tongue or throat, trouble swallowing, breathing or speaking (hoarse voice, wheezing), or hives all over WITH dizziness or fainting (more likely after an infusion, a new drug or an antibiotic); swollen lips, hives or a "strange" throat on their own are not enough; shock — skin that is cold and sweaty, or mottled, or grey or bluish lips, TOGETHER WITH at least one of: near-fainting on standing, new confusion or drowsiness, a racing heart at rest, or almost no urine (none in 12 hours or more); pallor, tiredness or weakness without those skin signs is not must-go (`asap`). Not must-go: hives or itching alone, mouth sores or swelling from mucositis, a puffy face from steroids, throat tightness brought on by cold after oxaliplatin, or cold hands, pallor or tiredness alone. When a sign is only partly described (swollen lips, hives or a strange throat with nothing else; cold or mottled skin with nothing else; weakness without knowing whether it is one side; leg weakness or numbness without knowing when it started — «sudden» means within minutes or hours, as the patient says, never assumed; numbness or tingling alone, without weakness, is not must-go unless it is of the face, of a whole side, or of the groin with leg weakness; numbness of one arm or one leg alone gets the onset question first), it is not confirmed yet: ask ONE question about the missing part before choosing the level; when leg weakness or numbness has no stated onset, that question MUST ask when it started (walking or back pain may go in the same question, never instead of it) (\'¿Ahorita tienes hinchazón de lengua o garganta, dificultad para tragar o respirar, voz ronca, o mareo?\' / \'¿Te mareas o casi te desmayas al ponerte de pie, y cuándo orinaste por última vez?\' / \'¿La debilidad es de todo el cuerpo, como cansancio, o de un brazo, una pierna o un lado?\' / \'¿Desde cuándo lo sientes, fue de golpe o poco a poco, y puedes caminar?\'). Confusion or drowsiness that is slowly increasing, or major bleeding that has already stopped, is not must-go. Any confirmed must-go sign is `stat`, never `asap`. Then calm and unambiguous: ve a urgencias ahora, acompañado, and they never drive themselves; if they are alone: \'pide que alguien venga por ti o toma un taxi; si no puedes moverte o te sientes peor, llama al 911\'. 911 (or an ambulance) FIRST, alone or not and even if they can move, for: anaphylaxis; fainting they have not fully recovered from; a seizure or sudden confusion; a possible stroke (sudden weakness of one side, an arm or a leg, sudden numbness of the face or a whole side, a drooping face, sudden trouble speaking); chest pain with clear shortness of breath, cold sweat, fainting or spreading to the arm or jaw; INTENSE shortness of breath at rest; shock; heavy bleeding (vomiting blood, a lot of black or bloody stool, or bleeding that soaks through cloths or towels; a nosebleed or other bleed that keeps going despite pressure without soaking through is must-go, not 911-first); and cord compression when they cannot walk. For anaphylaxis, if they have an adrenaline autoinjector, use it now; if they feel dizzy, lie down with the legs raised and do not stand up suddenly. Any other `stat` (not must-go, not fever): only the acknowledgement (\'Ya avisé al equipo médico\'), the availability line and, as in `asap` and `urgent`, at most the one conditional urgencias line below — no direct urgencias, no 911, no question; if the patient asks whether to go to urgencias or says it is getting worse, check it again against the must-go list and answer honestly. ' + FEVER_RULE + '`asap` and `urgent`: never 911 and never an instruction to go now, unless an internal instruction from the system (the patient timer) asks you to — the team decides where they are seen. The one warning sign allowed above may point to urgencias, as a single calm conditional line about ONE symptom they already reported getting clearly worse (\'si el dolor aumenta mucho, ve a urgencias con alguien que te acompañe\'): one condition, no list of signs and no \'si alguno de estos…\', no other symptom or body part, and never 911 in it (two exceptions: the fever rule, and chest pain with only mild or doubtful shortness of breath, kept at `asap`, where that line is always: \'si te cuesta más respirar o el dolor aumenta, ve a urgencias acompañado\'). If they ask whether to go to urgencias or what to watch, answer honestly with 1–2 points about their symptom — the only case where more than one sign is fine. Chest pain alone is not `stat` (anxiety, gastritis, muscle); chest pain WITH clear shortness of breath, cold sweat, fainting or spreading to the arm or jaw IS `stat` (on checkpoint-inhibitor immunotherapy, chest pain is at least `asap`) — even if the patient sounds calm, and even if the two come in different messages of the same episode; otherwise ask ONE question first. `routine`: acknowledgement and when to write again.\n- **Keep characterizing (except `stat`):** in the same message ask the ONE question that most helps the team; in later turns keep going, one question per message, and give high-value guidance that does not prescribe (comfort measures already in their plan or indicated by the team, what to have at hand, how to monitor). Each new datum goes to the SAME open escalation, not a new one: raise the level if it makes something more serious plausible; never lower it. In `stat`, ask no characterization question: after a must-go instruction only confirm they are on their way: accompanied, someone or a taxi coming, or the ambulance called.\n\n**Returns:** a RECEIPT, not a resolution — `{urgency_level, queued_for_team, safety_net_armed, safety_net_reason, team_has_reviewed, means, follow_up}`. `safety_net_armed` is `true`/`false`/`null`, where **`null` means this urgency tier gets no automatic check-in at all** (`routine`); read `follow_up` and, unless it says otherwise, make the fallback explicit to the patient whenever nothing is armed (an invitation to write again if it changes or worries them — never a time, and no urgencias beyond the one conditional line `asap` and `urgent` allow). `queued_for_team` says only that the ticket was written; `team_has_reviewed` is always `false` here because nothing on this path can know otherwise. Treat the escalation as OPEN and still your responsibility for the rest of the conversation: never tell the patient the team already reviewed it, and never close the topic because this call succeeded. If `queued_for_team` is `false` the team was NOT notified — say so instead of implying they were. When your `urgency_level` was out-of-enum it is coerced to `urgent` and disclosed via `{coerced_urgency, requested_urgency_level}`. A `details.category` outside the enum is dropped to `null` and disclosed via `{coerced_category, requested_category}`.\n\n**Side effects:** Emits `MEDICAL_ESCALATION_TRIGGERED`; the runtime routes it to the team by level (pages at `stat`/`asap`, ticket at `urgent`/`routine`).',
27
+ 'description': '**Does:** Escalates a MEDICAL situation to the oncology care team at a chosen urgency, with an explicit justification for the level. Covers the full medical-urgency spectrum — immediate emergencies through asynchronous team review. One-way commit; the payload is INTERNAL — the patient never sees it.\n\n**Required inputs:** `urgency_level` — the FHIR request-priority code (`stat` | `asap` | `urgent` | `routine`), `urgency_justification` (one or two sentences: why this level AND why not the tier above/below — the auditable decision record), `details` (object — `symptom` + `evidence_quote` required; pass `null` when unknown for `category`, `indicators`, `suspected_condition`, `recommended_action`).\n\n**Urgency levels:** FHIR request-priority, a RELATIVE order `routine` < `urgent` < `asap` < `stat` (priority/speed, not a fixed clock). The full per-tier rubric with clinical examples lives on the `urgency_level` input enum — read it there. Out-of-enum values are coerced to `urgent` and disclosed via `coerced_urgency` on the result.\n\n**Neurological constellation override:** TWO OR MORE of — visual change, dizziness/vertigo/loss of balance, inability to walk/stand, focal weakness/numbness, acute confusion, sudden severe headache — reported this turn or across the last 2–3 turns → escalate now, with no question that invites a downgrade: `asap` by default, `stat` if there is an acute deficit (new, sudden weakness of an arm, a leg or one side, numbness of the face or a whole side, a drooping face or new trouble speaking — even if they can still move it —; new loss of bladder or bowel control; new or worsening leg weakness with back or neck pain, known spine disease or bone metastases (or, with bone status unknown, a cancer that often spreads to the spine), or groin numbness, or sudden weakness of both legs → possible cord compression) or any instability; an acute deficit is must-go and asks nothing, except the one onset question when it is not yet known whether it came on suddenly. In `asap`, ask the short neuro checklist in the same message as ONE question on one line, not a numbered list (\'¿Sabes dónde estás y qué día es, puedes hablar bien, ves bien, sientes debilidad de un lado, has vomitado o convulsionado?\'), keeping the message ≤60 words — the one exception to asking about a single sign and to no lists.\n\n**When NOT to call:**\n- An open case in `turn_focus.team_cases` already covers this symptom at this level or higher. Read it before calling (load `getRouterContextBundle` first if you have not this turn). Call again, as an update, only for a new symptom, a higher grade, a new red flag, a detail that makes something more serious plausible, or a symptom that persists or worsens while the team has not answered; a characterization detail that changes none of these needs no call. Otherwise tell the patient where the case stands.\n- Unconfirmed/unspecific symptom — ask ONE characterization question via `DeliverPatientMessage` first.\n- Active mental-health crisis — use `reportCrisis`.\n- Patient shared lab/imaging/values/files — use `reportResultsReceived`.\n- Administrative / operative matter (appointments, insurance, authorizations, letters, transport, scheduling, out-of-scope request) or a non-clinical referral (psico-oncología, paliativos, non-oncology medical) — use `reportUnresolvedRequestv2`.\n- Twice in the same turn for the same episode — already committed; a later datum belongs to the same open escalation.\n\n**After the commit:** the escalation does not end the conversation.\n- **Patient message** (`DeliverPatientMessage`, calm, ≤60 words): acknowledge what they told you → \'Ya avisé al equipo médico\' → ONE concrete next step (a `stat` that is not must-go has none) → availability: \'si algo cambia o te preocupa, escríbeme por aquí\'. Outside a must-go `stat`, no warning signs by default: naming a sign the patient did not mention makes them watch for it and feel it. If one is truly needed, give at most ONE per episode, about the symptom they already reported getting worse or not easing (\'si el dolor no cede con lo que tomas, escríbeme y lo vemos\') — never another body part or symptom, never a list (not even of related symptoms), never the last line. Outside a must-go `stat` never write \'de inmediato\', \'con urgencia\', \'máxima urgencia\', \'no esperes\', \'por si acaso\' or \'es poco probable, pero\' — not in \'escríbeme de inmediato\' nor in \'ya avisé con urgencia\': the priority travels to the team, not to the patient. Explain the purpose only in general words (\'para revisar qué está pasando y ver si necesitas algo más\'): never name an organ, a complication, a mechanism or what is being ruled out (\'descartar que sea del corazón\', \'una presión en la columna\') — to an oncology patient that reads as a diagnosis. Reassure with the plan (\'ya le avisé al equipo médico para que lo revise\', \'vamos a darle seguimiento contigo\'), never with promises (\'no es nada\', \'no te preocupes\'). No diagnosis names, no lists of alarming symptoms, no \'grave/peligroso\', no timed fallback (\'si en 15 minutos…\'), and no promised contact time — not even \'te contactan hoy en las próximas horas\'; say what the team was asked to do (\'le pedí al equipo médico que lo revise\'), never that someone is already reviewing it, and not when they will reach out.\n- **By level:** `stat` asks no characterization question (the fever rule keeps its question about the treatment and the last dose; who can take them is part of the urgencias instruction), and it is the ONLY level that may send the patient now — only for fever (the fever rule below) or when it cannot wait for the team (must-go): bleeding that does not stop, or vomiting blood or black, tarry stool together with dizziness or near-fainting on standing (even without the skin signs of shock); fainting or loss of consciousness; INTENSE shortness of breath at rest (mild breathlessness at rest is not must-go, except with the checkpoint-inhibitor signs below); chest pain with CLEAR shortness of breath, cold sweat, or spreading to the arm or jaw; sudden confusion or a seizure; NEW, SUDDEN weakness of one arm, one leg or one side, numbness of the face or of a whole side (face, arm and leg), a drooping face or new trouble speaking, even if they can still move it (a known, long-standing limitation is not sudden; general weakness or tiredness, or not getting up from fatigue, is not must-go: `asap`, or `urgent` if it is gradual and they are eating, drinking and passing urine; if they cannot stand because they feel faint, check it against fainting and shock); possible cord compression — NEW or WORSENING weakness in the legs TOGETHER WITH back or neck pain, known spine disease or bone metastases (or, with bone status unknown, a cancer that often spreads to the spine: breast, prostate, lung, kidney, myeloma), or numbness in the groin or buttocks, even if it came on over hours or days; or SUDDEN weakness of both legs (it came on within hours), even without back pain; or new loss of bladder or bowel control on its own (not feeling or not holding urine or stool, or not being able to pass urine; urgency from diarrhea is not this) — tingling or numbness in hands and feet from neuropathy, or long-standing leg weakness without back pain, is not must-go, and new back pain with no neurologic sign is `asap`; on active or recent checkpoint-inhibitor immunotherapy, drooping eyelids, double vision, new trouble swallowing or leg weakness getting worse over days is at least `asap`, and must-go with shortness of breath at rest or when they cannot swallow; anaphylaxis, only once it is well characterized — the patient confirms swelling of the tongue or throat, trouble swallowing, breathing or speaking (hoarse voice, wheezing), or hives all over WITH dizziness or fainting (more likely after an infusion, a new drug or an antibiotic); swollen lips, hives or a "strange" throat on their own are not enough; shock — skin that is cold and sweaty, or mottled, or grey or bluish lips, TOGETHER WITH at least one of: near-fainting on standing, new confusion or drowsiness, a racing heart at rest, or almost no urine (none in 12 hours or more); pallor, tiredness or weakness without those skin signs is not must-go (`asap`). Not must-go: hives or itching alone, mouth sores or swelling from mucositis, a puffy face from steroids, throat tightness brought on by cold after oxaliplatin, or cold hands, pallor or tiredness alone. When a sign is only partly described (swollen lips, hives or a strange throat with nothing else; cold or mottled skin with nothing else; weakness without knowing whether it is one side; leg weakness or numbness without knowing when it started — «sudden» means within minutes or hours, as the patient says, never assumed; numbness or tingling alone, without weakness, is not must-go unless it is of the face, of a whole side, or of the groin with leg weakness; numbness of one arm or one leg alone gets the onset question first), it is not confirmed yet: ask ONE question about the missing part before choosing the level; when leg weakness or numbness has no stated onset, that question MUST ask when it started (walking or back pain may go in the same question, never instead of it) (\'¿Ahorita tienes hinchazón de lengua o garganta, dificultad para tragar o respirar, voz ronca, o mareo?\' / \'¿Te mareas o casi te desmayas al ponerte de pie, y cuándo orinaste por última vez?\' / \'¿La debilidad es de todo el cuerpo, como cansancio, o de un brazo, una pierna o un lado?\' / \'¿Desde cuándo lo sientes, fue de golpe o poco a poco, y puedes caminar?\'). Confusion or drowsiness that is slowly increasing, or major bleeding that has already stopped, is not must-go. Any confirmed must-go sign is `stat`, never `asap`. Then calm and unambiguous: ve a urgencias ahora, acompañado, and they never drive themselves; if they are alone: \'pide que alguien venga por ti o toma un taxi; si no puedes moverte o te sientes peor, llama al 911\'. 911 (or an ambulance) FIRST, alone or not and even if they can move, for: anaphylaxis; fainting they have not fully recovered from; a seizure or sudden confusion; a possible stroke (sudden weakness of one side, an arm or a leg, sudden numbness of the face or a whole side, a drooping face, sudden trouble speaking); chest pain with clear shortness of breath, cold sweat, fainting or spreading to the arm or jaw; INTENSE shortness of breath at rest; shock; heavy bleeding (vomiting blood, a lot of black or bloody stool, or bleeding that soaks through cloths or towels; a nosebleed or other bleed that keeps going despite pressure without soaking through is must-go, not 911-first); and cord compression when they cannot walk. For anaphylaxis, if they have an adrenaline autoinjector, use it now; if they feel dizzy, lie down with the legs raised and do not stand up suddenly. Any other `stat` (not must-go, not fever): only the acknowledgement (\'Ya avisé al equipo médico\'), the availability line and, as in `asap` and `urgent`, at most the one conditional urgencias line below — no direct urgencias, no 911, no question; if the patient asks whether to go to urgencias or says it is getting worse, check it again against the must-go list and answer honestly. ' + FEVER_RULE + '`asap` and `urgent`: never 911 and never an instruction to go now, unless an internal instruction from the system (the patient timer) asks you to — the team decides where they are seen. The one warning sign allowed above may point to urgencias, as a single calm conditional line about ONE symptom they already reported getting clearly worse (\'si el dolor aumenta mucho, ve a urgencias con alguien que te acompañe\'): one condition, no list of signs and no \'si alguno de estos…\', no other symptom or body part, and never 911 in it (one exception: chest pain with only mild or doubtful shortness of breath, kept at `asap`, where that line is always: \'si te cuesta más respirar o el dolor aumenta, ve a urgencias acompañado\'). If they ask whether to go to urgencias or what to watch, answer honestly with 1–2 points about their symptom — the only case where more than one sign is fine. Chest pain alone is not `stat` (anxiety, gastritis, muscle); chest pain WITH clear shortness of breath, cold sweat, fainting or spreading to the arm or jaw IS `stat` (on checkpoint-inhibitor immunotherapy, chest pain is at least `asap`) — even if the patient sounds calm, and even if the two come in different messages of the same episode; otherwise ask ONE question first. `routine`: acknowledgement and when to write again.\n- **Keep characterizing (except `stat`):** in the same message ask the ONE question that most helps the team; in later turns keep going, one question per message, and give high-value guidance that does not prescribe (comfort measures already in their plan or indicated by the team, what to have at hand, how to monitor). Each new datum goes to the SAME open escalation, not a new one: raise the level if it makes something more serious plausible; never lower it. In `stat`, ask no characterization question: after a must-go instruction only confirm they are on their way: accompanied, someone or a taxi coming, or the ambulance called.\n\n**Returns:** a RECEIPT, not a resolution — `{urgency_level, queued_for_team, safety_net_armed, safety_net_reason, team_has_reviewed, means, follow_up}`. `safety_net_armed` is `true`/`false`/`null`, where **`null` means this urgency tier gets no automatic check-in at all** (`routine`); read `follow_up` and, unless it says otherwise, make the fallback explicit to the patient whenever nothing is armed (an invitation to write again if it changes or worries them — never a time, and no urgencias beyond the one conditional line `asap` and `urgent` allow). `queued_for_team` says only that the ticket was written; `team_has_reviewed` is always `false` here because nothing on this path can know otherwise. Treat the escalation as OPEN and still your responsibility for the rest of the conversation: never tell the patient the team already reviewed it, and never close the topic because this call succeeded. If `queued_for_team` is `false` the team was NOT notified — say so instead of implying they were. When your `urgency_level` was out-of-enum it is coerced to `urgent` and disclosed via `{coerced_urgency, requested_urgency_level}`. A `details.category` outside the enum is dropped to `null` and disclosed via `{coerced_category, requested_category}`.\n\n**Side effects:** Emits `MEDICAL_ESCALATION_TRIGGERED`; the runtime routes it to the team by level (pages at `stat`/`asap`, ticket at `urgent`/`routine`).',
25
28
  'strict': true,
26
29
  'parameters': {
27
30
  'type': 'object',
@@ -155,20 +158,6 @@ const MODE_PROPERTY = {
155
158
 
156
159
  const MODE_DESCRIPTION = '\n\n**mode:** `new` abre un aviso; `update` actualiza la escalación abierta y nunca baja su nivel. Lo que el paciente responde después de escalar va con `update`. El `urgency_level` del recibo es el nivel aplicado: puede ser mayor que el que pediste, nunca menor.';
157
160
 
158
- // with the timer the fever rule sends to urgencias only from `stat`, like every other case
159
- const FEVER_SIGNS = 'Outside a must-go `stat` and the fever rule, no warning signs';
160
- const FEVER_SIGNS_TIMER = 'Outside a must-go `stat`, no warning signs';
161
- const FEVER_URGENCIAS = '(two exceptions: the fever rule, and chest pain';
162
- const FEVER_URGENCIAS_TIMER = '(one exception: chest pain';
163
- const FEVER_ASK = 'If they ask whether to go to urgencias or what to watch';
164
- const FEVER_ASK_TIMER = 'In a fever `asap` (`febrile_neutropenia`) leave that line out: its patient timer gives that instruction. ' + FEVER_ASK;
165
-
166
- const FEVER_RULE_TIMER = 'Fever within 6 weeks (42 days) of cytotoxic chemotherapy (or with a hematologic cancer, transplant, known neutropenia) — ≥38.0 °C, feeling feverish or chills with no thermometer, or malaise while on an antipyretic or steroid — is `asap` with `category: febrile_neutropenia`. A low reading means below 36.0 °C only; 36.0 °C is normal. A low reading is not fever and is never called fever, neither to the patient nor in `details`: before escalating, ask for a re-measure and how they feel right now. Still below 36.0 °C with current malaise, chills or shivering, or a confirmed ≤35.0 °C, is `asap`; still below 36.0 °C with no other symptom is `urgent`. Chills or rigors, even strong, are `asap`. It is `stat` only with a very obvious, confirmed red flag (clear shortness of breath at rest, clear confusion, fainting or unable to stand with the fever, mottled or cold skin, bleeding that does not stop), or any fever within 4 weeks of CAR-T or during bispecific step-up dosing — say it calmly: "ve a urgencias ahora y di que estás en tratamiento oncológico" (CAR-T / bispecific: call the treating center first). If you don\'t know the treatment or the last dose date, ask in the same message. 37.5–37.9 °C in that window is `urgent`: remeasure in 30–60 min. ';
167
-
168
- const FEVER_RUBRIC_STAT_TIMER = 'fiebre en la ventana de quimioterapia con una bandera roja confirmada (regla de fiebre),';
169
-
170
- const FEVER_RUBRIC_ASAP_TIMER = 'fiebre ≥38.0 °C, o temperatura baja (menos de 36.0 °C) confirmada al volver a medir con malestar o escalofríos, o ≤35.0 °C confirmado, en la ventana de quimioterapia sin bandera roja (regla de fiebre),';
171
-
172
161
  const CLINICAL_ASSESSMENT_PROPERTY = nullable({
173
162
  'type': 'object',
174
163
  'description': 'Tu razonamiento clínico, estructurado para auditoría. Todos los campos aceptan `null`. No cambia el nivel: el nivel lo decides tú en `urgency_level`.',
@@ -224,12 +213,7 @@ function liveDefinition() {
224
213
  properties.details.properties.clinical_assessment = CLINICAL_ASSESSMENT_PROPERTY;
225
214
  properties.details.required.push('clinical_assessment');
226
215
  }
227
- if (feverTimer) {
228
- live.description = live.description.replace(FEVER_RULE, FEVER_RULE_TIMER).replace(FEVER_SIGNS, FEVER_SIGNS_TIMER).replace(FEVER_URGENCIAS, FEVER_URGENCIAS_TIMER).replace(FEVER_ASK, FEVER_ASK_TIMER);
229
- properties.urgency_level.description = properties.urgency_level.description
230
- .replace(FEVER_RUBRIC_STAT, FEVER_RUBRIC_STAT_TIMER)
231
- .replace(FEVER_RUBRIC_ASAP, FEVER_RUBRIC_ASAP_TIMER);
232
- }
216
+ if (feverTimer) live.description = live.description.replace(FEVER_ASK, FEVER_ASK_TIMER);
233
217
  return live;
234
218
  }
235
219
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peopl-health/nexus",
3
- "version": "6.6.0-dev.20843",
3
+ "version": "6.6.0-dev.20869",
4
4
  "description": "Core messaging and assistant library for WhatsApp communication platforms",
5
5
  "keywords": [
6
6
  "whatsapp",