diff --git a/app/api/doctor_views.py b/app/api/doctor_views.py index 8d73a0a..b4f2793 100644 --- a/app/api/doctor_views.py +++ b/app/api/doctor_views.py @@ -34,6 +34,7 @@ from app.db import repo from app.db.clinical import Alert, DailyCheckin, Dose, PatientProfile, Prescription, SafetyPlan, ScaleResult from app.db.identity import Patient from app.integrations.base import Prescription as PrescriptionOut +from app.services.anonymous_care import display_name as anonymous_name COLOR_ORDER: dict[str, int] = {"red": 0, "yellow": 1, "grey": 2, "green": 3} _MODULES = frozenset(get_args(Module)) @@ -96,6 +97,7 @@ class PatientData: doses: Sequence[Dose] prescriptions: Sequence[Prescription] alerts: Sequence[Alert] # newest first + contact_requested_at: datetime | None = None async def load_patient_data(session: AsyncSession, profile: PatientProfile) -> PatientData: @@ -104,6 +106,9 @@ async def load_patient_data(session: AsyncSession, profile: PatientProfile) -> P rx = ( await session.scalars(select(Prescription).where(Prescription.token == token).order_by(Prescription.id)) ).all() + dialog = await repo.get_dialog_state(session, token) + requests = (dialog.data.get("contact_requests") or []) if dialog else [] + contact_at = datetime.fromisoformat(requests[-1]["ts"]) if requests else None return PatientData( profile=profile, checkins=await repo.list_checkins(session, token), @@ -111,6 +116,7 @@ async def load_patient_data(session: AsyncSession, profile: PatientProfile) -> P doses=doses, prescriptions=rx, alerts=await repo.list_alerts(session, token=token), + contact_requested_at=contact_at, ) @@ -228,6 +234,10 @@ def _last_event(d: PatientData, now: datetime) -> str: alert = d.alerts[0] if d.alerts else None scales = [r for r in d.results if r.complete and r.scale in _SCALE_LABELS] scale = scales[-1] if scales else None + if d.contact_requested_at is not None and all( + d.contact_requested_at >= ts for ts in [x.ts for x in (alert, scale) if x is not None] + ): + return "Пациент просит врача связаться" if scale is not None and (alert is None or scale.ts > alert.ts): day = _therapy_day(d.profile, _local(scale.ts, now)) return f"{_SCALE_LABELS[scale.scale]} = {scale.total} (день {day})" @@ -249,7 +259,7 @@ def list_item(d: PatientData, patient: Patient | None, now: datetime) -> Patient rx = _active_rx(d, today) return PatientListItem( token=p.token, - display_name=patient.display_name if patient else "Пациент", + display_name=patient.display_name if patient else anonymous_name(p.token), age=_age(patient, p, today), modules=[cast(Module, m) for m in p.modules or [] if m in _MODULES], drug=_drug_label(rx) if rx else None, diff --git a/app/api/patient_web.py b/app/api/patient_web.py index 15845c3..ac02043 100644 --- a/app/api/patient_web.py +++ b/app/api/patient_web.py @@ -7,9 +7,9 @@ exactly like the web console, and consent, onboarding, scales and check-ins come Two ways in: - **ЕМИАС** (demo): the doctor's one-time connect code via `EmiasMock`, or a synthetic demo persona. The patient is linked to the attending doctor, who sees the data on the dashboard. -- **Anonymous**: a random pseudonymous token and nothing else — no identity record, no doctor. The engine - supports tokens without an identity record (consent is kept in the dialog state), so no personal data is - stored at all. Crisis safety still works: the fixed crisis script does not depend on the doctor. +- **Anonymous**: a random pseudonymous token, no identity record, and access to the prototype care team. + Clinical answers are stored on the server and visible to the assigned doctor under a pseudonym. + Consent is kept in the dialog state. Existing doctor-less profiles require explicit care opt-in. The token returned here is the session credential of the prototype. Production needs short-lived sessions issued by the server instead of handing out the pseudonymous token itself. @@ -36,11 +36,13 @@ from app.core.interpretation import texts as results_texts from app.core.meds_reference import find_drug, indication_for, load_reference from app.core.safety import CrisisResource, crisis_reply from app.db import repo +from app.db.audit import audit from app.db.clinical import DailyCheckin, Dose, Prescription from app.db.identity import TOKEN_LEN from app.db.intake import QuestionnaireRecord from app.db.session import get_clinical_session from app.integrations.emias_mock import CODE_MAX_LEN, EmiasMock +from app.services import anonymous_care log = logging.getLogger(__name__) @@ -153,19 +155,40 @@ async def auth_emias_demo(body: EmiasDemoIn) -> AuthOut: @router.post("/auth/anonymous", response_model=AuthOut) async def auth_anonymous(body: AnonymousIn | None = None) -> AuthOut: - """Anonymous sign-in: a fresh random token; no identity record, no doctor. + """Anonymous sign-in: a fresh random token; care without an identity record. - The clinical side gets a doctor-less pseudonymous profile (the dialog API serves known profiles only). It holds - no personal data — only the module of the chosen `focus`; the stage 1 screening then sets the modules itself. + The clinical side gets a pseudonymous profile assigned to the prototype care team. It holds + no identity fields. Legacy clients may supply `focus`; the common stage 1 screening sets modules itself. """ token = secrets.token_hex(TOKEN_LEN // 2) focus = body.focus if body is not None else None async with get_clinical_session() as s: - await repo.upsert_profile(s, token=token, doctor_id="", modules=[_FOCUS_MODULE[focus]] if focus else []) + await repo.upsert_profile( + s, token=token, doctor_id=anonymous_care.doctor_id(), modules=[_FOCUS_MODULE[focus]] if focus else [] + ) log.info("web auth: anonymous tok=%s", token[:6]) return AuthOut(token=token, mode="anonymous") +@router.get("/patient/capabilities") +async def patient_capabilities() -> dict[str, bool]: + """Expose availability without leaking clinical policy or server configuration.""" + return {"primary_screening": intake_enabled()} + + +@router.post("/me/{token}/doctor/connect") +async def connect_anonymous_doctor(token: str) -> dict[str, bool]: + """Explicit opt-in for old doctor-less profiles; never reassign an existing doctor.""" + async with get_clinical_session() as s: + profile = await repo.get_profile(s, token) + if profile is None: + raise HTTPException(404, "patient not found") + if not profile.doctor_id: + profile.doctor_id = anonymous_care.doctor_id() + await audit(s, actor=token, action="anonymous_care_opt_in", token=token, ts=clock.now()) + return {"has_doctor": True} + + class DoseItem(BaseModel): id: int drug: str diff --git a/app/api/routes.py b/app/api/routes.py index 88266a7..be3feb9 100644 --- a/app/api/routes.py +++ b/app/api/routes.py @@ -43,6 +43,7 @@ from app.db.session import get_clinical_session, get_identity_session from app.dialog.contracts import Event, get_engine from app.integrations.base import integrations from app.scheduler import jobs as scheduler +from app.services.anonymous_care import display_name as anonymous_name from app.services.monitoring import refresh_status router = APIRouter(prefix="/api/v1") @@ -66,7 +67,7 @@ async def _patients(tokens: list[str]) -> dict[str, Patient]: def _name(patients: dict[str, Patient], token: str) -> str: p = patients.get(token) - return p.display_name if p else "Пациент" + return p.display_name if p else anonymous_name(token) # ------------------------------------------------------------------ doctor dashboard diff --git a/app/services/anonymous_care.py b/app/services/anonymous_care.py new file mode 100644 index 0000000..d2d02c1 --- /dev/null +++ b/app/services/anonymous_care.py @@ -0,0 +1,24 @@ +"""Pseudonymous care routing; no identity fields or changes to clinical release gates.""" + +from hashlib import sha256 + +import yaml +from pydantic import BaseModel, ConfigDict, Field + +from app.config import get_settings + + +class AnonymousCare(BaseModel): + model_config = ConfigDict(extra="forbid", str_strip_whitespace=True) + doctor_id: str = Field(min_length=1, max_length=64) + + +def doctor_id() -> str: + path = get_settings().config_dir / "anonymous_care.yaml" + return AnonymousCare.model_validate(yaml.safe_load(path.read_text())).doctor_id + + +def display_name(token: str) -> str: + # Do not use a piece of the bearer token itself as the public patient label. + label = sha256(("anonymous-patient:" + token).encode()).hexdigest()[:10].upper() + return f"Пациент {label}" diff --git a/config/anonymous_care.yaml b/config/anonymous_care.yaml new file mode 100644 index 0000000..8b0528a --- /dev/null +++ b/config/anonymous_care.yaml @@ -0,0 +1,3 @@ +# Routing for the current prototype: anonymous patients use the same doctor workspace, +# without an identity record. Set this to the responsible clinic's doctor when deploying. +doctor_id: doc-smirnova diff --git a/tests/test_api_patient_web.py b/tests/test_api_patient_web.py index cd6be56..10b941b 100644 --- a/tests/test_api_patient_web.py +++ b/tests/test_api_patient_web.py @@ -12,6 +12,7 @@ from app.db import identity_repo, repo, session from app.db.bootstrap import init_db from app.db.clinical import Dose, Prescription from app.main import app +from app.services.anonymous_care import doctor_id as anonymous_doctor MEM = "sqlite+aiosqlite:///:memory:" TOKEN = "b" * 32 @@ -48,17 +49,17 @@ async def test_anonymous_tokens_are_fresh_and_store_no_personal_data(client: Asy async with session.get_identity_session() as s: assert await identity_repo.get_patient(s, first["token"]) is None async with session.get_clinical_session() as s: - # Only a doctor-less pseudonymous profile: the dialog API serves known profiles only. + # The care team sees a pseudonymous profile without an identity record. profile = await repo.get_profile(s, first["token"]) - assert profile.doctor_id == "" and profile.modules == [] + assert profile.doctor_id == anonymous_doctor() and profile.modules == [] -async def test_anonymous_focus_picks_the_module_without_a_doctor(client: AsyncClient) -> None: +async def test_anonymous_focus_does_not_remove_access_to_doctor(client: AsyncClient) -> None: token = (await client.post("/api/v1/auth/anonymous", json={"focus": "ptsd"})).json()["token"] async with session.get_clinical_session() as s: profile = await repo.get_profile(s, token) - assert profile.modules == ["veteran"] and not profile.doctor_id - assert (await client.get(f"/api/v1/me/{token}/today")).json()["has_doctor"] is False + assert profile.modules == ["veteran"] and profile.doctor_id == anonymous_doctor() + assert (await client.get(f"/api/v1/me/{token}/today")).json()["has_doctor"] is True assert (await client.post("/api/v1/auth/anonymous", json={"focus": "flu"})).status_code == 422 @@ -122,7 +123,7 @@ async def test_today_plan_and_week_marks(client: AsyncClient) -> None: async def test_today_for_anonymous_is_empty(client: AsyncClient) -> None: token = (await client.post("/api/v1/auth/anonymous")).json()["token"] body = (await client.get(f"/api/v1/me/{token}/today")).json() - assert body["has_doctor"] is False and body["doses"] == [] and body["prescriptions"] == [] + assert body["has_doctor"] is True and body["doses"] == [] and body["prescriptions"] == [] async def test_crisis_resources_come_from_config(client: AsyncClient) -> None: @@ -220,3 +221,67 @@ async def test_stage_one_starts_without_modules(client: AsyncClient, monkeypatch async def test_patient_app_has_its_own_demo_personas(client: AsyncClient) -> None: body = (await client.get("/api/v1/patient/demo-personas")).json() assert [p["token"] for p in body] == [p.token for p in fixtures.DEMO_PERSONAS] + + +async def test_anonymous_is_visible_only_to_assigned_doctor(client: AsyncClient) -> None: + first = (await client.post("/api/v1/auth/anonymous")).json()["token"] + second = (await client.post("/api/v1/auth/anonymous")).json()["token"] + items = (await client.get(f"/api/v1/doctors/{anonymous_doctor()}/patients")).json() + names = {p["token"]: p["display_name"] for p in items} + assert names[first].startswith("Пациент ") and names[first] != names[second] + assert first not in names[first] + own = await client.get(f"/api/v1/patients/{first}", params={"doctor_id": anonymous_doctor()}) + assert own.status_code == 200 and own.json()["patient"]["display_name"] == names[first] + denied = await client.get(f"/api/v1/patients/{first}", params={"doctor_id": "another-doctor"}) + assert denied.status_code == 403 + assert (await client.get("/api/v1/doctors/another-doctor/patients")).json() == [] + + +async def test_old_anonymous_profile_requires_explicit_care_opt_in(client: AsyncClient) -> None: + async with session.get_clinical_session() as s: + await repo.upsert_profile(s, token=TOKEN, doctor_id="", modules=["veteran"]) + # Merely opening Today must not reveal an old private profile to a doctor. + assert not (await client.get(f"/api/v1/me/{TOKEN}/today")).json()["has_doctor"] + assert (await client.get(f"/api/v1/doctors/{anonymous_doctor()}/patients")).json() == [] + for _ in range(2): + assert (await client.post(f"/api/v1/me/{TOKEN}/doctor/connect")).json() == {"has_doctor": True} + async with session.get_clinical_session() as s: + p = await repo.get_profile(s, TOKEN) + assert p.doctor_id == anonymous_doctor() and p.modules == ["veteran"] + async with session.get_identity_session() as s: + assert await identity_repo.get_patient(s, TOKEN) is None + + +async def test_connect_care_does_not_reassign_or_create_patients(client: AsyncClient) -> None: + assert (await client.post(f"/api/v1/me/{TOKEN}/doctor/connect")).status_code == 404 + async with session.get_clinical_session() as s: + await repo.upsert_profile(s, token=TOKEN, doctor_id="own-doctor") + assert (await client.post(f"/api/v1/me/{TOKEN}/doctor/connect")).status_code == 200 + async with session.get_clinical_session() as s: + assert (await repo.get_profile(s, TOKEN)).doctor_id == "own-doctor" + + +async def test_screening_capability_respects_release_gate(client: AsyncClient, monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("INTAKE_DEMO", "0") + assert (await client.get("/api/v1/patient/capabilities")).json() == {"primary_screening": False} + monkeypatch.setenv("INTAKE_DEMO", "1") + assert (await client.get("/api/v1/patient/capabilities")).json() == {"primary_screening": True} + + +async def test_anonymous_contact_request_reaches_doctor(client: AsyncClient, monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("INTAKE_DEMO", "0") + token = (await client.post("/api/v1/auth/anonymous")).json()["token"] + for event in [ + {"type": "start"}, + {"type": "button", "button": "consent:yes"}, + {"type": "button", "button": "age:adult"}, + {"type": "button", "button": "menu:contact_doctor"}, + ]: + response = await client.post(f"/api/v1/dialog/{token}/events", json=event) + assert response.status_code == 200 + items = (await client.get(f"/api/v1/doctors/{anonymous_doctor()}/patients")).json() + assert items[0]["last_event"] == "Пациент просит врача связаться" + card = (await client.get(f"/api/v1/patients/{token}", params={"doctor_id": anonymous_doctor()})).json() + assert card["patient"]["last_event"] == items[0]["last_event"] + async with session.get_identity_session() as s: + assert await identity_repo.get_patient(s, token) is None diff --git a/web/src/api/client.ts b/web/src/api/client.ts index 3400cd7..1b21195 100644 --- a/web/src/api/client.ts +++ b/web/src/api/client.ts @@ -43,7 +43,9 @@ const post = (path: string, body?: unknown) => export const api = { signInEmias: (code: string) => post("/auth/emias", { code }), signInEmiasDemo: (personaToken: string) => post("/auth/emias/demo", { persona_token: personaToken }), - signInAnonymous: (focus: Focus) => post("/auth/anonymous", { focus }), + signInAnonymous: (focus?: Focus) => post("/auth/anonymous", { focus }), + patientCapabilities: () => request<{ primary_screening: boolean }>("/patient/capabilities"), + connectDoctor: (token: string) => post<{ has_doctor: boolean }>(`/me/${encodeURIComponent(token)}/doctor/connect`), demoPersonas: () => request("/patient/demo-personas"), crisisResources: () => request("/crisis/resources"), catalog: () => request("/instruments/catalog"), diff --git a/web/src/content/ru.ts b/web/src/content/ru.ts index 1810915..4078fc4 100644 --- a/web/src/content/ru.ts +++ b/web/src/content/ru.ts @@ -52,7 +52,7 @@ export const ru = { or: "или", anonymous: { title: "Войти анонимно", - text: "Без имени и полиса. Врач не видит ответы, история хранится только на этом устройстве.", + text: "Без имени, СНИЛС и полиса. Первичный опрос и связь с врачом — по обезличенному профилю.", }, disclaimer: "Сервис не ставит диагнозы и не назначает лечение — решения принимает врач.", }, @@ -71,12 +71,12 @@ export const ru = { demoDay: (day: number) => `${day}-й день терапии`, }, anonymous: { - title: "Что вы хотите проверить?", - note: "Анонимно: врач не видит ответы, история хранится только на этом устройстве.", - focus: { - depression: { title: "Депрессия", text: "Подавленность, потеря интереса, усталость" }, - ptsd: { title: "ПТСР", text: "Последствия травмы: флешбэки, кошмары, тревога" }, - }, + title: "Помощь без личных данных", + note: "Врач видит ваши ответы и результаты под условным номером, без имени, СНИЛС и полиса. Ответы хранятся на сервере, ключ доступа к профилю — на этом устройстве.", + start: "Начать первичный опрос", + continue: "Продолжить без личных данных", + lead: "Пройдите единый первичный опрос: заранее выбирать предполагаемый диагноз не нужно.", + unavailable: "Первичный опрос сейчас отключён на сервере. Кабинет и подключение врача доступны без личных данных.", submitting: "Создаём профиль…", }, today: { @@ -96,11 +96,11 @@ export const ru = { visit: "Следующий визит к врачу", medQuestion: "Вопрос о лекарстве", medQuestionHint: "Ответ по официальной инструкции", - messageDoctor: "Сообщение врачу", - messageDoctorHint: "Врач ответит в рабочее время", + messageDoctor: "Связаться с врачом", + messageDoctorHint: "Запрос появится в кабинете врача", week: "Приём на этой неделе", weekTaken: (taken: number, total: number) => (total ? `Принято ${taken} из ${total}` : "Отметок пока нет"), - noDoctor: "Врач не подключён. Подключите ЕМИАС в профиле, чтобы назначения и визиты появились здесь.", + noDoctor: "Врач пока не подключён. Подключите его без личных данных, чтобы передавать ответы и получать сопровождение.", newMessage: "Новое сообщение", open: "Открыть", continue: "Продолжить", @@ -127,7 +127,7 @@ export const ru = { tablet: "1 приём", week: ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"], onlyDoctor: "Схему меняет только врач. Не изменяйте дозировку самостоятельно.", - empty: "Назначения появятся здесь после входа через ЕМИАС.", + empty: "Здесь появятся назначения вашего врача.", question: "Вопрос о лекарстве", reminderTitle: "Время принять препарат", reminderLead: "По назначению врача", @@ -166,11 +166,13 @@ export const ru = { visit: "Следующий визит", visitNone: "Дата следующего визита пока не назначена", attending: "Ваш лечащий врач", - write: "Написать врачу", - writeNote: "Обычно врач отвечает в рабочее время. Если срочно — 112.", + connect: "Подключить врача без личных данных", + connecting: "Подключаем врача…", + write: "Попросить врача связаться", + writeNote: "Запрос на связь появится в кабинете врача. Если срочно — 112.", earlier: "Записаться к врачу раньше", plan: "Мой план безопасности", - noDoctor: "Врач не подключён. Подключите ЕМИАС в профиле, чтобы связаться с лечащим врачом.", + noDoctor: "Врач пока не подключён. Можно подключить его без имени, СНИЛС и полиса: он увидит обезличенные ответы и результаты.", }, profile: { title: "Профиль", @@ -185,7 +187,7 @@ export const ru = { revokeConfirm: "Да, отозвать", cancel: "Отмена", wipe: "Удалить данные с устройства", - wipeNote: "Для анонимного режима: история на этом устройстве будет удалена.", + wipeNote: "Удалятся ключ доступа и локальная копия переписки. Обезличенные ответы останутся на сервере; без ключа восстановить доступ к этому профилю не получится.", logout: "Выйти", messages: "Сообщения", result: "Предварительный результат", diff --git a/web/src/screens/AnonymousSignIn.tsx b/web/src/screens/AnonymousSignIn.tsx index 097248f..6852278 100644 --- a/web/src/screens/AnonymousSignIn.tsx +++ b/web/src/screens/AnonymousSignIn.tsx @@ -1,31 +1,35 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { api } from "../api/client"; -import type { Focus } from "../api/types"; import { AppShell, Notice, TopBar } from "../components/AppShell"; -import { Icon, type IconName } from "../components/Icon"; +import { Icon } from "../components/Icon"; import { ru } from "../content/ru"; import { useSession } from "../session/SessionContext"; -const FOCUS: { id: Focus; icon: IconName }[] = [ - { id: "depression", icon: "smile" }, - { id: "ptsd", icon: "heart" }, -]; - -// A3 · Анонимный вход: человек выбирает, что хочет проверить — от этого зависит стартовый опрос +// Anonymous means no identifying data, with the same screening and care path. export function AnonymousSignIn() { const t = ru.anonymous; const navigate = useNavigate(); const { signIn } = useSession(); const [busy, setBusy] = useState(false); const [error, setError] = useState(false); + const [screening, setScreening] = useState(null); - const start = async (focus: Focus) => { + useEffect(() => { + let alive = true; + api.patientCapabilities() + .then((v) => { if (alive) setScreening(v.primary_screening); }) + .catch(() => { if (alive) setError(true); }); + return () => { alive = false; }; + }, []); + + const start = async () => { setBusy(true); setError(false); try { - signIn(await api.signInAnonymous(focus)); + // No self-selected diagnosis: the common intake determines the follow-up modules. + signIn(await api.signInAnonymous()); navigate("/flow", { replace: true }); } catch { setError(true); @@ -38,27 +42,16 @@ export function AnonymousSignIn() {
navigate("/")} />
+

{t.title}

- -
- {FOCUS.map(({ id, icon }) => ( - - ))} -
- +

{t.lead}

+ {t.note} + {screening === false && {t.unavailable}} {error && {ru.common.networkError}} -

{busy ? t.submitting : t.note}

+
diff --git a/web/src/screens/Doctor.tsx b/web/src/screens/Doctor.tsx index 4417812..8e0056b 100644 --- a/web/src/screens/Doctor.tsx +++ b/web/src/screens/Doctor.tsx @@ -1,3 +1,6 @@ +import { useState } from "react"; +import { api } from "../api/client"; +import { useSession } from "../session/SessionContext"; import { useNavigate } from "react-router-dom"; import { AppShell, Notice } from "../components/AppShell"; @@ -11,7 +14,22 @@ export function Doctor() { const t = ru.doctor; const navigate = useNavigate(); const dialog = useDialog(); - const { plan } = useToday(); + const { plan, failed } = useToday(); + const { session } = useSession(); + const [connecting, setConnecting] = useState(false); + const [connectFailed, setConnectFailed] = useState(false); + const connect = async () => { + if (!session || connecting) return; + setConnecting(true); + setConnectFailed(false); + try { + await api.connectDoctor(session.token); + navigate("/today"); + } catch { + setConnectFailed(true); + setConnecting(false); + } + }; const go = (button: string, label: string) => void dialog.send({ type: "button", button }, label).then((ok) => ok && navigate("/flow")); @@ -29,8 +47,14 @@ export function Doctor() {

{t.title}

- {plan && !plan.has_doctor ? ( - {t.noDoctor} + {(failed || connectFailed) && {ru.common.networkError}} + {!plan ? (!failed &&
) : !plan.has_doctor ? ( +
+ {t.noDoctor} + +
) : (
diff --git a/web/src/screens/Today.tsx b/web/src/screens/Today.tsx index ec8c801..f885668 100644 --- a/web/src/screens/Today.tsx +++ b/web/src/screens/Today.tsx @@ -7,7 +7,6 @@ import { useCatalog } from "../content/reference"; import { ru } from "../content/ru"; import { useDialog } from "../dialog/DialogContext"; import { classify } from "../dialog/step"; -import { useSession } from "../session/SessionContext"; import { WeekDots } from "./Meds"; import { humanDate, useToday } from "./useToday"; @@ -84,7 +83,6 @@ function WeekCard({ rx, onOpen }: { rx: TodayPrescription; onOpen: () => void }) export function Today() { const t = ru.today; const navigate = useNavigate(); - const { session } = useSession(); const dialog = useDialog(); const { plan, failed } = useToday(); const catalog = useCatalog(); @@ -119,7 +117,7 @@ export function Today() { !diaryDue && q?.intake !== "review"; const nextDose = plan?.prescriptions.flatMap((p) => p.times).sort()[0]; - const noDoctor = session?.mode === "anonymous" || (plan !== null && !plan.has_doctor); + const noDoctor = plan !== null && !plan.has_doctor; const now = plan?.now ?? "00:00"; const openDose = (d: TodayDose) => navigate(`/dose/${d.id}`); @@ -292,7 +290,12 @@ export function Today() { {plan?.prescriptions[0] && navigate("/meds")} />} {noDoctor ? ( - {t.noDoctor} +
+ {t.noDoctor} + +
) : (