86 lines
3.1 KiB
Python
86 lines
3.1 KiB
Python
from fastapi import APIRouter, Request
|
|
|
|
from services.clinicServices import ClinicServices
|
|
from schemas.UpdateSchemas import ClinicStatusUpdate
|
|
from schemas.ApiResponse import ApiResponse
|
|
from schemas.BaseSchemas import CreateSuperAdmin, MasterAppointmentTypeBase, ClinicOffersBase
|
|
from services.authService import AuthService
|
|
from services.masterAppointmentServices import MasterAppointmentServices
|
|
from utils.constants import DEFAULT_LIMIT, DEFAULT_PAGE
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.put("/clinic/status")
|
|
def update_clinic_status(req:Request, data: ClinicStatusUpdate):
|
|
response = ClinicServices().update_clinic_status(req.state.user, data.clinic_id, data.status, data.documentStatus, data.rejection_reason)
|
|
return ApiResponse(data=response, message="Clinic status updated successfully")
|
|
|
|
|
|
@router.post("/user")
|
|
def create_user(req:Request, user_data: CreateSuperAdmin):
|
|
AuthService().create_super_admin(req.state.user, user_data)
|
|
return ApiResponse(data="OK", message="User created successfully")
|
|
|
|
|
|
@router.get("/")
|
|
def get_users(req:Request, limit:int = DEFAULT_LIMIT, page:int = DEFAULT_PAGE, search:str = ""):
|
|
if page < 1:
|
|
page = 1
|
|
offset = (page - 1) * limit
|
|
users = AuthService().get_admins(req.state.user, limit, offset, search)
|
|
return ApiResponse(data=users, message="Users retrieved successfully")
|
|
|
|
@router.post("/master-data")
|
|
def create_master_data(appointment_type: MasterAppointmentTypeBase):
|
|
MasterAppointmentServices().create_master_appointment_type(appointment_type)
|
|
return ApiResponse(data="OK", message="Master data created successfully")
|
|
|
|
|
|
@router.get("/master-data")
|
|
def get_master_data():
|
|
appointment_types = MasterAppointmentServices().get_master_appointment_types()
|
|
return ApiResponse(data=appointment_types, message="Master data retrieved successfully")
|
|
|
|
|
|
|
|
@router.get("/clinic/offers")
|
|
async def get_clinic_offers(
|
|
req:Request,
|
|
page: int = DEFAULT_PAGE,
|
|
limit: int = DEFAULT_LIMIT,
|
|
search:str = ""
|
|
):
|
|
if page < 1:
|
|
page = 1
|
|
offset = (page - 1) * limit
|
|
|
|
clinic_offers = ClinicServices().get_clinic_offers(req.state.user, limit, offset, search)
|
|
return ApiResponse(data=clinic_offers, message="Clinic offers retrieved successfully")
|
|
|
|
|
|
@router.post("/clinic/offer")
|
|
async def create_clinic_offer(
|
|
req:Request,
|
|
clinic_offer: ClinicOffersBase
|
|
):
|
|
ClinicServices().create_clinic_offer(req.state.user, clinic_offer)
|
|
return ApiResponse(data="OK", message="Clinic offer created successfully")
|
|
|
|
@router.put("/clinic/offer/{clinic_offer_id}")
|
|
async def update_clinic_offer(
|
|
req:Request,
|
|
clinic_offer_id: int,
|
|
clinic_offer: ClinicOffersBase
|
|
):
|
|
ClinicServices().update_clinic_offer(req.state.user, clinic_offer_id, clinic_offer)
|
|
return ApiResponse(data="OK", message="Clinic offer updated successfully")
|
|
|
|
@router.delete("/clinic/offer/{clinic_offer_id}")
|
|
async def delete_clinic_offer(
|
|
req:Request,
|
|
clinic_offer_id: int
|
|
):
|
|
ClinicServices().delete_clinic_offer(req.state.user, clinic_offer_id)
|
|
return ApiResponse(data="OK", message="Clinic offer deleted successfully")
|
|
|