Skip to content

Commit f793348

Browse files
committed
further constrain symptom fields
- when_started should be an enum rather than free text - investigated is a boolean and shouldn't allow null
1 parent a488dc8 commit f793348

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 5.2.5 on 2025-09-15 16:04
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('participants', '0024_remove_symptom_participant'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='symptom',
15+
name='investigated',
16+
field=models.BooleanField(default=False),
17+
),
18+
migrations.AlterField(
19+
model_name='symptom',
20+
name='when_started',
21+
field=models.CharField(blank=True, choices=[('LESS_THAN_THREE_MONTHS', 'Less than 3 months'), ('THREE MONTHS TO A YEAR', '3 months to a year'), ('ONE_TO_THREE_YEARS', '1 to 3 years'), ('OVER_THREE_YEARS', 'Over 3 years'), ('SINCE_A_SPECIFIC_DATE', 'Since a specific date'), ('NOT_SURE', 'Not sure')]),
22+
),
23+
]

manage_breast_screening/participants/models/symptom.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ class SymptomAreas(models.TextChoices):
2626
OTHER = ("OTHER", "Other")
2727

2828

29+
class RelativeDateChoices(models.TextChoices):
30+
LESS_THAN_THREE_MONTHS = "LESS_THAN_THREE_MONTHS", "Less than 3 months"
31+
THREE_MONTHS_TO_A_YEAR = "THREE MONTHS TO A YEAR", "3 months to a year"
32+
ONE_TO_THREE_YEARS = "ONE_TO_THREE_YEARS", "1 to 3 years"
33+
OVER_THREE_YEARS = "OVER_THREE_YEARS", "Over 3 years"
34+
SINCE_A_SPECIFIC_DATE = "SINCE_A_SPECIFIC_DATE", "Since a specific date"
35+
NOT_SURE = "NOT_SURE", "Not sure"
36+
37+
2938
class Symptom(BaseModel):
3039
symptom_type = models.ForeignKey(SymptomType, on_delete=models.PROTECT)
3140
symptom_sub_type = models.ForeignKey(
@@ -42,10 +51,10 @@ class Symptom(BaseModel):
4251
area_description = models.CharField(blank=True, null=False)
4352

4453
# Has the symptom been investigated already?
45-
investigated = models.BooleanField()
54+
investigated = models.BooleanField(null=False, default=False)
4655

4756
# Onset information
48-
when_started = models.CharField(blank=True, null=False)
57+
when_started = models.CharField(blank=True, null=False, choices=RelativeDateChoices)
4958
year_started = models.IntegerField(null=True, blank=True)
5059
month_started = models.IntegerField(null=True, blank=True)
5160
intermittent = models.BooleanField(null=False, default=False)

0 commit comments

Comments
 (0)