2020from manage_breast_screening .participants .models .symptom import (
2121 RelativeDateChoices ,
2222 SymptomAreas ,
23+ SymptomSubType ,
2324 SymptomType ,
2425)
2526
@@ -63,7 +64,7 @@ class CommonFields:
6364 investigated = yes_no_field (
6465 label = "Has this been investigated?" ,
6566 error_messages = {
66- "required" : "Select whether the lump has been investigated or not"
67+ "required" : "Select whether the symptom has been investigated or not"
6768 },
6869 )
6970 investigation_details = CharField (
@@ -101,6 +102,8 @@ def __init__(self, symptom_type, instance=None, **kwargs):
101102 kwargs ["initial" ] = {
102103 "area" : instance .area ,
103104 "area_description" : instance .area_description ,
105+ "symptom_sub_type" : instance .symptom_sub_type_id ,
106+ "symptom_sub_type_details" : instance .symptom_sub_type_details ,
104107 "when_started" : instance .when_started ,
105108 "specific_date" : (instance .month_started , instance .year_started ),
106109 "intermittent" : instance .intermittent ,
@@ -200,6 +203,8 @@ def _model_values(self):
200203 """
201204 area = self .cleaned_data ["area" ]
202205 area_description = self .cleaned_data .get ("area_description" , "" )
206+ symptom_sub_type = self .cleaned_data .get ("symptom_sub_type" )
207+ symptom_sub_type_details = self .cleaned_data .get ("symptom_sub_type_details" , "" )
203208 when_started = self .cleaned_data .get ("when_started" )
204209 specific_date = self .cleaned_data .get ("specific_date" )
205210 investigated = self .cleaned_data .get ("investigated" ) == YesNo .YES
@@ -212,6 +217,8 @@ def _model_values(self):
212217 return dict (
213218 area = area ,
214219 area_description = area_description ,
220+ symptom_sub_type_id = symptom_sub_type ,
221+ symptom_sub_type_details = symptom_sub_type_details ,
215222 investigated = investigated ,
216223 investigation_details = investigation_details ,
217224 when_started = when_started ,
@@ -326,3 +333,77 @@ def __init__(self, instance=None, **kwargs):
326333 predicate_field = "investigated" ,
327334 predicate_field_value = YesNo .YES ,
328335 )
336+
337+
338+ class SkinChangeForm (SymptomForm ):
339+ class SymptomSubTypeChoices (TextChoices ):
340+ SORES_OR_CYSTS = SymptomSubType .SORES_OR_CYSTS , "Sores or cysts"
341+ DIMPLES_OR_INDENTATION = (
342+ SymptomSubType .DIMPLES_OR_INDENTATION ,
343+ "Dimples or indentation" ,
344+ )
345+ RASH = SymptomSubType .RASH , "Rash"
346+ COLOUR_CHANGE = SymptomSubType .COLOUR_CHANGE , "Colour change"
347+ OTHER = SymptomSubType .OTHER , "Other"
348+
349+ area = ChoiceField (
350+ choices = RightLeftOtherChoices ,
351+ label = "Where is the skin change located?" ,
352+ error_messages = {"required" : "Select the location of the skin change" },
353+ )
354+ area_description = CharField (
355+ required = False ,
356+ label = "Describe the specific area" ,
357+ hint = "For example, the left armpit" ,
358+ error_messages = {
359+ "required" : "Describe the specific area where the skin change is located"
360+ },
361+ classes = "nhsuk-u-width-two-thirds" ,
362+ )
363+ symptom_sub_type = ChoiceField (
364+ choices = SymptomSubTypeChoices ,
365+ label = "How has the skin changed?" ,
366+ error_messages = {"required" : "Select how the skin has changed" },
367+ )
368+ symptom_sub_type_details = CharField (
369+ required = False ,
370+ label = "Describe the change" ,
371+ error_messages = {"required" : "Enter a description of the change" },
372+ classes = "nhsuk-u-width-two-thirds" ,
373+ )
374+ when_started = CommonFields .when_started
375+ specific_date = CommonFields .specific_date
376+ intermittent = CommonFields .intermittent
377+ recently_resolved = CommonFields .recently_resolved
378+ when_resolved = CommonFields .when_resolved
379+ investigated = CommonFields .investigated
380+ investigation_details = CommonFields .investigation_details
381+ additional_information = CommonFields .additional_information
382+
383+ def __init__ (self , instance = None , ** kwargs ):
384+ super ().__init__ (
385+ symptom_type = SymptomType .SKIN_CHANGE ,
386+ instance = instance ,
387+ ** kwargs ,
388+ )
389+
390+ self .set_conditionally_required (
391+ conditionally_required_field = "area_description" ,
392+ predicate_field = "area" ,
393+ predicate_field_value = RightLeftOtherChoices .OTHER ,
394+ )
395+ self .set_conditionally_required (
396+ conditionally_required_field = "symptom_sub_type_details" ,
397+ predicate_field = "symptom_sub_type" ,
398+ predicate_field_value = self .SymptomSubTypeChoices .OTHER ,
399+ )
400+ self .set_conditionally_required (
401+ conditionally_required_field = "specific_date" ,
402+ predicate_field = "when_started" ,
403+ predicate_field_value = RelativeDateChoices .SINCE_A_SPECIFIC_DATE ,
404+ )
405+ self .set_conditionally_required (
406+ conditionally_required_field = "investigation_details" ,
407+ predicate_field = "investigated" ,
408+ predicate_field_value = YesNo .YES ,
409+ )
0 commit comments