Skip to content

Commit 74b38e9

Browse files
Merge pull request #3541 from nhsuk/fix-triage-already-vaccinated
Stop requesting triage for already vaccinated patients
2 parents b40c8f6 + deb0eea commit 74b38e9

File tree

5 files changed

+54
-35
lines changed

5 files changed

+54
-35
lines changed

app/controllers/draft_vaccination_records_controller.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ def handle_confirm
121121

122122
send_vaccination_confirmation(@vaccination_record) if should_notify_parents
123123

124-
@vaccination_record.triage_patient_as_do_not_vaccinate!
125-
126124
# In case the user navigates back to try and edit the newly created
127125
# vaccination record.
128126
@draft_vaccination_record.update!(editing_id: @vaccination_record.id)

app/models/patient/triage_status.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,33 @@ def consent_requires_triage?
6868
def vaccination_history_requires_triage?
6969
vaccination_records.any? do
7070
it.programme_id == programme_id && it.administered?
71-
end && !VaccinatedCriteria.call(programme:, patient:, vaccination_records:)
71+
end && !vaccinated?
7272
end
7373

7474
private
7575

76+
def vaccinated?
77+
@vaccinated ||=
78+
VaccinatedCriteria.call(programme:, patient:, vaccination_records:)
79+
end
80+
7681
def status_should_be_safe_to_vaccinate?
82+
return false if vaccinated?
7783
latest_triage&.ready_to_vaccinate?
7884
end
7985

8086
def status_should_be_do_not_vaccinate?
87+
return false if vaccinated?
8188
latest_triage&.do_not_vaccinate?
8289
end
8390

8491
def status_should_be_delay_vaccination?
92+
return false if vaccinated?
8593
latest_triage&.delay_vaccination?
8694
end
8795

8896
def status_should_be_required?
97+
return false if vaccinated?
8998
return true if latest_triage&.needs_follow_up?
9099

91100
return false if latest_consents.empty?

app/models/vaccination_record.rb

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -174,33 +174,6 @@ def academic_year
174174
performed_at.to_date.academic_year
175175
end
176176

177-
def triage_patient_as_do_not_vaccinate!
178-
return unless already_had?
179-
180-
# If an "already had" vaccination record is created, and the patient needs
181-
# triage, we should record a "do not vaccinate" triage to make sure the
182-
# patient isn't double vaccinated.
183-
184-
patient = Patient.includes(:triage_statuses).find(patient_id)
185-
triage_status = patient.triage_status(programme:)
186-
187-
return unless triage_status.required? || triage_status.delay_vaccination?
188-
189-
triage_notes =
190-
"Recorded as already vaccinated on #{Date.current.to_fs(:long)}"
191-
triage_notes += ": #{notes}" if notes.present?
192-
193-
patient.triages.create!(
194-
programme:,
195-
organisation:,
196-
status: :do_not_vaccinate,
197-
performed_by: performed_by_user,
198-
notes: triage_notes
199-
)
200-
201-
StatusUpdater.call(patient:)
202-
end
203-
204177
private
205178

206179
def requires_location_name?

spec/features/td_ipv_already_had_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
when_i_record_the_patient_as_already_vaccinated
4747
then_i_see_the_patient_is_already_vaccinated
4848
and_i_click_on_triage
49-
then_i_see_the_patient_should_not_be_vaccinated
49+
then_i_see_the_patient_doesnt_need_triage
5050
end
5151

5252
scenario "can't record as already vaccinated as an admin" do
@@ -201,10 +201,10 @@ def and_i_click_on_triage
201201
click_on "Triage"
202202
end
203203

204-
def then_i_see_the_patient_should_not_be_vaccinated
205-
choose "Do not vaccinate"
204+
def then_i_see_the_patient_doesnt_need_triage
205+
choose "Any"
206206
click_on "Update results"
207207

208-
expect(page).to have_content(@patient.full_name)
208+
expect(page).not_to have_content(@patient.full_name)
209209
end
210210
end

spec/models/patient/triage_status_spec.rb

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
build(:patient_triage_status, patient:, programme:)
2525
end
2626

27-
let(:patient) { create(:patient) }
27+
let(:patient) { create(:patient, year_group: 9) }
2828
let(:programme) { create(:programme) }
2929

3030
it { should belong_to(:patient) }
@@ -110,5 +110,44 @@
110110

111111
it { should be(:not_required) }
112112
end
113+
114+
context "when the patient is already vaccinated" do
115+
shared_examples "a vaccinated patient with any triage status" do
116+
before do
117+
create(:triage, triage_trait, patient:, programme:) if triage_trait
118+
end
119+
120+
it { should be(:not_required) }
121+
end
122+
123+
before do
124+
create(:vaccination_record, patient:, programme:)
125+
create(:patient_vaccination_status, :vaccinated, patient:, programme:)
126+
end
127+
128+
context "with a safe to vaccinate triage" do
129+
it_behaves_like "a vaccinated patient with any triage status" do
130+
let(:triage_trait) { :ready_to_vaccinate }
131+
end
132+
end
133+
134+
context "with a do not vaccinate triage" do
135+
it_behaves_like "a vaccinated patient with any triage status" do
136+
let(:triage_trait) { :do_not_vaccinate }
137+
end
138+
end
139+
140+
context "with a needs follow up triage" do
141+
it_behaves_like "a vaccinated patient with any triage status" do
142+
let(:triage_trait) { :needs_follow_up }
143+
end
144+
end
145+
146+
context "with a delay vaccination triage" do
147+
it_behaves_like "a vaccinated patient with any triage status" do
148+
let(:triage_trait) { :delay_vaccination }
149+
end
150+
end
151+
end
113152
end
114153
end

0 commit comments

Comments
 (0)