fix(clinical): red flags, one crisis rule, callback after a crisis, one table of numbers
Clinical review of the questionnaires (ADR-013):
- Red-flag block first in stage 1 (config/instruments/red_flags.yaml); any «Да» stops the
questionnaire with an acute alert and the help screen of its category.
- One crisis rule: the crisis screen opens at a HIGH C-SSRS risk only; moderate stops and goes
to a psychiatrist (24 h as a guide), low is a flag with the safety plan. PHQ-9 item 9 with a
negative screener is a discrepancy flag; without a completed screener it asks the C-SSRS at once.
config/questionnaire.yaml: cssrs_positive_policy graded (C01).
- Every crisis leaves a callback task for the doctor on duty (post_crisis_call, one per patient)
and the app asks how the person is the next day, the safety plan one tap away.
- Routing: risk and flags first, scales second; PCL-5 >= 50 no longer means a priority
appointment (pcl5_severe is moderate on the dashboard too).
- Crisis numbers live only in config/texts/crisis.yaml; texts and the agent prompt refer to them
via {phone:<key>}. Fixes the children's helpline offered to adults by the chat agent.
Refs #92
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -395,6 +395,25 @@ def _crisis_cfg(path: Path = CRISIS_PATH) -> _CrisisCfg:
|
||||
return _CrisisCfg.model_validate(yaml.safe_load(path.read_text(encoding="utf-8")))
|
||||
|
||||
|
||||
_PHONE_REF = re.compile(r"\{phone:([a-z_]+)\}")
|
||||
|
||||
|
||||
def fill_phones(text: str, path: Path = CRISIS_PATH) -> str:
|
||||
"""Replace `{phone:<resource>}` with the number from the single table in config/texts/crisis.yaml.
|
||||
|
||||
Every patient text and prompt refers to the table instead of repeating a number, so a number is changed in one
|
||||
place. An unknown resource fails loudly: a wrong number on the crisis screen must never pass silently.
|
||||
"""
|
||||
resources = _crisis_cfg(path).resources
|
||||
|
||||
def number(m: re.Match[str]) -> str:
|
||||
if m.group(1) not in resources:
|
||||
raise ValueError(f"unknown crisis resource {m.group(1)!r}")
|
||||
return resources[m.group(1)].phone
|
||||
|
||||
return _PHONE_REF.sub(number, text)
|
||||
|
||||
|
||||
def _render(body: str, resources: list[CrisisResource], doctor_notified: str, grounding: str) -> str:
|
||||
lines = [body.strip(), ""]
|
||||
for r in resources:
|
||||
|
||||
Reference in New Issue
Block a user