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