from typing import Dict, Any
from apps.appointments.models import Appointment


class AppointmentRepository:
    """
    Repository layer for Appointment DB operations.
    """

    @staticmethod
    def create_appointment(data: Dict[str, Any]) -> Appointment:
        """
        Create and return an Appointment instance.
        Expects `data` keys to match Appointment model fields.
        """
        return Appointment.objects.create(**data)

    @staticmethod
    def get_queryset():
        return Appointment.objects.all()

    @staticmethod
    def get_by_id(appointment_id: int) -> Appointment:
        """
        Retrieve an Appointment by its ID.
        Returns None if not found.
        """
        return AppointmentRepository.get_queryset().filter(id=appointment_id).first()
