Skip to content

Commit b331ff5

Browse files
Don't add deceased patients to sessions
This ensures that when a patient has a date of death, they are not added to any upcoming sessions. Co-authored-by: Karim Elmestekawy <karim.mestekawy@gmail.com> Jira-Issue: MAV-1228
1 parent 4876c2a commit b331ff5

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

app/models/patient_import_row.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def to_patient
3939
end
4040

4141
def to_school_move(patient)
42+
return if patient.deceased?
43+
4244
if patient.new_record? || patient.school != school ||
4345
patient.home_educated != home_educated || patient.not_in_team?
4446
school_move =

spec/models/class_import_row_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,24 @@
131131
end
132132
end
133133

134+
describe "#to_school_move" do
135+
subject { class_import_row.to_school_move(patient) }
136+
137+
let(:data) { valid_data }
138+
139+
let(:patient) { class_import_row.to_patient }
140+
141+
context "without a date of death" do
142+
it { should_not be_nil }
143+
end
144+
145+
context "with a date of death" do
146+
before { patient.update!(date_of_death: today) }
147+
148+
it { should be_nil }
149+
end
150+
end
151+
134152
describe "#to_parents" do
135153
subject(:parents) { class_import_row.to_parents }
136154

spec/models/cohort_import_row_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,12 @@
561561

562562
it { should_not be_nil }
563563

564+
context "with a date of death" do
565+
before { patient.update!(date_of_death: today) }
566+
567+
it { should be_nil }
568+
end
569+
564570
describe "#school" do
565571
subject(:school) { school_move.school }
566572

0 commit comments

Comments
 (0)