Skip to content

Commit f2dff38

Browse files
committed
Amend AppPatientVaccinationTableComponent to show/hide extra details
The national reporting teams uses the same vaccination table but requires more details on vaccination records like location and source, whereas full-fat Mavis doesn't need so much information. The new `show_details` arg controls whether to show or hide this info.
1 parent 4204198 commit f2dff38

6 files changed

Lines changed: 48 additions & 21 deletions

app/components/app_patient_vaccination_table_component.html.erb

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<% if vaccination_records.present? %>
22
<%= govuk_table(html_attributes: { class: "nhsuk-table-responsive" }) do |table| %>
3-
<% table.with_caption(text: "Vaccination records", size: "s") if show_caption %>
3+
<% table.with_caption(text: "Vaccination outcomes", size: "s") if show_caption %>
44

55
<% table.with_head do |head| %>
66
<% head.with_row do |row| %>
77
<% row.with_cell(text: "Date") %>
8-
<% row.with_cell(text: "Location") %>
8+
<% row.with_cell(text: "Location") if show_details %>
99
<% row.with_cell(text: "Programme") if show_programme %>
10-
<% row.with_cell(text: "Source") %>
10+
<% row.with_cell(text: "Source") if show_details %>
1111
<% row.with_cell(text: "Outcome") %>
1212
<% end %>
1313
<% end %>
@@ -17,19 +17,21 @@
1717
<% body.with_row do |row| %>
1818
<% row.with_cell do %>
1919
<span class="nhsuk-table-responsive__heading">Date</span>
20-
<%= link_to vaccination_record.performed_at.to_date.to_fs(:long),
20+
<%= link_to vaccination_record.performed_at.to_fs(:long),
2121
vaccination_record_path(vaccination_record) %>
2222
<% end %>
2323

24-
<% row.with_cell do %>
25-
<span class="nhsuk-table-responsive__heading">Location</span>
26-
<%= helpers.vaccination_record_location(vaccination_record) %>
24+
<% if show_details %>
25+
<% row.with_cell do %>
26+
<span class="nhsuk-table-responsive__heading">Location</span>
27+
<%= helpers.vaccination_record_location(vaccination_record) %>
2728

28-
<% if (location = vaccination_record.location) && location.has_address? %>
29-
<br />
30-
<span class="nhsuk-u-secondary-text-colour">
31-
<%= helpers.format_address_single_line(location) %>
32-
</span>
29+
<% if (location = vaccination_record.location) && location.has_address? %>
30+
<br />
31+
<span class="nhsuk-u-secondary-text-colour">
32+
<%= helpers.format_address_single_line(location) %>
33+
</span>
34+
<% end %>
3335
<% end %>
3436
<% end %>
3537

@@ -40,9 +42,11 @@
4042
<% end %>
4143
<% end %>
4244

43-
<% row.with_cell do %>
44-
<span class="nhsuk-table-responsive__heading">Source</span>
45-
<%= vaccination_record_source(vaccination_record) %>
45+
<% if show_details %>
46+
<% row.with_cell do %>
47+
<span class="nhsuk-table-responsive__heading">Source</span>
48+
<%= vaccination_record_source(vaccination_record) %>
49+
<% end %>
4650
<% end %>
4751

4852
<% row.with_cell do %>

app/components/app_patient_vaccination_table_component.rb

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

33
class AppPatientVaccinationTableComponent < ViewComponent::Base
4-
def initialize(patient, academic_year:, programme: nil, show_caption: false)
4+
def initialize(
5+
patient,
6+
academic_year:,
7+
programme: nil,
8+
show_caption: false,
9+
show_details: true
10+
)
511
@patient = patient
612
@academic_year = academic_year
713
@programme = programme
814
@show_caption = show_caption
15+
@show_details = show_details
916
end
1017

1118
private
1219

1320
delegate :govuk_table, :vaccination_record_source, to: :helpers
1421

15-
attr_reader :patient, :academic_year, :programme, :show_caption
22+
attr_reader :patient, :academic_year, :programme, :show_caption, :show_details
1623

1724
def show_programme = programme.nil?
1825

spec/components/app_patient_vaccination_table_component_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44
subject { render_inline(component) }
55

66
let(:component) do
7-
described_class.new(patient, academic_year:, programme:, show_caption:)
7+
described_class.new(
8+
patient,
9+
academic_year:,
10+
programme:,
11+
show_caption:,
12+
show_details:
13+
)
814
end
915

1016
let(:patient) { create(:patient) }
1117
let(:academic_year) { 2023 }
1218
let(:programme) { nil }
1319
let(:show_caption) { false }
20+
let(:show_details) { true }
1421

1522
it { should have_content("No vaccinations") }
1623

@@ -50,6 +57,15 @@
5057
it { should have_content("Vaccinated") }
5158
it { should have_content("HPV") }
5259

60+
context "when show_details is false" do
61+
let(:show_details) { false }
62+
63+
it { should have_link("1 January 2024") }
64+
it { should have_content("Vaccinated") }
65+
it { should_not have_content("Test School") }
66+
it { should_not have_content("Waterloo Road, London, SE1 8TY") }
67+
end
68+
5369
context "when showing records from a specific programme" do
5470
let(:programme) { vaccination_record_programme }
5571

spec/features/hpv_vaccination_administered_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def then_i_see_that_the_status_is_vaccinated
274274
end
275275

276276
def and_i_see_the_vaccination_details
277-
expect(page).to have_content("Vaccination records")
277+
expect(page).to have_content("Vaccination outcomes")
278278
click_on Date.current.to_fs(:long)
279279

280280
expect(page).to have_content("Vaccination details")

spec/features/menacwy_vaccination_administered_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def then_i_see_that_the_status_is_vaccinated
201201
end
202202

203203
def and_i_see_the_vaccination_details
204-
expect(page).to have_content("Vaccination records")
204+
expect(page).to have_content("Vaccination outcomes")
205205
click_on Date.current.to_fs(:long)
206206

207207
expect(page).to have_content("Vaccination details")

spec/features/td_ipv_vaccination_administered_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def then_i_see_that_the_status_is_vaccinated
201201
end
202202

203203
def and_i_see_the_vaccination_details
204-
expect(page).to have_content("Vaccination records")
204+
expect(page).to have_content("Vaccination outcomes")
205205
click_on Date.current.to_fs(:long)
206206

207207
expect(page).to have_content("Vaccination details")

0 commit comments

Comments
 (0)