TorbatYar/backend/services/healthcare/app/commands/appointments.py
Mortezakoohjani 625275e55b feat(healthcare): add backend service and finalize frontend build
Add the Healthcare platform backend (phases 13.0–13.7) with Alembic migration revision fix, production deploy script, validation reports, shared UI exports, and loyalty list page client directives so Next.js build succeeds.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 11:38:31 +03:30

73 lines
2.8 KiB
Python

"""Appointment command handlers — Phase 13.1."""
from __future__ import annotations
from uuid import UUID
from sqlalchemy.ext.asyncio import AsyncSession
from app.schemas.appointments import (
AppointmentCreate,
AppointmentLifecycleRequest,
AppointmentReschedule,
AppointmentTypeCreate,
AvailabilityWindowCreate,
ScheduleCreate,
WaitingListEntryCreate,
)
from app.services.appointments import (
AppointmentService,
AppointmentTypeService,
AvailabilityWindowService,
ScheduleService,
WaitingListService,
)
from shared.security import CurrentUser
class AppointmentCommands:
def __init__(self, session: AsyncSession) -> None:
self.schedules = ScheduleService(session)
self.availability = AvailabilityWindowService(session)
self.types = AppointmentTypeService(session)
self.appointments = AppointmentService(session)
self.waiting_list = WaitingListService(session)
async def create_schedule(self, tenant_id: UUID, body: ScheduleCreate, *, actor: CurrentUser | None):
return await self.schedules.create(tenant_id, body, actor=actor)
async def create_availability(
self, tenant_id: UUID, body: AvailabilityWindowCreate, *, actor: CurrentUser | None
):
return await self.availability.create(tenant_id, body, actor=actor)
async def create_type(self, tenant_id: UUID, body: AppointmentTypeCreate, *, actor: CurrentUser | None):
return await self.types.create(tenant_id, body, actor=actor)
async def book(self, tenant_id: UUID, body: AppointmentCreate, *, actor: CurrentUser | None):
return await self.appointments.book(tenant_id, body, actor=actor)
async def confirm(
self, tenant_id: UUID, appointment_id: UUID, body: AppointmentLifecycleRequest, *, actor
):
return await self.appointments.confirm(tenant_id, appointment_id, body, actor=actor)
async def cancel(
self, tenant_id: UUID, appointment_id: UUID, body: AppointmentLifecycleRequest, *, actor
):
return await self.appointments.cancel(tenant_id, appointment_id, body, actor=actor)
async def reschedule(
self, tenant_id: UUID, appointment_id: UUID, body: AppointmentReschedule, *, actor
):
return await self.appointments.reschedule(tenant_id, appointment_id, body, actor=actor)
async def mark_no_show(
self, tenant_id: UUID, appointment_id: UUID, body: AppointmentLifecycleRequest, *, actor
):
return await self.appointments.mark_no_show(tenant_id, appointment_id, body, actor=actor)
async def create_waiting_list(
self, tenant_id: UUID, body: WaitingListEntryCreate, *, actor: CurrentUser | None
):
return await self.waiting_list.create(tenant_id, body, actor=actor)