25 lines
794 B
Python
25 lines
794 B
Python
"""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}"
|