wip
This commit is contained in:
parent
f5c59bbea2
commit
ddb9edf013
@ -3,13 +3,16 @@
|
|||||||
namespace App\Http\Controllers\System;
|
namespace App\Http\Controllers\System;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\OrthancHost;
|
||||||
use App\Services\Pacs\Sync\StudiesSync;
|
use App\Services\Pacs\Sync\StudiesSync;
|
||||||
|
|
||||||
class SyncOrthancController extends Controller
|
class SyncOrthancController extends Controller
|
||||||
{
|
{
|
||||||
public function __invoke()
|
public function __invoke()
|
||||||
{
|
{
|
||||||
(new StudiesSync)->execute();
|
foreach (OrthancHost::active()->get() as $host) {
|
||||||
|
(new StudiesSync($host))->execute();
|
||||||
|
}
|
||||||
|
|
||||||
return redirect()->route('staff.worklist.index');
|
return redirect()->route('staff.worklist.index');
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Traits\Active;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
class Facility extends Model
|
class Facility extends Model
|
||||||
{
|
{
|
||||||
|
use Active;
|
||||||
|
|
||||||
public function institute(): BelongsTo
|
public function institute(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Institute::class);
|
return $this->belongsTo(Institute::class);
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Traits\Active;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
class Institute extends BaseModel
|
class Institute extends BaseModel
|
||||||
{
|
{
|
||||||
|
use Active;
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
|
@ -2,16 +2,19 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Traits\Active;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
class OrthancHost extends BaseModel
|
class OrthancHost extends BaseModel
|
||||||
{
|
{
|
||||||
|
use Active;
|
||||||
|
|
||||||
public function institute(): BelongsTo
|
public function institute(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Institute::class);
|
return $this->belongsTo(Institute::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function facilty(): BelongsTo
|
public function facility(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Facility::class);
|
return $this->belongsTo(Facility::class);
|
||||||
}
|
}
|
||||||
|
23
app/Models/Traits/Active.php
Normal file
23
app/Models/Traits/Active.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
|
trait Active
|
||||||
|
{
|
||||||
|
public function scopeActive(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->getActiveColumnName(), '=', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeInactive(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where($this->getActiveColumnName(), '=', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getActiveColumnName(): string
|
||||||
|
{
|
||||||
|
return 'is_active';
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\ACL\Permission;
|
use App\Domain\ACL\Permission;
|
||||||
use App\Domain\ACL\Role;
|
use App\Domain\ACL\Role;
|
||||||
|
use App\Models\Traits\Active;
|
||||||
use App\Models\Traits\HashableId;
|
use App\Models\Traits\HashableId;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@ -21,11 +22,10 @@
|
|||||||
|
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
|
use Active;
|
||||||
use HasApiTokens;
|
use HasApiTokens;
|
||||||
|
|
||||||
/** @use HasFactory<UserFactory> */
|
/** @use HasFactory<UserFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
use HashableId;
|
use HashableId;
|
||||||
use HasProfilePhoto;
|
use HasProfilePhoto;
|
||||||
use HasRoles;
|
use HasRoles;
|
||||||
@ -77,11 +77,6 @@ class User extends Authenticatable
|
|||||||
'last_seen',
|
'last_seen',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function scopeActive($query)
|
|
||||||
{
|
|
||||||
return $query->where('is_active', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isAdmin(): bool
|
public function isAdmin(): bool
|
||||||
{
|
{
|
||||||
return cache()->remember('user.is_admin:' . $this->id,
|
return cache()->remember('user.is_admin:' . $this->id,
|
||||||
|
@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Services\Pacs;
|
namespace App\Services\Pacs;
|
||||||
|
|
||||||
|
use App\Models\OrthancHost;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
|
||||||
final class OrthancRestClient
|
final class OrthancRestClient
|
||||||
{
|
{
|
||||||
|
public function __construct(private readonly OrthancHost $orthancHost) {}
|
||||||
|
|
||||||
public function getClient(): Client
|
public function getClient(): Client
|
||||||
{
|
{
|
||||||
return new Client([
|
return new Client([
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Study\Priority;
|
use App\Domain\Study\Priority;
|
||||||
use App\Domain\Study\StudyLevelStatus;
|
use App\Domain\Study\StudyLevelStatus;
|
||||||
|
use App\Models\OrthancHost;
|
||||||
use App\Services\Pacs\DicomUtils;
|
use App\Services\Pacs\DicomUtils;
|
||||||
use App\Services\Pacs\InstituteMapper;
|
use App\Services\Pacs\InstituteMapper;
|
||||||
use App\Services\Pacs\OrthancRestClient;
|
use App\Services\Pacs\OrthancRestClient;
|
||||||
@ -25,13 +26,18 @@ class StudiesSync
|
|||||||
|
|
||||||
private OrthancRestClient $client;
|
private OrthancRestClient $client;
|
||||||
|
|
||||||
public function __construct(?OrthancRestClient $client = null)
|
public function __construct(private readonly OrthancHost $orthancHost, ?OrthancRestClient $client = null)
|
||||||
{
|
{
|
||||||
$this->study_ids = collect();
|
$this->study_ids = collect();
|
||||||
$this->client = $client ?? new OrthancRestClient;
|
$this->client = $client ?? new OrthancRestClient($orthancHost);
|
||||||
$this->resetQueues();
|
$this->resetQueues();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOrthancHost(): OrthancHost
|
||||||
|
{
|
||||||
|
return $this->orthancHost;
|
||||||
|
}
|
||||||
|
|
||||||
public function execute(): void
|
public function execute(): void
|
||||||
{
|
{
|
||||||
app(Pipeline::class)
|
app(Pipeline::class)
|
||||||
@ -61,7 +67,7 @@ public function setStudyIds(array $study_ids): void
|
|||||||
$this->study_ids = collect($study_ids);
|
$this->study_ids = collect($study_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resetQueues()
|
public function resetQueues(): void
|
||||||
{
|
{
|
||||||
$this->insert_queue = collect();
|
$this->insert_queue = collect();
|
||||||
$this->update_queue = collect();
|
$this->update_queue = collect();
|
||||||
@ -107,6 +113,7 @@ public function transformData(mixed $orthanc_src): array
|
|||||||
$patient_name = data_get($orthanc_src, 'PatientMainDicomTags.PatientName');
|
$patient_name = data_get($orthanc_src, 'PatientMainDicomTags.PatientName');
|
||||||
|
|
||||||
$study = [
|
$study = [
|
||||||
|
'orthanc_host_id' => $this->orthancHost->id,
|
||||||
'orthanc_uuid' => strtolower($orthanc_src['ID']),
|
'orthanc_uuid' => strtolower($orthanc_src['ID']),
|
||||||
'institution_name' => $inst_name,
|
'institution_name' => $inst_name,
|
||||||
'institute_id' => $inst_id,
|
'institute_id' => $inst_id,
|
||||||
|
@ -15,7 +15,7 @@ public function up(): void
|
|||||||
Schema::create('studies', function (Blueprint $table) {
|
Schema::create('studies', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignIdFor(OrthancHost::class)->index();
|
$table->foreignIdFor(OrthancHost::class)->index();
|
||||||
$table->uuid('orthanc_uuid')->index();
|
$table->string('orthanc_uuid')->index();
|
||||||
$table->boolean('is_archived')->default(false);
|
$table->boolean('is_archived')->default(false);
|
||||||
$table->unsignedTinyInteger('priority')->default(Priority::Routine);
|
$table->unsignedTinyInteger('priority')->default(Priority::Routine);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user