"""
Physicians URL Configuration
"""

from django.urls import path
from rest_framework.routers import DefaultRouter

from . import api_views, import_views, ui_views, views

app_name = "physicians"

# API Router
router = DefaultRouter()
router.register(r"api/physicians", views.PhysicianViewSet, basename="physician")
router.register(r"api/physicians/ratings", views.PhysicianMonthlyRatingViewSet, basename="physician-rating")

# UI URL patterns
urlpatterns = [
    # Overview pages
    path("overview/specialization/", ui_views.specialization_overview, name="specialization_overview"),
    path("overview/department/", ui_views.department_overview, name="department_overview"),
    # Physician management
    path("", ui_views.physician_list, name="physician_list"),
    path("<uuid:pk>/", ui_views.physician_detail, name="physician_detail"),
    # Leaderboard
    path("leaderboard/", ui_views.leaderboard, name="leaderboard"),
    # Dashboard
    path("dashboard/", ui_views.physician_ratings_dashboard, name="physician_ratings_dashboard"),
    path("api/dashboard/", ui_views.physician_ratings_dashboard_api, name="physician_ratings_dashboard_api"),
    # Monthly Ratings
    path("ratings/", ui_views.ratings_list, name="ratings_list"),
    path("ratings/export/", ui_views.ratings_export, name="ratings_export"),
    # Individual Ratings & Import
    path("individual-ratings/", import_views.individual_ratings_list, name="individual_ratings_list"),
    # Doctor Rating Import (CSV Upload)
    path("import/", import_views.doctor_rating_import, name="doctor_rating_import"),
    # Doctor Rating Fetch (HIS API)
    path("fetch/", import_views.doctor_rating_fetch, name="doctor_rating_fetch"),
    path("import/review/", import_views.doctor_rating_review, name="doctor_rating_review"),
    path("import/jobs/", import_views.doctor_rating_job_list, name="doctor_rating_job_list"),
    path("import/jobs/<uuid:job_id>/", import_views.doctor_rating_job_status, name="doctor_rating_job_status"),
    # API Endpoints for Doctor Rating Import
    # Single rating import (authenticated)
    path("api/ratings/import/single/", api_views.import_single_rating, name="api_import_single_rating"),
    # Bulk rating import (authenticated, background processing)
    path("api/ratings/import/bulk/", api_views.import_bulk_ratings, name="api_import_bulk_ratings"),
    # Import job status
    path("api/ratings/import/jobs/", api_views.import_job_list, name="api_import_job_list"),
    path("api/ratings/import/jobs/<uuid:job_id>/", api_views.import_job_status, name="api_import_job_status"),
    # HIS-compatible endpoint (for direct HIS integration)
    path("api/ratings/his/", api_views.his_doctor_rating_handler, name="api_his_doctor_rating"),
    # Trigger monthly aggregation
    path("api/ratings/aggregate/", api_views.trigger_monthly_aggregation, name="api_trigger_aggregation"),
    # AJAX endpoints
    path("api/jobs/<uuid:job_id>/progress/", import_views.api_job_progress, name="api_job_progress"),
    path("api/match-doctor/", import_views.api_match_doctor, name="api_match_doctor"),
]

# Add API routes
urlpatterns += router.urls
