add the ablitiy to truncate series on the site

This commit is contained in:
Ross
2023-12-18 11:54:00 +00:00
parent e1c81e04b1
commit 7b21b1ad6f
7 changed files with 255 additions and 77 deletions
+2 -16
View File
@@ -466,7 +466,7 @@ def extract_image_dicom_json_from_ds(ds, url, image_index):
class SeriesImage(SeriesImageBase):
image = models.FileField(upload_to=image_directory_path)
image = models.FileField(upload_to=image_directory_path, null=True)
series = models.ForeignKey(
"Series", related_name="images", on_delete=models.CASCADE, null=True
)
@@ -479,11 +479,6 @@ class SeriesImage(SeriesImageBase):
help_text="Reference to the object that has replaced this one.",
)
removed = models.BooleanField(
default=False,
help_text="Set to true if the file this object refers to has been removed (either from series truncation or merging)",
)
def get_dicom_data(self):
try:
with pydicom.dcmread(self.image) as d:
@@ -563,15 +558,6 @@ class Series(SeriesBase):
related_name="series",
)
class SeriesModifiedChocies(models.TextChoices):
NO = "NO", "Not modified",
TR = "TR", "Truncated",
RE = "RE", "Resliced/resampled",
modified = models.CharField(max_length=2, default=SeriesModifiedChocies.NO, choices=SeriesModifiedChocies.choices)
series_instance_uid = models.CharField(max_length=255, blank=True, null=True)
# findings = models.TextField(null=True, blank=True, help_text="Findings on the series / stack")
@@ -603,7 +589,7 @@ class Series(SeriesBase):
# TODO: clean up (this is rather convoluted....)
image: SeriesImage
for series_n, image in enumerate(self.images.all()):
for series_n, image in enumerate(self.images.filter(removed=False)):
ds = image.get_dicom_data()
if series_n == 0:
for tag in to_keep: