Skip to content

Commit 5dc903a

Browse files
committed
Combine programme and dates check
It's no longer possible to edit the programmes for a session after it has been created, so we can combine the dates and programmes check in to a single page that is shown when editing dates or when first creating a session. Jira-Issue: MAV-2645
1 parent 9fcbaf9 commit 5dc903a

8 files changed

Lines changed: 82 additions & 105 deletions

File tree

app/controllers/draft_sessions_controller.rb

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ class DraftSessionsController < ApplicationController
1010
before_action :set_programmes, if: -> { current_step == :programmes }
1111
before_action :set_year_group_options, if: -> { current_step == :year_groups }
1212

13-
with_options only: :show,
14-
if: -> do
15-
%i[dates_check programmes_check].include?(current_step)
16-
end do
13+
with_options only: :show, if: -> { current_step == :dates_check } do
1714
before_action :set_catch_up_year_groups
1815
before_action :set_catch_up_patients_vaccinated_percentage
1916
before_action :set_catch_up_patients_receiving_consent_requests_count
@@ -27,10 +24,7 @@ class DraftSessionsController < ApplicationController
2724
def show
2825
authorize @session, @session.new_record? ? :new? : :edit?
2926

30-
if (current_step == :dates_check && should_skip_dates_check?) ||
31-
(current_step == :programmes_check && should_skip_programmes_check?)
32-
skip_step
33-
end
27+
skip_step if current_step == :dates_check && should_skip_dates_check?
3428

3529
render_wizard
3630
end
@@ -278,7 +272,6 @@ def update_params
278272
programmes: {
279273
programme_types: []
280274
},
281-
programmes_check: [],
282275
register_attendance: %i[requires_registration],
283276
school: %i[location_id],
284277
year_groups: {
@@ -332,11 +325,6 @@ def go_to_confirm_after_submission?
332325
return false
333326
end
334327

335-
if current_step == :programmes && steps.include?("programmes-check") &&
336-
!should_skip_programmes_check?
337-
return false
338-
end
339-
340328
# If we're creating a new session, then we skip a few of the later steps
341329
# in the journey, but users can go to them via the check and confirm page.
342330

@@ -369,17 +357,6 @@ def should_skip_dates_check?
369357
!any_programme_has_high_unvaccinated_count
370358
end
371359

372-
def should_skip_programmes_check?
373-
return true if @draft_session.new_programmes.empty?
374-
375-
any_new_programme_has_high_unvaccinated_count =
376-
@draft_session.new_programmes.any? do |programme|
377-
programme_has_high_unvaccinated_count?(programme)
378-
end
379-
380-
!any_new_programme_has_high_unvaccinated_count
381-
end
382-
383360
def programme_has_high_unvaccinated_count?(programme)
384361
catch_up_year_groups =
385362
@draft_session.year_groups.select do |year_group|

app/models/draft_session.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ def wizard_steps
4040
steps << :school if school? && !editing?
4141

4242
steps << :programmes
43-
steps << :programmes_check if school?
44-
4543
steps << :year_groups if school? && !editing?
4644

4745
steps << :dates

app/views/draft_sessions/_catch_up_warning.html.erb

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1-
<%= render "catch_up_warning",
2-
programmes: @draft_session.programmes.map(&:name).to_sentence,
3-
submit_button_text: "Keep session dates",
4-
cancel_link_text: "Remove session dates",
5-
cancel_link_path: draft_session_path("dates") %>
1+
<% content_for :before_main do %>
2+
<%= govuk_back_link(href: @back_link_path) %>
3+
<% end %>
4+
5+
<% title = t(".title", programmes: @draft_session.programmes.map(&:name).to_sentence) %>
6+
<% content_for :page_title, title %>
7+
8+
<%= govuk_panel(title_text: title, classes: %w[app-panel--interruption]) do %>
9+
<p>
10+
<%= @catch_up_patients_vaccinated_percentage == 0 ? "" : "Only " %>
11+
<%= @catch_up_patients_vaccinated_percentage %>% of children in
12+
<%= format_year_groups(@catch_up_year_groups) %> in
13+
this session have vaccination records. This is unusually low coverage for
14+
catch-up year groups.
15+
</p>
16+
17+
<p>
18+
Check and confirm that vaccination records have been imported for all
19+
children in this school before you continue.
20+
</p>
21+
22+
<% if @draft_session.open_for_consent? && @catch_up_patients_receiving_consent_requests_count > 0 %>
23+
<p>
24+
Scheduling this session now will send consent requests to
25+
<%= pluralize(@catch_up_patients_receiving_consent_requests_count, "parent") %>
26+
of children in <%= format_year_groups(@catch_up_year_groups) %> on
27+
<%= @draft_session.send_consent_requests_at.to_fs(:long) %>. Many of them
28+
may be parents of already vaccinated children.
29+
</p>
30+
<% end %>
31+
32+
<%= form_with model: @draft_session, url: wizard_path, method: :put do |f| %>
33+
<div class="nhsuk-button-group">
34+
<%= f.govuk_submit "Keep session dates", class: "nhsuk-button--reverse" %>
35+
<%= link_to "Remove session dates", draft_session_path("dates") %>
36+
</div>
37+
<% end %>
38+
<% end %>

app/views/draft_sessions/programmes_check.html.erb

Lines changed: 0 additions & 5 deletions
This file was deleted.

config/locales/en.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ en:
624624
personal_choice: Why are they refusing to give consent?
625625
will_be_vaccinated_elsewhere: Where will their child get their vaccination?
626626
draft_sessions:
627-
catch_up_warning:
627+
dates_check:
628628
title: Have you imported historical vaccination records for %{programmes}?
629629
import_duplicate_form:
630630
options:

config/locales/wicked.en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ en:
3434
parent: parent
3535
parent_details: parent-details
3636
programmes: programmes
37-
programmes_check: programmes-check
3837
questions: questions
3938
reason_for_refusal: reason-for-refusal
4039
reason_for_refusal_notes: reason-for-refusal-notes

spec/features/edit_session_programmes_spec.rb

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,75 @@
33
describe "Edit session programmes" do
44
around { |example| travel_to(Time.zone.local(2024, 2, 1)) { example.run } }
55

6-
scenario "add new programme" do
7-
given_a_session_exists
8-
and_the_session_has_unvaccinated_catch_up_patients
6+
before { Flipper.enable(:schools_and_sessions) }
97

10-
when_i_visit_the_session_overview_page
11-
and_i_click_on_edit_session
12-
and_i_add_the_mmr_programme
8+
scenario "choosing programmes with a high number of unvaccinated catch up patients" do
9+
given_a_school_exists
10+
and_the_school_has_unvaccinated_catch_up_patients
11+
12+
when_i_visit_the_school_page
13+
and_i_create_a_new_session
14+
and_i_choose_the_programmes
15+
and_i_choose_the_year_groups
16+
and_i_choose_the_date
1317
then_i_see_the_warning_panel_about_unvaccinated_patients
1418

1519
when_i_click_continue
1620
then_i_should_see_the_mmr_programme
17-
screenshot_and_save_page
1821
end
1922

20-
def given_a_session_exists
23+
def given_a_school_exists
2124
@team =
2225
create(:team, :with_one_nurse, programmes: [Programme.hpv, Programme.mmr])
2326

24-
location = create(:school, programmes: [Programme.hpv, Programme.mmr])
25-
@session =
26-
create(
27-
:session,
28-
:scheduled,
29-
programmes: [Programme.hpv],
30-
team: @team,
31-
location:
32-
)
27+
@location =
28+
create(:school, team: @team, programmes: [Programme.hpv, Programme.mmr])
3329
end
3430

35-
def and_the_session_has_unvaccinated_catch_up_patients
31+
def and_the_school_has_unvaccinated_catch_up_patients
3632
create_list(
3733
:patient,
3834
2,
3935
:eligible_for_vaccination,
40-
session: @session,
41-
year_group: 9
36+
location: @location,
37+
year_group: 9,
38+
programmes: [Programme.hpv, Programme.mmr]
4239
)
4340
end
4441

45-
def when_i_visit_the_session_overview_page
42+
def when_i_visit_the_school_page
4643
sign_in @team.users.first
47-
visit session_path(@session)
44+
visit school_sessions_path(@location)
4845
end
4946

50-
def and_i_click_on_edit_session
51-
click_on "Edit session"
47+
def and_i_create_a_new_session
48+
click_on "Add a new session"
5249
end
5350

54-
def and_i_add_the_mmr_programme
55-
within(".nhsuk-summary-list__row", text: "Programmes") { click_on "Change" }
51+
def and_i_choose_the_programmes
52+
check "HPV"
5653
check "MMR"
57-
when_i_click_continue
54+
click_on "Continue"
55+
end
56+
57+
def and_i_choose_the_year_groups
58+
check "Year 8"
59+
check "Year 9"
60+
check "Year 10"
61+
check "Year 11"
62+
click_on "Continue"
63+
end
64+
65+
def and_i_choose_the_date
66+
fill_in "Year", with: "2024"
67+
fill_in "Month", with: "2"
68+
fill_in "Day", with: "8"
69+
click_on "Continue"
5870
end
5971

6072
def then_i_see_the_warning_panel_about_unvaccinated_patients
6173
expect(page).to have_content(
62-
"Have you imported historical vaccination records for MMR?"
74+
"Have you imported historical vaccination records for HPV and MMR?"
6375
)
6476
expect(page).to have_content(
6577
"0% of children in Years 9 to 11 in this session have vaccination " \
@@ -73,7 +85,7 @@ def then_i_see_the_warning_panel_about_unvaccinated_patients
7385
end
7486

7587
def when_i_click_continue
76-
click_on "Continue"
88+
click_on "Keep session dates"
7789
end
7890

7991
def then_i_should_see_the_mmr_programme

0 commit comments

Comments
 (0)