<?php

use App\Http\Controllers\AntibioticController;
use App\Http\Controllers\BaseController;
use App\Http\Controllers\CommentController;
use App\Http\Controllers\Controller;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\InvoiceController;
use App\Http\Controllers\OrganismController;
use App\Http\Controllers\PatientController;
use App\Http\Controllers\PatientTypeController;
use App\Http\Controllers\PhysicianController;
use App\Http\Controllers\QuantityController;
use App\Http\Controllers\ReportController;
use App\Http\Controllers\RoleController;
use App\Http\Controllers\SampleController;
use App\Http\Controllers\SampleSourceController;
use App\Http\Controllers\SampleTypeController;
use App\Http\Controllers\TestController;
use App\Http\Controllers\TestGroupController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\UtilController;
use App\Http\Middleware\VerifyBaseLab;
use App\Models\User;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Auth\AuthController;
use App\Http\Controllers\LabController;
use App\Http\Controllers\DepartmentController;
use App\Http\Controllers\ShareController;
use App\Http\Controllers\TelegramController;

use App\Http\Controllers\PublicationController;
use App\Http\Controllers\RepaymentController;
use App\Http\Controllers\AppointmentController;
use App\Http\Controllers\ActivityLogsController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/lang/{locale}', function ($locale){
    session(['locale' => $locale]);
    App::setLocale($locale);
    return redirect()->back();
});

Route::get('/telescope', function () {
    Gate::define('viewTelescope', function (User $user) {
        return in_array($user->email, [
            'taylor@laravel.com',
        ]);
    });
});

Route::get('/', function () {
    return view('login');
});

Route::post('do_login', [AuthController::class, 'do_login'])->name('auth.do_login');


Route::middleware(['auth'])->group(function () {

    Route::get('/base', [BaseController::class, 'index'])->name('base');
    Route::post('base.save', [BaseController::class, 'store'])->name('base.save');
    Route::get('base.forget', [BaseController::class, 'forget'])->name('base.change');

    Route::get('/laboratory-profile', [LabController::class, 'profile'])->name('laboratory-profile');
    Route::post('/laboratory-profile/save', [LabController::class, 'labSettingSetters']);
    Route::post('/laboratory-profile/configure/save', [LabController::class, 'saveLabConfigure']);
    Route::post('/laboratory-profile/avatar/upload', [LabController::class, 'uploadImage']);
    Route::post('/laboratory-profile/avatar/remove', [LabController::class, 'removeLabLogo']);

    Route::post('/laboratory-profile/update', [LabController::class, 'updateInfo'])->middleware(VerifyBaseLab::class);


    Route::post('/laboratory-profile/verifies/upload', [LabController::class, 'uploadVerifyImage']);
    Route::post('/laboratory-profile/verifies/remove', [LabController::class, 'removeVerifyImage']);

	Route::post('/laboratory-profile/alter-verify-sign/upload', [LabController::class, 'uploadAlterVerifySignature']);
    Route::post('/laboratory-profile/alter-verify-sign/remove', [LabController::class, 'removeAlterVerifySignature']);
	Route::post('/laboratory-profile/alter-labtech-sign/upload', [LabController::class, 'uploadAlterLabtechSignature']);
    Route::post('/laboratory-profile/alter-labtech-sign/remove', [LabController::class, 'removeAlterLabtechSignature']);


	Route::post('/laboratory-profile/alternative-logo/upload', [LabController::class, 'uploadAlternativeLogo']);
    Route::post('/laboratory-profile/alternative-logo/remove', [LabController::class, 'removeAlternativeLogo']);

    Route::post('/laboratory-profile/default-footer/upload', [LabController::class, 'uploadDefaultFooter']);
    Route::post('/laboratory-profile/default-footer/remove', [LabController::class, 'removeDefaultFooter']);

    Route::post('/laboratory-profile/alternative-footer/upload', [LabController::class, 'uploadAlternativeFooter']);
    Route::post('/laboratory-profile/alternative-footer/remove', [LabController::class, 'removeAlternativeFooter']);

    Route::get('laboratory', [LabController::class, 'index'])->name('laboratory')->middleware(VerifyBaseLab::class);
    Route::get('laboratory/search', [LabController::class, 'index'])->name('laboratory.search')->middleware(VerifyBaseLab::class);
    Route::post('laboratory.save', [LabController::class, 'save'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.get', [LabController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.update', [LabController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.delete', [LabController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory.restore', [LabController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('laboratory/clone-configs', [LabController::class, 'initLabData'])->middleware(VerifyBaseLab::class);
    Route::get('laboratory/get-data/{id}', [LabController::class, 'getLabData'])->middleware(VerifyBaseLab::class);
    Route::post('laboratory/clone-data', [LabController::class, 'cloneLabData'])->middleware(VerifyBaseLab::class);

    Route::get('laboratory/clone-customs', [LabController::class, 'cloneLabDataBySampleType'])->middleware(VerifyBaseLab::class);
    Route::get('laboratory/update-heading', [LabController::class, 'updateHeading'])->middleware(VerifyBaseLab::class);


    Route::get('user', [UserController::class, 'index'])->name('user')->middleware(VerifyBaseLab::class);
    Route::get('lab-users', [UserController::class, 'labUsers'])->name('lab_user')->middleware(VerifyBaseLab::class);
    Route::get('user/search', [UserController::class, 'index'])->name('user.search')->middleware(VerifyBaseLab::class);
    Route::post('user.save', [UserController::class, 'save'])->middleware(VerifyBaseLab::class);
    Route::post('user.get', [UserController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('user.update', [UserController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('user.delete', [UserController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('user.restore', [UserController::class, 'restore'])->middleware(VerifyBaseLab::class);
    Route::post('user.assign-labs', [UserController::class, 'assignLabs'])->middleware(VerifyBaseLab::class);

    //Route::get('user/profile', [UserController::class, 'profile'])->middleware(VerifyBaseLab::class);

    Route::post('user/profile/signature/upload', [UserController::class, 'uploadSignature']);
    Route::post('user/profile/signature/remove', [UserController::class, 'removeSignature']);
    Route::post('user/password/change', [UserController::class, 'changePassword'])->name('profile.change_password')->middleware(VerifyBaseLab::class);

      Route::post('user.reset_password', [UserController::class, 'resetPassword'])->middleware(VerifyBaseLab::class);


    Route::get('role', [RoleController::class, 'index'])->name('role')->middleware(VerifyBaseLab::class);
    Route::get('role/search', [RoleController::class, 'index'])->name('role.search')->middleware(VerifyBaseLab::class);
    Route::post('role.save', [RoleController::class, 'save'])->middleware(VerifyBaseLab::class);
    Route::post('role.get', [RoleController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('role.update', [RoleController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('role.delete', [RoleController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('role.restore', [RoleController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('department', [DepartmentController::class, 'index'])->name('department')->middleware(VerifyBaseLab::class);
    Route::get('department/search', [DepartmentController::class, 'index'])->name('department.search')->middleware(VerifyBaseLab::class);
    Route::post('department.save', [DepartmentController::class, 'save'])->name('department.save')->middleware(VerifyBaseLab::class);
    Route::post('department.get', [DepartmentController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('department.update', [DepartmentController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('department.delete', [DepartmentController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('department.restore', [DepartmentController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('patient-type', [PatientTypeController::class, 'index'])->name('patient-type')->middleware(VerifyBaseLab::class);
    Route::get('patient-type/search', [PatientTypeController::class, 'index'])->name('patient-type.search')->middleware(VerifyBaseLab::class);
    Route::post('patient-type.save', [PatientTypeController::class, 'save'])->name('patient-type.save')->middleware(VerifyBaseLab::class);
    Route::post('patient-type.get', [PatientTypeController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('patient-type.update', [PatientTypeController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('patient-type.delete', [PatientTypeController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('patient-type.restore', [PatientTypeController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('sample-type', [SampleTypeController::class, 'index'])->name('sample-type')->middleware(VerifyBaseLab::class);
    Route::get('sample-type/search', [SampleTypeController::class, 'index'])->name('sample-type.search')->middleware(VerifyBaseLab::class);
    Route::post('sample-type.save', [SampleTypeController::class, 'save'])->name('sample-type.save')->middleware(VerifyBaseLab::class);
    Route::post('sample-type.get', [SampleTypeController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::get('sample-type/{id}', [SampleTypeController::class, 'getById'])->middleware(VerifyBaseLab::class);
    Route::post('sample-type.update', [SampleTypeController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('sample-type.delete', [SampleTypeController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('sample-type.restore', [SampleTypeController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('comment', [CommentController::class, 'index'])->name('comment')->middleware(VerifyBaseLab::class);
    Route::get('comment/search', [CommentController::class, 'index'])->name('comment.search')->middleware(VerifyBaseLab::class);
    Route::post('comment.save', [CommentController::class, 'save'])->name('comment.save')->middleware(VerifyBaseLab::class);
    Route::post('comment.get', [CommentController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('comment.update', [CommentController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('comment.delete', [CommentController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('comment.restore', [CommentController::class, 'restore'])->middleware(VerifyBaseLab::class);


    Route::get('sample-source', [SampleSourceController::class, 'index'])->name('sample-source')->middleware(VerifyBaseLab::class);
    Route::get('sample-source/search', [SampleSourceController::class, 'index'])->name('sample-source.search')->middleware(VerifyBaseLab::class);
    Route::post('sample-source.save', [SampleSourceController::class, 'save'])->name('sample-source.save')->middleware(VerifyBaseLab::class);
    Route::post('sample-source.get', [SampleSourceController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('sample-source.update', [SampleSourceController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('sample-source.delete', [SampleSourceController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('sample-source.restore', [SampleSourceController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('physician', [PhysicianController::class, 'index'])->name('physician')->middleware(VerifyBaseLab::class);
    Route::get('physician/search', [PhysicianController::class, 'index'])->name('physician.search')->middleware(VerifyBaseLab::class);
    Route::post('physician.save', [PhysicianController::class, 'save'])->name('physician.save')->middleware(VerifyBaseLab::class);
    Route::post('physician.get', [PhysicianController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('physician.update', [PhysicianController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('physician.delete', [PhysicianController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('physician.restore', [PhysicianController::class, 'restore'])->middleware(VerifyBaseLab::class);
    Route::post('physician/photo/delete', [PhysicianController::class, 'deletePhysicianLogo'])->middleware(VerifyBaseLab::class);
    Route::post('physician/footer/delete', [PhysicianController::class, 'deletePhysicianFooter'])->middleware(VerifyBaseLab::class);

    Route::get('test', [TestController::class, 'testSamples'])->name('test')->middleware(VerifyBaseLab::class);
    Route::get('test/search', [TestController::class, 'testSamples'])->name('test.search')->middleware(VerifyBaseLab::class);
    Route::post('test.save', [TestController::class, 'save'])->name('test.save')->middleware(VerifyBaseLab::class);
    Route::post('test.get', [TestController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('test.update', [TestController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('test.delete', [TestController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('test.restore', [TestController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('test-sample', [TestController::class, 'testSamples'])->name('test-sample')->middleware(VerifyBaseLab::class);
    Route::get('test-sample/search', [TestController::class, 'testSamples'])->name('test.search')->middleware(VerifyBaseLab::class);
    Route::post('test-sample.save', [TestController::class, 'saveTestSample'])->name('test-sample.save')->middleware(VerifyBaseLab::class);
    Route::post('test-sample.get', [TestController::class, 'getTestSample'])->middleware(VerifyBaseLab::class);
    Route::post('test-sample.update', [TestController::class, 'updateTestSample'])->middleware(VerifyBaseLab::class);
    Route::post('test-sample.delete', [TestController::class, 'deleteTestSample'])->middleware(VerifyBaseLab::class);
    Route::post('test-sample.restore', [TestController::class, 'restoreTestSample'])->middleware(VerifyBaseLab::class);
    Route::post('test-sample.reorder', [TestController::class, 'editTestSampleOrder'])->middleware(VerifyBaseLab::class);
    Route::post('test-sample/physician-commission', [TestController::class, 'storePhysicianCommission'])->middleware(VerifyBaseLab::class);
    Route::post('test-sample/all/physician-commission', [TestController::class, 'setCommissionToAllTest'])->middleware(VerifyBaseLab::class);

    Route::post('test-sample/clone', [LabController::class, 'cloneTestSample'])->middleware(VerifyBaseLab::class);
    Route::post('test-sample-property/clone', [TestController::class, 'cloneTestSampleProperties'])->middleware(VerifyBaseLab::class);



    Route::get('organism', [OrganismController::class, 'index'])->name('organism')->middleware(VerifyBaseLab::class);
    Route::get('organism/search', [OrganismController::class, 'index'])->name('organism.search')->middleware(VerifyBaseLab::class);
    Route::post('organism.save', [OrganismController::class, 'save'])->name('organism.save')->middleware(VerifyBaseLab::class);
    Route::post('organism.get', [OrganismController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('organism.update', [OrganismController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('organism.delete', [OrganismController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('organism.restore', [OrganismController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('antibiotic', [AntibioticController::class, 'index'])->name('antibiotic')->middleware(VerifyBaseLab::class);
    Route::get('antibiotic/search', [AntibioticController::class, 'index'])->name('antibiotic.search')->middleware(VerifyBaseLab::class);
    Route::post('antibiotic.save', [AntibioticController::class, 'save'])->name('antibiotic.save')->middleware(VerifyBaseLab::class);
    Route::post('antibiotic.get', [AntibioticController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('antibiotic.update', [AntibioticController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('antibiotic.delete', [AntibioticController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('antibiotic.restore', [AntibioticController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('quantity', [QuantityController::class, 'index'])->name('quantity')->middleware(VerifyBaseLab::class);
    Route::get('quantity/search', [QuantityController::class, 'index'])->name('quantity.search')->middleware(VerifyBaseLab::class);
    Route::post('quantity.save', [QuantityController::class, 'save'])->name('quantity.save')->middleware(VerifyBaseLab::class);
    Route::post('quantity.get', [QuantityController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('quantity.update', [QuantityController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('quantity.delete', [QuantityController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('quantity.restore', [QuantityController::class, 'restore'])->middleware(VerifyBaseLab::class);

    Route::get('patient', [PatientController::class, 'index'])->name('patient')->middleware(VerifyBaseLab::class);
    Route::get('patient/search', [PatientController::class, 'index'])->name('patient.search')->middleware(VerifyBaseLab::class);
    Route::post('patient.save', [PatientController::class, 'save'])->name('patient.save')->middleware(VerifyBaseLab::class);
    Route::get('patient.get', [PatientController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('patient.update', [PatientController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('patient.delete', [PatientController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('patient.restore', [PatientController::class, 'restore'])->middleware(VerifyBaseLab::class);
    Route::get('patient/async', [PatientController::class, 'search'])->name('patient.async')->middleware(VerifyBaseLab::class);
    Route::get('patient/live-filter', [PatientController::class, 'patientSearchAjax'])->name('patient.async')->middleware(VerifyBaseLab::class);
    Route::get('patient/live-search', [PatientController::class, 'searchPatientToSelect2'])->middleware(VerifyBaseLab::class);


    Route::prefix('appointment')->group(function (){
        Route::get('/', [AppointmentController::class, 'index'])->middleware(VerifyBaseLab::class);
        Route::get('/search', [AppointmentController::class, 'index'])->middleware(VerifyBaseLab::class);
        Route::post('/save', [AppointmentController::class, 'store'])->name('appointment.save')->middleware(VerifyBaseLab::class);
        Route::post('/get', [AppointmentController::class, 'get'])->name('appointment.get')->middleware(VerifyBaseLab::class);
        Route::post('/update', [AppointmentController::class, 'update'])->name('appointment.update')->middleware(VerifyBaseLab::class);
        Route::post('/delete', [AppointmentController::class, 'delete'])->name('appointment.delete')->middleware(VerifyBaseLab::class);
    });

    Route::prefix('refs')->group(function (){
        Route::get('/uuid.generate/{data_type?}', [UtilController::class, 'generatePatientUuId'])->name('uuid.generate')->middleware(VerifyBaseLab::class);
        Route::get('/uuidv2.generate/{data_type?}/{manual_code}', [UtilController::class, 'generateUuIdForManual'])->name('uuidv2.generate')->middleware(VerifyBaseLab::class);
        Route::get('/department', [UtilController::class, 'getDepartment'])->middleware(VerifyBaseLab::class);
        Route::get('/sample-type/department/{department_id?}', [UtilController::class, 'getSampleTypeByDepartment'])->middleware(VerifyBaseLab::class);
        Route::get('/organism/{res_type?}', [UtilController::class, 'getOrganisms'])->middleware(VerifyBaseLab::class);
        Route::get('/antibiotic/{res_type?}', [UtilController::class, 'getAntibiotic'])->middleware(VerifyBaseLab::class);
        Route::get('/provinces/{data_type?}', [UtilController::class, 'province'])->name('provinces')->middleware(VerifyBaseLab::class);
        Route::get('/districts/{data_type?}/{province_id?}', [UtilController::class, 'district'])->name('districts')->middleware(VerifyBaseLab::class);
        Route::get('/communes/{data_type?}/{district_id?}', [UtilController::class, 'commune'])->name('communes')->middleware(VerifyBaseLab::class);
        Route::get('/villages/{data_type?}/{commune_id?}', [UtilController::class, 'village'])->name('villages')->middleware(VerifyBaseLab::class);
        Route::post('/reject-comment/save', [UtilController::class, 'storeRejectComment'])->name('reject_comment.save')->middleware(VerifyBaseLab::class);
        Route::get('/test-items', [UtilController::class, 'getTestItem'])->name('getTestItem')->middleware(VerifyBaseLab::class);
        Route::get('/test-items/{id}/{previous_id?}', [UtilController::class, 'getTestItemBySampleId'])->name('getTestItemBySampleId')->middleware(VerifyBaseLab::class);
        Route::get('/test-items-get/{sample_type_id?}/{field_type?}', [UtilController::class, 'getTestSampleItems'])->name('getTestSampleItems')->middleware(VerifyBaseLab::class);

        Route::get('/test-sample/sample-type/{sample_type_id?}', [UtilController::class, 'getTestSampleBySampleType'])->name('getTestSampleBySampleType')->middleware(VerifyBaseLab::class);

        Route::get('/patient-types', [UtilController::class, 'getPatientTypes'])->name('get-patient-type')->middleware(VerifyBaseLab::class);

        Route::post('/test-group/save', [TestGroupController::class, 'save'])->middleware(VerifyBaseLab::class);
        Route::get('/test-group/get/{id}', [TestGroupController::class, 'get'])->middleware(VerifyBaseLab::class);
        Route::post('/test-group/delete/{id}', [TestGroupController::class, 'delete'])->middleware(VerifyBaseLab::class);
        Route::get('/test-sample-organism/get/{id}/{sample_id?}', [UtilController::class, 'getTestSampleOrganisms'])->middleware(VerifyBaseLab::class);
        Route::post('/test-sample-organism-search', [UtilController::class, 'getTestSampleOrganismsByName'])->middleware(VerifyBaseLab::class);
        Route::get('/test-sample-commission/{test_sample_id}', [UtilController::class, 'getPhysicianCommission'])->middleware(VerifyBaseLab::class);

        Route::get('/department/{lab_id}', [UtilController::class, 'getDepartmentByLabId'])->middleware(VerifyBaseLab::class);

    });

    Route::prefix('sample')->group(function (){
        Route::get('/', [SampleController::class, 'index'])->name('sample')->middleware(VerifyBaseLab::class);
        Route::get('/search', [SampleController::class, 'index'])->name('sample')->middleware(VerifyBaseLab::class);
        Route::get('/new', [SampleController::class, 'create'])->name('sample.new')->middleware(VerifyBaseLab::class);
        Route::get('/patient/{id?}/new', [SampleController::class, 'create'])->name('sample.new')->middleware(VerifyBaseLab::class);
        Route::post('/save', [SampleController::class, 'store'])->name('sample.save')->middleware(VerifyBaseLab::class);
        Route::post('/update/{id}', [SampleController::class, 'update'])->name('sample.update')->middleware(VerifyBaseLab::class);
        Route::post('/restore', [SampleController::class, 'restore'])->name('sample.restore')->middleware(VerifyBaseLab::class);
        Route::post('/delete', [SampleController::class, 'delete'])->name('sample.delete')->middleware(VerifyBaseLab::class);
        Route::post('/assign-test', [SampleController::class, 'storeSampleDetail'])->name('sample.assign-test')->middleware(VerifyBaseLab::class);
        Route::get('/edit/{id?}', [SampleController::class, 'edit'])->name('sample.new')->middleware(VerifyBaseLab::class);
        Route::get('/patient/{id?}', [SampleController::class, 'edit'])->name('sample.new')->middleware(VerifyBaseLab::class);
        Route::get('/{id}/tests', [SampleController::class, 'getSampleTest'])->middleware(VerifyBaseLab::class);
        Route::post('/add-test-result', [SampleController::class, 'storeSampleTestResult'])->name('sample.add-test-result')->middleware(VerifyBaseLab::class);
        Route::post('/approve', [SampleController::class, 'approve'])->name('sample.approve')->middleware(VerifyBaseLab::class);
        Route::post('/print-record', [SampleController::class, 'printRecorder'])->name('sample.printRecorder')->middleware(VerifyBaseLab::class);
        Route::get('/add-org-result/{sampleId}/{testSampleId}/{organId}', [SampleController::class, 'temporarySaveOrganismResult'])->middleware(VerifyBaseLab::class);
        Route::get('/save-org-result-qty/{sampleId}/{testSampleId}/{organId}/{qtyId}', [SampleController::class, 'temporarySaveOrganismResultQuantity'])->middleware(VerifyBaseLab::class);
        Route::post('/upload-attachment-result', [SampleController::class, 'uploadAttachmentResult'])->name('sample.upload-attachment-result')->middleware(VerifyBaseLab::class);

        Route::post('/result/tg-webhook/{patientId}/{sampleId}', [SampleController::class, 'sendLabResultLink'])->middleware(VerifyBaseLab::class);

        Route::post('/set-result-template', [SampleController::class, 'updateSampleResultTemplate'])->middleware(VerifyBaseLab::class);
    });

    Route::prefix('invoice')->group(function (){
        Route::get('/', [InvoiceController::class, 'index'])->name('invoice')->middleware(VerifyBaseLab::class);
        Route::get('/new', [InvoiceController::class, 'create'])->name('invoice.create')->middleware(VerifyBaseLab::class);
        Route::post('/save', [InvoiceController::class, 'store'])->name('invoice.save')->middleware(VerifyBaseLab::class);
        Route::get('/edit/{id}', [InvoiceController::class, 'edit'])->name('invoice.edit')->middleware(VerifyBaseLab::class);
        Route::post('/update', [InvoiceController::class, 'update'])->name('invoice.update')->middleware(VerifyBaseLab::class);
        Route::post('/delete', [InvoiceController::class, 'delete'])->name('invoice.delete')->middleware(VerifyBaseLab::class);
        Route::post('/restore', [InvoiceController::class, 'restore'])->middleware(VerifyBaseLab::class);
        Route::post('/{id}/paid', [InvoiceController::class, 'paid'])->name('invoice.paid')->middleware(VerifyBaseLab::class);
    });

    Route::prefix('report')->group(function (){
        Route::get('/invoice-report/year/{year}', [ReportController::class, 'yearlyInvoiceReport'])->middleware(VerifyBaseLab::class);
        Route::get('/invoice-report/{date}', [ReportController::class, 'dailyInvoiceReport'])->middleware(VerifyBaseLab::class);
        Route::get('/invoice-report/{date}/{report_type?}', [ReportController::class, 'dailyInvoiceReport'])->middleware(VerifyBaseLab::class);
        Route::get('/summary-report', [ReportController::class, 'summaryReport'])->middleware(VerifyBaseLab::class);
        Route::get('/doctor-report', [ReportController::class, 'doctorReport'])->middleware(VerifyBaseLab::class);
        Route::get('/financial-report', [ReportController::class, 'financialReport'])->middleware(VerifyBaseLab::class);
    });

    Route::prefix('system')->group(function (){
        Route::get('/role-permission/{role_id}', [RoleController::class, 'viewPermissionByRoleId'])->middleware(VerifyBaseLab::class);
        Route::post('/role-permission', [RoleController::class, 'storeRolePermission'])->middleware(VerifyBaseLab::class);
    });

    Route::prefix('dashboard')->group(function (){
        Route::get('/', [DashboardController::class, 'index'])->name('homepage')->middleware(VerifyBaseLab::class);
        Route::get('/trend/samples-comparison', [DashboardController::class, 'samplesYearComparison'])->middleware(VerifyBaseLab::class);
        Route::get('/trend/revenue-comparison', [DashboardController::class, 'revenueYearComparison'])->middleware(VerifyBaseLab::class);
        Route::get('filter/samples', [DashboardController::class, 'filter_sample'])->middleware(VerifyBaseLab::class);
        Route::get('filter/income', [DashboardController::class, 'filter_income'])->middleware(VerifyBaseLab::class);
        Route::get('filter/patient', [DashboardController::class, 'filter_patient'])->middleware(VerifyBaseLab::class);
        Route::get('filter/rejected-sample', [DashboardController::class, 'filter_rejected_sample'])->middleware(VerifyBaseLab::class);
        Route::get('/source-distribution', [DashboardController::class, 'getSampleSourceByDistributor'])->middleware(VerifyBaseLab::class);
        Route::get('/panel-distribution', [DashboardController::class, 'getPanelDistributor'])->middleware(VerifyBaseLab::class);
    });
    //Activity Log Route
    Route::get('/activity-logs', [ActivityLogsController::class, 'index'])->name('activity-logs')->middleware(VerifyBaseLab::class);
    Route::get('/audit-logs', [ActivityLogsController::class,'index'])->name('audit.logs')->middleware(VerifyBaseLab::class);
    Route::get('/audit-logs/data', [ActivityLogsController::class,'data'])->name('audit.logs.data')->middleware(VerifyBaseLab::class);

    //Alert Notification Route
    Route::get('appointments/notify', [AppointmentController::class, 'getAlertNofication'])->name('alert-notifications')->middleware(VerifyBaseLab::class);
    Route::post('/alert-notifications/mark-as-read', [AlertNotificationController::class, 'markAsRead'])->name('alert-notifications.mark-as-read')->middleware(VerifyBaseLab::class);

    Route::get('publication', [PublicationController::class, 'index'])->name('publication')->middleware(VerifyBaseLab::class);
    Route::get('publication/search', [PublicationController::class, 'index'])->name('publication.search')->middleware(VerifyBaseLab::class);
    Route::post('publication.save', [PublicationController::class, 'save'])->name('publication.save')->middleware(VerifyBaseLab::class);
    Route::post('publication.get', [PublicationController::class, 'get'])->middleware(VerifyBaseLab::class);
    Route::post('publication.update', [PublicationController::class, 'update'])->middleware(VerifyBaseLab::class);
    Route::post('publication.delete', [PublicationController::class, 'delete'])->middleware(VerifyBaseLab::class);
    Route::post('publication.restore', [PublicationController::class, 'restore'])->middleware(VerifyBaseLab::class);
    Route::get('publication/read/{id}', [PublicationController::class, 'read'])->middleware(VerifyBaseLab::class);


    Route::prefix('repayment')->group(function (){
        Route::get('/', [RepaymentController::class, 'index'])->name('repayment')->middleware(VerifyBaseLab::class);
        Route::post('/save', [RepaymentController::class, 'store'])->name('repayment.save')->middleware(VerifyBaseLab::class);
        Route::post('/update', [RepaymentController::class, 'update'])->name('repayment.update')->middleware(VerifyBaseLab::class);
        Route::post('/delete', [RepaymentController::class, 'delete'])->name('repayment.delete')->middleware(VerifyBaseLab::class);
        Route::post('/get', [RepaymentController::class, 'get'])->name('repayment.get')->middleware(VerifyBaseLab::class);
        Route::post('/invoice/get', [RepaymentController::class, 'getInvoice'])->name('repayment.get-invoice')->middleware(VerifyBaseLab::class);
    });

    /** end block share routes */


});

Route::post('/telegram/webhook', [TelegramController::class, 'handle']);

Route::get('/shared/lab-result/{id}', [ShareController::class, 'index']);
Route::get('/shared/test-items/{id}/{previousId?}', [ShareController::class, 'getTestItemBySampleId']);
Route::get('/shared/patient/{labId}/search', [ShareController::class, 'searchPatientToSelect2']);
Route::get('/shared/patient/{labId}/search-by-phone', [ShareController::class, 'searchPatientPhoneToSelect2']);


Route::get('/anonymous/{hashLabId}', [ShareController::class, 'startAnonymousSession']);

Route::post('/customer/register/{hashLabId}', [ShareController::class, 'anonymousRegister']);
Route::get('/customer/logout/{hashLabId}/', [ShareController::class, 'anonymousLogOut']);
Route::post('/customer/login/{hashLabId}/', [ShareController::class, 'anonymousLogin']);
Route::get('/customer/{hashLabId}', [ShareController::class, 'profile']);
Route::get('/customer/result/{hashLabId}/{hashSampleId}', [ShareController::class, 'viewLabResult']);
Route::get('/customer/clone/{hashLabId}/{hashSampleId}', [ShareController::class, 'cloneRequestedLabServices']);

Route::get('lab-test/test-group/get/{id}/{lab_id}', [ShareController::class, 'getTestGroup']);
Route::get('lab-test/test-items', [ShareController::class, 'getTestItem']);
Route::post('lab-request/tests', [ShareController::class, 'storeSampleDetail']);

require __DIR__.'/auth.php';
