Skip to content

Commit 34bf20e

Browse files
authored
Merge pull request #6276 from NHSDigital/hide-archived-from-invite-to-clinic
Hide archived from invite to clinic
2 parents c6850f9 + 8d19c24 commit 34bf20e

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

app/controllers/schools/invite_to_clinic_controller.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Schools::InviteToClinicController < Schools::BaseController
44
before_action :check_can_send_clinic_invitations
55
before_action :set_back_link_path
66
before_action :set_programme_statuses
7-
before_action :set_eligible_patients_not_vaccinated
7+
before_action :set_patients_to_invite
88
before_action :set_invitations_count_by_programme_type
99

1010
layout "two_thirds"
@@ -22,7 +22,7 @@ def update
2222

2323
if @form.valid?
2424
clinic_notifcations =
25-
@eligible_patients_not_vaccinated.filter_map do |patient|
25+
@patients_to_invite.filter_map do |patient|
2626
patient.notifier.send_clinic_invitation(
2727
Programme.find_all(@form.programme_types),
2828
team: current_team,
@@ -60,8 +60,8 @@ def set_programme_statuses
6060
Patient::ProgrammeStatus::VACCINATED_STATUSES.keys
6161
end
6262

63-
def set_eligible_patients_not_vaccinated
64-
@eligible_patients_not_vaccinated =
63+
def set_patients_to_invite
64+
@patients_to_invite =
6565
Patient
6666
.joins(:patient_locations)
6767
.where(
@@ -71,6 +71,7 @@ def set_eligible_patients_not_vaccinated
7171
}
7272
)
7373
.where(school_id: @location.school_id)
74+
.not_archived(team: current_team)
7475
.includes_statuses
7576
.has_programme_status(
7677
@programme_statuses,
@@ -82,7 +83,7 @@ def set_eligible_patients_not_vaccinated
8283
def set_invitations_count_by_programme_type
8384
@invitations_count_by_programme_type =
8485
current_team.programmes.index_with do |programme|
85-
@eligible_patients_not_vaccinated
86+
@patients_to_invite
8687
.includes(:clinic_notifications)
8788
.has_programme_status(
8889
@programme_statuses,

app/views/schools/invite_to_clinic/edit.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<p><%= link_to "Return to school", school_patients_path(Location::URN_UNKNOWN) %></p>
1414
<% else %>
15-
<p><%= I18n.t("children_be", count: @eligible_patients_not_vaccinated.count) %> due a vaccination for at least 1 programme.</p>
15+
<p><%= I18n.t("children_be", count: @patients_to_invite.count) %> due a vaccination for at least 1 programme.</p>
1616

1717
<p>You can now send clinic booking invitations to their parents.</p>
1818

spec/features/schools_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ def given_a_team_with_no_known_school_children
172172
end
173173

174174
# We create these to ensure these children aren't invited.
175+
176+
# No parent contact details
175177
create(
176178
:patient,
177179
:consent_no_response,
@@ -181,6 +183,8 @@ def given_a_team_with_no_known_school_children
181183
location: @generic_clinic,
182184
academic_year: AcademicYear.pending
183185
)
186+
187+
# Refused consent
184188
create(
185189
:patient,
186190
:consent_refused,
@@ -190,6 +194,8 @@ def given_a_team_with_no_known_school_children
190194
location: @generic_clinic,
191195
academic_year: AcademicYear.pending
192196
)
197+
198+
# Conflicting consent
193199
create(
194200
:patient,
195201
:consent_conflicting,
@@ -200,6 +206,19 @@ def given_a_team_with_no_known_school_children
200206
academic_year: AcademicYear.pending
201207
)
202208

209+
# Archived
210+
create(
211+
:patient,
212+
:consent_no_response,
213+
:archived,
214+
school: nil,
215+
parents: [build(:parent)],
216+
programmes:,
217+
location: @generic_clinic,
218+
academic_year: AcademicYear.pending,
219+
team: @team
220+
)
221+
203222
@nurse = create(:nurse, team: @team)
204223
end
205224

0 commit comments

Comments
 (0)