68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
import uuid
|
|
from datetime import date, datetime
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
|
|
def _not_in_future(value: date | None) -> date | None:
|
|
if value is not None and value > date.today():
|
|
raise ValueError("date_of_birth cannot be in the future")
|
|
return value
|
|
|
|
|
|
class DoctorCreate(BaseModel):
|
|
headquarters_id: uuid.UUID
|
|
name: str = Field(min_length=2, max_length=200)
|
|
clinic_address: str = Field(min_length=2, max_length=500)
|
|
speciality: str | None = Field(default=None, max_length=100)
|
|
qualification: str | None = Field(default=None, max_length=100)
|
|
contact_number: str | None = Field(default=None, max_length=20)
|
|
date_of_birth: date | None = None
|
|
is_core_doctor: bool = False
|
|
|
|
_check_dob = field_validator("date_of_birth")(_not_in_future)
|
|
|
|
|
|
class DoctorUpdate(BaseModel):
|
|
name: str | None = Field(default=None, min_length=2, max_length=200)
|
|
clinic_address: str | None = Field(default=None, min_length=2, max_length=500)
|
|
speciality: str | None = Field(default=None, max_length=100)
|
|
qualification: str | None = Field(default=None, max_length=100)
|
|
contact_number: str | None = Field(default=None, max_length=20)
|
|
date_of_birth: date | None = None
|
|
is_core_doctor: bool | None = None
|
|
is_active: bool | None = None
|
|
|
|
_check_dob = field_validator("date_of_birth")(_not_in_future)
|
|
|
|
|
|
class DoctorRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
id: uuid.UUID
|
|
headquarters_id: uuid.UUID
|
|
name: str
|
|
clinic_address: str
|
|
speciality: str | None
|
|
qualification: str | None
|
|
contact_number: str | None
|
|
date_of_birth: date | None
|
|
is_core_doctor: bool
|
|
is_active: bool
|
|
#: PENDING / APPROVED / REJECTED — see app/common/master_approval.py.
|
|
approval_status: str
|
|
rejection_reason: str | None
|
|
requested_by_name: str | None
|
|
created_at: datetime
|
|
|
|
|
|
class AssignToMR(BaseModel):
|
|
mr_user_id: uuid.UUID
|
|
effective_from: date | None = None
|
|
|
|
|
|
class RejectMaster(BaseModel):
|
|
"""Why the Area Manager refused a doctor or chemist an MR added — shown to that MR."""
|
|
|
|
reason: str = Field(min_length=3, max_length=500)
|