add future relations to cases in collection
This commit is contained in:
+29
-2
@@ -1054,6 +1054,21 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
|
||||
|
||||
return prior_cases
|
||||
|
||||
def get_all_future_cases(self):
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
future_cases = []
|
||||
current = self
|
||||
while True:
|
||||
try:
|
||||
next_c = current.next_case
|
||||
except ObjectDoesNotExist:
|
||||
break
|
||||
if next_c is None:
|
||||
break
|
||||
future_cases.append(next_c)
|
||||
current = next_c
|
||||
return future_cases
|
||||
|
||||
def get_series(self):
|
||||
return self.series.all().prefetch_related("images", "examination", "plane")
|
||||
|
||||
@@ -2383,11 +2398,12 @@ class CaseDetail(models.Model):
|
||||
if prior.prior_visibility == CasePrior.PriorVisibility.REVIEW and not review_mode:
|
||||
continue
|
||||
prior_case = prior.prior_case
|
||||
label = "Prior" if prior.relation_type == CasePrior.RelationType.PRIOR else "Future"
|
||||
results.append(
|
||||
{
|
||||
"caseId": f"CASE-{prior_case.pk}",
|
||||
"studyId": f"Prior: {prior.relation_text}",
|
||||
"stacks": build_stacks_for(prior_case, prefix="Prior"),
|
||||
"studyId": f"{label}: {prior.relation_text}",
|
||||
"stacks": build_stacks_for(prior_case, prefix=label),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2420,6 +2436,17 @@ class CasePrior(models.Model):
|
||||
|
||||
relation_text = models.CharField(max_length=255, blank=True, help_text="Text to describe the relationship between the cases")
|
||||
|
||||
class RelationType(models.TextChoices):
|
||||
PRIOR = "PR", _("Prior")
|
||||
FUTURE = "FU", _("Future")
|
||||
|
||||
relation_type = models.CharField(
|
||||
max_length=2,
|
||||
choices=RelationType.choices,
|
||||
default=RelationType.PRIOR,
|
||||
help_text="Defines whether the related case is a prior or a future exam",
|
||||
)
|
||||
|
||||
class PriorVisibility(models.TextChoices):
|
||||
NONE = "NO", _("None")
|
||||
ALWAYS = "AL", _("Always")
|
||||
|
||||
Reference in New Issue
Block a user