"""
URL configuration for childrensun project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.views.static import serve
from django.contrib import admin
from django.contrib.auth.views import LoginView, LogoutView
from django.urls import path, include, re_path
from childmonitoring.views import (
    login_view, home, create_outpatient_view, list_outpatients_view, create_school_view,
    list_schools_view, create_region_view, list_regions_view, delete_region,  update_school_view, delete_school,
    update_region_view, create_leisure_view, list_leisure_view, update_leisure_view,
    day_hospital_create_view, update_day_hospital_view, list_day_hospital_view, day_hospital_delete,
    create_case_view, update_case_view, list_case_view, case_delete, delete_leisure, list_sunchild_view,
    details_sunchild_view, delete_surgical_medical_history, list_surgical_medical_history_view,
    update_surgical_medical_history_view, create_surgical_medical_history_view, create_family_medical_history_view,
    delete_family_medical_history, list_family_medical_history_view, update_family_medical_history_view,
    update_password, create_identified_allergy_view, update_identified_allergy_view, list_identified_allergy_view,
    delete_identified_allergy, create_identified_pathology_view, update_identified_pathology_view,
    list_identified_pathology_view, delete_identified_pathology, create_base_medical_history_view,
    update_base_medical_history_view, list_base_medical_history_view, delete_base_medical_history,
    update_outpatient_view, delete_outpatient, details_day_hospital_view, list_reporting_view,
    index, all_events, add_event, update_event, delete_event,
    # Appointment
    all_appointments_view, list_appointments_view, create_appointment_view, update_appointment_view, delete_appointment_view,
    delete_specialist_report, list_specialist_report_view, update_specialist_report_view, create_specialist_report_view,
    list_speciality_view, delete_speciality, update_speciality_view, create_speciality_view, details_base_medical_history_view,
    details_speciality_view, details_specialist_report_view, details_school_view, details_outpatient_view, details_regions_view,
    details_leisure_view, details_case_view, details_surgical_view, details_family_view, details_identified_allergy_view,
    details_identified_pathology_view, create_child_view, delete_child_view, update_child_view,
    # Cases Paginator and Search
    cases_paginator, cases_search,
    # For Zam Project
    list_services_view, create_service_view, update_service_view, delete_service_view,
    create_patient_view, list_patients_view, update_patient_view, delete_patient_view,
    create_general_report_view, list_general_reports_view, update_general_report_view, delete_general_report_view,
    create_team_member_view, list_team_members_view, update_team_member_view, delete_team_member_view,
)


urlpatterns = [
    # For Zam Project
    # Team Member
    path('team_members/list/', list_team_members_view, name='list_team_members_view'),
    path('team_member/create/', create_team_member_view, name='create_team_member_view'),
    path('team_member/update/<int:pk>/', update_team_member_view, name='update_team_member_view'),
    path('team_member/delete/<int:pk>/', delete_team_member_view, name='delete_team_member_view'),

    # Services
    path('services/list/', list_services_view, name='list_services_view'),
    path('service/create/', create_service_view, name='create_service_view'),
    path('service/update/<int:pk>/', update_service_view, name='update_service_view'),
    path('service/delete/<int:pk>/', delete_service_view, name='delete_service_view'),

    # Patients
    path('patient/create/', create_patient_view, name='create_patient_view'),
    path('patients/list/', list_patients_view, name='list_patients_view'),
    path('patient/update/<int:pk>/', update_patient_view, name='update_patient_view'),
    path('patient/delete/<int:pk>/', delete_patient_view, name='delete_patient_view'),

    # General Reports
    path('general_report/create/', create_general_report_view, name='create_general_report_view'),
    path('general_reports/list/', list_general_reports_view, name='list_general_reports_view'),
    path('general_report/update/<int:pk>/', update_general_report_view, name='update_general_report_view'),
    path('general_report/delete/<int:pk>/', delete_general_report_view, name='delete_general_report_view'),

    # admin URL
    path('admin/', admin.site.urls),
    # Include authentication URLs
    path('accounts/', include('django.contrib.auth.urls')),
    # path('accounts/register/user/', register_user, name='register_user'),
    path('accounts/login/', LoginView.as_view(), name='login'),
    path('accounts/logout/', LogoutView.as_view(), name='logout'),
    # Other app URLs
    path('', list_services_view, name='list_services_view'),
    path('home/', home, name='home'),
    # Path for School
    path('school/create/', create_school_view, name='create_school_view'),
    path('schools/list/', list_schools_view, name='list_schools_view'),
    path('school/update/<int:pk>/', update_school_view, name='update_school_view'),
    path('school/delete/<int:pk>/', delete_school, name='delete_school'),
    path('school/details/<int:pk>/', details_school_view, name='details_school_view'),
    # Path for Region
    path('region/create)', create_region_view, name='create_region_view'),
    path('regions/list/', list_regions_view, name='list_regions_view'),
    path('region/update/<int:pk>/', update_region_view, name='update_region_view'),
    path('region/delete/<int:pk>/', delete_region, name='delete_region'),
    path('region/details/<int:pk>/', details_regions_view, name='details_regions_view'),

    # Path for Leisure
    path('leisure/create/', create_leisure_view, name='create_leisure_view'),
    path('leisure/list/', list_leisure_view, name='list_leisure_view'),
    path('leisure/update/<int:pk>/', update_leisure_view, name='update_leisure_view'),
    path('leisure/delete/<int:pk>/', delete_leisure, name='delete_leisure'),
    path('leisure/details/<int:pk>/', details_leisure_view, name='details_leisure_view'),

    # Path for SunChild
    path('sunchild/list/', list_sunchild_view, name='list_sunchild_view'),
    path('sunchild/details/<int:pk>/', details_sunchild_view, name='details_sunchild_view'),
    path('sunchild/create/', create_child_view, name='create_child_view'),
    path('sunchild/delete/<int:pk>/', delete_child_view, name='delete_child_view'),
    path('sunchild/update/<int:pk>/', update_child_view, name='update_child_view'),

    # Path for DayHospital
    path('day_hospital/create/', day_hospital_create_view, name='day_hospital_create_view'),
    path('day_hospital/list/', list_day_hospital_view, name='list_day_hospital_view'),
    path('day_hospital/details/<int:pk>/', details_day_hospital_view, name='details_day_hospital_view'),
    path('day_hospital/update/<int:pk>/', update_day_hospital_view, name='update_day_hospital_view'),
    path('day_hospital/delete/<int:pk>/', day_hospital_delete, name='day_hospital_delete'),
    # Path for Case
    path('case/create/', create_case_view, name='create_case_view'),
    path('case/list/', list_case_view, name='list_case_view'),
    path('case/update/<int:pk>/', update_case_view, name='update_case_view'),
    path('case/delete/<int:pk>/', case_delete, name='case_delete'),
    path('case/details/<int:pk>/', details_case_view, name='details_case_view'),

    # Path for Outpatient
    path('outpatient/create/', create_outpatient_view, name='create_outpatient_view'),
    path('outpatients/list/', list_outpatients_view, name='list_outpatients_view'),
    path('outpatient/update/<int:pk>/', update_outpatient_view, name='update_outpatient_view'),
    path('outpatient/delete/<int:pk>/', delete_outpatient, name='delete_outpatient'),
    path('outpatient/details/<int:pk>/', details_outpatient_view, name='details_outpatient_view'),

    # Path for Reporting
    path('reporting/list/', list_reporting_view, name='list_reporting_view'),
    # Path for change Pasword
    path('password/update/', update_password, name='update_password'),

    # Path for SurgicalMedicalHistory
    path('surgical_medical_history/create/', create_surgical_medical_history_view, name='create_surgical_medical_history_view'),
    path('surgicalMedicalHistory/list/', list_surgical_medical_history_view, name='list_surgical_medical_history_view'),
    path('surgical_medical_history/update/<int:pk>/', update_surgical_medical_history_view, name='update_surgical_medical_history_view'),
    path('surgical_medical_history/delete/<int:pk>/', delete_surgical_medical_history, name='delete_surgical_medical_history'),
    path('surgical_medical_history/details/<int:pk>/', details_surgical_view, name='details_surgical_view'),

    # Path for FamilyMedicalHistory
    path('family_medical_history/create/', create_family_medical_history_view, name='create_family_medical_history_view'),
    path('family_medical_history/list/', list_family_medical_history_view, name='list_family_medical_history_view'),
    path('family_medical_history/update/<int:pk>/', update_family_medical_history_view, name='update_family_medical_history_view'),
    path('family_medical_history/delete/<int:pk>/', delete_family_medical_history, name='delete_family_medical_history'),
    path('family_medical_history/details/<int:pk>/', details_family_view, name='details_family_view'),

    # Path for IdentifiedAllergy
    path('identified_allergy/create/', create_identified_allergy_view, name='create_identified_allergy_view'),
    path('identified_allergy/list/', list_identified_allergy_view, name='list_identified_allergy_view'),
    path('identified_allergy/update/<int:pk>/', update_identified_allergy_view, name='update_identified_allergy_view'),
    path('identified_allergy/delete/<int:pk>/', delete_identified_allergy, name='delete_identified_allergy'),
    path('identified_allergy/details/<int:pk>/', details_identified_allergy_view, name='details_identified_allergy_view'),

    # Path for IdentifiedPathology
    path('identified_pathology/create/', create_identified_pathology_view, name='create_identified_pathology_view'),
    path('identified_pathology/list/', list_identified_pathology_view, name='list_identified_pathology_view'),
    path('identified_pathology/update/<int:pk>/', update_identified_pathology_view, name='update_identified_pathology_view'),
    path('identified_pathology/delete/<int:pk>/', delete_identified_pathology, name='delete_identified_pathology'),
    path('identified_pathology/details/<int:pk>/', details_identified_pathology_view, name='details_identified_pathology_view'),

    # Path for BaseMedicalHistory
    path('base_medical_history/create/', create_base_medical_history_view, name='create_base_medical_history_view'),
    path('base_medical_history/list/', list_base_medical_history_view, name='list_base_medical_history_view'),
    path('base_medical_history/update/<int:pk>/', update_base_medical_history_view,  name='update_base_medical_history_view'),
    path('base_medical_history/delete/<int:pk>/', delete_base_medical_history, name='delete_base_medical_history'),
    path('base_medical_history/details/<int:pk>/',details_base_medical_history_view, name='details_base_medical_history_view'),

    # Path for SpecialistReport
    path('specialist_report/create/', create_specialist_report_view, name='create_specialist_report_view'),
    path('specialist_report/list/', list_specialist_report_view, name='list_specialist_report_view'),
    path('specialist_report/update/<int:pk>/', update_specialist_report_view, name='update_specialist_report_view'),
    path('specialist_report/delete/<int:pk>/', delete_specialist_report, name='delete_specialist_report'),
    path('specialist_report/details/<int:pk>/', details_specialist_report_view, name='details_specialist_report_view'),

    # Path for Full Calendar
    path('index/', index, name='index'),
    path('all_events/', all_events, name='all_events'), # JsonResponse
    path('add_event/', add_event, name='add_event'),  # JsonResponse
    path('update_event/', update_event, name='update_event'),  # JsonResponse
    path('delete_event/', delete_event, name='delete_event'),  # JsonResponse

    # Path for Appointment
    path('appointments/list/', list_appointments_view, name='list_appointments_view'),
    path('appointments/all/', all_appointments_view, name='all_appointments_view'),
    path('appointment/create/', create_appointment_view, name='create_appointment_view'),  # JsonResponse
    path('appointment/update/', update_appointment_view, name='update_appointment_view'),  # JsonResponse
    path('appointment/delete/', delete_appointment_view, name='delete_appointment_view'),  # JsonResponse
    # Path for Speciality
    path('speciality/create/', create_speciality_view, name='create_speciality_view'),
    path('speciality/list/', list_speciality_view, name='list_speciality_view'),
    path('speciality/update/<int:pk>/', update_speciality_view, name='update_speciality_view'),
    path('speciality/delete/<int:pk>/', delete_speciality, name='delete_speciality'),
    path('speciality/details/<int:pk>/', details_speciality_view, name='details_speciality_view'),
    # Cases Paginator and Search
    path('cases/paginator/', cases_paginator, name='cases_paginator'),
    path('cases/search/', cases_search, name='cases_search'),
]

# Serve static files in development
if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
else:
    urlpatterns += [
        re_path(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}),
        re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
    ]
