Skip to content

Commit c616638

Browse files
authored
Merge pull request #4547 from nhsuk/fix-viewing-patient-session-registration
Fix viewing patient when there's no date today
2 parents 72ab958 + 3f6b528 commit c616638

File tree

3 files changed

+62
-7
lines changed

3 files changed

+62
-7
lines changed

app/components/app_patient_session_record_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def render?
2020
(
2121
patient_session.registration_status&.attending? ||
2222
patient_session.registration_status&.completed? ||
23-
!session.requires_registration?
23+
(!session.requires_registration? && session.today?)
2424
)
2525
end
2626

spec/factories/sessions.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
date { Date.current }
7272
end
7373

74+
trait :yesterday do
75+
date { Date.yesterday }
76+
end
77+
7478
trait :unscheduled do
7579
date { nil }
7680
end

spec/features/manage_attendance_spec.rb

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,64 @@
7171
then_i_do_not_see_the_register_tab
7272
end
7373

74+
scenario "Viewing a patient from yesterday with attendance turned off" do
75+
given_my_team_is_running_an_hpv_vaccination_programme
76+
and_there_is_a_vaccination_session_yesterday_that_requires_no_registration
77+
and_the_session_has_patients
78+
79+
when_i_go_to_the_session
80+
and_i_click_on_the_record_tab
81+
then_i_cant_see_the_patients
82+
83+
when_i_go_to_the_session
84+
and_i_click_on_the_children_tab
85+
and_i_go_to_a_patient
86+
then_i_cant_record_a_vaccination
87+
end
88+
7489
def given_my_team_is_running_an_hpv_vaccination_programme
7590
@programmes = [create(:programme, :hpv_all_vaccines)]
76-
@team = create(:team, :with_one_nurse, programmes: @programmes)
91+
@team =
92+
create(
93+
:team,
94+
:with_one_nurse,
95+
:with_generic_clinic,
96+
programmes: @programmes
97+
)
7798
end
7899

79100
def and_there_is_a_vaccination_session_today
80-
location = create(:school, team: @team)
81101
@session =
82-
create(:session, :today, programmes: @programmes, team: @team, location:)
102+
create(
103+
:session,
104+
:today,
105+
programmes: @programmes,
106+
team: @team,
107+
location: create(:school, team: @team)
108+
)
83109
end
84110

85111
def and_there_is_a_vaccination_session_today_that_requires_no_registration
86-
location = create(:school, team: @team)
87112
@session =
88113
create(
89114
:session,
90115
:today,
91116
:requires_no_registration,
92117
programmes: @programmes,
93118
team: @team,
94-
location:
119+
location: create(:school, team: @team)
120+
)
121+
end
122+
123+
def and_there_is_a_vaccination_session_yesterday_that_requires_no_registration
124+
@session =
125+
create(
126+
:session,
127+
:yesterday,
128+
:requires_no_registration,
129+
programmes: @programmes,
130+
team: @team,
131+
location: create(:school, team: @team)
95132
)
96133
end
97134

@@ -112,18 +149,28 @@ def when_i_go_to_the_session
112149
click_link @session.location.name
113150
end
114151

152+
def and_i_click_on_the_children_tab
153+
within(".app-secondary-navigation") { click_on "Children" }
154+
end
155+
115156
def and_i_click_on_the_register_tab
116157
click_link "Register"
117158
end
118159

119-
def when_i_click_on_the_record_vaccinations_tab
160+
def and_i_click_on_the_record_tab
120161
click_link "Record vaccinations"
121162
end
122163

123164
def then_i_do_not_see_the_register_tab
124165
expect(page).not_to have_content("Register")
125166
end
126167

168+
def then_i_cant_see_the_patients
169+
expect(page).to have_content(
170+
"You can record vaccinations when a session is in progress."
171+
)
172+
end
173+
127174
def then_i_should_not_see_link_to_update_attendance
128175
expect(page).not_to have_content("Update attendance")
129176
end
@@ -226,4 +273,8 @@ def and_i_turn_off_register_attendance
226273
choose "No"
227274
click_on "Continue"
228275
end
276+
277+
def then_i_cant_record_a_vaccination
278+
expect(page).not_to have_content("Record vaccination")
279+
end
229280
end

0 commit comments

Comments
 (0)