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

from .ui_views import SurveyTemplateMappingViewSet, survey_mapping_settings
from .views import (
    EventMappingViewSet,
    HISPatientDataView,
    InboundEventViewSet,
    IntegrationConfigViewSet,
    SimulateHISPayloadView,
    TestHISDataView,
)

app_name = "integrations"

router = DefaultRouter()
router.register(r"configs", IntegrationConfigViewSet, basename="integration-config")
router.register(r"mappings", EventMappingViewSet, basename="event-mapping")
router.register(r"legacy-events", InboundEventViewSet, basename="inbound-event")
router.register(r"survey-template-mappings", SurveyTemplateMappingViewSet, basename="survey-template-mapping")

urlpatterns = [
    # Survey template mapping settings page
    path("settings/survey-mappings/", survey_mapping_settings, name="survey-mapping-settings"),
    # Main HIS integration endpoint - receives complete patient data
    path("events/", HISPatientDataView.as_view(), name="his-patient-data"),
    # Test HIS data endpoint - mimics real HIS API from loaded test data
    path("test-his-data/", TestHISDataView.as_view(), name="test-his-data"),
    # Simulate HIS payload - POST data to test the full pipeline
    path("simulate-his-payload/", SimulateHISPayloadView.as_view(), name="simulate-his-payload"),
    # Legacy event-based endpoint (deprecated, kept for backward compatibility)
    path("", include(router.urls)),
]
