Skip to content

Commit 97990ef

Browse files
committed
Amend Gillick assessments rather than replacing
This changes how Gillick assessments are editing by always creating a new record based on the previous one rather than updating the record. This allows us to keep a history of Gillick assessments per patient, and show them all in the activity log.
1 parent be42c76 commit 97990ef

File tree

2 files changed

+89
-89
lines changed

2 files changed

+89
-89
lines changed

app/controllers/gillick_assessments_controller.rb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ def new
1010
end
1111

1212
def create
13-
if @gillick_assessment.update(
14-
performed_by: current_user,
15-
**gillick_assessment_params
16-
)
13+
if @gillick_assessment.update(gillick_assessment_params)
1714
redirect_to session_patient_path(id: @patient.id)
1815
else
1916
render :new, status: :unprocessable_entity
@@ -24,7 +21,9 @@ def edit
2421
end
2522

2623
def update
27-
if @gillick_assessment.update(gillick_assessment_params)
24+
@gillick_assessment.assign_attributes(gillick_assessment_params)
25+
26+
if !@gillick_assessment.changed? || @gillick_assessment.save
2827
redirect_to session_patient_path(id: @patient.id)
2928
else
3029
render :edit, status: :unprocessable_entity
@@ -48,18 +47,21 @@ def set_patient_session
4847

4948
def set_gillick_assessment
5049
@gillick_assessment =
51-
authorize @patient_session.latest_gillick_assessment ||
50+
authorize @patient_session.latest_gillick_assessment&.dup ||
5251
@patient_session.gillick_assessments.build
5352
end
5453

5554
def gillick_assessment_params
56-
params.require(:gillick_assessment).permit(
57-
:knows_consequences,
58-
:knows_delivery,
59-
:knows_disease,
60-
:knows_side_effects,
61-
:knows_vaccination,
62-
:notes
63-
)
55+
params
56+
.require(:gillick_assessment)
57+
.permit(
58+
:knows_consequences,
59+
:knows_delivery,
60+
:knows_disease,
61+
:knows_side_effects,
62+
:knows_vaccination,
63+
:notes
64+
)
65+
.merge(performed_by: current_user)
6466
end
6567
end

spec/features/self_consent_spec.rb

Lines changed: 73 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,27 @@
44
before { Flipper.enable(:release_1b) }
55
after { Flipper.disable(:release_1b) }
66

7-
scenario "No consent from parent, the child is Gillick competent so can self-consent" do
7+
scenario "From Gillick assessment" do
88
given_an_hpv_programme_is_underway
99
and_there_is_a_child_without_parental_consent
1010

1111
when_the_nurse_assesses_the_child_as_not_being_gillick_competent
12-
and_the_details_of_the_gillick_non_competence_assessment_are_visible
13-
then_the_nurse_assesses_the_child_as_gillick_competent
14-
then_the_child_can_give_their_own_consent_that_the_nurse_records
12+
then_the_details_of_the_gillick_non_competence_assessment_are_visible
13+
and_the_child_cannot_give_their_own_consent
14+
and_the_child_status_reflects_that_there_is_no_consent
15+
and_the_activity_log_shows_the_gillick_non_competence
16+
17+
when_the_nurse_edits_the_assessment_the_child_as_gillick_competent
18+
then_the_details_of_the_gillick_competence_assessment_are_visible
19+
and_the_activity_log_shows_the_gillick_non_competence
20+
and_the_activity_log_shows_the_gillick_competence
21+
and_the_child_can_give_their_own_consent_that_the_nurse_records
1522

1623
when_the_nurse_views_the_childs_record
1724
then_they_see_that_the_child_has_consent
1825
and_the_child_should_be_safe_to_vaccinate
1926
end
2027

21-
scenario "No consent from parent, the child is not Gillick competent" do
22-
given_an_hpv_programme_is_underway
23-
and_there_is_a_child_without_parental_consent
24-
25-
when_the_nurse_assesses_the_child_as_gillick_competent
26-
and_the_details_of_the_gillick_competence_assessment_are_visible
27-
then_the_nurse_assesses_the_child_as_not_being_gillick_competent
28-
then_the_child_cannot_give_their_own_consent
29-
and_the_childs_status_reflects_that_there_is_no_consent
30-
end
31-
3228
def given_an_hpv_programme_is_underway
3329
programme = create(:programme, :hpv)
3430
@organisation =
@@ -65,93 +61,121 @@ def and_there_is_a_child_without_parental_consent
6561
expect(page).to have_content(@patient.full_name)
6662
end
6763

68-
def when_the_nurse_assesses_the_child_as_gillick_competent
64+
def when_the_nurse_assesses_the_child_as_not_being_gillick_competent
6965
click_on @patient.full_name
7066
click_on "Assess Gillick competence"
71-
fill_in_as_competent
72-
click_on "Complete your assessment"
73-
end
74-
75-
def then_the_nurse_assesses_the_child_as_gillick_competent
76-
click_on "Edit Gillick competence"
77-
fill_in_as_competent
78-
click_on "Update your assessment"
79-
end
8067

81-
def fill_in_as_competent
8268
within(
8369
"fieldset",
8470
text: "The child knows which vaccination they will have"
85-
) { choose "Yes" }
71+
) { choose "No" }
8672

8773
within(
8874
"fieldset",
8975
text: "The child knows which disease the vaccination protects against"
90-
) { choose "Yes" }
76+
) { choose "No" }
9177

9278
within(
9379
"fieldset",
9480
text: "The child knows what could happen if they got the disease"
95-
) { choose "Yes" }
81+
) { choose "No" }
9682

9783
within(
9884
"fieldset",
9985
text: "The child knows how the injection will be given"
100-
) { choose "Yes" }
86+
) { choose "No" }
10187

10288
within(
10389
"fieldset",
10490
text: "The child knows which side effects they might experience"
105-
) { choose "Yes" }
91+
) { choose "No" }
10692

10793
fill_in "Assessment notes (optional)",
108-
with: "They understand the benefits and risks of the vaccine"
109-
end
94+
with: "They didn't understand the benefits and risks of the vaccine"
11095

111-
def when_the_nurse_assesses_the_child_as_not_being_gillick_competent
112-
click_on @patient.full_name
113-
click_on "Assess Gillick competence"
114-
fill_in_as_non_competent
11596
click_on "Complete your assessment"
11697
end
11798

118-
def then_the_nurse_assesses_the_child_as_not_being_gillick_competent
119-
click_on "Edit Gillick competence"
120-
fill_in_as_non_competent
121-
click_on "Update your assessment"
99+
def then_the_details_of_the_gillick_non_competence_assessment_are_visible
100+
expect(page).to have_content("Child assessed as not Gillick competent")
101+
expect(page).to have_content(
102+
"They didn't understand the benefits and risks of the vaccine"
103+
)
122104
end
123105

124-
def fill_in_as_non_competent
106+
def and_the_child_cannot_give_their_own_consent
107+
click_on "Get consent"
108+
expect(page).not_to have_content("Child (Gillick competent)")
109+
click_on "Back"
110+
end
111+
112+
def and_the_child_status_reflects_that_there_is_no_consent
113+
expect(page).to have_content("No response")
114+
end
115+
116+
def and_the_activity_log_shows_the_gillick_non_competence
117+
click_on "Activity log"
118+
expect(page).to have_content(
119+
"Completed Gillick assessment as not Gillick competent"
120+
)
121+
click_on "Child record"
122+
end
123+
124+
def when_the_nurse_edits_the_assessment_the_child_as_gillick_competent
125+
click_on "Edit Gillick competence"
126+
127+
# notes from previous assessment
128+
expect(page).to have_content(
129+
"They didn't understand the benefits and risks of the vaccine"
130+
)
131+
125132
within(
126133
"fieldset",
127134
text: "The child knows which vaccination they will have"
128-
) { choose "No" }
135+
) { choose "Yes" }
129136

130137
within(
131138
"fieldset",
132139
text: "The child knows which disease the vaccination protects against"
133-
) { choose "No" }
140+
) { choose "Yes" }
134141

135142
within(
136143
"fieldset",
137144
text: "The child knows what could happen if they got the disease"
138-
) { choose "No" }
145+
) { choose "Yes" }
139146

140147
within(
141148
"fieldset",
142149
text: "The child knows how the injection will be given"
143-
) { choose "No" }
150+
) { choose "Yes" }
144151

145152
within(
146153
"fieldset",
147154
text: "The child knows which side effects they might experience"
148-
) { choose "No" }
155+
) { choose "Yes" }
149156

150157
fill_in "Assessment notes (optional)",
151-
with: "They didn't understand the benefits and risks of the vaccine"
158+
with: "They understand the benefits and risks of the vaccine"
159+
160+
click_on "Update your assessment"
161+
end
162+
163+
def then_the_details_of_the_gillick_competence_assessment_are_visible
164+
expect(page).to have_content("Child assessed as Gillick competent")
165+
expect(page).to have_content(
166+
"They understand the benefits and risks of the vaccine"
167+
)
152168
end
153169

154-
def then_the_child_can_give_their_own_consent_that_the_nurse_records
170+
def and_the_activity_log_shows_the_gillick_competence
171+
click_on "Activity log"
172+
expect(page).to have_content(
173+
"Updated Gillick assessment as Gillick competent"
174+
)
175+
click_on "Child record"
176+
end
177+
178+
def and_the_child_can_give_their_own_consent_that_the_nurse_records
155179
click_on "Get consent"
156180

157181
# who
@@ -191,33 +215,7 @@ def then_they_see_that_the_child_has_consent
191215
expect(page).to have_content("Consent given")
192216
end
193217

194-
def and_the_details_of_the_gillick_competence_assessment_are_visible
195-
expect(page).to have_content("Child assessed as Gillick competent")
196-
expect(page).to have_content(
197-
"They understand the benefits and risks of the vaccine"
198-
)
199-
end
200-
201-
def and_the_details_of_the_gillick_non_competence_assessment_are_visible
202-
expect(page).to have_content("Child assessed as not Gillick competent")
203-
expect(page).to have_content(
204-
"They didn't understand the benefits and risks of the vaccine"
205-
)
206-
end
207-
208218
def and_the_child_should_be_safe_to_vaccinate
209219
expect(page).to have_content("Safe to vaccinate")
210220
end
211-
212-
def then_the_child_cannot_give_their_own_consent
213-
click_on "Get consent"
214-
215-
expect(page).not_to have_content("Child (Gillick competent)")
216-
217-
click_on "Back"
218-
end
219-
220-
def and_the_childs_status_reflects_that_there_is_no_consent
221-
expect(page).to have_content("No response")
222-
end
223221
end

0 commit comments

Comments
 (0)