1- from django .db .models import TextChoices
2- from django .forms .widgets import Textarea
3-
41from 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+ )
55from manage_breast_screening .mammograms .services .appointment_services import (
66 RecallService ,
77)
88from 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- )
2111from manage_breast_screening .nhsuk_forms .forms import FormWithConditionalFields
2212from 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