11from decimal import Decimal
2+ from django .urls import reverse
23
34from ..models .education_response import EducationValues
45from ..models .respiratory_conditions_response import RespiratoryConditionValues
@@ -108,6 +109,7 @@ def relatives_age_when_diagnosed(self):
108109
109110 return self .response_set .relatives_age_when_diagnosed .get_value_display ()
110111
112+
111113 @property
112114 def respiratory_conditions (self ):
113115 if not hasattr (self .response_set , 'respiratory_conditions_response' ):
@@ -119,6 +121,24 @@ def respiratory_conditions(self):
119121 ])
120122
121123
124+ def family_history_responses_items (self ):
125+ items = [
126+ self ._check_your_answer_item (
127+ "Have any of your parents, siblings or children ever been diagnosed with lung cancer?" ,
128+ self .family_history_lung_cancer ,
129+ "questions:family_history_lung_cancer" ,
130+ )
131+ ]
132+ if self ._should_display_relatives_age_when_diagnosed ():
133+ items .append (self ._check_your_answer_item (
134+ "Were any of your relatives younger than 60 years old when they were diagnosed with lung cancer?" ,
135+ self .relatives_age_when_diagnosed ,
136+ "questions:relatives_age_when_diagnosed" ,
137+ ))
138+
139+ return items
140+
141+
122142 def _list_to_sentence (self , list ):
123143 if len (list ) == 0 :
124144 return ''
@@ -128,3 +148,29 @@ def _list_to_sentence(self, list):
128148 return '{} and {}' .format (list [0 ], list [1 ])
129149
130150 return '{}, and {}' .format (', ' .join (list [:- 1 ]), list [- 1 ])
151+
152+
153+ def _should_display_relatives_age_when_diagnosed (self ):
154+ if not hasattr (self .response_set , 'family_history_lung_cancer' ):
155+ return False
156+
157+ return self .response_set .family_history_lung_cancer != FamilyHistoryLungCancerValues .YES
158+
159+
160+ def _change_query_params (self ):
161+ return { "change" : "True" }
162+
163+
164+ def _check_your_answer_item (self , question , value , url_lookup_name ):
165+ return {
166+ "key" : { "text" : question },
167+ "value" : { "text" : value },
168+ "actions" : {
169+ "items" : [
170+ {
171+ "href" : reverse (url_lookup_name , query = self ._change_query_params ()),
172+ "text" : "Change"
173+ }
174+ ]
175+ }
176+ }
0 commit comments