Add Procedure model and integrate into CaseForm; update views and templates for procedure handling

This commit is contained in:
Ross
2026-02-16 14:04:37 +00:00
parent c61f92ae9e
commit a51a5c8d54
7 changed files with 141 additions and 1 deletions
+37
View File
@@ -396,6 +396,35 @@ class PathologicalProcess(models.Model):
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self.name)
class Procedure(SynMixin, models.Model):
"""A procedure or operation performed on the patient (attachable to Cases).
This mirrors the lightweight structure used by `Presentation` / `PathologicalProcess`.
"""
name = models.CharField(max_length=255, unique=True)
# Optional canonical/alias pointer for future synonym handling
canonical = models.ForeignKey(
"self",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="aliases",
help_text="If set, this Procedure is an alias and points to the canonical Procedure.",
)
subspecialty = models.ManyToManyField("subspecialty", blank=True)
def __str__(self) -> str:
return self.name
def get_absolute_url(self):
return reverse("atlas:procedure_detail", kwargs={"pk": self.pk})
def get_link(self):
return format_html("<a href='{}'>{}</a>", self.get_absolute_url(), self.name)
class Differential(models.Model):
condition = models.ForeignKey(Condition, on_delete=models.CASCADE)
case = models.ForeignKey(
@@ -484,6 +513,13 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
help_text="The presentation(s) the case is associated with.",
)
# Procedures performed on the patient (e.g. operations, interventions)
procedures = models.ManyToManyField(
"Procedure",
blank=True,
help_text="Procedure(s) or operations the patient has undergone.",
)
pathological_process = models.ManyToManyField(PathologicalProcess, blank=True)
differential = models.ManyToManyField(
@@ -830,6 +866,7 @@ class NormalCase(models.Model, AuthorMixin):
notes = models.TextField(null=True, blank=True)
class Meta:
ordering = ["-added_date"]