<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\Modules\Patient\Repositories\PatientRepository;
use App\Modules\Patient\Services\PatientService;
use App\Modules\Clinical\Repositories\EncounterRepository;
use App\Modules\Clinical\Services\EncounterService;
use App\Modules\Appointment\Repositories\AppointmentRepository;
use App\Modules\Appointment\Services\AppointmentService;
use App\Modules\Billing\Repositories\InvoiceRepository;
use App\Modules\Billing\Services\InvoiceService;
use App\Models\Patient;
use App\Models\Encounter;
use App\Models\Visit;

class ModuleServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        // Patient Module
        $this->app->bind(PatientRepository::class , function ($app) {
            return new PatientRepository(new Patient());
        });
        $this->app->singleton(PatientService::class);

        // Clinical Module
        $this->app->bind(EncounterRepository::class , function ($app) {
            return new EncounterRepository(new Encounter());
        });
        $this->app->singleton(EncounterService::class);
        $this->app->singleton(PrescriptionService::class);

        // Appointment Module
        $this->app->bind(AppointmentRepository::class , function ($app) {
            return new AppointmentRepository(new Visit());
        });
        $this->app->singleton(AppointmentService::class);

        // Billing Module
        $this->app->bind(InvoiceRepository::class , function ($app) {
            return new InvoiceRepository(new \App\Models\Invoice());
        });
        $this->app->singleton(InvoiceService::class);

        // Core Services
        $this->app->singleton(\App\Core\Services\DashboardService::class);
        $this->app->singleton(\App\Core\Base\GlobalSearchService::class);
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
    //
    }
}
