36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Carbon\Carbon;
|
|
use GuzzleHttp\Client;
|
|
|
|
final class Pacs
|
|
{
|
|
public function getClient(): Client
|
|
{
|
|
return new Client([
|
|
'base_uri' => config('pacs.api.endpoint'),
|
|
]);
|
|
}
|
|
|
|
public function getStudies(): array
|
|
{
|
|
$url = '/studies?'.http_build_query(['expand' => '1']);
|
|
$response = $this->getClient()->get($url);
|
|
|
|
$studies = json_decode($response->getBody()->getContents(), true);
|
|
$result = [];
|
|
foreach ($studies as $study) {
|
|
$study['LastUpdate'] = Carbon::parse($study['LastUpdate'], 'UTC')->tz(config('app.timezone'))->toDateTimeString();
|
|
$sdt = $study['MainDicomTags']['StudyDate'].' '.$study['MainDicomTags']['StudyTime'];
|
|
$study_date = Carbon::createFromFormat('Ymd His.u', $study['MainDicomTags']['StudyDate'].' '.$study['MainDicomTags']['StudyTime'], 'UTC');
|
|
$study['StudyDateTime'] = $study_date->tz(config('app.timezone'))->toDateTimeString();
|
|
|
|
$result[] = $study;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|