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