"""Router Patients (médical) : dossier clinique + langue par patient.""" from __future__ import annotations from fastapi import APIRouter from pydantic import BaseModel from kazeia_central.core.context import Ctx from . import service as svc class _Fiche(BaseModel): fiche: dict language: str | None = None class _Lang(BaseModel): language: str def make_router(ctx: Ctx) -> APIRouter: r = APIRouter(prefix="/api/patients", tags=["patients"]) g, now = ctx.guard, ctx.now_ms @r.get("/{serial}") def list_patients(serial: str): return g(lambda: svc.list_patients(ctx.adb, ctx.store, serial)) @r.get("/{serial}/{profile_id}") def get_patient(serial: str, profile_id: str): return g(lambda: svc.get_patient(ctx.adb, ctx.store, serial, profile_id)) @r.put("/{serial}/{profile_id}/fiche") def save_fiche(serial: str, profile_id: str, body: _Fiche): return g(lambda: svc.save_fiche(ctx.store, serial, profile_id, body.fiche, body.language, now=now(), actor=ctx.operator)) @r.put("/{serial}/{profile_id}/language") def set_language(serial: str, profile_id: str, body: _Lang): return g(lambda: svc.set_language(ctx.adb, ctx.store, serial, profile_id, body.language, now=now(), actor=ctx.operator)) return r