From 1259426390e9e0a91faa7fe20db3fe9c018924ac Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 16 Aug 2022 11:15:29 +0100 Subject: [PATCH] Only set all housing needs values to 1 if there are no housingneeds --- app/models/derived_variables/case_log_variables.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/models/derived_variables/case_log_variables.rb b/app/models/derived_variables/case_log_variables.rb index 29fe4adb3..cf51c6a49 100644 --- a/app/models/derived_variables/case_log_variables.rb +++ b/app/models/derived_variables/case_log_variables.rb @@ -189,15 +189,13 @@ private end def set_housingneeds_fields - set_housingneeds_values_to_zero - - self.housingneeds_a = 1 if fully_wheelchair_accessible? - self.housingneeds_b = 1 if essential_wheelchair_access? - self.housingneeds_c = 1 if level_access_housing? - self.housingneeds_f = 1 if other_housingneeds? + self.housingneeds_a = fully_wheelchair_accessible? ? 1 : 0 + self.housingneeds_b = essential_wheelchair_access? ? 1 : 0 + self.housingneeds_c = level_access_housing? ? 1 : 0 + self.housingneeds_f = other_housingneeds? ? 1 : 0 set_housingneeds_values_to_zero unless has_housingneeds? - self.housingneeds_g = 1 if no_housingneeds? - self.housingneeds_h = 1 if unknown_housingneeds? + self.housingneeds_g = no_housingneeds? ? 1 : 0 + self.housingneeds_h = unknown_housingneeds? ? 1 : 0 end def set_housingneeds_values_to_zero