diff --git a/atlas/migrations/0006_auto_20211128_1448.py b/atlas/migrations/0006_auto_20211128_1448.py new file mode 100644 index 00000000..8f18b425 --- /dev/null +++ b/atlas/migrations/0006_auto_20211128_1448.py @@ -0,0 +1,34 @@ +# Generated by Django 3.2.4 on 2021-11-28 14:48 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('atlas', '0005_condition_primary_name'), + ] + + operations = [ + migrations.CreateModel( + name='Subspecialty', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + ), + migrations.RemoveField( + model_name='case', + name='subspecialty', + ), + migrations.AddField( + model_name='condition', + name='subspecialty', + field=models.ManyToManyField(blank=True, to='atlas.Subspecialty'), + ), + migrations.AddField( + model_name='case', + name='subspecialty', + field=models.ManyToManyField(blank=True, to='atlas.Subspecialty'), + ), + ] diff --git a/atlas/models.py b/atlas/models.py index cc0288d4..ebe0a6b2 100644 --- a/atlas/models.py +++ b/atlas/models.py @@ -81,6 +81,8 @@ class Condition(models.Model): primary_name = models.BooleanField(default="True") + subspecialty = models.ManyToManyField("subspecialty", blank=True) + def __str__(self) -> str: if self.synonym.count() == 0: return self.name @@ -88,21 +90,23 @@ class Condition(models.Model): synonyms = ",".join([i.name for i in self.synonym.all()]) return f"{self.name} ({synonyms})" +class Subspecialty(models.Model): + name = models.CharField(max_length=255) @reversion.register class Case(models.Model): - class SubspecialtyChoices(models.TextChoices): - BREAST = "BR", _("Breast") - CARDIAC = "CA", _("Cardiac") - GASTRO = "GI", _("Gastrointestinal and hepatobiliary") - HEADNECK = "HN", _("Head and Neck") - MSK = "MS", _("Musculoskeletal") - NEURO = "NE", _("Neuroradiology") - OBSGYN = "OG", _("Obstectric and Gynaecological") - PAED = "PA", _("Paediatric") - URO = "UR", _("Uroradiology") - VASC = "VA", _("Vascular") - HAEMONC = "HA", _("Haemotology and Oncology") + #class SubspecialtyChoices(models.TextChoices): + # BREAST = "BR", _("Breast") + # CARDIAC = "CA", _("Cardiac") + # GASTRO = "GI", _("Gastrointestinal and hepatobiliary") + # HEADNECK = "HN", _("Head and Neck") + # MSK = "MS", _("Musculoskeletal") + # NEURO = "NE", _("Neuroradiology") + # OBSGYN = "OG", _("Obstectric and Gynaecological") + # PAED = "PA", _("Paediatric") + # URO = "UR", _("Uroradiology") + # VASC = "VA", _("Vascular") + # HAEMONC = "HA", _("Haemotology and Oncology") title = models.CharField(max_length=255, help_text="Title of the case", default="") # author = models.ForeignKey('auth.User', on_delete=models.CASCADE) @@ -116,7 +120,8 @@ class Case(models.Model): findings = models.TextField(null=True, blank=True) - subspecialty = models.CharField(max_length=2, choices=SubspecialtyChoices.choices) + #subspecialty = models.CharField(max_length=2, choices=SubspecialtyChoices.choices) + subspecialty = models.ManyToManyField(Subspecialty, blank=True) condition = models.ManyToManyField(Condition, blank=True)