From 0bbe1e0932a0531a2b51fefe76cc1bbf0dc789e3 Mon Sep 17 00:00:00 2001 From: Lacky1234union Date: Sun, 4 Oct 2026 17:52:23 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20web=20demo=20token=20tok-andrey=20shares?= =?UTF-8?q?=20Andrey's=20=D0=95=D0=9C=D0=98=D0=90=D0=A1=20record;=20REVISI?= =?UTF-8?q?ON=20written=20only=20after=20a=20healthy=20deploy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- app/integrations/emias_record.py | 6 +++++- data/emias/records.yaml | 2 ++ infra/deploy/deploy.sh | 3 +-- tests/test_llm_agent.py | 5 +++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/integrations/emias_record.py b/app/integrations/emias_record.py index 09624f0..c082946 100644 --- a/app/integrations/emias_record.py +++ b/app/integrations/emias_record.py @@ -63,7 +63,11 @@ def _load(path: Path) -> dict[str, PatientRecord]: raw = yaml.safe_load(path.read_text(encoding="utf-8")) or {} out: dict[str, PatientRecord] = {} for snils, rec in (raw.get("records") or {}).items(): - out[pseudo_id(snils)] = PatientRecord.model_validate(rec) + aliases = rec.pop("tokens", []) if isinstance(rec, dict) else [] + record = PatientRecord.model_validate(rec) + out[pseudo_id(snils)] = record + for token in aliases: # demo tokens used by the patient web app (e.g. tok-andrey) share the record + out[token] = record return out diff --git a/data/emias/records.yaml b/data/emias/records.yaml index be4977e..02dae74 100644 --- a/data/emias/records.yaml +++ b/data/emias/records.yaml @@ -8,10 +8,12 @@ # allergies — аллергии и непереносимости; `tags` сверяются с составом препаратов (вспомогательные вещества) # other_medications — назначения других специалистов; `classes` сверяются со взаимодействиями # pregnancy — для женщин: беременность/лактация (null — нет данных) +# tokens — демо-токены веб-приложения, которым принадлежит та же карта # Текущее психотропное назначение приходит из таблицы prescriptions (мок МИС, app/integrations/mis_mock.py). records: "900-000-013 34": # Андрей С., 34, ветеран СВО — герой демо + tokens: [tok-andrey] # демо-вход веб-приложения пациента diagnoses: - {code: "F43.1", name: "Посттравматическое стрессовое расстройство"} - {code: "F32.1", name: "Депрессивный эпизод средней степени"} diff --git a/infra/deploy/deploy.sh b/infra/deploy/deploy.sh index 8dbae52..a63f378 100755 --- a/infra/deploy/deploy.sh +++ b/infra/deploy/deploy.sh @@ -29,9 +29,8 @@ cp .env app.new/.env rm -rf app.old; [ -d app ] && mv app app.old; mv app.new app chmod 755 $DIR cd app -echo "$SHA" > REVISION docker run --rm --user "\$(id -u):\$(id -g)" -e HOME=/tmp -e npm_config_cache=/tmp/.npm -v "\$PWD/web:/w" -w /w node:20-alpine sh -c "npm ci --no-audit --no-fund >/dev/null && npm run build >/dev/null" docker compose -p ptsr -f docker-compose.yml -f infra/deploy/docker-compose.server.yml up -d --build /dev/null && break; sleep 3; done -curl -sf 127.0.0.1:8010/health >/dev/null && echo "api ok @ $SHA" +curl -sf 127.0.0.1:8010/health >/dev/null && echo "$SHA" > REVISION && echo "api ok @ $SHA" SH diff --git a/tests/test_llm_agent.py b/tests/test_llm_agent.py index 3752f15..6bc272f 100644 --- a/tests/test_llm_agent.py +++ b/tests/test_llm_agent.py @@ -269,3 +269,8 @@ def test_build_provider_prefers_gigachat(): s = Settings(_env_file=None, chat_agent="auto", gigachat_credentials="x", openrouter_api_key="y") assert isinstance(agent.build_provider(s), GigaChatToolProvider) + + +async def test_web_demo_token_shares_andreys_record(): + rec = await emias_records.get("tok-andrey") + assert rec is not None and any("язвенная" in c.name.lower() for c in rec.conditions)