extract a little more shared case /longs
This commit is contained in:
+3
-13
@@ -42,6 +42,7 @@ from generic.models import (
|
||||
Contrast,
|
||||
QuestionNote,
|
||||
SeriesBase,
|
||||
SeriesImageBase,
|
||||
)
|
||||
|
||||
# from generic.models import Examination, Site, Condition, Sign
|
||||
@@ -319,23 +320,12 @@ class Case(models.Model):
|
||||
return f"{self.pk}:{self.title} {'/'.join([str(c) for c in self.condition.all()])} [{', '.join(examinations)}]"
|
||||
|
||||
|
||||
class SeriesImage(models.Model):
|
||||
class SeriesImage(SeriesImageBase):
|
||||
image = models.FileField(upload_to=image_directory_path)
|
||||
position = models.IntegerField(default=0)
|
||||
upload_filename = models.CharField(max_length=255, blank=True)
|
||||
series = models.ForeignKey(
|
||||
"Series", related_name="images", on_delete=models.SET_NULL, null=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["position"]
|
||||
|
||||
def get_dicom_info(self):
|
||||
try:
|
||||
info = pretty_print_dicom(pydicom.read_file(self.image))
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
info = "File is not a dicom."
|
||||
return info
|
||||
|
||||
|
||||
class SeriesFinding(models.Model):
|
||||
@@ -400,7 +390,7 @@ class Series(SeriesBase):
|
||||
|
||||
def get_full_str(self):
|
||||
if self.case:
|
||||
case_id = ", ".format([case.pk for case in self.case.all()])
|
||||
case_id = ", ".join([case.pk for case in self.case.all()])
|
||||
# case_id = self.case.pk
|
||||
else:
|
||||
case_id = "None"
|
||||
|
||||
@@ -24,6 +24,7 @@ from django.contrib.auth.models import User
|
||||
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from helpers.images import pretty_print_dicom
|
||||
from rad.settings import REMOTE_URL
|
||||
from django.utils.html import format_html
|
||||
|
||||
@@ -115,6 +116,24 @@ class QuestionBase(models.Model):
|
||||
"""If this makes sense in the question/answer context override"""
|
||||
return None
|
||||
|
||||
class SeriesImageBase(models.Model):
|
||||
position = models.IntegerField(default=0)
|
||||
upload_filename = models.CharField(max_length=255, blank=True)
|
||||
series = models.ForeignKey(
|
||||
"Series", related_name="images", on_delete=models.SET_NULL, null=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["position"]
|
||||
abstract = True
|
||||
|
||||
def get_dicom_info(self):
|
||||
try:
|
||||
info = pretty_print_dicom(pydicom.read_file(self.image))
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
info = "File is not a dicom."
|
||||
return info
|
||||
|
||||
|
||||
class SeriesBase(models.Model):
|
||||
description = models.TextField(
|
||||
|
||||
+2
-13
@@ -38,6 +38,7 @@ from generic.models import (
|
||||
QuestionBase,
|
||||
QuestionNote,
|
||||
SeriesBase,
|
||||
SeriesImageBase,
|
||||
UserAnswerBase,
|
||||
UserUserGroup,
|
||||
)
|
||||
@@ -351,24 +352,12 @@ def test_image_validator(file):
|
||||
pass
|
||||
|
||||
|
||||
class LongSeriesImage(models.Model):
|
||||
class LongSeriesImage(SeriesImageBase):
|
||||
image = models.FileField(upload_to=image_directory_path)
|
||||
position = models.IntegerField(default=0)
|
||||
upload_filename = models.CharField(max_length=255, blank=True)
|
||||
series = models.ForeignKey(
|
||||
"LongSeries", related_name="images", on_delete=models.SET_NULL, null=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["position"]
|
||||
|
||||
def get_dicom_info(self):
|
||||
try:
|
||||
info = pretty_print_dicom(pydicom.read_file(self.image))
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
info = "File is not a dicom."
|
||||
return info
|
||||
|
||||
|
||||
@reversion.register
|
||||
class LongSeries(SeriesBase):
|
||||
|
||||
Reference in New Issue
Block a user