Skip to content

Commit 76e8886

Browse files
authored
Merge pull request #4746 from nhsuk/offline-spreadsheet-triage-status
Align the triage status between the Mavis UI and the offline spreadsheet
2 parents 2404f98 + 55149fc commit 76e8886

File tree

6 files changed

+78
-5
lines changed

6 files changed

+78
-5
lines changed

app/helpers/triages_helper.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# frozen_string_literal: true
22

33
module TriagesHelper
4-
def triage_status_tag(triage)
4+
def triage_status_text(triage)
5+
return if triage.nil?
6+
57
status_method =
68
if triage.programme.has_multiple_vaccine_methods? &&
79
triage.vaccine_method.present?
@@ -10,7 +12,11 @@ def triage_status_tag(triage)
1012
triage.status
1113
end
1214

13-
text = Triage.human_enum_name(:status, status_method)
15+
Triage.human_enum_name(:status, status_method)
16+
end
17+
18+
def triage_status_tag(triage)
19+
text = triage_status_text(triage)
1420

1521
colour =
1622
if triage.invalidated?

app/lib/reports/offline_session_exporter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
class Reports::OfflineSessionExporter
44
include Reports::ExportFormatters
5+
include TriagesHelper
56

67
def initialize(session)
78
@session = session
@@ -290,7 +291,7 @@ def add_patient_cells(row, patient:, programme:)
290291
}
291292
}
292293
)
293-
row[:triage_status] = triage&.status&.humanize
294+
row[:triage_status] = triage_status_text(triage)
294295
row[:triaged_by] = triage&.performed_by&.full_name
295296
row[:triage_date] = triage&.created_at
296297
row[:triage_notes] = triage&.notes

spec/factories/patients.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,18 @@
555555
end
556556
end
557557

558+
triages do
559+
programmes.map do |programme|
560+
association(
561+
:triage,
562+
:ready_to_vaccinate,
563+
:nasal_only,
564+
patient: instance,
565+
programme:
566+
)
567+
end
568+
end
569+
558570
consent_statuses do
559571
programmes.map do |programme|
560572
association(

spec/factories/triage.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
vaccine_method { "injection" }
6060
end
6161

62+
trait :nasal_only do
63+
vaccine_method { "nasal" }
64+
end
65+
6266
trait :do_not_vaccinate do
6367
status { "do_not_vaccinate" }
6468
vaccine_method { nil }

spec/features/flu_vaccination_hca_pgd_supply_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def given_a_session_exists
5555
vaccine: @programme.vaccines.nasal.first
5656
)
5757

58-
@nurse = create(:nurse, team: @team)
58+
@nurse =
59+
create(:nurse, team: @team, given_name: "Supplying", family_name: "Nurse")
5960
@user = create(:healthcare_assistant, team: @team)
6061

6162
@session =
@@ -140,7 +141,7 @@ def then_i_am_able_to_vaccinate_them_nasal_only
140141
expect(page).not_to have_content("injected flu instead")
141142

142143
check "I have checked that the above statements are true"
143-
select @nurse.full_name
144+
select "NURSE, Supplying"
144145
within all("section")[1] do
145146
choose "Yes"
146147
end

spec/lib/reports/offline_session_exporter_spec.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,32 @@ def validation_formula(worksheet:, column_name:, row: 1)
226226
end
227227
end
228228

229+
context "with a triage assessment" do
230+
let!(:patient) do
231+
create(:patient, :triage_ready_to_vaccinate, session:)
232+
end
233+
234+
it "adds a row with the triage details" do
235+
expect(rows.count).to eq(1)
236+
expected_status =
237+
(
238+
if programme.flu?
239+
"Safe to vaccinate with injection"
240+
else
241+
"Safe to vaccinate"
242+
end
243+
)
244+
expect(rows.first["TRIAGE_STATUS"]).to eq(expected_status)
245+
expect(rows.first["TRIAGED_BY"]).to be_present
246+
247+
triage = patient.triages.find_by(programme:, academic_year:)
248+
expect(Time.zone.parse(rows.first["TRIAGE_DATE"]).to_i).to eq(
249+
triage.created_at.to_i
250+
)
251+
expect(rows.first["TRIAGE_NOTES"]).to eq(triage.notes)
252+
end
253+
end
254+
229255
context "with a vaccinated patient" do
230256
before { create(:patient_location, patient:, session:) }
231257

@@ -1057,6 +1083,29 @@ def validation_formula(worksheet:, column_name:, row: 1)
10571083
end
10581084

10591085
include_examples "generates a report"
1086+
1087+
context "with a triage assessment for injection only" do
1088+
subject(:rows) { worksheet_to_hashes(workbook.worksheets[0]) }
1089+
1090+
let(:session) { create(:session, programmes: [programme]) }
1091+
let(:patient) do
1092+
create(
1093+
:patient,
1094+
:consent_given_nasal_triage_safe_to_vaccinate_nasal,
1095+
session:
1096+
)
1097+
end
1098+
let(:workbook) { RubyXL::Parser.parse_buffer(call) }
1099+
1100+
it "adds a row with the triage details" do
1101+
patient
1102+
1103+
expect(rows.count).to eq(1)
1104+
expect(rows.first["TRIAGE_STATUS"]).to eq(
1105+
"Safe to vaccinate with nasal spray"
1106+
)
1107+
end
1108+
end
10601109
end
10611110

10621111
context "HPV programme" do

0 commit comments

Comments
 (0)