39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Pacs\Sync\Pipes;
|
|
|
|
use App\Services\AuditTrail\Activity;
|
|
use App\Services\AuditTrail\Category;
|
|
use App\Services\Pacs\Sync\StudiesSync;
|
|
use Closure;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
final readonly class ArchiveStudies
|
|
{
|
|
public function __invoke(StudiesSync $sync, Closure $next): StudiesSync
|
|
{
|
|
foreach ($sync->getArchiveQueue() as $orthanc_uuid) {
|
|
$row_id = DB::table('studies')->where(compact('orthanc_uuid'))->value('id');
|
|
if ($row_id === null) {
|
|
continue;
|
|
}
|
|
|
|
$payload = [
|
|
'is_archived' => true,
|
|
'updated_at' => now(),
|
|
];
|
|
DB::table('studies')->find($row_id)->update($payload);
|
|
|
|
audit()
|
|
->by(sync_agent_id())
|
|
->category(Category::SYSTEM)
|
|
->on($row_id)
|
|
->orthanc($orthanc_uuid)
|
|
->did(Activity::Study_Archived)
|
|
->log(false);
|
|
}
|
|
|
|
return $next($sync);
|
|
}
|
|
}
|