Server backup 2026-11-07 of uncommitted work in projects/pharma-web-celtic

Snapshot of the working tree on srv1071960 (branch main), taken during
server cleanup. .env files, node_modules, builds, logs and media were excluded.
This commit is contained in:
Shubhankar45
2026-11-07 05:43:12 +00:00
parent b001e2d03c
commit 0d30c58bf0
98 changed files with 1878 additions and 573 deletions
+27 -10
View File
@@ -17,9 +17,15 @@ router = APIRouter(prefix="/doctors", tags=["doctors"])
@router.get("", response_model=list[DoctorRead])
async def list_doctors(
current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db)
) -> list[Doctor]:
) -> list[DoctorRead]:
"""S5 — an MR gets only their assigned doctors; managers get their HQ scope."""
return await DoctorService(db).list_for(current_user)
rows = await DoctorService(db).list_for(current_user)
return [
DoctorRead.model_validate(doctor).model_copy(
update={"assigned_mr_name": assigned_mr_name, "assigned_mr_id": mr_id}
)
for doctor, assigned_mr_name, mr_id in rows
]
@router.post("", response_model=DoctorRead, status_code=status.HTTP_201_CREATED)
@@ -29,7 +35,7 @@ async def create_doctor(
current_user: User = Depends(require_role(Role.ADMIN, Role.MR)),
db: AsyncSession = Depends(get_db),
) -> Doctor:
"""An Administrator, or an MR within their own headquarters (AM and GM cannot)."""
"""An Administrator, or an MR within their own headquarters (ABM and AGM cannot)."""
return await DoctorService(db).create(payload, current_user, client_ip(request))
@@ -44,15 +50,26 @@ async def update_doctor(
return await DoctorService(db).update(doctor_id, payload, current_user, client_ip(request))
@router.delete("/{doctor_id}/assign", status_code=status.HTTP_204_NO_CONTENT)
async def unassign_doctor(
doctor_id: uuid.UUID,
request: Request,
current_user: User = Depends(require_role(Role.ADMIN)),
db: AsyncSession = Depends(get_db),
) -> None:
"""Administrator only: leave the doctor with no MR."""
await DoctorService(db).unassign(doctor_id, current_user, client_ip(request))
@router.post("/{doctor_id}/assign", status_code=status.HTTP_201_CREATED)
async def assign_doctor(
doctor_id: uuid.UUID,
payload: AssignToMR,
request: Request,
current_user: User = Depends(require_role(Role.ADMIN, Role.GM, Role.AM)),
current_user: User = Depends(require_role(Role.ADMIN, Role.AGM, Role.ABM)),
db: AsyncSession = Depends(get_db),
):
"""An AM may assign only within their own headquarters — enforced by data scope."""
"""An ABM may assign only within their own headquarters — enforced by data scope."""
assignment = await DoctorService(db).assign_to_mr(
doctor_id, payload.mr_user_id, payload.effective_from, current_user, client_ip(request)
)
@@ -68,8 +85,8 @@ async def assign_doctor(
async def list_doctor_requests(
current_user: User = Depends(get_current_user), db: AsyncSession = Depends(get_db)
) -> list[Doctor]:
"""Doctors an MR added that wait for the Area Manager: an MR sees their own (with any
rejected and why), an Area Manager what waits for them, the administrator and GM all."""
"""Doctors an MR added that wait for the Area Business Manager: an MR sees their own (with any
rejected and why), an Area Business Manager what waits for them, the administrator and AGM all."""
return await DoctorService(db).requests_for(current_user)
@@ -77,10 +94,10 @@ async def list_doctor_requests(
async def approve_doctor(
doctor_id: uuid.UUID,
request: Request,
current_user: User = Depends(require_role(Role.AM, Role.ADMIN)),
current_user: User = Depends(require_role(Role.ABM, Role.ADMIN)),
db: AsyncSession = Depends(get_db),
) -> Doctor:
"""The Area Manager of its headquarters adds it to the list, assigned to the MR who asked."""
"""The Area Business Manager of its headquarters adds it to the list, assigned to the MR who asked."""
return await DoctorService(db).review(doctor_id, True, None, current_user, client_ip(request))
@@ -89,7 +106,7 @@ async def reject_doctor(
doctor_id: uuid.UUID,
payload: RejectMaster,
request: Request,
current_user: User = Depends(require_role(Role.AM, Role.ADMIN)),
current_user: User = Depends(require_role(Role.ABM, Role.ADMIN)),
db: AsyncSession = Depends(get_db),
) -> Doctor:
return await DoctorService(db).review(doctor_id, False, payload.reason, current_user, client_ip(request))