<?php

declare(strict_types=1);

require_once dirname(__DIR__) . '/app/bootstrap.php';

use App\Controllers\AuthController;
use App\Controllers\BedsController;
use App\Controllers\ActionCenterController;
use App\Controllers\DashboardController;
use App\Controllers\DoctorsController;
use App\Controllers\LabRadiologyController;
use App\Controllers\InpatientDailyRevenueController;
use App\Controllers\OperationsController;
use App\Controllers\RevenueController;
use App\Controllers\SpecialtyFinanceController;
use App\Core\Request;

$page = (string) Request::get('page', 'dashboard');
$method = Request::method();

switch ($page) {
    case 'login':
        if ($method === 'POST') {
            (new AuthController())->login();
        } else {
            (new AuthController())->loginForm();
        }
        break;

    case 'switch-hospital':
        if ($method === 'POST') {
            (new AuthController())->switchHospital();
        } else {
            \redirect('index.php?page=dashboard&lang=' . \current_lang());
        }
        break;

    case 'logout':
        (new AuthController())->logout();
        break;

    case 'dashboard':
        (new DashboardController())->index();
        break;

    case 'action-center':
        (new ActionCenterController())->index();
        break;

    case 'action-review':
        if ($method === 'POST') {
            (new ActionCenterController())->updateReview();
        } else {
            (new ActionCenterController())->review();
        }
        break;

    case 'revenue':
        (new RevenueController())->index();
        break;

    case 'inpatient-daily-revenue':
        (new InpatientDailyRevenueController())->index();
        break;

    case 'inpatient-daily-revenue-export':
        (new InpatientDailyRevenueController())->export();
        break;

    case 'specialty-finance':
        (new SpecialtyFinanceController())->index();
        break;

    case 'visits':
    case 'operations':
        (new OperationsController())->module($page);
        break;

    case 'beds':
        (new BedsController())->index();
        break;

    case 'doctors':
        (new DoctorsController())->index();
        break;

    case 'lab':
        (new LabRadiologyController())->index();
        break;

    default:
        (new DashboardController())->index();
        break;
}
