Skip to content

Commit

Permalink
#136 Skip DICOM files without required uids (#138)
Browse files Browse the repository at this point in the history
- Encode url path segments
  • Loading branch information
ayselafsar authored Dec 24, 2024
1 parent 39d49e4 commit 56a385f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/Controller/DisplayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ private function isEncryptionEnabled() {
return $encryptionEnabled === 'yes';
}

private function encodeUrlPathSegments($url) {
$segments = explode('/', $url);

foreach ($segments as $index => $segment) {
if ($index > 2 && $segment !== '') {
$segments[$index] = rawurlencode($segment);
}
}

return implode('/', $segments);
}

private function generateDICOMJson($dicomFilePaths, $dicomFileNodes, $selectedFileFullPath, $parentFullPath, $currentUserPathToFile, $downloadUrlPrefix, $isPublic, $singlePublicFileDownload) {
$dicomJson = array('studies' => array());

Expand Down Expand Up @@ -271,6 +283,11 @@ private function generateDICOMJson($dicomFilePaths, $dicomFileNodes, $selectedFi
$WindowWidth = $this->cleanDICOMTagValue($dicom->value(0x0028, 0x1051));
$SeriesDate = $this->cleanDICOMTagValue($dicom->value(0x0008, 0x0021));

if (!$StudyInstanceUID || !$SeriesInstanceUID || !$SOPInstanceUID) {
// Skip if any of the required tags are missing
continue;
}

// STUDY
$studyIndex = $this->arrayFindIndex($dicomJson['studies'], 'StudyInstanceUID', $StudyInstanceUID);
if ($studyIndex < 0) {
Expand Down Expand Up @@ -335,7 +352,7 @@ private function generateDICOMJson($dicomFilePaths, $dicomFileNodes, $selectedFi
'WindowWidth' => $WindowWidth ? explode('\\', $WindowWidth)[0] : $WindowWidth,
'SeriesDate' => $SeriesDate,
),
'url' => 'dicomweb:'.$fileUrl,
'url' => 'dicomweb:'.$this->encodeUrlPathSegments($fileUrl),
);
array_push($dicomJson['studies'][$studyIndex]['series'][$seriesIndex]['instances'], $instance);
$dicomJson['studies'][$studyIndex]['NumInstances']++;
Expand Down

0 comments on commit 56a385f

Please sign in to comment.