Skip to content

Commit 5a9f37b

Browse files
committed
Use ID suffix for Eklund views BreastImplantPresent tag
1 parent 811cd1f commit 5a9f37b

10 files changed

Lines changed: 290 additions & 190 deletions

File tree

manage_breast_screening/dicom/models.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ class Meta:
140140

141141
@property
142142
def laterality_and_view(self):
143-
if self.laterality and self.implant_present:
144-
laterality = "Left" if self.laterality == "L" else "Right"
145-
return f"{laterality} Eklund"
146-
elif self.laterality and self.view_position:
147-
return f"{self.laterality}{self.view_position}".upper()
143+
if self.laterality and self.view_position:
144+
result = f"{self.laterality}{self.view_position}".upper()
145+
if self.implant_present:
146+
result = f"{result}ID"
147+
return result
148148
return ""
149149

150150
def __str__(self):

manage_breast_screening/dicom/study_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@ def images_by_laterality_and_view(
6262
grouped_images = {
6363
"LCC": [],
6464
"LMLO": [],
65-
"Left Eklund": [],
65+
"LCCID": [],
66+
"LMLOID": [],
6667
"RCC": [],
6768
"RMLO": [],
68-
"Right Eklund": [],
69+
"RCCID": [],
70+
"RMLOID": [],
6971
}
7072
for image in images:
7173
if image.laterality_and_view in grouped_images:

manage_breast_screening/dicom/tests/test_study_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ def test_images_by_laterality_and_view(self):
8282
assert StudyService.images_by_laterality_and_view(series.images.all()) == {
8383
"LCC": [image1],
8484
"LMLO": [image3],
85-
"Left Eklund": [image6],
85+
"LCCID": [],
86+
"LMLOID": [image6],
8687
"RCC": [image2],
8788
"RMLO": [image4, image5],
88-
"Right Eklund": [image7],
89+
"RCCID": [image7],
90+
"RMLOID": [],
8991
}

manage_breast_screening/mammograms/forms/images/gateway_image_details_form.py

Lines changed: 8 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,20 @@
1-
from django.db.models import TextChoices
2-
from django.forms.widgets import Textarea
3-
41
from manage_breast_screening.dicom.study_service import StudyService
2+
from manage_breast_screening.mammograms.forms.images.gateway_images_form_fields_mixin import (
3+
GatewayImagesFormFieldsMixin,
4+
)
55
from manage_breast_screening.mammograms.services.appointment_services import (
66
RecallService,
77
)
88
from manage_breast_screening.manual_images.models import (
9-
IncompleteImagesReason,
109
StudyCompleteness,
1110
)
12-
from manage_breast_screening.nhsuk_forms.fields import (
13-
BooleanField,
14-
CharField,
15-
IntegerField,
16-
)
17-
from manage_breast_screening.nhsuk_forms.fields.choice_fields import (
18-
ChoiceField,
19-
MultipleChoiceField,
20-
)
2111
from manage_breast_screening.nhsuk_forms.forms import FormWithConditionalFields
2212
from manage_breast_screening.participants.models.appointment import (
2313
AppointmentWorkflowStepCompletion,
2414
)
2515

2616

27-
class GatewayImageDetailsForm(FormWithConditionalFields):
28-
class RecallChoices(TextChoices):
29-
TO_BE_RECALLED = "TO_BE_RECALLED", "Yes, record as 'to be recalled'"
30-
PARTIAL_MAMMOGRAPHY = (
31-
"PARTIAL_MAMMOGRAPHY",
32-
"No, record as 'partial mammography'",
33-
)
34-
35-
rmlo_count = IntegerField(
36-
required=True,
37-
min_value=0,
38-
max_value=20,
39-
initial=1,
40-
error_messages={
41-
"min_value": "Number of RMLO images must be at least 0",
42-
"max_value": "Number of RMLO images must be at most 20",
43-
"invalid": "Enter a valid number of RMLO images",
44-
"required": "Enter the number of RMLO images",
45-
},
46-
)
47-
rcc_count = IntegerField(
48-
required=True,
49-
min_value=0,
50-
max_value=20,
51-
initial=1,
52-
error_messages={
53-
"min_value": "Number of RCC images must be at least 0",
54-
"max_value": "Number of RCC images must be at most 20",
55-
"invalid": "Enter a valid number of RCC images",
56-
"required": "Enter the number of RCC images",
57-
},
58-
)
59-
right_eklund_count = IntegerField(
60-
required=False,
61-
min_value=0,
62-
max_value=20,
63-
initial=0,
64-
error_messages={
65-
"min_value": "Number of right Eklund images must be at least 0",
66-
"max_value": "Number of right Eklund images must be at most 20",
67-
"invalid": "Enter a valid number of right Eklund images",
68-
"required": "Enter the number of right Eklund images",
69-
},
70-
)
71-
lmlo_count = IntegerField(
72-
required=True,
73-
min_value=0,
74-
max_value=20,
75-
initial=1,
76-
error_messages={
77-
"min_value": "Number of LMLO images must be at least 0",
78-
"max_value": "Number of LMLO images must be at most 20",
79-
"invalid": "Enter a valid number of LMLO images",
80-
"required": "Enter the number of LMLO images",
81-
},
82-
)
83-
lcc_count = IntegerField(
84-
required=True,
85-
min_value=0,
86-
max_value=20,
87-
initial=1,
88-
error_messages={
89-
"min_value": "Number of LCC images must be at least 0",
90-
"max_value": "Number of LCC images must be at most 20",
91-
"invalid": "Enter a valid number of LCC images",
92-
"required": "Enter the number of LCC images",
93-
},
94-
)
95-
left_eklund_count = IntegerField(
96-
required=False,
97-
min_value=0,
98-
max_value=20,
99-
initial=0,
100-
error_messages={
101-
"min_value": "Number of left Eklund images must be at least 0",
102-
"max_value": "Number of left Eklund images must be at most 20",
103-
"invalid": "Enter a valid number of left Eklund images",
104-
"required": "Enter the number of left Eklund images",
105-
},
106-
)
107-
108-
imperfect_but_best_possible = BooleanField(
109-
label="Imperfect, but best possible images",
110-
hint="Image readers will be advised not to request a technical recall",
111-
required=False,
112-
)
113-
114-
not_all_mammograms_taken = BooleanField(
115-
label="Not all mammograms taken", required=False
116-
)
117-
118-
reasons_incomplete = MultipleChoiceField(
119-
label="Why could you not take all the images?",
120-
choices=IncompleteImagesReason,
121-
required=False,
122-
label_classes="nhsuk-label--s",
123-
error_messages={
124-
"required": "Select a reason why you could not take all the images"
125-
},
126-
choice_hints={
127-
IncompleteImagesReason.UNABLE_TO_SCAN_TISSUE: "For example, large breasts or implanted device"
128-
},
129-
)
130-
131-
reasons_incomplete_details = CharField(
132-
label="Provide details (optional)",
133-
required=False,
134-
label_classes="nhsuk-label--s",
135-
widget=Textarea(attrs={"rows": 2}),
136-
max_words=500,
137-
threshold=0,
138-
error_messages={"max_words": "Details must be 500 words or less"},
139-
)
140-
141-
should_recall = ChoiceField(
142-
label="Should the participant be recalled to take more images?",
143-
label_classes="nhsuk-label--s",
144-
required=False,
145-
choices=RecallChoices,
146-
error_messages={
147-
"required": "Select whether the participant should be recalled to take more images"
148-
},
149-
)
150-
151-
additional_details = CharField(
152-
hint="Provide information for image readers when reviewing",
153-
required=False,
154-
label="Notes for reader (optional)",
155-
label_classes="nhsuk-label--s",
156-
widget=Textarea(attrs={"rows": 2}),
157-
max_words=500,
158-
error_messages={"max_words": "Notes for reader must be 500 words or less"},
159-
)
160-
17+
class GatewayImageDetailsForm(GatewayImagesFormFieldsMixin, FormWithConditionalFields):
16118
def __init__(self, *args, instance=None, **kwargs):
16219
if instance:
16320
match instance.completeness:
@@ -180,10 +37,12 @@ def __init__(self, *args, instance=None, **kwargs):
18037
"additional_details": instance.additional_details,
18138
"lmlo_count": len(grouped_images["LMLO"]),
18239
"lcc_count": len(grouped_images["LCC"]),
183-
"left_eklund_count": len(grouped_images["Left Eklund"]),
40+
"lccid_count": len(grouped_images["LCCID"]),
41+
"lmloid_count": len(grouped_images["LMLOID"]),
18442
"rmlo_count": len(grouped_images["RMLO"]),
18543
"rcc_count": len(grouped_images["RCC"]),
186-
"right_eklund_count": len(grouped_images["Right Eklund"]),
44+
"rccid_count": len(grouped_images["RCCID"]),
45+
"rmloid_count": len(grouped_images["RMLOID"]),
18746
}
18847

18948
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)