40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Pacs\Sync\Pipes;
|
|
|
|
use App\DAL\Studies;
|
|
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) {
|
|
$study_id = Studies::getStudyIdByOrthancUuid($orthanc_uuid);
|
|
if ($study_id === null) {
|
|
continue;
|
|
}
|
|
|
|
$payload = [
|
|
'is_archived' => true,
|
|
'updated_at' => now(),
|
|
];
|
|
DB::table('studies')->where('id', $study_id)->update($payload);
|
|
|
|
audit()
|
|
->by(sync_agent_id())
|
|
->category(Category::SYSTEM)
|
|
->on($study_id)
|
|
->orthanc($orthanc_uuid)
|
|
->did(Activity::Study_Archived)
|
|
->log(false);
|
|
}
|
|
|
|
return $next($sync);
|
|
}
|
|
}
|