<?php

use Illuminate\Support\Facades\Route;
use Modules\DermatologyClinic\Http\Controllers\DermaLesionController;
use Modules\DermatologyClinic\Http\Controllers\DermaScoreController;

/*
 * DermatologyClinic is a ClinicCore plugin and provides no clinic UI of its own.
 * These are the AJAX endpoints behind the lesion body-map / ABCDE checklist /
 * photo comparison and the severity-score entry that the DermatologySpecialtyDriver
 * fragments render into ClinicCore's shared patient/appointment screens.
 *
 * Permission enforcement (derma.lesions.manage / derma.scores.manage) is done
 * inside the controllers; the route group only requires an authenticated web
 * session (business_id is read from session('user.business_id')).
 */
Route::middleware(['web', 'auth'])->prefix('derma')->name('derma.')->group(function () {
    // Lesion register (body map + ABCDE + photo links)
    Route::post('patients/{patient}/lesions',                    [DermaLesionController::class, 'store'])->name('lesions.store');
    Route::delete('patients/{patient}/lesions/{lesion}',         [DermaLesionController::class, 'destroy'])->name('lesions.destroy');
    Route::post('patients/{patient}/lesions/{lesion}/photos',    [DermaLesionController::class, 'linkPhotos'])->name('lesions.photos');

    // Severity scores (PASI / EASI / DLQI / IGA)
    Route::post('patients/{patient}/scores',            [DermaScoreController::class, 'store'])->name('scores.store');
    Route::delete('patients/{patient}/scores/{score}',  [DermaScoreController::class, 'destroy'])->name('scores.destroy');
});
