from django.urls import include, path from rest_framework.routers import DefaultRouter from .views import ( PublicSurveyViewSet, SurveyInstanceViewSet, SurveyQuestionViewSet, SurveyResponseViewSet, SurveyTemplateViewSet, ) from .analytics_views import SurveyAnalyticsViewSet, SurveyTrackingViewSet from . import public_views, ui_views, his_views app_name = "surveys" router = DefaultRouter() router.register(r"api/templates", SurveyTemplateViewSet, basename="survey-template-api") router.register(r"api/questions", SurveyQuestionViewSet, basename="survey-question-api") router.register(r"api/instances", SurveyInstanceViewSet, basename="survey-instance-api") router.register(r"api/responses", SurveyResponseViewSet, basename="survey-response-api") router.register(r"api/analytics", SurveyAnalyticsViewSet, basename="survey-analytics-api") router.register(r"api/tracking", SurveyTrackingViewSet, basename="survey-tracking-api") urlpatterns = [ # Public survey pages (no auth required) path("invalid/", public_views.invalid_token, name="invalid_token"), # UI Views (authenticated) - specific paths first path("send/", ui_views.manual_survey_send, name="manual_send"), path("send/phone/", ui_views.manual_survey_send_phone, name="manual_send_phone"), path("send/csv/", ui_views.manual_survey_send_csv, name="manual_send_csv"), # HIS Patient Import path("his-import/", his_views.his_patient_import, name="his_patient_import"), path("his-import/review/", his_views.his_patient_review, name="his_patient_review"), path("his-import/send/", his_views.his_patient_survey_send, name="his_patient_survey_send"), # Bulk Survey Jobs path("bulk-jobs/", his_views.bulk_job_list, name="bulk_job_list"), path("bulk-jobs//", his_views.bulk_job_status, name="bulk_job_status"), path("reports/", ui_views.survey_analytics_reports, name="analytics_reports"), path( "reports//view/", ui_views.survey_analytics_report_view_inline, name="analytics_report_view_inline", ), path( "reports//download/", ui_views.survey_analytics_report_download, name="analytics_report_download" ), path("reports//delete/", ui_views.survey_analytics_report_delete, name="analytics_report_delete"), path("reports//", ui_views.survey_analytics_report_view, name="analytics_report_view"), # Enhanced Reports (separate report per survey type) path("enhanced-reports/", ui_views.enhanced_survey_reports_list, name="enhanced_reports_list"), path("enhanced-reports/generate/", ui_views.generate_enhanced_report_ui, name="generate_enhanced_report"), path("enhanced-reports//", ui_views.enhanced_survey_report_view, name="enhanced_report_view"), path( "enhanced-reports//", ui_views.enhanced_survey_report_file, name="enhanced_report_file", ), path("comments/", ui_views.survey_comments_list, name="survey_comments_list"), path("instances/", ui_views.survey_instance_list, name="instance_list"), path("instances//", ui_views.survey_instance_detail, name="instance_detail"), path("instances//log-contact/", ui_views.survey_log_patient_contact, name="log_patient_contact"), path( "instances//send-satisfaction/", ui_views.survey_send_satisfaction_feedback, name="send_satisfaction_feedback", ), # Survey Templates (manual/ad-hoc surveys) path("templates/", ui_views.survey_template_list, name="template_list"), path("templates/create/", ui_views.survey_template_create, name="template_create"), path("templates//", ui_views.survey_template_detail, name="template_detail"), path("templates//edit/", ui_views.survey_template_edit, name="template_edit"), path("templates//delete/", ui_views.survey_template_delete, name="template_delete"), # Public API endpoints (no auth required) path("public//", PublicSurveyViewSet.as_view({"get": "retrieve"}), name="public-survey"), path("public//submit/", PublicSurveyViewSet.as_view({"post": "submit"}), name="public-survey-submit"), # Authenticated API endpoints path("", include(router.urls)), # Public survey token access (requires /s/ prefix) path("s//", public_views.survey_form, name="survey_form"), path("s//thank-you/", public_views.thank_you, name="thank_you"), path("s//track-start/", public_views.track_survey_start, name="track_survey_start"), ]