DDL
This commit is contained in:
parent
ce182aa792
commit
d5a30a79ea
@ -5,9 +5,9 @@
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final readonly class Radiologist
|
||||
final readonly class Radiologists
|
||||
{
|
||||
public static function assignables()
|
||||
public static function worklist_stats(int $days, int $report_status)
|
||||
{
|
||||
$sql = <<<'SQL'
|
||||
SELECT
|
||||
@ -26,8 +26,8 @@ public static function assignables()
|
||||
studies
|
||||
WHERE
|
||||
--received_at::DATE >= NOW() - INTERVAL '3 DAY'
|
||||
assigned_at::DATE >= NOW() - INTERVAL '3 DAY'
|
||||
AND report_status < 3
|
||||
assigned_at::DATE >= NOW() - INTERVAL '%d DAY'
|
||||
AND report_status < %d
|
||||
AND reported_at IS NULL
|
||||
GROUP BY
|
||||
assigned_physician_id
|
||||
@ -42,7 +42,7 @@ public static function assignables()
|
||||
users.display_name
|
||||
SQL;
|
||||
|
||||
$rows = DB::select($sql);
|
||||
$rows = DB::select(sprintf($sql, $days, $report_status));
|
||||
foreach ($rows as $row) {
|
||||
$row->last_seen = UserService::getLastSeen((int) $row->id);
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Staff;
|
||||
|
||||
use App\DAL\Radiologist;
|
||||
use App\DAL\Radiologists;
|
||||
use App\Http\Controllers\HashidControllerBase;
|
||||
use App\Http\Requests\AssignPhysicianRequest;
|
||||
use App\Models\Enums\UserRole;
|
||||
@ -18,7 +18,7 @@ public function show()
|
||||
$this->decodeKeys();
|
||||
$study = Study::with('assignedPhysician')->findOrFail($this->key);
|
||||
$rads = User::active()->role(UserRole::Radiologist)->get(['id', 'display_name', 'profile_photo_path', 'first_name', 'last_name', 'created_at']);
|
||||
$stats = Radiologist::assignables();
|
||||
$stats = Radiologists::worklist_stats();
|
||||
foreach ($stats as $rad) {
|
||||
$found = $rads->where('id', $rad->id)->first();
|
||||
if ($found) {
|
||||
|
@ -35,7 +35,6 @@ public function definition(): array
|
||||
'username' => fake()->unique()->userName(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => fake()->dateTime(),
|
||||
'last_seen_at' => fake()->dateTime(),
|
||||
'phone' => fake()->phoneNumber(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'two_factor_secret' => null,
|
||||
|
@ -27,7 +27,6 @@ public function up(): void
|
||||
$table->foreignIdFor(Institute::class)->nullable()->index();
|
||||
$table->foreignIdFor(Facility::class)->nullable()->index();
|
||||
$table->string('timezone')->default('Asia/Dhaka');
|
||||
$table->timestamp('last_seen_at')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
@ -19,8 +19,8 @@ public function run(): void
|
||||
'name' => 'Chevron',
|
||||
'is_active' => true,
|
||||
]);
|
||||
$srini = Institute::create([
|
||||
'name' => 'Srinivasa',
|
||||
$cmch = Institute::create([
|
||||
'name' => 'CMCH',
|
||||
'is_active' => true,
|
||||
]);
|
||||
Institute::create([
|
||||
|
@ -24,7 +24,7 @@ public function run(): void
|
||||
|
||||
$usr = User::factory()->create([
|
||||
'first_name' => 'Administrator',
|
||||
'display_name' => 'Administrator',
|
||||
'display_name' => 'Admin',
|
||||
'username' => 'admin',
|
||||
'email' => 'admin@example.com',
|
||||
'email_verified_at' => now(),
|
||||
@ -33,7 +33,7 @@ public function run(): void
|
||||
$usr->assignRole(UserRole::Admin);
|
||||
|
||||
$chevron = Institute::where('name', 'Chevron')->first();
|
||||
$srini = Institute::where('name', 'Srinivasa')->first();
|
||||
$cmch = Institute::where('name', 'CMCH')->first();
|
||||
|
||||
User::factory(2)->create([
|
||||
'institute_id' => $chevron->id,
|
||||
@ -42,18 +42,18 @@ public function run(): void
|
||||
$u->assignRole(UserRole::Technician);
|
||||
});
|
||||
User::factory(2)->create([
|
||||
'institute_id' => $srini->id,
|
||||
'institute_id' => $cmch->id,
|
||||
])
|
||||
->each(function ($u) {
|
||||
$u->assignRole(UserRole::Technician);
|
||||
});
|
||||
|
||||
User::factory(4)->create()
|
||||
User::factory(8)->create()
|
||||
->each(function ($u) {
|
||||
$u->assignRole(UserRole::Radiologist);
|
||||
});
|
||||
|
||||
User::factory(4)->create()
|
||||
User::factory(3)->create()
|
||||
->each(function ($u) {
|
||||
$u->assignRole(UserRole::Guest);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user