feat(backend): patient garden — deterministic growth from activities
CI / ruff · pytest (pull_request) Successful in 2m17s

GET /api/v1/me/{token}/garden computes the garden on the fly from taken doses,
check-ins/diary and finished questionnaires (no new table). Rules and texts in
config/garden.yaml: per-day caps, points only add up, answers never count.

Refs #118

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 11:22:44 +03:00
co-authored by Claude Opus 5.5
parent 4b166cf488
commit 1cafaa87ec
4 changed files with 295 additions and 0 deletions
+13
View File
@@ -43,6 +43,7 @@ from app.db.intake import QuestionnaireRecord
from app.db.session import get_clinical_session, get_identity_session
from app.integrations.emias_mock import CODE_MAX_LEN, EmiasMock
from app.services import anonymous_care
from app.services.garden import Garden, garden_for
log = logging.getLogger(__name__)
@@ -374,6 +375,18 @@ async def my_today(token: str) -> TodayOut:
)
@router.get("/me/{token}/garden", response_model=Garden)
async def my_garden(token: str) -> Garden:
"""The patient's garden (#118): grows from medication marks, check-ins/diary and finished questionnaires.
Never shrinks and never depends on answers. Seen only by the patient — not on the dashboard, not in summaries.
"""
async with get_clinical_session() as s:
if await repo.get_profile(s, token) is None:
raise HTTPException(404, "patient not found")
return await garden_for(s, token)
class ResultFinding(BaseModel):
code: str
title: str