Add the Healthcare platform backend (phases 13.0–13.7) with Alembic migration revision fix, production deploy script, validation reports, shared UI exports, and loyalty list page client directives so Next.js build succeeds. Co-authored-by: Cursor <cursoragent@cursor.com>
23 lines
734 B
Python
23 lines
734 B
Python
"""Patient-scoped API dependencies — Phase 13.4."""
|
|
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from fastapi import Depends, Header
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.api.deps import get_db, require_tenant
|
|
from app.repositories.profiles import PatientRepository
|
|
from shared.exceptions import NotFoundError
|
|
|
|
|
|
async def require_patient_context(
|
|
tenant_id: UUID = Depends(require_tenant),
|
|
db: AsyncSession = Depends(get_db),
|
|
x_patient_id: UUID = Header(..., alias="X-Patient-ID"),
|
|
) -> UUID:
|
|
repo = PatientRepository(db)
|
|
if await repo.get(tenant_id, x_patient_id) is None:
|
|
raise NotFoundError("بیمار یافت نشد")
|
|
return x_patient_id
|