feat: presentation demo mode — one-click private demo patient, screening on/off switch
CI / ruff · pytest (pull_request) Failing after 2m33s
CI / ruff · pytest (pull_request) Failing after 2m33s
- POST /auth/demo/fresh + «Демо: войти как Андрей» on the welcome screen: every sign-in gets a fresh private copy of veteran Andrey (consent, prescription, ЕМИАС record) and lands in the chat — no codes, nobody's crisis or half-done questionnaire leaks into another viewer. - Initial screening switch: SCREENING_ENABLED env default + /demo/settings + a toggle in the demo console; off → after consent straight to the chat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Presentation switches (demo): stored in `demo_settings`, default from settings/env.
|
||||
|
||||
SCREENING_ENABLED=false # env default
|
||||
POST /api/v1/demo/settings {"screening_enabled": false} # one button in the demo console
|
||||
|
||||
Screening off: after consent the patient goes straight to the chat — no onboarding questionnaires.
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.config import get_settings
|
||||
from app.db.clinical import DemoSetting
|
||||
|
||||
SCREENING = "screening_enabled"
|
||||
|
||||
|
||||
async def get_all(session: AsyncSession) -> dict[str, Any]:
|
||||
row = await session.get(DemoSetting, SCREENING)
|
||||
return {SCREENING: bool(row.value) if row is not None else get_settings().screening_enabled}
|
||||
|
||||
|
||||
async def screening_enabled(session: AsyncSession) -> bool:
|
||||
return (await get_all(session))[SCREENING]
|
||||
|
||||
|
||||
async def set_screening(session: AsyncSession, enabled: bool) -> None:
|
||||
row = await session.get(DemoSetting, SCREENING)
|
||||
if row is None:
|
||||
session.add(DemoSetting(key=SCREENING, value=enabled))
|
||||
else:
|
||||
row.value = enabled
|
||||
await session.flush()
|
||||
Reference in New Issue
Block a user