@@ -4,14 +4,23 @@ module ParentInterface
4
4
class ConsentForms ::EditController < ConsentForms ::BaseController
5
5
include WizardControllerConcern
6
6
7
- before_action :validate_params , only : %i[ update ]
7
+ before_action :validate_params , only : : update
8
8
before_action :set_health_answer , if : :is_health_question_step?
9
- before_action :set_follow_up_changes_start_page , only : %i[ show ]
9
+ before_action :set_follow_up_changes_start_page , only : : show
10
10
11
11
HOME_EDUCATED_SCHOOL_ID = "home-educated"
12
12
13
13
def show
14
- set_response if current_step == :consent
14
+ case current_step
15
+ when :response_doubles
16
+ set_response_doubles
17
+ when :response_flu
18
+ set_response_flu
19
+ when :response_hpv
20
+ set_response_hpv
21
+ when :injection_alternative
22
+ set_injection_alternative
23
+ end
15
24
16
25
render_wizard
17
26
end
@@ -48,7 +57,9 @@ def update
48
57
@consent_form . parent_phone . present?
49
58
jump_to ( "contact-method" , skip_to_confirm : true )
50
59
end
51
- elsif current_step == :consent
60
+ elsif current_step == :injection_alternative
61
+ @consent_form . update_injection_alternative
62
+ elsif is_response_step?
52
63
@consent_form . update_programme_responses
53
64
@consent_form . seed_health_questions
54
65
end
@@ -97,9 +108,12 @@ def update_params
97
108
parent_contact_method_type
98
109
parent_contact_method_other_details
99
110
] ,
100
- consent : %i[ response chosen_programme ] ,
101
111
reason : %i[ reason ] ,
102
112
reason_notes : %i[ reason_notes ] ,
113
+ response_doubles : %i[ response chosen_programme ] ,
114
+ response_flu : %i[ response ] ,
115
+ response_hpv : %i[ response ] ,
116
+ injection_alternative : %i[ injection_alternative ] ,
103
117
address : %i[ address_line_1 address_line_2 address_town address_postcode ]
104
118
} . fetch ( current_step )
105
119
@@ -125,18 +139,48 @@ def set_health_answer
125
139
@health_answer = @consent_form . health_answers [ @question_number ]
126
140
end
127
141
128
- def set_response
142
+ def set_response_doubles
129
143
if @consent_form . response_given? && @consent_form . response_refused?
130
144
@consent_form . response = "given_one"
131
145
@consent_form . chosen_programme =
132
- @consent_form . given_programmes . first & .type
146
+ @consent_form . given_programmes . first . type
133
147
elsif @consent_form . response_given?
134
148
@consent_form . response = "given"
135
149
elsif @consent_form . response_refused?
136
150
@consent_form . response = "refused"
137
151
end
138
152
end
139
153
154
+ def set_response_flu
155
+ if @consent_form . response_given?
156
+ method =
157
+ @consent_form
158
+ . given_consent_form_programmes
159
+ . first
160
+ . vaccine_methods
161
+ . first
162
+ @consent_form . response = "given_#{ method } "
163
+ elsif @consent_form . response_refused?
164
+ @consent_form . response = "refused"
165
+ end
166
+ end
167
+
168
+ def set_response_hpv
169
+ if @consent_form . response_given?
170
+ @consent_form . response = "given"
171
+ elsif @consent_form . response_refused?
172
+ @consent_form . response = "refused"
173
+ end
174
+ end
175
+
176
+ def set_injection_alternative
177
+ if @consent_form . consent_form_programmes . any? (
178
+ &:vaccine_method_injection_and_nasal?
179
+ )
180
+ @consent_form . injection_alternative = "true"
181
+ end
182
+ end
183
+
140
184
def validate_params
141
185
case current_step
142
186
when :date_of_birth
@@ -154,9 +198,9 @@ def validate_params
154
198
end
155
199
end
156
200
157
- def is_health_question_step?
158
- step == "health-question"
159
- end
201
+ def is_response_step? = step . start_with? ( "response-" )
202
+
203
+ def is_health_question_step? = step == "health-question"
160
204
161
205
def current_health_answer
162
206
index = step . split ( "-" ) . last . to_i - 1
0 commit comments