diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 08b2fde60..d63d6394c 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -48,8 +48,24 @@ module Validations::SoftValidations end end + def no_females_in_the_household? + (1..8).none? do |n| + public_send("sex#{n}") == "F" + end && preg_occ == 1 + end + + def female_in_pregnant_household_in_soft_validation_range? + (females_in_age_range(11, 15) || females_in_age_range(51, 65)) && !females_in_age_range(16, 50) + end + private + def females_in_age_range(min, max) + (1..8).any? do |n| + public_send("sex#{n}") == "F" && public_send("age#{n}").present? && public_send("age#{n}").between?(min, max) + end + end + def tenant_is_retired?(economic_status) economic_status == 5 end diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 5b5954d3f..9b639a426 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -3824,6 +3824,76 @@ } } }, + "no_females_pregnant_household_value_check": { + "depends_on": [{ "no_females_in_the_household?": true }], + "title_text": { + "translation": "soft_validations.pregnancy.title", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "informative_text": { + "translation": "soft_validations.pregnancy.no_females", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "questions": { + "pregnancy_value_check": { + "check_answer_label": "Pregnancy soft validation", + "hidden_in_check_answers": true, + "header": "Are you sure this is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value":"Yes" + }, + "1": { + "value":"No" + } + } + } + } + }, + "females_in_soft_age_range_in_pregnant_household_value_check": { + "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }], + "title_text": { + "translation": "soft_validations.pregnancy.title", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "informative_text": { + "translation": "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "questions": { + "pregnancy_value_check": { + "check_answer_label": "Pregnancy soft validation", + "hidden_in_check_answers": true, + "header": "Are you sure this is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value":"Yes" + }, + "1": { + "value":"No" + } + } + } + } + }, "access_needs": { "header": "", "description": "", diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index ef7b49077..1bc7b3da9 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -3876,6 +3876,76 @@ } } }, + "no_females_pregnant_household_value_check": { + "depends_on": [{ "no_females_in_the_household?": true }], + "title_text": { + "translation": "soft_validations.pregnancy.title", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "informative_text": { + "translation": "soft_validations.pregnancy.no_females", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "questions": { + "pregnancy_value_check": { + "check_answer_label": "Pregnancy soft validation", + "hidden_in_check_answers": true, + "header": "Are you sure this is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value":"Yes" + }, + "1": { + "value":"No" + } + } + } + } + }, + "females_in_soft_age_range_in_pregnant_household_value_check": { + "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }], + "title_text": { + "translation": "soft_validations.pregnancy.title", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "informative_text": { + "translation": "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments": [{ + "key": "sex1", + "label": true, + "i18n_template": "sex1" + }] + }, + "questions": { + "pregnancy_value_check": { + "check_answer_label": "Pregnancy soft validation", + "hidden_in_check_answers": true, + "header": "Are you sure this is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value":"Yes" + }, + "1": { + "value":"No" + } + } + } + } + }, "access_needs": { "header": "", "description": "", diff --git a/config/locales/en.yml b/config/locales/en.yml index 4581ec05f..a0cb371d1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -250,6 +250,10 @@ en: max: title: "You told us this person is %{age} or over and not retired" hint_text: "The minimum expected retirement age for %{gender} in England is %{age}." + pregnancy: + title: "You told us somebody in the household is pregnant" + no_females: "You also told us there are no women living at the property." + females_not_in_soft_age_range: "You also told us that any women living at the property are in the following age ranges: