migrated - orthanc_host to dicom_server

This commit is contained in:
Dr Masroor Ehsan 2025-01-10 15:52:28 +06:00
parent b28eb94014
commit de0dd230b0
10 changed files with 32 additions and 32 deletions

View File

@ -164,7 +164,7 @@ protected function getStudiesQuery(): Builder
$q = Study::query();
}
return $q->with(['readingPhysician', 'assignedPhysician', 'orthancHost']);
return $q->with(['readingPhysician', 'assignedPhysician', 'dicomServer']);
}
protected function applySort(Builder $query): Builder

View File

@ -3,14 +3,14 @@
namespace App\Http\Controllers\System;
use App\Http\Controllers\Controller;
use App\Models\OrthancHost;
use App\Models\DicomServer;
use App\Services\Pacs\Sync\StudiesSync;
class SyncOrthancController extends Controller
{
public function __invoke()
{
foreach (OrthancHost::active()->get() as $host) {
foreach (DicomServer::active()->get() as $host) {
(new StudiesSync($host))->execute();
}

View File

@ -6,7 +6,7 @@
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Uri;
class OrthancHost extends BaseModel
class DicomServer extends BaseModel
{
use Active;

View File

@ -118,9 +118,9 @@ public function assignedPhysician(): BelongsTo
return $this->belongsTo(User::class, 'assigned_physician_id');
}
public function orthancHost(): BelongsTo
public function dicomServer(): BelongsTo
{
return $this->belongsTo(OrthancHost::class);
return $this->belongsTo(DicomServer::class);
}
public function isAssigned(int $rad_id): bool
@ -163,7 +163,7 @@ public function getReportStatusLedAttribute(): string
public function getArchiveLink(): ?string
{
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::archive($this->orthancHost, $this);
return PacsUrlGen::archive($this->dicomServer, $this);
}
return null;
@ -172,7 +172,7 @@ public function getArchiveLink(): ?string
public function getStoneLink(): ?string
{
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::stoneViewer($this->orthancHost, $this);
return PacsUrlGen::stoneViewer($this->dicomServer, $this);
}
return null;
@ -181,7 +181,7 @@ public function getStoneLink(): ?string
public function getOhifLink(): ?string
{
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::ohifViewer($this->orthancHost, $this);
return PacsUrlGen::ohifViewer($this->dicomServer, $this);
}
return null;
@ -190,7 +190,7 @@ public function getOhifLink(): ?string
public function getOhifSegmentationLink(): ?string
{
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::ohifSegmentation($this->orthancHost, $this);
return PacsUrlGen::ohifSegmentation($this->dicomServer, $this);
}
return null;
@ -199,7 +199,7 @@ public function getOhifSegmentationLink(): ?string
public function getOhifMprLink(): ?string
{
if (me()->may(Permission::StudyDownload)) {
return PacsUrlGen::ohifViewerMpr($this->orthancHost, $this);
return PacsUrlGen::ohifViewerMpr($this->dicomServer, $this);
}
return null;

View File

@ -2,12 +2,12 @@
namespace App\Services\Pacs;
use App\Models\OrthancHost;
use App\Models\DicomServer;
use GuzzleHttp\Client;
final class OrthancRestClient
{
public function __construct(private readonly OrthancHost $orthancHost) {}
public function __construct(private readonly DicomServer $orthancHost) {}
public function getClient(): Client
{

View File

@ -2,20 +2,20 @@
namespace App\Services\Pacs;
use App\Models\OrthancHost;
use App\Models\DicomServer;
use App\Models\Study;
use Uri;
final class PacsUrlGen
{
public static function stoneViewer(OrthancHost $host, Study $study): string
public static function stoneViewer(DicomServer $host, Study $study): string
{
$url = $host->stoneViewerUrl()->withQuery(['study' => $study->study_instance_uid]);
return (string) $url;
}
public static function ohifViewer(OrthancHost $host, Study $study): string
public static function ohifViewer(DicomServer $host, Study $study): string
{
$url = $host->ohifViewerUrl()
->withQuery(['StudyInstanceUIDs' => $study->study_instance_uid]);
@ -23,7 +23,7 @@ public static function ohifViewer(OrthancHost $host, Study $study): string
return (string) $url;
}
public static function ohifViewerMpr(OrthancHost $host, Study $study): string
public static function ohifViewerMpr(DicomServer $host, Study $study): string
{
$url = $host->ohifViewerUrl()
->withQuery([
@ -34,7 +34,7 @@ public static function ohifViewerMpr(OrthancHost $host, Study $study): string
return (string) $url;
}
public static function ohifSegmentation(OrthancHost $host, Study $study): string
public static function ohifSegmentation(DicomServer $host, Study $study): string
{
$url = $host->ohifViewerUrl()
->withPath('/ohif/segmentation')
@ -43,7 +43,7 @@ public static function ohifSegmentation(OrthancHost $host, Study $study): string
return (string) $url;
}
public static function archive(OrthancHost $host, Study $study): string
public static function archive(DicomServer $host, Study $study): string
{
$url = Uri::of($host->rest_api_endpoint)
->withPath('/studies/' . $study->study_instance_uid . '/archive');

View File

@ -4,7 +4,7 @@
use App\Domain\Study\Priority;
use App\Domain\Study\StudyLevelStatus;
use App\Models\OrthancHost;
use App\Models\DicomServer;
use App\Services\Pacs\DicomUtils;
use App\Services\Pacs\InstituteMapper;
use App\Services\Pacs\OrthancRestClient;
@ -26,16 +26,16 @@ class StudiesSync
private OrthancRestClient $client;
public function __construct(private readonly OrthancHost $orthancHost, ?OrthancRestClient $client = null)
public function __construct(private readonly DicomServer $dicomServer, ?OrthancRestClient $client = null)
{
$this->study_ids = collect();
$this->client = $client ?? new OrthancRestClient($orthancHost);
$this->client = $client ?? new OrthancRestClient($dicomServer);
$this->resetQueues();
}
public function getOrthancHost(): OrthancHost
public function getDicomServer(): DicomServer
{
return $this->orthancHost;
return $this->dicomServer;
}
public function execute(): void
@ -113,7 +113,7 @@ public function transformData(mixed $orthanc_src): array
$patient_name = data_get($orthanc_src, 'PatientMainDicomTags.PatientName');
$study = [
'orthanc_host_id' => $this->orthancHost->id,
'dicom_server_id' => $this->dicomServer->id,
'orthanc_uuid' => strtolower($orthanc_src['ID']),
'institution_name' => $inst_name,
'institute_id' => $inst_id,

View File

@ -10,7 +10,7 @@
{
public function up(): void
{
Schema::create('orthanc_hosts', static function (Blueprint $table) {
Schema::create('dicom_servers', static function (Blueprint $table) {
$table->id();
$table->boolean('is_active')->index();
$table->string('server_name')->unique();
@ -31,6 +31,6 @@ public function up(): void
public function down(): void
{
Schema::dropIfExists('orthanc_hosts');
Schema::dropIfExists('dicom_servers');
}
};

View File

@ -3,7 +3,7 @@
use App\Domain\Report\ReportStatus;
use App\Domain\Study\Priority;
use App\Domain\Study\StudyLevelStatus;
use App\Models\OrthancHost;
use App\Models\DicomServer;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -14,7 +14,7 @@ public function up(): void
{
Schema::create('studies', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(OrthancHost::class)->index();
$table->foreignIdFor(DicomServer::class)->index();
$table->string('orthanc_uuid')->index();
$table->unsignedTinyInteger('priority')->default(Priority::Routine);

View File

@ -3,9 +3,9 @@
namespace Database\Seeders;
use App\Domain\Rule\NameMatchModes;
use App\Models\DicomServer;
use App\Models\Facility;
use App\Models\Institute;
use App\Models\OrthancHost;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
@ -56,7 +56,7 @@ public function run(): void
'match_mode' => NameMatchModes::StartsWith->value,
]);
OrthancHost::create(
DicomServer::create(
[
'is_active' => true,
'server_name' => 'Orthanc Main',
@ -68,7 +68,7 @@ public function run(): void
'ohif_viewer_path' => 'ohif/viewer',
]
);
OrthancHost::create(
DicomServer::create(
[
'is_active' => false,
'server_name' => 'Orthanc XR',