Skip to content

Commit ddfca2e

Browse files
Only send notifications to children that should have notifications sent
This had likely never been noticed before as the message has only been sent roughly 500 times when sourced from a historical upload. For issues imported through FHIR Imms they will frequently be recent vaccinations and therefore not frequently to children that are invalidated, deceased, or restricted. Jira-Issue: MAV-3284
1 parent 1a1ecbe commit ddfca2e

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

app/lib/notification_parent_selector.rb

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,14 @@
33
class NotificationParentSelector
44
def initialize(vaccination_record:, consents: nil)
55
@vaccination_record = vaccination_record
6-
76
@consents =
8-
if consents.present?
9-
consents
7+
if @vaccination_record.patient.send_notifications?(
8+
team: @vaccination_record.team,
9+
send_to_archived: true
10+
) && @vaccination_record.notify_parents
11+
consents || @vaccination_record.patient.consents
1012
else
11-
patient = @vaccination_record.patient
12-
13-
if patient.send_notifications?(
14-
team: @vaccination_record.team,
15-
send_to_archived: true
16-
) && @vaccination_record.notify_parents
17-
patient.consents
18-
else
19-
[]
20-
end
13+
[]
2114
end
2215
end
2316

spec/lib/notification_parent_selector_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,21 @@
173173
end
174174

175175
context "when patient should not send notifications" do
176-
let(:consents) { nil }
177-
178176
before do
179177
allow(patient).to receive(:send_notifications?).and_return(false)
180178
end
181179

182180
it "returns empty array" do
183181
expect(parents).to be_empty
184182
end
183+
184+
context "when no consents are provided" do
185+
let(:consents) { nil }
186+
187+
it "returns empty array" do
188+
expect(parents).to be_empty
189+
end
190+
end
185191
end
186192

187193
context "edge cases" do

0 commit comments

Comments
 (0)