<?php

use Illuminate\Support\Facades\Route;
use Modules\OphthalmologyClinic\Http\Controllers\OpthExamController;
use Modules\OphthalmologyClinic\Http\Controllers\OpthGlassesRxController;

/*
 * OphthalmologyClinic is a ClinicCore plugin and provides no clinic UI of its
 * own. These are the endpoints behind the eye-exam entry, glasses-prescription
 * entry/print and IOP/DR tracking that the OphthalmologySpecialtyDriver
 * fragments render into ClinicCore's shared patient/appointment screens.
 *
 * Permission enforcement (opth.exams.manage / opth.glasses_rx.manage) is done
 * inside the controllers; the group only requires an authenticated web session.
 */
Route::middleware(['web', 'auth'])->prefix('ophth')->name('opth.')->group(function () {
    // Per-visit eye exam (OD/OS) — persists, syncs the summary profile, raises IOP alert
    Route::post('patients/{patient}/exams', [OpthExamController::class, 'store'])->name('exams.store');

    // Glasses (spectacle) prescription + print
    Route::post('patients/{patient}/glasses',                 [OpthGlassesRxController::class, 'store'])->name('glasses.store');
    Route::delete('patients/{patient}/glasses/{rx}',          [OpthGlassesRxController::class, 'destroy'])->name('glasses.destroy');
    Route::get('patients/{patient}/glasses/{rx}/print',       [OpthGlassesRxController::class, 'print'])->name('glasses.print');
});
