Skip to content

Commit 67ff88b

Browse files
committed
Ensure we send the MMRV specific consent request
For patients that are elegible for MMRV, we have a specific template for the initial request that should be sent instead of the MMR one.
1 parent 02cca77 commit 67ff88b

3 files changed

Lines changed: 109 additions & 3 deletions

File tree

app/models/consent_notification.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def self.create_and_send!(
8585
mail_template =
8686
if is_school
8787
group = ProgrammeGrouper.call(programmes).first.first
88+
89+
group = :mmrv if group == :mmr && patient.eligible_for_mmrv?
90+
8891
:"#{template}_#{group}"
8992
else
9093
template

config/initializers/govuk_notify.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
consent_school_request_flu: "017853bc-2b35-4aff-99b1-193e514613a0",
2121
consent_school_request_hpv: "7b9bb010-0742-460a-ae25-1922355b6776",
2222
consent_school_request_mmr: "7e86e688-ceca-4dcc-a1cf-19cb559d38a8",
23+
consent_school_request_mmrv: "fe194b88-5692-49a2-ab14-648e8ce2af63",
2324
consent_school_subsequent_reminder_doubles:
2425
"ea03aada-0912-4373-91e1-80082071a7aa",
2526
consent_school_subsequent_reminder_flu:

spec/features/parental_consent_send_request_spec.rb

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
and_an_activity_log_entry_is_visible_for_the_text_tagged_as("HPV")
2323
end
2424

25-
scenario "Send request where patient is eligible for MMRV" do
25+
scenario "Send clinic request where patient is eligible for MMRV" do
2626
given_a_programme_exists(:mmr)
2727
and_a_patient_without_consent_exists
2828
and_i_am_signed_in
@@ -40,6 +40,44 @@
4040
and_an_activity_log_entry_is_visible_for_the_text_tagged_as("MMRV")
4141
end
4242

43+
scenario "Send school request where patient is eligible for MMRV" do
44+
given_a_programme_exists(:mmr)
45+
and_a_school_session_with_mmrv_eligible_patient_exists
46+
and_i_am_signed_in
47+
48+
when_i_go_to_a_patient_without_consent
49+
then_i_see_no_requests_sent
50+
51+
when_i_click_send_consent_request
52+
then_i_see_the_confirmation_banner
53+
and_the_mmrv_email_template_is_sent_to_the_parent
54+
55+
when_i_click_on_session_activity_and_notes
56+
then_an_activity_log_entry_is_visible_for_the_email_tagged_as(
57+
"MMRV",
58+
clinic: false
59+
)
60+
end
61+
62+
scenario "Send school request where patient is not eligible for MMRV" do
63+
given_a_programme_exists(:mmr)
64+
and_a_school_session_with_mmr_only_patient_exists
65+
and_i_am_signed_in
66+
67+
when_i_go_to_a_patient_without_consent
68+
then_i_see_no_requests_sent
69+
70+
when_i_click_send_consent_request
71+
then_i_see_the_confirmation_banner
72+
and_the_mmr_email_template_is_sent_to_the_parent
73+
74+
when_i_click_on_session_activity_and_notes
75+
then_an_activity_log_entry_is_visible_for_the_email_tagged_as(
76+
"MMR",
77+
clinic: false
78+
)
79+
end
80+
4381
def given_a_programme_exists(programme_type)
4482
@programmes = [Programme.public_send(programme_type)]
4583
end
@@ -71,6 +109,60 @@ def and_a_patient_without_consent_exists
71109
PatientStatusUpdater.call
72110
end
73111

112+
def and_a_school_session_with_mmrv_eligible_patient_exists
113+
@team = create(:team, :with_one_nurse, programmes: @programmes)
114+
@user = @team.users.first
115+
116+
location = create(:school, team: @team, programmes: @programmes)
117+
118+
@session =
119+
create(
120+
:session,
121+
team: @team,
122+
programmes: @programmes,
123+
location:,
124+
date: Date.current + 2.days
125+
)
126+
127+
@parent = create(:parent)
128+
@patient =
129+
create(
130+
:patient,
131+
session: @session,
132+
parents: [@parent],
133+
date_of_birth: Programme::MIN_MMRV_ELIGIBILITY_DATE + 1.month
134+
)
135+
136+
PatientStatusUpdater.call
137+
end
138+
139+
def and_a_school_session_with_mmr_only_patient_exists
140+
@team = create(:team, :with_one_nurse, programmes: @programmes)
141+
@user = @team.users.first
142+
143+
location = create(:school, team: @team, programmes: @programmes)
144+
145+
@session =
146+
create(
147+
:session,
148+
team: @team,
149+
programmes: @programmes,
150+
location:,
151+
date: Date.current + 2.days
152+
)
153+
154+
@parent = create(:parent)
155+
@patient =
156+
create(
157+
:patient,
158+
session: @session,
159+
parents: [@parent],
160+
date_of_birth: Programme::MIN_MMRV_ELIGIBILITY_DATE - 1.month
161+
)
162+
163+
PatientStatusUpdater.call
164+
end
165+
74166
def and_i_am_signed_in
75167
sign_in @user
76168
end
@@ -107,15 +199,25 @@ def and_a_text_is_sent_to_the_parent
107199
expect_sms_to(@parent.phone, :consent_clinic_request)
108200
end
109201

202+
def and_the_mmrv_email_template_is_sent_to_the_parent
203+
expect_email_to(@parent.email, :consent_school_request_mmrv)
204+
end
205+
206+
def and_the_mmr_email_template_is_sent_to_the_parent
207+
expect_email_to(@parent.email, :consent_school_request_mmr)
208+
end
209+
110210
def when_i_click_on_session_activity_and_notes
111211
click_on "Session activity and notes"
112212
end
113213

114214
def then_an_activity_log_entry_is_visible_for_the_email_tagged_as(
115-
programme_name
215+
programme_name,
216+
clinic: true
116217
)
117218
expect(page).to have_content(
118-
"Consent clinic request sent\n#{@parent.email}\n" \
219+
"Consent #{clinic ? "clinic" : "school"} request#{clinic ? "" : " #{programme_name.downcase}"} sent" \
220+
"\n#{@parent.email}\n" \
119221
"#{programme_name} 1 January 2024 at 12:00am · USER, Test"
120222
)
121223
end

0 commit comments

Comments
 (0)