Skip to content

Commit 9b193b1

Browse files
authored
Merge pull request #730 from NHSDigital/dtos-114466-fix-systemic-treatments
make systemic_treatments an ArrayField
2 parents 9af62b7 + 56899b9 commit 9b193b1

File tree

8 files changed

+82
-7
lines changed

8 files changed

+82
-7
lines changed

manage_breast_screening/data/east_tester_one_week_ago_clinic_data.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ clinic:
6868
diagnosis_year: 2024
6969
left_breast_procedure: NO_PROCEDURE
7070
right_breast_procedure: LUMPECTOMY
71-
systemic_treatments: NO_RADIOTHERAPY
71+
systemic_treatments: [NO_SYSTEMIC_TREATMENTS]
7272
intervention_location: NHS_HOSPITAL
7373
intervention_location_details: East Tester Hospital
7474

manage_breast_screening/data/east_tester_today_clinic_data.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ clinic:
3939
diagnosis_year: 2024
4040
left_breast_procedure: NO_PROCEDURE
4141
right_breast_procedure: LUMPECTOMY
42-
systemic_treatments: NO_SYSTEMIC_TREATMENTS
42+
systemic_treatments: [NO_SYSTEMIC_TREATMENTS]
4343
intervention_location: NHS_HOSPITAL
4444
intervention_location_details: East Tester Hospital
4545
implanted_medical_device_history_items:

manage_breast_screening/mammograms/presenters/breast_cancer_history_item_presenter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ def __init__(self, breast_cancer_history_item):
2424
self.left_breast_treatment = self._format_multiple_choices(
2525
self._item.left_breast_treatment, BreastCancerHistoryItem.Treatment
2626
)
27-
self.systemic_treatments = self._item.get_systemic_treatments_display()
27+
self.systemic_treatments = self._format_multiple_choices(
28+
self._item.systemic_treatments,
29+
BreastCancerHistoryItem.SystemicTreatment,
30+
)
2831
self.additional_details = nl2br(self._item.additional_details)
2932

3033
@property
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Generated by Django 5.2.8 on 2025-11-17 16:08
2+
3+
import django.contrib.postgres.fields
4+
from django.db import migrations, models
5+
6+
import manage_breast_screening.nhsuk_forms.validators
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
("participants", "0042_alter_implantedmedicaldevicehistoryitem_device"),
13+
]
14+
15+
operations = [
16+
migrations.AddField(
17+
model_name="breastcancerhistoryitem",
18+
name="systemic_treatments2",
19+
field=django.contrib.postgres.fields.ArrayField(
20+
base_field=models.CharField(
21+
choices=[
22+
("CHEMOTHERAPY", "Chemotherapy"),
23+
("HORMONE_THERAPY", "Hormone therapy"),
24+
("OTHER", "Other"),
25+
("NO_SYSTEMIC_TREATMENTS", "No systemic treatments"),
26+
]
27+
),
28+
default=list,
29+
size=None,
30+
validators=[
31+
manage_breast_screening.nhsuk_forms.validators.ExcludesOtherOptionsValidator(
32+
"NO_SYSTEMIC_TREATMENTS", "No systemic treatments"
33+
)
34+
],
35+
),
36+
),
37+
migrations.AlterField(
38+
model_name="breastcancerhistoryitem",
39+
name="systemic_treatments",
40+
field=models.CharField(
41+
choices=[
42+
("CHEMOTHERAPY", "Chemotherapy"),
43+
("HORMONE_THERAPY", "Hormone therapy"),
44+
("OTHER", "Other"),
45+
("NO_SYSTEMIC_TREATMENTS", "No systemic treatments"),
46+
],
47+
db_default="NO_SYSTEMIC_TREATMENTS", # add a default so the migration is reversable
48+
),
49+
),
50+
migrations.RunSQL(
51+
sql="update participants_breastcancerhistoryitem set systemic_treatments2 = ARRAY[systemic_treatments]",
52+
reverse_sql="update participants_breastcancerhistoryitem set systemic_treatments = systemic_treatments2[1]",
53+
),
54+
migrations.RemoveField(
55+
model_name="breastcancerhistoryitem", name="systemic_treatments"
56+
),
57+
migrations.RenameField(
58+
model_name="breastcancerhistoryitem",
59+
old_name="systemic_treatments2",
60+
new_name="systemic_treatments",
61+
),
62+
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0042_alter_implantedmedicaldevicehistoryitem_device
1+
0043_alter_breastcancerhistoryitem_systemic_treatments

manage_breast_screening/participants/models/breast_cancer_history_item.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,16 @@ class InterventionLocation(models.TextChoices):
9696
],
9797
)
9898

99-
systemic_treatments = models.CharField(choices=SystemicTreatment)
99+
systemic_treatments = ArrayField(
100+
base_field=models.CharField(choices=SystemicTreatment),
101+
default=list,
102+
validators=[
103+
ExcludesOtherOptionsValidator(
104+
SystemicTreatment.NO_SYSTEMIC_TREATMENTS.value,
105+
SystemicTreatment.NO_SYSTEMIC_TREATMENTS.label,
106+
)
107+
],
108+
)
100109
systemic_treatments_other_treatment_details = models.CharField(
101110
blank=True, null=False, default=""
102111
)

manage_breast_screening/participants/tests/factories.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ class Meta:
173173
right_breast_other_surgery = [BreastCancerHistoryItem.Surgery.NO_SURGERY]
174174
left_breast_treatment = [BreastCancerHistoryItem.Treatment.NO_RADIOTHERAPY]
175175
right_breast_treatment = [BreastCancerHistoryItem.Treatment.NO_RADIOTHERAPY]
176-
systemic_treatments = (
176+
systemic_treatments = [
177177
BreastCancerHistoryItem.SystemicTreatment.NO_SYSTEMIC_TREATMENTS
178-
)
178+
]
179179

180180
intervention_location = (
181181
BreastCancerHistoryItem.InterventionLocation.EXACT_LOCATION_UNKNOWN
@@ -195,6 +195,7 @@ class Meta:
195195
surgery_reason = MastectomyOrLumpectomyHistoryItem.SurgeryReason.OTHER_REASON
196196
additional_details = ""
197197

198+
198199
class CystHistoryItemFactory(DjangoModelFactory):
199200
class Meta:
200201
model = models.CystHistoryItem

manage_breast_screening/participants/tests/models/test_breast_cancer_history_item_test.py renamed to manage_breast_screening/participants/tests/models/test_breast_cancer_history_item.py

File renamed without changes.

0 commit comments

Comments
 (0)