<?php

use Illuminate\Support\Facades\Route;
use Modules\DentalClinic\Http\Controllers\DentalToothChartController;
use Modules\DentalClinic\Http\Controllers\DentalProcedureController;
use Modules\DentalClinic\Http\Controllers\DentalTreatmentPlanController;
use Modules\DentalClinic\Http\Controllers\DentalRecallController;

/*
 * DentalClinic is a ClinicCore plugin and provides no clinic UI of its own.
 * These routes back the interactive fragments the DentalSpecialtyDriver renders
 * into ClinicCore's shared patient and appointment screens: the tooth chart,
 * the procedures log, the treatment-plan builder, and the recall system.
 */
Route::middleware(['web', 'auth'])->prefix('dental')->name('dental.')->group(function () {
    // Interactive tooth chart (existing).
    Route::post('patients/{patient}/tooth-chart', [DentalToothChartController::class, 'update'])
        ->name('toothchart.update');

    // Procedures log (P5-T2).
    Route::get('patients/{patient}/procedures', [DentalProcedureController::class, 'index'])->name('procedures.index');
    Route::post('patients/{patient}/procedures', [DentalProcedureController::class, 'store'])->name('procedures.store');
    // NOTE: procedures.update PUT route removed — no UI wires it (controller
    // DentalProcedureController::update kept for a future edit surface).
    Route::delete('patients/{patient}/procedures/{procedure}', [DentalProcedureController::class, 'destroy'])->name('procedures.destroy');

    // Treatment-plan builder (P5-T2).
    Route::get('patients/{patient}/treatment-plan', [DentalTreatmentPlanController::class, 'index'])->name('plan.index');
    Route::post('patients/{patient}/treatment-plan', [DentalTreatmentPlanController::class, 'store'])->name('plan.store');
    Route::put('patients/{patient}/treatment-plan/{item}', [DentalTreatmentPlanController::class, 'update'])->name('plan.update');
    Route::delete('patients/{patient}/treatment-plan/{item}', [DentalTreatmentPlanController::class, 'destroy'])->name('plan.destroy');
    Route::post('patients/{patient}/treatment-plan/convert', [DentalTreatmentPlanController::class, 'convert'])->name('plan.convert');
    Route::get('patients/{patient}/treatment-plan/print', [DentalTreatmentPlanController::class, 'print'])->name('plan.print');

    // Recall system (P5-T2).
    Route::get('recalls/due', [DentalRecallController::class, 'due'])->name('recalls.due');
    Route::get('patients/{patient}/recalls', [DentalRecallController::class, 'index'])->name('recalls.index');
    Route::post('patients/{patient}/recalls', [DentalRecallController::class, 'store'])->name('recalls.store');
    // NOTE: recalls.update PUT route removed — no UI wires it (controller
    // DentalRecallController::update kept for a future edit surface).
    Route::delete('patients/{patient}/recalls/{recall}', [DentalRecallController::class, 'destroy'])->name('recalls.destroy');
});
