Skip to content

Commit ee6ff7b

Browse files
committed
Ensure patients who don't need triage are hidden
When viewing the "Triage" tab of a session, patients who don't need triage should not be shown in this list. This was always the intention behind the design and this commit fixes a bug which meant that it wasn't working as expected.
1 parent 361a646 commit ee6ff7b

File tree

2 files changed

+44
-17
lines changed

2 files changed

+44
-17
lines changed

app/controllers/sessions/triage_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Sessions::TriageController < ApplicationController
1010
layout "full"
1111

1212
def show
13-
@statuses = Patient::TriageStatus.statuses.keys - [:not_required]
13+
@statuses = Patient::TriageStatus.statuses.keys - %w[not_required]
1414
@programmes = @session.programmes
1515

1616
scope =

spec/features/triage_spec.rb

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
describe "Triage" do
44
scenario "nurse can triage a patient" do
55
given_a_programme_with_a_running_session
6+
and_a_patient_who_needs_triage_exists
7+
and_a_patient_who_doesnt_need_triage_exists
8+
9+
when_i_go_to_the_session_triage_tab
10+
then_i_see_the_patient_who_needs_triage
11+
and_i_dont_see_the_patient_who_doesnt_need_triage
12+
613
when_i_go_to_the_patient_that_needs_triage
714
then_i_see_the_triage_options
815

@@ -36,40 +43,60 @@ def given_a_programme_with_a_running_session
3643
organisation: @organisation,
3744
vaccine: programmes.first.vaccines.first
3845
)
39-
location = create(:school)
40-
@session =
41-
create(:session, organisation: @organisation, programmes:, location:)
42-
@patient =
46+
47+
@session = create(:session, organisation: @organisation, programmes:)
48+
end
49+
50+
def and_a_patient_who_needs_triage_exists
51+
@patient_triage_needed =
4352
create(
4453
:patient_session,
4554
:consent_given_triage_needed,
46-
programmes:,
4755
session: @session
4856
).patient
57+
4958
create(
5059
:consent,
5160
:given,
5261
:health_question_notes,
5362
:from_granddad,
54-
patient: @patient,
55-
programme: programmes.first
63+
patient: @patient_triage_needed,
64+
programme: @session.programmes.first
5665
)
5766

58-
@patient.reload # Make sure both consents are accessible
67+
@patient_triage_needed.reload # Make sure both consents are accessible
5968
end
6069

61-
def when_i_go_to_the_patient_that_needs_triage
62-
sign_in @organisation.users.first
70+
def and_a_patient_who_doesnt_need_triage_exists
71+
@patient_triage_not_needed =
72+
create(
73+
:patient_session,
74+
:consent_given_triage_not_needed,
75+
session: @session
76+
).patient
77+
end
6378

79+
def when_i_go_to_the_session_triage_tab
80+
sign_in @organisation.users.first
6481
visit session_triage_path(@session)
82+
end
83+
84+
def then_i_see_the_patient_who_needs_triage
85+
expect(page).to have_content(@patient_triage_needed.full_name)
86+
end
87+
88+
def and_i_dont_see_the_patient_who_doesnt_need_triage
89+
expect(page).not_to have_content(@patient_triage_not_needed.full_name)
90+
end
91+
92+
def when_i_go_to_the_patient_that_needs_triage
6593
choose "Needs triage"
6694
click_on "Update results"
67-
68-
click_link @patient.full_name
95+
click_link @patient_triage_needed.full_name
6996
end
7097

7198
def when_i_go_to_the_patient
72-
click_link @patient.full_name, match: :first
99+
click_link @patient_triage_needed.full_name, match: :first
73100
end
74101

75102
def when_i_record_that_they_need_triage
@@ -109,19 +136,19 @@ def then_i_see_the_update_triage_link
109136
end
110137

111138
def and_needs_triage_emails_are_sent_to_both_parents
112-
@patient.parents.each do |parent|
139+
@patient_triage_needed.parents.each do |parent|
113140
expect_email_to parent.email, :consent_confirmation_triage, :any
114141
end
115142
end
116143

117144
def and_vaccination_wont_happen_emails_are_sent_to_both_parents
118-
@patient.parents.each do |parent|
145+
@patient_triage_needed.parents.each do |parent|
119146
expect_email_to parent.email, :triage_vaccination_wont_happen, :any
120147
end
121148
end
122149

123150
def and_vaccination_will_happen_emails_are_sent_to_both_parents
124-
@patient.parents.each do |parent|
151+
@patient_triage_needed.parents.each do |parent|
125152
expect_email_to parent.email, :triage_vaccination_will_happen, :any
126153
end
127154
end

0 commit comments

Comments
 (0)