Refactor code structure and remove redundant functions for improved readability
This commit is contained in:
@@ -585,6 +585,30 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
|
|||||||
else:
|
else:
|
||||||
return images
|
return images
|
||||||
|
|
||||||
|
def get_case_named_stacks(self):
|
||||||
|
def build_stacks_for(case_obj, prefix=None):
|
||||||
|
logger.debug(f"Building stacks for case {case_obj.pk} with prefix '{prefix}'")
|
||||||
|
stacks = []
|
||||||
|
for series in case_obj.get_ordered_series():
|
||||||
|
images = [f"{REMOTE_URL}{img.image.url}" for img in series.images.all()]
|
||||||
|
name = f"{prefix}: {series}" if prefix else str(series)
|
||||||
|
stacks.append({"name": name, "imageIds": images})
|
||||||
|
return stacks
|
||||||
|
|
||||||
|
results = []
|
||||||
|
|
||||||
|
logger.debug(f"Building stacks for case {self.pk}")
|
||||||
|
|
||||||
|
# main case entry
|
||||||
|
results.append(
|
||||||
|
{
|
||||||
|
"caseId": f"",
|
||||||
|
"studyId": f"Current Case",
|
||||||
|
"stacks": build_stacks_for(self, prefix=None),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return json.dumps(results)
|
||||||
|
|
||||||
def extract_image_dicom_json_from_ds(ds, url, image_index):
|
def extract_image_dicom_json_from_ds(ds, url, image_index):
|
||||||
to_keep = [
|
to_keep = [
|
||||||
|
|||||||
@@ -125,7 +125,7 @@
|
|||||||
<div id="main_viewer" class="dicom-viewer-root"
|
<div id="main_viewer" class="dicom-viewer-root"
|
||||||
style="box-sizing: border-box; background: #222; width: 100%; height: 600px;"
|
style="box-sizing: border-box; background: #222; width: 100%; height: 600px;"
|
||||||
data-auto-cache-stack="false"
|
data-auto-cache-stack="false"
|
||||||
data-images='{{case.get_series_images_nested}}'
|
data-named-stacks='{{case.get_case_named_stacks}}'
|
||||||
></div>
|
></div>
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|||||||
+160
-160
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user