<?php

use App\Http\Controllers\admin\HomeController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/

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

Route::post('calendly/get-auth-url', 'App\Http\Controllers\Admin\Api\CalendlyController@getCalendlyAuthUrl');
Route::get('calendly/redirect-code', 'App\Http\Controllers\Admin\Api\CalendlyController@getRedirectCode')->name("redirectURI");
Route::any('calendly/get-available-times-schedule', 'App\Http\Controllers\Admin\Api\CalendlyController@getAvailableTimes');
Route::any('calendly/get-events', 'App\Http\Controllers\Admin\Api\CalendlyController@getEvent');
Route::any('calendly/set-event', 'App\Http\Controllers\Admin\Api\CalendlyController@setEvent');
Route::any('calendly/reset-event', 'App\Http\Controllers\Admin\Api\CalendlyController@resetEventUri');



Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'as' => 'admin.', 'middleware' => ['admin_auth']], function () {

    Route::get('register', 'Auth\RegisterController@showRegisterForm')->name('register');
    Route::post('registerPost', 'Auth\RegisterController@register')->name('registerPost');

    Route::get('login', 'Auth\LoginController@showLoginForm');
    Route::post('login', 'Auth\LoginController@login')->name('login');


    Route::get('password/request', 'Auth\ResetPasswordController@resetPassword')->name('password.request');

    Route::group(['middleware' => ['admin_authenticated']], function () {

        Route::post('logout', 'Auth\LoginController@logout')->name('logout');
        Route::get('/', 'HomeController@index')->name('home');

        Route::get('/agents', 'AgentController@index')->name('agents');
        Route::get('/add/agent', 'AgentController@add')->name('add.agent');
        Route::post('/add/agent/post', 'AgentController@save')->name('add.agent.post');
        Route::get('/edit/agent/{id}', 'AgentController@edit')->name('edit.agent');
        Route::post('/edit/agent/post/{id}', 'AgentController@update')->name('update.agent.post');
        Route::get('/delete/agent/{id}', 'AgentController@delete')->name('delete.agent');

        Route::get('/doctors', 'DoctorController@index')->name('doctors');
        Route::get('/add/doctor', 'DoctorController@add')->name('add.doctor');
        Route::post('/add/doctor/post', 'DoctorController@save')->name('add.doctor.post');
        Route::get('/edit/doctor/{id}', 'DoctorController@edit')->name('edit.doctor');
        Route::post('/edit/doctor/post/{id}', 'DoctorController@update')->name('update.doctor.post');
        Route::get('/delete/doctor/{id}', 'DoctorController@delete')->name('delete.doctor');

        Route::get('/patients', 'PatientController@index')->name('patients');
        Route::get('/delete/patient/{id}', 'PatientController@delete')->name('delete.patient');
        //labs routes
        Route::get('/labs', 'LabsController@index')->name('labs');
        Route::get('/lab/create', 'LabsController@create')->name('lab.create');
        Route::post('/lab/save', 'LabsController@save')->name('lab.save');
        Route::get('/lab/edit/{id}', 'LabsController@edit')->name('lab.edit');
        Route::post('/lab/update/{id}', 'LabsController@update')->name('lab.update');

        Route::post('/get-order-data', 'LabsController@getOrderData');
    });
});

Route::group(['prefix' => 'api/admin', 'namespace' => 'Admin\Api', 'as' => 'api.admin.', 'middleware' => ['api']], function () {
    Route::post('login', 'LoginController@loginApi');
    Route::post('plans', [App\Http\Controllers\PatientController::class, 'getPlans']);

    Route::group(['middleware' => ['admin_authenticated:sanctum']], function () {
        Route::post('patient-list', 'PatientController@patientList');
        Route::post('/store-order-data/{labkit}/{patient}', 'HomeController@storeOrderData');
        Route::post('/edit-order-data/{cart}', 'HomeController@editOrderData');

        Route::post('subscription-list-data', 'SubscriptionController@getSubscriptionList');

        Route::post('product/{product}', 'HomeController@product');
        Route::post('/admin-profile-update', 'HomeController@updateAdminProfile');

        Route::post('/patient/{patient}', 'PatientController@patient');
        Route::post('/patient-full-detail/{patient}', 'PatientController@patientFullDetail');
        Route::post('/telemed-full-detail/{telemed}', 'TelemedProAgentController@telemedProFullDetail');

        //patient crud start here
        Route::post('/save-patient', 'PatientController@newPatient');
        Route::post('/save-shipping-address/{id}', 'PatientController@patientShippingAddress');


        Route::post('/patient-delete/{patient}', 'PatientController@patientDelete');
        Route::post('/patient-update/{patient}', 'PatientController@patientUpdate');

        Route::post('/telemed-pro-list', 'TelemedProAgentController@telemedList');
        Route::post('/telemed-pro/{telemed}', 'TelemedProAgentController@telemed');
        Route::post('/telemed-pro-delete/{telemed}', 'TelemedProAgentController@telemedDelete');
        Route::post('/telemed-pro-update/{telemed}', 'TelemedProAgentController@telemedUpdate');

        Route::post('/labs-list', 'HomeController@labsList');
        Route::post('/labs/{lab}', 'HomeController@labs');
        Route::post('/labs-delete/{lab}', 'HomeController@labsDelete');
        Route::post('/labs-update/{lab}', 'HomeController@labsUpdate');

        Route::post('get-appointment-list', 'AppointmentController@getAppointmentList');
        Route::post('get-meeting-history/{patient}', 'AppointmentController@getMeetingHistory');
        Route::post('get-meeting-history-with-agent/{telemedpro}', 'TelemedProAgentController@getMeetingHistoryTelemedpro');


        Route::post('get-med-list', 'MedicineController@getMedList');
        Route::post('save-med', 'MedicineController@SaveMed');
        Route::post('update-med/{id}', 'MedicineController@EditMed');
        Route::post('delete-med/{id}', 'MedicineController@DeleteMed');
        Route::post('questions-files', 'MedicineController@getFileList');

        Route::post('get-note/{patient}/{appointment}', 'PatientController@getNotePatient');

        Route::post('get-appointment/{patient}/{appointment}', 'AppointmentController@getAppointmentByid');
        Route::post('get-patient-prescriptions/{patient_id}/{appointment_id}', 'PatientController@getPatientPrescription');

        Route::post('get-stats', 'DashboardController@getStats');
        Route::post('site-settings', 'SiteSettingsController@getSiteSettings');
        Route::post('update-settings/{id}', 'SiteSettingsController@updateSettings');
        Route::post('password-update', 'SiteSettingsController@passwordReset');
        Route::post('admin-details', 'DashboardController@getAdminDetails');
        Route::post('patient-prescription-status-update/{PatientPrescription}', 'MedicineController@updateStatusPatientPrescription');
        Route::post('labkit-status-update/{cart}', 'MedicineController@updateStatusLabkit');

        Route::post('labkit-list', 'MedicineController@labkitList');
        Route::post('patient-labkit-list', 'MedicineController@getPatientLabKitOrders');
        Route::post('admin-update-profile', 'DashboardController@updateAdminDetails');
        Route::post('labkit-list-create', 'MedicineController@labskitCreate');
        Route::post('labkit-update/{labkit}', 'MedicineController@labskitUpdate');
        Route::post('labkit-delete/{labkit}', 'MedicineController@labsKitDelete');

        Route::post('patient-labkit-list/{patient}', 'MedicineController@getPatientLabKitOrders');

        Route::post('get-question-builder/{patient}',  'HomeController@getQuestionBuilderStore');
        /////////////////////////////////////
        ////////////////REPORTING APIS//////
        Route::post('provider-report',  'ReportsController@providerReportFilters');
        Route::post('provider-report-post',  'ReportsController@providerReportPost');
        Route::post('get-total_sales',  'ReportsController@totalSales');
        Route::post('order-analytics',  'ReportsController@ordersAnalytics');

        Route::post('order-list', 'OrderController@orderList');
        Route::post('order-list/{patient}', 'OrderController@orderListbyPatient');
        Route::post('item-status/{id}', 'OrderController@updateItemStatus');
        Route::post('order-count', 'OrderController@orderCount');
        Route::post('order-details/{id}', 'OrderController@orderDetails');
        Route::post('get-payment-details/{order_id}', 'OrderController@getPaymentDetail');
        Route::post('labkit-order-items-get', 'OrderController@labkitOrderItemGet');
        Route::post('analytics-overview', 'ReportsController@overviewReport');
        Route::post('analytics-order', 'ReportsController@ordersReport');
        Route::post('product-analytics', 'ReportsController@productAnalytics');
        Route::post('order-filters', 'ReportsController@ordersFilters');
        Route::post('patients/initial', 'ReportsController@initialPatients');
        Route::post('patients/search', 'ReportsController@searchPatients');
        Route::post('get-plans', 'HomeController@getProducts');
        //dashboard
        Route::post('/dashboard', 'DashboardController@index');
        Route::post('telemedpro/register', 'TelemedProAgentController@register');
        Route::post('telemedpro/details/{id}', 'TelemedProAgentController@details');
        Route::post('admin-list', 'AdminController@index');
        Route::post('admin-save', 'AdminController@saveAdmin');
        Route::post('admin-edit/{id}', 'AdminController@editAdmin');
        Route::post('admin-update/{id}', 'AdminController@updateAdmin');
        Route::post('admin-details/{id}', 'AdminController@detailAdmin');
        // permissions crud
        Route::post('store-role', 'PermissionsController@storeRole');
        Route::post('edit-role/{id}', 'PermissionsController@editRoles');
        Route::post('update-role/{id}', 'PermissionsController@updateRoles');
        Route::post('delete-role/{id}', 'PermissionsController@deleteRoles');
        Route::post('update-permission/{id}', 'PermissionsController@updatePermissions');
        Route::post('roles-list', 'PermissionsController@index');
        Route::post('get-permissions/{id}', 'PermissionsController@getPermissions');
        Route::post('update-pmerissions/{id}', 'PermissionsController@savePermissions');
        Route::post('roles', 'AdminController@getRoles');
        Route::post('get-prescriptions', 'HomeController@getPrescription');
        Route::post('store-patient-prescriptions', 'PatientController@storePatientPrescription');
        Route::post('edit-patient-prescriptions/{id}', 'PatientController@updatePatientPrescription');
        Route::post('delete-patient-prescriptions/{id}', 'PatientController@deletePatientPrescription');
        Route::post('update-status-prescriptions/{patient_prescription_id}', 'PatientController@updateStatusPrescription');
        Route::post('get-status-prescriptions/{patient_prescription_id}', 'PatientController@getStatusPrescription');
        Route::post('get-patient-prescriptions/{patient_prescription_id}', 'PatientController@getStatusPrescription');
        Route::post('update-subscription/{subid}', 'SubscriptionController@updateSubscription');
        Route::post('prescription-save', 'PrescriptionController@create');
        Route::post('prescription-update/{id}', 'PrescriptionController@update');
        Route::post('prescription-edit/{id}', 'PrescriptionController@edit');
        Route::post('prescription-delete/{id}', 'PrescriptionController@delete');
        Route::post('/available-slots/{date}',  'AppointmentController@availableSlots');
        Route::post('/item-by-order/{order_id}',  'AppointmentController@getItemByOrder');
        Route::post('create-subscription', 'SubscriptionController@CreateSubscription');
        Route::post('get-subscription/{subscription}', 'SubscriptionController@getSubscription');
        Route::post('delete-subscription/{subscription}', 'SubscriptionController@deleteSubscription');

        Route::post('/agent-last-appointment-detail/{patient}', 'AppointmentController@getAgentLastAppointment');
        Route::post('/create-question-builder/{category}', 'HomeController@questionBuilderStore');

        Route::post('/medical-history-question-get/{patient}', 'HomeController@getMedicalHistoryQuestion');
        Route::post('/medical-history-question-post/{patient}', 'HomeController@postMedicalHistoryQuestion');
        Route::post('/process-payment', 'HomeController@processPayment');
        Route::post('/book-appointment', 'AppointmentController@bookAppointment');
        Route::post('/edit-booking-appointment/{appointment}', 'AppointmentController@editAppointment');
        Route::post('/add-note/{cart}', 'OrderController@addNotePatient');
        Route::post('/edit-note/{id}', 'OrderController@editNotePatient');
        Route::post('/get-note/{id}', 'OrderController@getNotePatient');

        Route::post('/delete-note/{id}', 'OrderController@deleteNotePatient');
    });
});
