Skip to content

Commit c68fb29

Browse files
Merge pull request #5806 from nhsuk/alistair/national-reporting-hide-import-issues
Remove import issues for national reporting imports
2 parents 9efe5c7 + 1dba0a7 commit c68fb29

9 files changed

Lines changed: 129 additions & 30 deletions

File tree

app/components/app_imports_navigation_component.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ def call
2020
selected: active == :imported
2121
)
2222

23-
nav.with_item(
24-
href: imports_issues_path,
25-
text: issues_text,
26-
selected: active == :issues
27-
)
23+
if policy(%i[import issue]).index?
24+
nav.with_item(
25+
href: imports_issues_path,
26+
text: issues_text,
27+
selected: active == :issues
28+
)
29+
end
2830

2931
if policy(ImportantNotice).index?
3032
nav.with_item(

app/controllers/concerns/navigation_concern.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def set_navigation_items
5959
@navigation_items << {
6060
title: t("imports.index.title_short"),
6161
path: imports_path,
62-
count: @cached_counts.import_issues
62+
count: (@cached_counts.import_issues if policy(%i[import issue]).index?)
6363
}
6464
end
6565

app/models/immunisation_import_row.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ def to_vaccination_record
173173
}
174174

175175
vaccination_record =
176-
if uuid.present?
176+
if bulk?
177+
VaccinationRecord.find_or_initialize_by(
178+
attributes.merge(attributes_to_stage_if_already_exists)
179+
)
180+
elsif uuid.present?
177181
VaccinationRecord
178182
.find_by!(uuid: uuid.to_s)
179183
.tap { it.stage_changes(attributes) }
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# frozen_string_literal: true
22

33
class Import::IssuePolicy < ApplicationPolicy
4-
def index? = true
4+
def index? = !team.has_upload_only_access?
55

6-
def create? = true
6+
def create? = !team.has_upload_only_access?
77

8-
def show? = true
8+
def show? = !team.has_upload_only_access?
99

10-
def update? = true
10+
def update? = !team.has_upload_only_access?
1111
end

app/views/imports/_header.html.erb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<%= h1 t("imports.index.title"), size: "xl" %>
22

3-
<% if current_team.has_upload_only_access? %>
4-
<p class="nhsuk-u-reading-width">
5-
Use this page to upload and import vaccination records.
6-
</p>
7-
<% else %>
8-
<p class="nhsuk-u-reading-width">
3+
<p class="nhsuk-u-reading-width">
4+
<% if policy(ClassImport).new? && policy(CohortImport).new? %>
95
Use this page to upload and import child, class list and vaccination records.
10-
</p>
11-
<% end %>
6+
<% else %>
7+
Use this page to upload and import vaccination records.
8+
<% end %>
9+
</p>
1210

1311
<p class="nhsuk-u-reading-width">
1412
After import, files move to the <strong>Completed imports</strong> tab.
15-
Any close matches to resolve will appear in the <strong>Issues</strong> tab.
13+
14+
<% if policy(%i[import issue]).index? %>
15+
Any close matches to resolve will appear in the <strong>Issues</strong> tab.
16+
<% end %>
1617
</p>
1718

1819
<p class="nhsuk-u-reading-width">

spec/features/import_vaccination_records_bulk_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
when_i_go_to_the_import_page
1313
then_i_should_see_the_upload_link
14+
and_i_should_not_see_any_reference_to_import_issues
1415

1516
when_i_click_on_the_upload_link
1617
then_i_should_see_the_upload_page
@@ -102,6 +103,17 @@ def then_i_should_see_the_upload_link
102103
expect(page).to have_button("Upload records")
103104
end
104105

106+
def and_i_should_not_see_any_reference_to_import_issues
107+
expect(page).not_to have_content(
108+
"Any close matches to resolve will appear in the Issues tab."
109+
)
110+
111+
navigation_items = page.all(".app-secondary-navigation__link")
112+
expect(navigation_items.map(&:text)).not_to include(
113+
a_string_including("Issues")
114+
)
115+
end
116+
105117
def when_i_click_on_the_upload_link
106118
click_on "Upload records"
107119
end

spec/features/upload_only_team_spec.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
scenario "Navigation shows only import, children and your team" do
1414
given_i_am_signed_in_as_an_upload_only_team
1515
when_i_visit_the_dashboard
16-
then_i_should_see_only_import_children_and_team_navigation_items
16+
then_i_should_see_only_import_and_children_navigation_items
17+
and_there_should_be_no_count_next_to_the_import_link
1718
end
1819

1920
scenario "Children page search shows limited filters and the patient's card" do
@@ -110,13 +111,17 @@ def and_i_should_see_the_children_card
110111
expect(card).to have_link("Children", href: patients_path)
111112
end
112113

113-
def then_i_should_see_only_import_children_and_team_navigation_items
114+
def then_i_should_see_only_import_and_children_navigation_items
114115
navigation_items = page.all(".nhsuk-header__navigation-item")
115116
expect(navigation_items.count).to eq(2)
116117
expect(navigation_items[0]).to have_link("Imports", href: imports_path)
117118
expect(navigation_items[1]).to have_link("Children", href: patients_path)
118119
end
119120

121+
def and_there_should_be_no_count_next_to_the_import_link
122+
expect(page).not_to have_css(".app-count", text: "(0)")
123+
end
124+
120125
def when_i_visit_the_children_page
121126
visit patients_path
122127
end

spec/models/immunisation_import_row_spec.rb

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
end
1616

1717
let(:programmes) { [Programme.hpv] }
18-
let(:team) { create(:team, ods_code: "abc", programmes:) }
18+
let(:team) { create(:team, ods_code: "ABC", programmes:) }
1919

2020
let(:nhs_number) { "9449306168" }
2121
let(:given_name) { "Harry" }
@@ -25,7 +25,7 @@
2525
let(:vaccinator) { create(:user, team:) }
2626
let(:valid_patient_data) do
2727
{
28-
"ORGANISATION_CODE" => "abc",
28+
"ORGANISATION_CODE" => "ABC",
2929
"SCHOOL_NAME" => "Hogwarts",
3030
"SCHOOL_URN" => "123456",
3131
"PERSON_FORENAME" => given_name,
@@ -2417,7 +2417,7 @@
24172417

24182418
let(:import_type) { "bulk" }
24192419

2420-
shared_examples "with existing vaccination records" do |programme|
2420+
shared_examples "date deduplication with existing vaccination records" do |programme|
24212421
let(:patient) { create(:patient, nhs_number:) }
24222422

24232423
let(:other_vaccination_record) do
@@ -2429,15 +2429,19 @@
24292429

24302430
before { other_vaccination_record }
24312431

2432+
it { should_not be_nil }
24322433
it { should_not eq other_vaccination_record }
2434+
its(:pending_changes) { should be_empty }
24332435
end
24342436

24352437
context "with an existing vaccination record on a different date in the same academic year" do
24362438
let(:performed_at) { Time.zone.local(2026, 1, 1, 12, 10, 2) }
24372439

24382440
before { other_vaccination_record }
24392441

2442+
it { should_not be_nil }
24402443
it { should_not eq other_vaccination_record }
2444+
its(:pending_changes) { should be_empty }
24412445
end
24422446

24432447
context "with an existing vaccination record on the same date" do
@@ -2466,9 +2470,11 @@
24662470

24672471
let(:data) { valid_bulk_flu_data }
24682472

2473+
let(:programme) { Programme.flu }
2474+
24692475
it { should be_administered }
24702476

2471-
its(:programme) { should eq(Programme.flu) }
2477+
its(:programme) { should eq programme }
24722478

24732479
its(:source) { should eq("bulk_upload") }
24742480

@@ -2552,7 +2558,73 @@
25522558

25532559
include_examples "with pseudo-postcodes"
25542560

2555-
include_examples "with existing vaccination records", Programme.flu
2561+
include_examples "date deduplication with existing vaccination records",
2562+
Programme.flu
2563+
2564+
context "when a similar vaccination record exists" do
2565+
let!(:other_vaccination_record) do
2566+
vaccine = Vaccine.find_by(nivs_name: "AstraZeneca Fluenz LAIV")
2567+
2568+
create(
2569+
:vaccination_record,
2570+
:sourced_from_bulk_upload,
2571+
patient:,
2572+
programme:,
2573+
performed_at: Time.zone.local(2026, 1, 5, 0, 0, 0),
2574+
location:,
2575+
local_patient_id: "CIN-OXFORD-pat123456",
2576+
local_patient_id_uri: "https://cinnamon.nhs.uk/0de/system1",
2577+
performed_by_user: nil,
2578+
performed_by_given_name: vaccinator.given_name,
2579+
performed_by_family_name: vaccinator.family_name,
2580+
vaccine:,
2581+
batch:
2582+
create(
2583+
:batch,
2584+
team: nil,
2585+
name: "456",
2586+
expiry: Date.new(2026, 1, 6),
2587+
vaccine:
2588+
) # different
2589+
)
2590+
end
2591+
2592+
it { should_not be_nil }
2593+
it { should_not eq other_vaccination_record }
2594+
its(:pending_changes) { should be_empty }
2595+
end
2596+
2597+
context "when an identical vaccination record exists" do
2598+
let!(:other_vaccination_record) do
2599+
vaccine = Vaccine.find_by(nivs_name: "AstraZeneca Fluenz LAIV")
2600+
create(
2601+
:vaccination_record,
2602+
:sourced_from_bulk_upload,
2603+
patient:,
2604+
programme:,
2605+
performed_at: Time.zone.local(2026, 1, 5, 0, 0, 0),
2606+
location:,
2607+
local_patient_id: "CIN-OXFORD-pat123456",
2608+
local_patient_id_uri: "https://cinnamon.nhs.uk/0de/system1",
2609+
performed_by_user: nil,
2610+
performed_by_given_name: vaccinator.given_name,
2611+
performed_by_family_name: vaccinator.family_name,
2612+
vaccine:,
2613+
batch:
2614+
create(
2615+
:batch,
2616+
team: nil,
2617+
name: "123",
2618+
expiry: Date.new(2026, 1, 6),
2619+
vaccine:
2620+
) # identical
2621+
)
2622+
end
2623+
2624+
it { should_not be_nil }
2625+
it { should eq other_vaccination_record }
2626+
its(:pending_changes) { should be_empty }
2627+
end
25562628
end
25572629

25582630
context "of type hpv" do
@@ -2570,9 +2642,11 @@
25702642

25712643
let(:data) { valid_bulk_hpv_data }
25722644

2645+
let(:programme) { Programme.hpv }
2646+
25732647
it { should be_administered }
25742648

2575-
its(:programme) { should eq(Programme.hpv) }
2649+
its(:programme) { should eq programme }
25762650

25772651
its(:source) { should eq("bulk_upload") }
25782652

@@ -2649,7 +2723,8 @@
26492723

26502724
include_examples "with pseudo-postcodes"
26512725

2652-
include_examples "with existing vaccination records", Programme.hpv
2726+
include_examples "date deduplication with existing vaccination records",
2727+
Programme.hpv
26532728
end
26542729
end
26552730
end

spec/policies/import/issue_policy_spec.rb

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

1212
permissions :index?, :create?, :edit?, :new?, :show?, :update? do
1313
it { should permit(poc_only_user, vaccination_record) }
14-
it { should permit(upload_only_user, vaccination_record) }
14+
it { should_not permit(upload_only_user, vaccination_record) }
1515
end
1616

1717
permissions :destroy? do

0 commit comments

Comments
 (0)