Skip to content

Commit 9b84dd4

Browse files
Show the denormalised batch data in the UI
This displays the denormalised batch data on the VaccinationRecord view page.
1 parent c6acb22 commit 9b84dd4

File tree

2 files changed

+89
-13
lines changed

2 files changed

+89
-13
lines changed

app/components/app_vaccination_record_summary_component.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def initialize(
1313
@show_notes = show_notes
1414

1515
@batch = vaccination_record.batch
16+
@batch_name = vaccination_record.batch_name
17+
@batch_expiry = vaccination_record.batch_expiry
1618
@identity_check = vaccination_record.identity_check
1719
@patient = vaccination_record.patient
1820
@programme = vaccination_record.programme
@@ -68,10 +70,10 @@ def call
6870
summary_list.with_row do |row|
6971
row.with_key { "Batch ID" }
7072

71-
if @batch
73+
if @batch || @batch_name
7274
row.with_value(classes: ["app-u-monospace"]) { batch_id_value }
7375

74-
if (href = @change_links[:batch])
76+
if @batch && (href = @change_links[:batch])
7577
row.with_action(
7678
text: "Change",
7779
href:,
@@ -85,7 +87,7 @@ def call
8587
end
8688
end
8789

88-
if @batch
90+
if @batch || @batch_expiry
8991
summary_list.with_row do |row|
9092
row.with_key { "Batch expiry date" }
9193
row.with_value { batch_expiry_value }
@@ -318,13 +320,18 @@ def dose_volume_value
318320
end
319321

320322
def batch_id_value
321-
highlight_if(@batch.name, @vaccination_record.batch_id_changed?)
323+
highlight_if(
324+
@batch&.name || @batch_name,
325+
@vaccination_record.batch_id_changed? ||
326+
@vaccination_record.batch_name_changed?
327+
)
322328
end
323329

324330
def batch_expiry_value
325331
highlight_if(
326-
@batch.expiry&.to_fs(:long) || "Unknown",
327-
@vaccination_record.batch_id_changed?
332+
@batch&.expiry&.to_fs(:long) || @batch_expiry&.to_fs(:long) || "Unknown",
333+
@vaccination_record.batch_id_changed? ||
334+
@vaccination_record.batch_expiry_changed?
328335
)
329336
end
330337

spec/components/app_vaccination_record_summary_component_spec.rb

Lines changed: 76 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
let(:batch) do
1818
create(:batch, name: "ABC", expiry: Date.new(2026, 1, 1), vaccine:)
1919
end
20+
let(:batch_name) { nil }
21+
let(:batch_expiry) { nil }
2022
let(:other_batch) do
2123
create(:batch, name: "DEF", expiry: Date.new(2027, 1, 1), vaccine:)
2224
end
@@ -31,6 +33,8 @@
3133
performed_at:,
3234
outcome:,
3335
batch:,
36+
batch_name:,
37+
batch_expiry:,
3438
vaccine:,
3539
patient:,
3640
session:,
@@ -161,24 +165,89 @@
161165
end
162166

163167
describe "batch ID row" do
164-
it { should have_css(".nhsuk-summary-list__row", text: "Batch IDABC") }
168+
context "with a batch, and vaccine" do
169+
it { should have_css(".nhsuk-summary-list__row", text: "Batch IDABC") }
170+
end
165171

166-
context "without a vaccine" do
172+
context "with a batch_name, and vaccine" do
173+
let(:batch) { nil }
174+
let(:batch_name) { "ABC" }
175+
let(:batch_expiry) { Date.new(2026, 1, 1) }
176+
177+
it { should have_css(".nhsuk-summary-list__row", text: "Batch IDABC") }
178+
end
179+
180+
context "with a batch_name, and no vaccine" do
181+
let(:vaccine) { nil }
182+
let(:batch) { nil }
183+
let(:batch_name) { "ABC" }
184+
let(:batch_expiry) { nil }
185+
let(:other_batch) { nil }
186+
187+
it { should have_css(".nhsuk-summary-list__row", text: "Batch IDABC") }
188+
end
189+
190+
context "without a vaccine, batch_name or batch_expiry" do
167191
let(:outcome) { :not_well }
168192
let(:vaccine) { nil }
169193
let(:batch) { nil }
194+
let(:batch_name) { nil }
195+
let(:batch_expiry) { nil }
170196
let(:other_batch) { nil }
171197

172198
it { should_not have_css(".nhsuk-summary-list__row", text: "Batch ID") }
173199
end
174200
end
175201

176202
describe "batch expiry date row" do
177-
it do
178-
expect(rendered).to have_css(
179-
".nhsuk-summary-list__row",
180-
text: "Batch expiry date1 January 2026"
181-
)
203+
context "with a batch, and vaccine" do
204+
it do
205+
expect(rendered).to have_css(
206+
".nhsuk-summary-list__row",
207+
text: "Batch expiry date1 January 2026"
208+
)
209+
end
210+
end
211+
212+
context "with a batch_expiry, and vaccine" do
213+
let(:batch) { nil }
214+
let(:batch_name) { "ABC" }
215+
let(:batch_expiry) { Date.new(2026, 1, 1) }
216+
217+
it do
218+
expect(rendered).to have_css(
219+
".nhsuk-summary-list__row",
220+
text: "Batch expiry date1 January 2026"
221+
)
222+
end
223+
end
224+
225+
context "with a batch_expiry, and no vaccine" do
226+
let(:vaccine) { nil }
227+
let(:batch) { nil }
228+
let(:batch_name) { "ABC" }
229+
let(:batch_expiry) { Date.new(2026, 1, 1) }
230+
let(:other_batch) { nil }
231+
232+
it do
233+
expect(rendered).to have_css(
234+
".nhsuk-summary-list__row",
235+
text: "Batch expiry date1 January 2026"
236+
)
237+
end
238+
end
239+
240+
context "with a batch_expiry, but no batch_name" do
241+
let(:batch) { nil }
242+
let(:batch_name) { nil }
243+
let(:batch_expiry) { Date.new(2026, 1, 1) }
244+
245+
it do
246+
expect(rendered).to have_css(
247+
".nhsuk-summary-list__row",
248+
text: "Batch expiry date1 January 2026"
249+
)
250+
end
182251
end
183252

184253
context "without a vaccine" do

0 commit comments

Comments
 (0)