Skip to content

Commit 27026a6

Browse files
committed
Get programmes for GOV.UK Notify personalisation
At the moment, to determine the programmes (used in GOV.UK Notify personalisation), they need to be passed in explicitly when we send the email. This is causing an issue with the `vaccine_side_effects` variable where it's not available for session reminders because the programmes cannot be determined correctly. Jira-Issue: MAV-1355
1 parent e70dbb0 commit 27026a6

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

app/lib/govuk_notify_personalisation.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def initialize(
3030
consent&.organisation || vaccination_record&.organisation
3131
@team = session&.team || consent_form&.team || vaccination_record&.team
3232
@vaccination_record = vaccination_record
33+
34+
if @programmes.empty? && @session.present? && @patient.present?
35+
@programmes = @session.eligible_programmes_for(patient: @patient)
36+
end
3337
end
3438

3539
def to_h

spec/lib/govuk_notify_personalisation_spec.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# frozen_string_literal: true
22

33
describe GovukNotifyPersonalisation do
4-
subject(:to_h) do
5-
described_class.new(
4+
subject(:to_h) { described_class.new(**params).to_h }
5+
6+
let(:params) do
7+
{
68
patient:,
79
session:,
810
consent:,
911
consent_form:,
1012
programmes:,
1113
vaccination_record:
12-
).to_h
14+
}
1315
end
1416

1517
let(:programmes) { [create(:programme, :hpv)] }
@@ -256,5 +258,20 @@
256258
)
257259
)
258260
end
261+
262+
context "when programmes comes from the session" do
263+
let(:params) do
264+
{ patient:, session:, consent:, consent_form:, vaccination_record: }
265+
end
266+
267+
it do
268+
expect(to_h).to match(
269+
hash_including(
270+
vaccine_side_effects:
271+
"- generally feeling unwell\n- swelling or pain where the injection was given"
272+
)
273+
)
274+
end
275+
end
259276
end
260277
end

0 commit comments

Comments
 (0)