Production

This commit is contained in:
Shubhankar45
2026-09-22 06:23:46 +00:00
commit 8fdd20b29f
217 changed files with 31212 additions and 0 deletions
+126
View File
@@ -0,0 +1,126 @@
import uuid
from datetime import date, datetime, time
from pydantic import BaseModel, ConfigDict, Field
from app.common.enums import CallOutcome, ConversionStatus, DCRStatus, Role
from app.config.settings import settings
class DoctorCallCreate(BaseModel):
doctor_id: uuid.UUID
visit_time: time
call_outcome: CallOutcome
#: V7 — accepted only when the doctor is flagged as a core doctor.
conversion_status: ConversionStatus | None = None
product_promote: str | None = Field(default=None, max_length=200)
product_sample: str | None = Field(default=None, max_length=200)
remarks: str | None = Field(default=None, max_length=2000)
class ChemistCallCreate(BaseModel):
chemist_id: uuid.UUID
visit_time: time
pob: str | None = Field(default=None, max_length=100)
remarks: str | None = Field(default=None, max_length=2000)
class DoctorCallRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
doctor_id: uuid.UUID
doctor_name: str
doctor_speciality: str | None
is_core_doctor: bool
visit_time: time
call_outcome: CallOutcome
conversion_status: ConversionStatus | None
product_promote: str | None
product_sample: str | None
remarks: str | None
class ChemistCallRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
chemist_id: uuid.UUID
chemist_name: str
visit_time: time
pob: str | None
remarks: str | None
class DCRCreate(BaseModel):
report_date: date
mr_remarks: str | None = Field(default=None, max_length=2000)
doctor_calls: list[DoctorCallCreate] = Field(default_factory=list)
chemist_calls: list[ChemistCallCreate] = Field(default_factory=list)
class DCRUpdate(BaseModel):
mr_remarks: str | None = Field(default=None, max_length=2000)
stockist_visit: str | None = Field(default=None, max_length=200)
order_value: str | None = Field(default=None, max_length=100)
class ReturnRequest(BaseModel):
"""V8 — a manager must say WHY. This reason is what makes the audit trail useful."""
reason: str = Field(min_length=settings.MIN_RETURN_REASON_LENGTH, max_length=2000)
class ApproveRequest(BaseModel):
comment: str | None = Field(default=None, max_length=2000)
class DCRListItem(BaseModel):
"""Row for S2/S6 — the list screens that replaced the cut dashboards."""
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
report_date: date
status: DCRStatus
mr_user_id: uuid.UUID
mr_name: str
headquarters_id: uuid.UUID
headquarters_name: str
doctor_call_count: int
chemist_call_count: int
submitted_at: datetime | None
approved_at: datetime | None
returned_by_role: Role | None
class DCRRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
mr_user_id: uuid.UUID
mr_name: str
employee_code: str
headquarters_id: uuid.UUID
headquarters_name: str
report_date: date
status: DCRStatus
is_locked: bool
mr_remarks: str | None
stockist_visit: str | None
order_value: str | None
return_reason: str | None
returned_by_role: Role | None
submitted_at: datetime | None
approved_at: datetime | None
doctor_calls: list[DoctorCallRead]
chemist_calls: list[ChemistCallRead]
class StatusCounts(BaseModel):
"""Header counts on the list screens — the cheap replacement for dashboards."""
DRAFT: int = 0
PENDING_AM: int = 0
RETURNED: int = 0
APPROVED: int = 0