--
This commit is contained in:
@@ -15,6 +15,7 @@ from sqlalchemy import Boolean, Date, ForeignKey, Index, String, UniqueConstrain
|
||||
from sqlalchemy.dialects.postgresql import UUID as PGUUID
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.common.enums import MasterApproval
|
||||
from app.database.base import Base, TimestampMixin, UUIDMixin
|
||||
|
||||
|
||||
@@ -35,9 +36,26 @@ class Doctor(Base, UUIDMixin, TimestampMixin):
|
||||
qualification: Mapped[str | None] = mapped_column(String(100))
|
||||
clinic_address: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
contact_number: Mapped[str | None] = mapped_column(String(20))
|
||||
date_of_birth: Mapped[date | None] = mapped_column(Date)
|
||||
#: Core doctors are the high-value targets tracked for conversion.
|
||||
is_core_doctor: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
|
||||
#: PENDING until the Area Manager approves one an MR added; only APPROVED ones are listed or visited.
|
||||
approval_status: Mapped[str] = mapped_column(
|
||||
String(10), default=MasterApproval.APPROVED.value, server_default=MasterApproval.APPROVED.value, nullable=False
|
||||
)
|
||||
#: The MR who asked for it (None for one the administrator created).
|
||||
requested_by_user_id: Mapped[uuid.UUID | None] = mapped_column(
|
||||
PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="SET NULL")
|
||||
)
|
||||
rejection_reason: Mapped[str | None] = mapped_column(String(500))
|
||||
requested_by: Mapped["User | None"] = relationship( # noqa: F821
|
||||
lazy="selectin", foreign_keys=[requested_by_user_id]
|
||||
)
|
||||
|
||||
@property
|
||||
def requested_by_name(self) -> str | None:
|
||||
return self.requested_by.full_name if self.requested_by else None
|
||||
|
||||
assignments: Mapped[list["DoctorAssignment"]] = relationship(back_populates="doctor")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user