Refactor code structure for improved readability and maintainability
This commit is contained in:
+31
-3
@@ -839,7 +839,21 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
|
||||
for series in case_obj.get_ordered_series():
|
||||
images = [f"{REMOTE_URL}{img.image.url}" for img in series.get_images()]
|
||||
name = f"{prefix}: {series}" if prefix else str(series)
|
||||
stacks.append({"name": name, "imageIds": images, "seriesId": series.pk})
|
||||
stacks.append(
|
||||
{
|
||||
"name": name,
|
||||
"imageIds": images,
|
||||
"seriesId": series.pk,
|
||||
"series": [
|
||||
{
|
||||
"name": name,
|
||||
"imageIds": images,
|
||||
"seriesId": series.pk,
|
||||
"seriesInstanceUID": series.series_instance_uid,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
return stacks
|
||||
|
||||
results = []
|
||||
@@ -1929,9 +1943,23 @@ class CaseDetail(models.Model):
|
||||
def build_stacks_for(case_obj, prefix=None):
|
||||
stacks = []
|
||||
for series in case_obj.get_ordered_series():
|
||||
images = [f"{REMOTE_URL}{img.image.url}" for img in series.images.all()]
|
||||
images = [f"{REMOTE_URL}{img.image.url}" for img in series.get_images()]
|
||||
name = f"{prefix}: {series}" if prefix else str(series)
|
||||
stacks.append({"name": name, "imageIds": images, "seriesId": series.pk})
|
||||
stacks.append(
|
||||
{
|
||||
"name": name,
|
||||
"imageIds": images,
|
||||
"seriesId": series.pk,
|
||||
"series": [
|
||||
{
|
||||
"name": name,
|
||||
"imageIds": images,
|
||||
"seriesId": series.pk,
|
||||
"seriesInstanceUID": series.series_instance_uid,
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
return stacks
|
||||
|
||||
results = []
|
||||
|
||||
@@ -1676,6 +1676,7 @@
|
||||
caseId: stack.caseId || caseId,
|
||||
studyId: stack.studyId || studyId,
|
||||
seriesId: stack.seriesId || null,
|
||||
series: Array.isArray(stack.series) ? stack.series : null,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1686,6 +1687,7 @@
|
||||
caseId: item.caseId || null,
|
||||
studyId: item.studyId || null,
|
||||
seriesId: item.seriesId || null,
|
||||
series: Array.isArray(item.series) ? item.series : null,
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1756,7 +1758,7 @@
|
||||
// Fallback: at least add stack to viewer list and auto-fill an empty viewport if available.
|
||||
const loadAdditionalStackFn = getViewerApi('loadAdditionalStack');
|
||||
if (loadAdditionalStackFn) {
|
||||
await loadAdditionalStackFn(target.imageIds, target.studyId);
|
||||
await loadAdditionalStackFn(target.imageIds, target.studyId, target.series || undefined);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
+73
-73
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user