from django.urls import include, path from rest_framework.routers import DefaultRouter from .views import ( DepartmentViewSet, HospitalViewSet, LocationViewSet, MainSectionViewSet, OrganizationViewSet, PatientViewSet, StaffViewSet, SubSectionViewSet, api_location_list, api_main_section_list, api_staff_hierarchy, api_staff_hierarchy_children, api_subsection_list, ajax_main_sections, ajax_subsections, ) from . import ui_views from .ui_views import ( department_create, department_update, department_delete, section_list, section_create, section_update, section_delete, subsection_list, subsection_create, subsection_update, subsection_delete, ) app_name = 'organizations' router = DefaultRouter() router.register(r'organizations', OrganizationViewSet, basename='organization-api') router.register(r'hospitals', HospitalViewSet, basename='hospital-api') router.register(r'departments', DepartmentViewSet, basename='department-api') router.register(r'staff', StaffViewSet, basename='staff-api') router.register(r'patients', PatientViewSet, basename='patient-api') router.register(r'locations', LocationViewSet, basename='location-api') router.register(r'main-sections', MainSectionViewSet, basename='main-section-api') router.register(r'subsections', SubSectionViewSet, basename='subsection-api') urlpatterns = [ # UI Views (come first - more specific routes) path('organizations/create/', ui_views.organization_create, name='organization_create'), path('organizations//', ui_views.organization_detail, name='organization_detail'), path('organizations/', ui_views.organization_list, name='organization_list'), path('hospitals/', ui_views.hospital_list, name='hospital_list'), path('departments/', ui_views.department_list, name='department_list'), path('staff/create/', ui_views.staff_create, name='staff_create'), path('staff//edit/', ui_views.staff_update, name='staff_update'), path('staff//', ui_views.staff_detail, name='staff_detail'), path('staff/hierarchy/d3/', ui_views.staff_hierarchy_d3, name='staff_hierarchy_d3'), path('staff/hierarchy/', ui_views.staff_hierarchy, name='staff_hierarchy'), path('staff/', ui_views.staff_list, name='staff_list'), path('patients/', ui_views.patient_list, name='patient_list'), path('patients/create/', ui_views.patient_create, name='patient_create'), path('patients//', ui_views.patient_detail, name='patient_detail'), path('patients//edit/', ui_views.patient_update, name='patient_update'), path('patients//delete/', ui_views.patient_delete, name='patient_delete'), # Department CRUD path('departments/create/', department_create, name='department_create'), path('departments//edit/', department_update, name='department_update'), path('departments//delete/', department_delete, name='department_delete'), # Section CRUD path('sections/', section_list, name='section_list'), path('sections/create/', section_create, name='section_create'), path('sections//edit/', section_update, name='section_update'), path('sections//delete/', section_delete, name='section_delete'), # Subsection CRUD path('subsections/', subsection_list, name='subsection_list'), path('subsections/create/', subsection_create, name='subsection_create'), path('subsections//edit/', subsection_update, name='subsection_update'), path('subsections//delete/', subsection_delete, name='subsection_delete'), # API Routes for complaint form dropdowns (public access) path('dropdowns/locations/', api_location_list, name='api_location_list'), path('dropdowns/main-sections/', api_main_section_list, name='api_main_section_list'), path('dropdowns/subsections/', api_subsection_list, name='api_subsection_list'), # AJAX Routes for cascading dropdowns in complaint form path('ajax/main-sections/', ajax_main_sections, name='ajax_main_sections'), path('ajax/subsections/', ajax_subsections, name='ajax_subsections'), # Staff Hierarchy API (for D3 visualization) path('api/staff/hierarchy/', api_staff_hierarchy, name='api_staff_hierarchy'), path('api/staff/hierarchy//children/', api_staff_hierarchy_children, name='api_staff_hierarchy_children'), # API Routes (must come last - catches anything not matched above) path('api/', include(router.urls)), ]