"""Doctor panel query handlers — Phase 13.2."""
from __future__ import annotations

from uuid import UUID

from sqlalchemy.ext.asyncio import AsyncSession

from app.services.doctor_panel import VisitNoteService, VisitSessionService
from app.specifications.doctor_panel import VisitSessionListSpec


class DoctorPanelQueries:
    def __init__(self, session: AsyncSession) -> None:
        self.sessions = VisitSessionService(session)
        self.notes = VisitNoteService(session)

    async def get_session(self, tenant_id: UUID, visit_session_id: UUID):
        return await self.sessions.get(tenant_id, visit_session_id)

    async def list_sessions(
        self,
        tenant_id: UUID,
        *,
        offset: int = 0,
        limit: int = 20,
        spec: VisitSessionListSpec | None = None,
    ):
        return await self.sessions.list(tenant_id, offset=offset, limit=limit, spec=spec)

    async def dashboard(self, tenant_id: UUID, *, doctor_id: UUID):
        return await self.sessions.dashboard(tenant_id, doctor_id=doctor_id)

    async def queue(self, tenant_id: UUID, *, doctor_id: UUID):
        return await self.sessions.queue(tenant_id, doctor_id=doctor_id)

    async def list_notes(self, tenant_id: UUID, visit_session_id: UUID):
        return await self.notes.list_by_session(tenant_id, visit_session_id)
