orthanc
This commit is contained in:
parent
5a75524633
commit
3eb06e20a0
@ -3,6 +3,7 @@
|
||||
namespace App\Services\Pacs;
|
||||
|
||||
use App\Models\DicomServer;
|
||||
use App\Services\StudyRouter\RawDicomTags;
|
||||
use GuzzleHttp\Client;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
@ -10,14 +11,19 @@ final class OrthancRestClient
|
||||
{
|
||||
public function __construct(private readonly DicomServer $orthancHost) {}
|
||||
|
||||
private static function studyPath(string $study_id, ?string $sub = null): string
|
||||
private static function relativePath(string $study_id, ?string $child = null, array $query = [], string $parent = 'studies'): string
|
||||
{
|
||||
$parts = ['studies', ltrim($study_id, '/')];
|
||||
if (filled($sub)) {
|
||||
$parts[] = ltrim($sub, '/');
|
||||
$parts = [$parent, ltrim($study_id, '/')];
|
||||
if (filled($child)) {
|
||||
$parts[] = ltrim($child, '/');
|
||||
}
|
||||
|
||||
return implode('/', $parts);
|
||||
$path = implode('/', $parts);
|
||||
if (! empty($query)) {
|
||||
$path .= '?' . http_build_query($query);
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
private static function jsonify(ResponseInterface $response, bool $associative = true): mixed
|
||||
@ -51,21 +57,21 @@ public function getServerStatistics(): array
|
||||
|
||||
public function getStudySeries(string $study_id): array
|
||||
{
|
||||
$response = $this->getClient()->get(self::studyPath($study_id, 'series?expand'));
|
||||
$response = $this->getClient()->get(self::relativePath($study_id, 'series', ['expand' => 1]));
|
||||
|
||||
return self::jsonify($response);
|
||||
}
|
||||
|
||||
public function getStudyInstances(string $study_id): array
|
||||
{
|
||||
$response = $this->getClient()->get(self::studyPath($study_id, 'instances?expand'));
|
||||
$response = $this->getClient()->get(self::relativePath($study_id, 'instances', ['expand' => 1]));
|
||||
|
||||
return self::jsonify($response);
|
||||
}
|
||||
|
||||
public function getStudyInstancesList(string $study_id): array
|
||||
{
|
||||
$response = $this->getClient()->get(self::studyPath($study_id, 'instances?expand=0'));
|
||||
$response = $this->getClient()->get(self::relativePath($study_id, 'instances', ['expand' => 0]));
|
||||
|
||||
return self::jsonify($response);
|
||||
}
|
||||
@ -75,7 +81,18 @@ public function getStudyDetails(string $study_id): array
|
||||
$query = [
|
||||
'requested-tags' => implode(';', array_column(DicomTags::cases(), 'value')),
|
||||
];
|
||||
$response = $this->getClient()->get('/studies/' . $study_id . '?' . http_build_query($query));
|
||||
$response = $this->getClient()->get(self::relativePath($study_id, null, $query));
|
||||
|
||||
return self::jsonify($response);
|
||||
}
|
||||
|
||||
public function getInstanceDetails(string $instance_id, bool $rawTags = false): array
|
||||
{
|
||||
$query = $rawTags ? [
|
||||
'requested-tags' => implode(';', array_column(RawDicomTags::cases(), 'value')),
|
||||
'short' => 1,
|
||||
] : [];
|
||||
$response = $this->getClient()->get(self::relativePath($instance_id, null, $query, 'instances'));
|
||||
|
||||
return self::jsonify($response);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user