<?php

use CodeIgniter\Router\RouteCollection;
/** @var RouteCollection $routes */
$routes->setAutoRoute(false);
$routes->get('/', 'Home::index');
$routes->get('sitemap.xml','Seo::sitemap');
$routes->get('healthz','Seo::health');
foreach (['about','services','how-it-works','for-practitioners','partners','resources','faq','contact','privacy','terms'] as $page) {
    $routes->get($page, 'Home::page/' . $page);
}
$routes->get('find-care', 'FindCare::index');
$routes->get('practitioners/(:num)', 'FindCare::profile/$1');

$routes->group('', ['filter'=>'guest'], static function($routes){
    $routes->get('login','Auth::loginForm'); $routes->post('login','Auth::login',['filter'=>'ratelimit:8,60']);
    $routes->get('register','Auth::registerForm'); $routes->post('register','Auth::patientRegister',['filter'=>'ratelimit:6,120']);
    $routes->get('forgot-password','Auth::forgotForm'); $routes->post('forgot-password','Auth::forgot',['filter'=>'ratelimit:5,300']); $routes->get('reset-password/(:segment)','Auth::resetForm/$1'); $routes->post('reset-password/(:segment)','Auth::reset/$1',['filter'=>'ratelimit:5,300']);
    $routes->get('join-practitioner','Auth::practitionerRegisterForm'); $routes->post('join-practitioner','Auth::practitionerRegister',['filter'=>'ratelimit:6,120']);
});
$routes->post('logout','Auth::logout',['filter'=>'auth']);

$routes->group('patient',['filter'=>'role:patient'],static function($routes){
    $routes->get('/','Patient::dashboard'); $routes->get('request-care','Patient::requestForm'); $routes->post('request-care','Patient::submitRequest',['filter'=>'ratelimit:10,60']);
    $routes->get('visits','Patient::visits'); $routes->get('visits/active','Patient::activeVisit'); $routes->get('health','Patient::health'); $routes->post('prescriptions/(:num)/order','Patient::orderPrescription/$1'); $routes->get('labs','Patient::labs'); $routes->get('pharmacy','Patient::pharmacy'); $routes->get('telehealth','Patient::telehealth'); $routes->get('packages','Patient::packages'); $routes->post('packages/(:num)/subscribe','Patient::subscribePackage/$1'); $routes->get('family','Patient::family'); $routes->post('family','Patient::addFamilyMember'); $routes->post('family/(:num)/archive','Patient::archiveFamilyMember/$1'); $routes->get('payments','Patient::payments'); $routes->get('messages','Patient::messages'); $routes->get('notifications','Patient::notifications'); $routes->get('profile','Patient::profile'); $routes->post('profile','Patient::updateProfile');
});
$routes->group('practitioner',['filter'=>'role:practitioner'],static function($routes){
    $routes->get('/','Practitioner::dashboard'); $routes->get('requests','Practitioner::requests'); $routes->post('requests/(:num)/(:alpha)','Practitioner::respond/$1/$2'); $routes->post('availability/toggle','Practitioner::toggleOnline');
    $routes->get('visits','Practitioner::visits'); $routes->get('visits/(:num)','Practitioner::visitDetail/$1'); $routes->post('visits/(:num)/status','Practitioner::updateVisitStatus/$1'); $routes->post('visits/(:num)/notes','Practitioner::saveClinicalNote/$1'); $routes->post('visits/(:num)/prescription','Practitioner::createPrescription/$1'); $routes->post('visits/(:num)/lab','Practitioner::createLabRequest/$1'); $routes->get('patients','Practitioner::patients'); $routes->get('records','Practitioner::records'); $routes->get('prescriptions','Practitioner::prescriptions'); $routes->get('labs','Practitioner::labs'); $routes->get('telehealth','Practitioner::telehealth'); $routes->get('earnings','Practitioner::earnings'); $routes->get('availability','Practitioner::availability'); $routes->get('profile','Practitioner::profilePage'); $routes->post('profile','Practitioner::updateProfile'); $routes->post('credentials','Practitioner::addCredential');
});
$routes->group('partner',['filter'=>'role:partner'],static function($routes){
    $routes->get('/','Partner::dashboard'); $routes->get('labs','Partner::labs'); $routes->get('pharmacy','Partner::pharmacy'); $routes->get('referrals','Partner::referrals'); $routes->get('payments','Partner::payments'); $routes->get('settings','Partner::settings');
});
$routes->group('admin',['filter'=>'role:admin,operations'],static function($routes){
    $routes->get('/','Admin::dashboard'); $routes->get('practitioners','Admin::practitioners'); $routes->get('credentials','Admin::credentials'); $routes->post('credentials/(:num)/(:alpha)','Admin::credentialDecision/$1/$2'); $routes->post('practitioners/(:num)/approve','Admin::approvePractitioner/$1'); $routes->get('patients','Admin::patients'); $routes->get('requests','Admin::requests'); $routes->get('visits','Admin::visits'); $routes->get('clinical','Admin::clinical'); $routes->get('payments','Admin::payments'); $routes->get('payouts','Admin::payouts'); $routes->get('partners','Admin::partners'); $routes->get('reviews','Admin::reviews'); $routes->get('services','Admin::services'); $routes->post('services','Admin::saveService'); $routes->post('services/(:num)/toggle','Admin::toggleService/$1'); $routes->get('analytics','Admin::analytics'); $routes->get('audit','Admin::audit'); $routes->get('settings','Admin::settings');
});
$routes->post('api/v1/auth/login','Api\\MobileApi::login',['filter'=>'ratelimit:10,60']);
$routes->group('api/v1/mobile',['filter'=>'apitoken'],static function($routes){ $routes->get('me','Api\\MobileApi::me'); $routes->post('logout','Api\\MobileApi::logout'); $routes->post('patient/requests','Api\\MobileApi::createPatientRequest'); $routes->get('practitioner/offers','Api\\MobileApi::practitionerOffers'); });
$routes->group('api/v1',['filter'=>'ratelimit:60,60'],static function($routes){
    $routes->get('services','Api\\CareApi::services'); $routes->get('practitioners/nearby','Api\\CareApi::nearby'); $routes->get('requests/(:num)/status','Api\\CareApi::requestStatus/$1',['filter'=>'auth']);
});
