Skip to content

Commit 2cc738c

Browse files
authored
Merge pull request #6021 from nhsuk/feature-flag-for-already-vaccinated-journey
Add `already_vaccinated` feature flag
2 parents bfd382a + d96f6f7 commit 2cc738c

10 files changed

Lines changed: 343 additions & 216 deletions

app/components/app_vaccination_record_summary_component.rb

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,18 @@ def call
234234
end
235235
end
236236

237-
summary_list.with_row do |row|
238-
row.with_key { "Vaccinator" }
239-
row.with_value { vaccinator_value }
240-
if (href = @change_links[:vaccinator])
241-
row.with_action(
242-
text: "Change",
243-
visually_hidden_text: "vaccinator",
244-
href:
245-
)
237+
if @vaccination_record.performed_by.present? ||
238+
Flipper.enabled?(:already_vaccinated)
239+
summary_list.with_row do |row|
240+
row.with_key { "Vaccinator" }
241+
row.with_value { vaccinator_value }
242+
if (href = @change_links[:vaccinator])
243+
row.with_action(
244+
text: "Change",
245+
visually_hidden_text: "vaccinator",
246+
href:
247+
)
248+
end
246249
end
247250
end
248251

@@ -291,14 +294,16 @@ def call
291294
end
292295
end
293296

294-
if @vaccination_record.reported_by.present?
297+
if Flipper.enabled?(:already_vaccinated) &&
298+
@vaccination_record.reported_by.present?
295299
summary_list.with_row do |row|
296300
row.with_key { "Reported by" }
297301
row.with_value { @vaccination_record.reported_by&.full_name }
298302
end
299303
end
300304

301-
if @vaccination_record.reported_at.present?
305+
if Flipper.enabled?(:already_vaccinated) &&
306+
@vaccination_record.reported_at.present?
302307
summary_list.with_row do |row|
303308
row.with_key { "Reported on" }
304309
row.with_value { @vaccination_record.reported_at.to_fs(:long) }
@@ -343,7 +348,8 @@ def outcome_value
343348
outcome =
344349
VaccinationRecord.human_enum_name(:outcome, @vaccination_record.outcome)
345350

346-
if @vaccination_record.already_had? &&
351+
if Flipper.enabled?(:already_vaccinated) &&
352+
@vaccination_record.already_had? &&
347353
@vaccination_record.reported_as_already_vaccinated?
348354
outcome = VaccinationRecord.human_enum_name(:outcome, "administered")
349355
end

app/controllers/api/reporting/totals_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
3434
consent_conflicts: "Consent Conflicts",
3535
consent_given: "Consent Given",
3636
not_vaccinated: "Not Vaccinated",
37-
vaccinated: "Vaccinated",
37+
vaccinated: "Vaccinated"
3838
}.freeze
3939

4040
FLU_SPECIFIC_METRIC_HEADERS = {}.freeze

app/controllers/patient_sessions/programmes_controller.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,35 @@ def record_already_vaccinated
1818
DraftVaccinationRecord.new(request_session: session, current_user:)
1919

2020
draft_vaccination_record.clear_attributes
21+
22+
first_active_wizard_step =
23+
if Flipper.enabled?(:already_vaccinated)
24+
eligible_for_mmr_or_mmrv? ? :mmr_or_mmrv : :date_and_time
25+
else
26+
:confirm
27+
end
28+
2129
draft_vaccination_record.update!(
22-
dose_sequence: dose_sequence,
23-
first_active_wizard_step:
24-
eligible_for_mmr_or_mmrv? ? :mmr_or_mmrv : :date_and_time,
30+
dose_sequence: (dose_sequence if Flipper.enabled?(:already_vaccinated)),
31+
first_active_wizard_step:,
2532
location_id: nil,
2633
location_name: "Unknown",
2734
outcome: :already_had,
2835
patient: @patient,
36+
performed_at: (Time.current unless Flipper.enabled?(:already_vaccinated)),
37+
performed_by_user_id:
38+
(current_user.id unless Flipper.enabled?(:already_vaccinated)),
2939
performed_ods_code: current_team.organisation.ods_code,
3040
programme: @programme,
31-
reported_by_id: current_user.id,
32-
reported_at: Time.current,
41+
reported_by_id:
42+
(current_user.id if Flipper.enabled?(:already_vaccinated)),
43+
reported_at: (Time.current if Flipper.enabled?(:already_vaccinated)),
3344
session: @session,
3445
source: "service"
3546
)
3647

3748
redirect_to draft_vaccination_record_path(
38-
eligible_for_mmr_or_mmrv? ? "mmr-or-mmrv" : "date-and-time"
49+
first_active_wizard_step.to_s.dasherize
3950
)
4051
end
4152

app/helpers/vaccination_records_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def vaccination_record_source(vaccination_record)
2828
end
2929

3030
def already_vaccinated_link_label(session:, patient:, programme:)
31-
if programme.mmr?
31+
if programme.mmr? && Flipper.enabled?(:already_vaccinated)
3232
if had_first_dose?(session:, patient:, programme:)
3333
"Record 2nd dose as already given"
3434
else

app/models/draft_vaccination_record.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def wizard_steps
6363
(:notes unless national_reporting_user_and_record?),
6464
(
6565
if programme&.mmr? && (administered? || already_had?) &&
66-
patient.eligible_for_mmrv?
66+
patient.eligible_for_mmrv? && Flipper.enabled?(:already_vaccinated)
6767
:mmr_or_mmrv
6868
end
6969
),
@@ -191,7 +191,8 @@ def already_had?
191191
end
192192

193193
def reported_as_already_vaccinated?
194-
already_had? && reported_by_id.present?
194+
Flipper.enabled?(:already_vaccinated) && already_had? &&
195+
reported_by_id.present?
195196
end
196197

197198
# So that a form error matches to a field in this model

config/feature_flags.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
already_vaccinated: |
2+
New questions for the already vaccinated flow triggered
3+
from the 'Record as already vaccinated' link on the session > children page.
4+
15
basic_auth: Require users to sign in with basic authentication before they
26
can use the service.
37

spec/features/mmr_already_had_spec.rb

Lines changed: 117 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3,90 +3,113 @@
33
describe "MMR/MMRV" do
44
around { |example| travel_to(Date.new(2025, 7, 1)) { example.run } }
55

6-
scenario "record a patient born after January 2020 as already had their 1st MMR dose outside the school session" do
7-
given_an_mmr_programme_with_a_session
8-
and_a_patient_is_in_the_session_born_after_january_2020
9-
and_the_patient_doesnt_need_triage
10-
and_the_patient_has_not_had_a_first_dose
11-
12-
when_i_go_the_session
13-
then_i_see_one_patient_needing_consent
14-
and_i_click_on_the_patient
15-
then_i_see_the_patient_needs_consent
16-
17-
when_i_click_record_as_already_had_first_dose
18-
when_i_click_back
19-
then_i_see_the_patient_session_page
20-
21-
when_i_click_record_as_already_had_first_dose
22-
then_i_see_the_did_you_have_mmr_or_mmrv_page
23-
24-
when_i_choose_mmr_and_continue
25-
then_i_see_the_mmr_date_page
26-
27-
when_i_fill_in_the_date_and_continue
28-
then_i_see_the_confirmation_page
29-
and_the_confirmation_summary_is_not_displayed_as_a_warning
30-
31-
when_i_confirm_the_details
32-
then_i_see_the_patient_is_already_vaccinated
33-
and_i_see_that_the_vaccinator_is_unknown
34-
and_i_see_that_the_location_is_unknown
35-
and_i_see_that_the_reporter_is_set
36-
expect(page).to have_content("LocationUnknown")
37-
and_had_been_vaccinated_with_mmr
38-
and_the_dose_number_is_first
39-
and_the_performed_at_date_only_is_set
40-
and_the_consent_requests_are_sent
41-
then_the_parent_doesnt_receive_a_consent_request
42-
end
43-
44-
scenario "record a patient born before January 2020 as already had their 1st MMR dose outside the school session" do
45-
given_an_mmr_programme_with_a_session
46-
and_a_patient_is_in_the_session_born_before_january_2020
47-
and_the_patient_doesnt_need_triage
48-
and_the_patient_has_not_had_a_first_dose
49-
50-
when_i_go_the_session
51-
then_i_see_one_patient_needing_consent
52-
and_i_click_on_the_patient
53-
then_i_see_the_patient_needs_consent
54-
55-
when_i_click_record_as_already_had_first_dose
56-
then_i_see_the_mmr_date_instead_of_the_mmr_or_mmrv_page
57-
end
58-
59-
scenario "record a patient born after January 2020 as already had their 2nd MMRV dose outside the school session" do
60-
given_an_mmr_programme_with_a_session
61-
and_a_patient_is_in_the_session_born_after_january_2020
62-
and_the_patient_doesnt_need_triage
63-
and_the_patient_already_has_first_dose
64-
65-
when_i_go_the_session
66-
then_i_see_one_patient_needing_consent
67-
and_i_click_on_the_patient
68-
then_i_see_the_patient_needs_consent
69-
70-
when_i_click_record_as_already_had_second_dose
71-
then_i_see_the_did_you_have_mmr_or_mmrv_page
72-
73-
when_i_choose_mmrv_and_continue
74-
then_i_see_the_mmrv_date_page
75-
76-
when_i_fill_in_the_date_and_time_and_continue
77-
then_i_see_the_confirmation_page
78-
and_the_confirmation_summary_is_not_displayed_as_a_warning
79-
80-
when_i_confirm_the_details
81-
then_i_see_the_patient_is_already_vaccinated
82-
and_i_see_that_the_vaccinator_is_unknown
83-
and_i_see_that_the_location_is_unknown
84-
and_i_see_that_the_reporter_is_set
85-
and_had_been_vaccinated_with_mmrv
86-
and_the_dose_number_is_second
87-
and_the_performed_at_date_and_time_are_set
88-
and_the_consent_requests_are_sent
89-
then_the_parent_doesnt_receive_a_consent_request
6+
context "when `already_vaccinated` feature flag is NOT enabled" do
7+
scenario "record a patient born after January 2020 as already had their 1st MMR dose" do
8+
given_an_mmr_programme_with_a_session
9+
and_a_patient_is_in_the_session_born_after_january_2020
10+
and_the_patient_doesnt_need_triage
11+
and_the_patient_has_not_had_a_first_dose
12+
13+
when_i_go_the_session
14+
then_i_see_one_patient_needing_consent
15+
and_i_click_on_the_patient
16+
then_i_see_the_patient_needs_consent
17+
18+
when_i_click_record_as_already_vaccinated
19+
when_i_click_back
20+
then_i_see_the_patient_session_page
21+
22+
when_i_click_record_as_already_vaccinated
23+
then_i_see_the_confirmation_page
24+
end
25+
end
26+
27+
context "when `already_vaccinated` feature flag is enabled" do
28+
before { Flipper.enable(:already_vaccinated) }
29+
30+
scenario "record a patient born after January 2020 as already had their 1st MMR dose outside the school session" do
31+
given_an_mmr_programme_with_a_session
32+
and_a_patient_is_in_the_session_born_after_january_2020
33+
and_the_patient_doesnt_need_triage
34+
and_the_patient_has_not_had_a_first_dose
35+
36+
when_i_go_the_session
37+
then_i_see_one_patient_needing_consent
38+
and_i_click_on_the_patient
39+
then_i_see_the_patient_needs_consent
40+
41+
when_i_click_record_as_already_had_first_dose
42+
when_i_click_back
43+
then_i_see_the_patient_session_page
44+
45+
when_i_click_record_as_already_had_first_dose
46+
then_i_see_the_did_you_have_mmr_or_mmrv_page
47+
48+
when_i_choose_mmr_and_continue
49+
then_i_see_the_mmr_date_page
50+
51+
when_i_fill_in_the_date_and_time_and_continue
52+
then_i_see_the_confirmation_page
53+
and_the_confirmation_summary_is_not_displayed_as_a_warning
54+
55+
when_i_confirm_the_details
56+
then_i_see_the_patient_is_already_vaccinated
57+
and_i_see_that_the_vaccinator_is_unknown
58+
and_i_see_that_the_location_is_unknown
59+
and_i_see_that_the_reporter_is_set
60+
expect(page).to have_content("LocationUnknown")
61+
and_had_been_vaccinated_with_mmr
62+
and_the_dose_number_is_first
63+
and_the_consent_requests_are_sent
64+
then_the_parent_doesnt_receive_a_consent_request
65+
end
66+
67+
scenario "record a patient born before January 2020 as already had their 1st MMR dose outside the school session" do
68+
given_an_mmr_programme_with_a_session
69+
and_a_patient_is_in_the_session_born_before_january_2020
70+
and_the_patient_doesnt_need_triage
71+
and_the_patient_has_not_had_a_first_dose
72+
73+
when_i_go_the_session
74+
then_i_see_one_patient_needing_consent
75+
and_i_click_on_the_patient
76+
then_i_see_the_patient_needs_consent
77+
78+
when_i_click_record_as_already_had_first_dose
79+
then_i_see_the_mmr_date_instead_of_the_mmr_or_mmrv_page
80+
end
81+
82+
scenario "record a patient born after January 2020 as already had their 2nd MMRV dose outside the school session" do
83+
given_an_mmr_programme_with_a_session
84+
and_a_patient_is_in_the_session_born_after_january_2020
85+
and_the_patient_doesnt_need_triage
86+
and_the_patient_already_has_first_dose
87+
88+
when_i_go_the_session
89+
then_i_see_one_patient_needing_consent
90+
and_i_click_on_the_patient
91+
then_i_see_the_patient_needs_consent
92+
93+
when_i_click_record_as_already_had_second_dose
94+
then_i_see_the_did_you_have_mmr_or_mmrv_page
95+
96+
when_i_choose_mmrv_and_continue
97+
then_i_see_the_mmrv_date_page
98+
99+
when_i_fill_in_the_date_and_continue
100+
then_i_see_the_confirmation_page
101+
and_the_confirmation_summary_is_not_displayed_as_a_warning
102+
103+
when_i_confirm_the_details
104+
then_i_see_the_patient_is_already_vaccinated
105+
and_i_see_that_the_vaccinator_is_unknown
106+
and_i_see_that_the_location_is_unknown
107+
and_i_see_that_the_reporter_is_set
108+
and_had_been_vaccinated_with_mmrv
109+
and_the_dose_number_is_second
110+
and_the_consent_requests_are_sent
111+
then_the_parent_doesnt_receive_a_consent_request
112+
end
90113
end
91114

92115
def given_an_mmr_programme_with_a_session(clinic: false)
@@ -169,6 +192,10 @@ def then_i_see_the_patient_needs_consent
169192
expect(page).to have_content("No response")
170193
end
171194

195+
def when_i_click_record_as_already_vaccinated
196+
click_on "Record as already vaccinated"
197+
end
198+
172199
def when_i_click_record_as_already_had_first_dose
173200
click_on "Record 1st dose as already given"
174201
end
@@ -294,12 +321,16 @@ def and_the_dose_number_is_second
294321
end
295322

296323
def and_the_performed_at_date_and_time_are_set
297-
expect(page).to have_content("Date#{@vaccination_date.strftime('%-d %B %Y')}")
324+
expect(page).to have_content(
325+
"Date#{@vaccination_date.strftime("%-d %B %Y")}"
326+
)
298327
expect(page).to have_content("Time12:30")
299328
end
300329

301330
def and_the_performed_at_date_only_is_set
302-
expect(page).to have_content("Date#{@vaccination_date.strftime('%-d %B %Y')}")
331+
expect(page).to have_content(
332+
"Date#{@vaccination_date.strftime("%-d %B %Y")}"
333+
)
303334
end
304335

305336
def and_the_consent_requests_are_sent

0 commit comments

Comments
 (0)