Skip to content

Commit 5977f03

Browse files
authored
Merge pull request #6661 from NHSDigital/fix-patient-programme-status-after-consent-request
Update patient status after sending consent requests
2 parents 9f0eb01 + 90a236b commit 5977f03

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

app/lib/notifier/patient.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ def send_consent_notification(
237237
SMSDeliveryJob.perform_later(sms_template, **params)
238238
end
239239

240+
PatientStatusUpdaterJob.perform_async(patient.id)
241+
240242
consent_notification
241243
end
242244

spec/lib/notifier/patient_spec.rb

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
let(:disease_types) { programmes.flat_map(&:disease_types).uniq.presence }
1515
let(:programme_types) { programmes.map(&:type) }
1616
let(:team) { create(:team, programmes:) }
17-
let(:session) { create(:session, location:, programmes:, team:) }
17+
let(:send_consent_requests_at) { nil }
18+
let(:session) do
19+
create(:session, location:, programmes:, team:, send_consent_requests_at:)
20+
end
1821
let(:team_location) { session.team_location }
1922

2023
context "with a session" do
@@ -40,6 +43,38 @@
4043
expect(consent_notification.sent_at).to eq(today)
4144
end
4245

46+
context "when the consent request was scheduled for the future" do
47+
let(:send_consent_requests_at) { today + 1.day }
48+
49+
it "updates the programme status after sending the request" do
50+
travel_to(today) do
51+
PatientStatusUpdater.call(patient:)
52+
53+
expect(
54+
patient.programme_status(
55+
programmes.first,
56+
academic_year: session.academic_year
57+
)
58+
).to be_needs_consent_request_scheduled
59+
60+
notifier.send_consent_request(programmes, session:, sent_by:)
61+
62+
expect(PatientStatusUpdaterJob).to have_enqueued_sidekiq_job(
63+
patient.id
64+
)
65+
66+
PatientStatusUpdaterJob.drain
67+
68+
expect(
69+
patient.programme_status(
70+
programmes.first,
71+
academic_year: session.academic_year
72+
).reload
73+
).to be_needs_consent_no_response
74+
end
75+
end
76+
end
77+
4378
it "enqueues an email per parent" do
4479
expect { send_consent_request }.to have_delivered_email(
4580
:consent_school_request_hpv

0 commit comments

Comments
 (0)