study importer

This commit is contained in:
Dr Masroor Ehsan 2024-12-28 22:35:52 +06:00
parent 3d6eb1543e
commit 3a9b27ef19
4 changed files with 10 additions and 14 deletions

View File

@ -29,9 +29,10 @@ public function show($id)
public function import() public function import()
{ {
$studies = (new OrthancRestClient)->getStudies(); $svc = (new StudyImporter);
$svc->scanStudies();
(new StudyImporter)->import($studies); $svc->filterStudies();
$svc->importStudies();
return redirect()->route('studies.index'); return redirect()->route('studies.index');
} }

View File

@ -25,7 +25,7 @@ public function getStudyDetails(string $study_id): array
$query = [ $query = [
'requested-tags' => implode(';', array_column(DicomTags::cases(), 'value')), 'requested-tags' => implode(';', array_column(DicomTags::cases(), 'value')),
]; ];
$response = $this->getClient()->get('/studies/'.$study_id.http_build_query($query)); $response = $this->getClient()->get('/studies/'.$study_id.'?'.http_build_query($query));
return json_decode($response->getBody()->getContents(), true); return json_decode($response->getBody()->getContents(), true);
} }

View File

@ -22,13 +22,6 @@ public function __construct(?OrthancRestClient $client = null)
$this->client = $client ?? new OrthancRestClient; $this->client = $client ?? new OrthancRestClient;
} }
public function import(array $studies): void
{
foreach ($studies as $study) {
$this->importStudy($study);
}
}
public function scanStudies() public function scanStudies()
{ {
$this->study_ids = $this->client->getStudiesIds(); $this->study_ids = $this->client->getStudiesIds();
@ -38,8 +31,10 @@ private function checkUpdate(string $orthanc_uid): void
{ {
$row = DB::table('studies')->where('orthanc_uid', $orthanc_uid)->first(['id', 'study_status']); $row = DB::table('studies')->where('orthanc_uid', $orthanc_uid)->first(['id', 'study_status']);
if ($row == null) { if ($row === null) {
$this->insert_queue[] = $orthanc_uid; $this->insert_queue[] = $orthanc_uid;
return;
} }
if ($row->study_status < StudyLevelStatus::StudyArrived->value) { if ($row->study_status < StudyLevelStatus::StudyArrived->value) {
@ -140,7 +135,7 @@ private function prepareData(mixed $study): array
if ($descr != null) { if ($descr != null) {
$descr = data_get($study, 'RequestedTags.AcquisitionDeviceProcessingDescription'); $descr = data_get($study, 'RequestedTags.AcquisitionDeviceProcessingDescription');
} }
$data['study_description'] = trim($descr); $data['study_description'] = trim($descr);
return $data; return $data;
} }

View File

@ -47,7 +47,7 @@ public function up(): void
$table->unsignedSmallInteger('image_count')->nullable(); $table->unsignedSmallInteger('image_count')->nullable();
$table->unsignedSmallInteger('series_count')->nullable(); $table->unsignedSmallInteger('series_count')->nullable();
$table->unsignedSmallInteger('disk_size')->nullable(); $table->unsignedInteger('disk_size')->nullable();
$table->foreignIdFor(User::class, 'assigned_physician_id')->nullable()->constrained()->onDelete('set null'); $table->foreignIdFor(User::class, 'assigned_physician_id')->nullable()->constrained()->onDelete('set null');
$table->foreignIdFor(User::class, 'interpreting_physician_id')->nullable()->constrained()->onDelete('set null'); $table->foreignIdFor(User::class, 'interpreting_physician_id')->nullable()->constrained()->onDelete('set null');