Skip to content

Commit c785c74

Browse files
committed
Ignore completed sessions when deriving consent request status
Fixes a bug where an eligible patient in a new cohort with contactable parents could be marked as `:no_response` if they were not in an active session but only had completed sessions. These patients should instead be marked as `:request_not_scheduled`. Jira-Issue: MAV-6067
1 parent 3dfc97a commit c785c74

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

app/lib/status_generator/programme.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ def sessions
339339
.select { it.academic_year == academic_year }
340340
.flat_map(&:sessions)
341341
.select { it.programme_types.include?(programme_type) }
342+
.reject(&:completed?)
342343
end
343344
end
344345
end

spec/lib/status_generator/programme_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@
405405
its(:vaccine_methods) { should be_nil }
406406
its(:without_gelatine) { should be_nil }
407407

408+
context "when the only session is completed" do
409+
let(:session) { create(:session, :completed, programmes: [programme]) }
410+
411+
before { ConsentNotification.delete_all }
412+
413+
its(:status) { should be(:needs_consent_request_not_scheduled) }
414+
end
415+
408416
context "when the patient only has a generic clinic location" do
409417
let(:team) { create(:team, programmes: [programme]) }
410418
let(:location) { create(:generic_clinic, team:) }

0 commit comments

Comments
 (0)