radfusion/app/DAL/Studies/WorklistFactory.php
2025-01-03 20:04:47 +06:00

26 lines
655 B
PHP

<?php
namespace App\DAL\Studies;
use App\Models\Enums\UserRole;
use Exception;
final readonly class WorklistFactory
{
/**
* @throws Exception
*/
public static function getLister(): IUserStudyLister
{
$role = auth()->user()->roles()->first()->name;
return match (UserRole::from($role)) {
UserRole::Admin => new AdminWorklist,
UserRole::Technician => new TechnicianWorklist,
UserRole::Radiologist => new RadiologistWorklist,
UserRole::ReferringDoctor => new ReferrerWorklist,
default => throw new Exception("Unknown user role: $role"),
};
}
}