Spaces:
Running
Running
| import uuid | |
| from typing import List, TYPE_CHECKING | |
| from sqlmodel import Field, SQLModel, Relationship | |
| from .membership import Membership | |
| if TYPE_CHECKING: | |
| from .user import User | |
| from .procedure import Procedure | |
| from .institution import Institution | |
| from .team_procedure_value import TeamProcedureValue | |
| class Team(SQLModel, table=True): | |
| """ | |
| Represents a medical group within an institution. | |
| Holds goals and invite codes. | |
| """ | |
| __tablename__ = "teams" | |
| id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True) | |
| name: str = Field(nullable=False) | |
| institution_id: uuid.UUID = Field(foreign_key="institutions.id", nullable=False) | |
| invite_code: str = Field(unique=True, index=True, nullable=False) | |
| revenue_goal: float = Field(default=0.0, nullable=False) | |
| procedure_goal: int = Field(default=0, nullable=False) | |
| safety_goal: float = Field(default=3.0, description="Meta máxima de complicações (%)") | |
| # Relationships | |
| institution: "Institution" = Relationship(back_populates="teams") | |
| members: List["User"] = Relationship(back_populates="teams", link_model=Membership) | |
| procedures: List["Procedure"] = Relationship(back_populates="team") | |
| procedure_values: List["TeamProcedureValue"] = Relationship(back_populates="team") | |