Skip to content

Commit 21d930b

Browse files
committed
PPHA-512: Improve chack you answer wording for respiratory conditions
1 parent d753986 commit 21d930b

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

lung_cancer_screening/questions/presenters/response_set_presenter.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ def respiratory_conditions(self):
116116
if not hasattr(self.response_set, 'respiratory_conditions_response'):
117117
return None
118118

119+
if RespiratoryConditionValues.NONE in self.response_set.respiratory_conditions_response.value:
120+
values_sentence = self._list_to_sentence([
121+
label
122+
for label in RespiratoryConditionValues.labels
123+
if label != RespiratoryConditionValues.NONE.label
124+
], final_separator = "or")
125+
126+
return f"No, I have not been diagnosed with {values_sentence}"
127+
119128
return self._list_to_sentence([
120129
RespiratoryConditionValues(code).label
121130
for code in self.response_set.respiratory_conditions_response.value
@@ -209,15 +218,15 @@ def family_history_responses_items(self):
209218
return items
210219

211220

212-
def _list_to_sentence(self, list):
221+
def _list_to_sentence(self, list, final_separator = "and"):
213222
if len(list) == 0:
214223
return ''
215224
if len(list) == 1:
216225
return list[0]
217226
if len(list) == 2:
218-
return '{} and {}'.format(list[0], list[1])
227+
return f'{list[0]} {final_separator} {list[1]}'
219228

220-
return '{}, and {}'.format(', '.join(list[:-1]), list[-1])
229+
return f'{", ".join(list[:-1])} {final_separator} {list[-1]}'
221230

222231

223232
def _should_display_relatives_age_when_diagnosed(self):

0 commit comments

Comments
 (0)