Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ gem "good_job"
gem "govuk-components"
gem "govuk_design_system_formbuilder"
gem "govuk_markdown"
gem "indefinite_article"
gem "jsonb_accessor"
gem "jwt"
gem "mechanize"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ GEM
domain_name (~> 0.5)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
indefinite_article (0.2.5)
activesupport
io-console (0.8.1)
irb (1.15.2)
pp (>= 0.6.0)
Expand Down Expand Up @@ -790,6 +792,7 @@ DEPENDENCIES
govuk_design_system_formbuilder
govuk_markdown
hotwire-livereload
indefinite_article
its
jsbundling-rails
jsonb_accessor
Expand Down
2 changes: 1 addition & 1 deletion app/components/app_activity_log_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def vaccination_events
discarded =
if vaccination_record.discarded?
{
title: "Vaccination record deleted",
title: "Vaccination record archived",
at: vaccination_record.discarded_at,
programmes: programmes_for(vaccination_record)
}
Expand Down
12 changes: 12 additions & 0 deletions app/components/app_vaccination_record_summary_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ def call
end
end

if @vaccination_record.respond_to?(:discarded_at) &&
@vaccination_record.discarded_at.present?
summary_list.with_row do |row|
row.with_key { "Archived" }
row.with_value { discarded_value }
end
end

if @vaccination_record.respond_to?(:sync_status) &&
Flipper.enabled?(:immunisations_fhir_api_integration)
summary_list.with_row do |row|
Expand Down Expand Up @@ -357,6 +365,10 @@ def dose_number_value
highlight_if(dose_number, @vaccination_record.dose_sequence_changed?)
end

def discarded_value
@vaccination_record&.discarded_at&.to_fs(:long)
end

def dose_number
dose_sequence = @vaccination_record.dose_sequence

Expand Down
22 changes: 21 additions & 1 deletion app/controllers/imports/issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Imports::IssuesController < ApplicationController
before_action :set_vaccination_record, only: %i[show update]
before_action :set_patient, only: %i[show update]
before_action :set_form, only: %i[show update]
before_action :set_type

layout "full"

Expand Down Expand Up @@ -53,7 +54,7 @@ def set_import_issues
def set_record
@record =
if params[:type] == "vaccination-record"
@vaccination_records.find(params[:id])
@vaccination_records.with_discarded.find(params[:id])
else
@patients.find(params[:id])
end
Expand All @@ -72,4 +73,23 @@ def set_form

@form = ImportDuplicateForm.new(object: @record, apply_changes:)
end

def set_type
@type =
(
if @record.is_a?(VaccinationRecord)
"vaccination"
else
"child"
end
)
@existing_or_deleted =
(
if @record.is_a?(VaccinationRecord) && @record.discarded_at
"archived"
else
"existing"
end
)
end
end
2 changes: 1 addition & 1 deletion app/controllers/vaccination_records_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def destroy

StatusUpdater.call(patient: @vaccination_record.patient)

redirect_to @return_to, flash: { success: "Vaccination record deleted" }
redirect_to @return_to, flash: { success: "Vaccination record archived" }
end

private
Expand Down
3 changes: 2 additions & 1 deletion app/models/immunisation_import_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def to_vaccination_record
delivery_method: delivery_method_value,
delivery_site: delivery_site_value,
notes: notes&.to_s,
vaccine_id: vaccine&.id
vaccine_id: vaccine&.id,
discarded_at: nil
}

vaccination_record =
Expand Down
37 changes: 16 additions & 21 deletions app/views/imports/issues/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,18 @@
]) %>
<% end %>

<% if @vaccination_record %>
<% title = "Review duplicate vaccination record" %>
<% else %>
<% title = "Review duplicate child record" %>
<% end %>
<% title = "Uploaded #{@type} record duplicates #{@existing_or_deleted.with_indefinite_article} record" %>

<span class="nhsuk-caption-l"><%= @patient.full_name %></span>
<%= h1 title, page_title: "#{@patient.full_name} – #{title}" %>

<%= render AppWarningCalloutComponent.new(
heading: "This record needs reviewing",
description: "A field in a duplicate record does not match that in a previously uploaded record.",
) %>

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-one-half">
<%= render AppCardComponent.new(heading_level: 2, colour: "blue") do |c| %>
<% c.with_heading { "Duplicate record" } %>
<h3 class="nhsuk-heading-s">Duplicate child record</h3>
<%= render AppChildSummaryComponent.new(@patient.with_pending_changes) %>
<% if @vaccination_record %>
<h3 class="nhsuk-heading-s">Duplicate vaccination record</h3>
<% c.with_heading { "Uploaded record" } %>
<% if @type == "child" %>
<%= render AppChildSummaryComponent.new(@patient.with_pending_changes) %>
<% else %>
<%= render AppVaccinationRecordSummaryComponent.new(
@vaccination_record.with_pending_changes, current_user:,
) %>
Expand All @@ -37,11 +27,10 @@

<div class="nhsuk-grid-column-one-half">
<%= render AppCardComponent.new(heading_level: 2, colour: "blue") do |c| %>
<% c.with_heading { "Existing record" } %>
<h3 class="nhsuk-heading-s">Existing child record</h3>
<%= render AppChildSummaryComponent.new(@patient) %>
<% if @vaccination_record %>
<h3 class="nhsuk-heading-s">Existing vaccination record</h3>
<% c.with_heading { "#{@existing_or_deleted.capitalize} record" } %>
<% if @type == "child" %>
<%= render AppChildSummaryComponent.new(@patient) %>
<% else %>
<%= render AppVaccinationRecordSummaryComponent.new(
@vaccination_record, current_user:,
) %>
Expand All @@ -58,7 +47,13 @@
) do |f| %>
<% content_for(:before_content) { f.govuk_error_summary } %>

<%= f.govuk_collection_radio_buttons :apply_changes, @form.apply_changes_options, :itself, nil %>
<%= f.govuk_collection_radio_buttons :apply_changes,
@form.apply_changes_options,
:itself,
->(option) { I18n.t(option, scope: "import_duplicate_form.options.label.#{@existing_or_deleted}", type: @type) },
->(option) { I18n.t(option, scope: "import_duplicate_form.options.hint.#{@existing_or_deleted}") },
bold_labels: false,
small: true %>

<%= f.govuk_submit "Resolve duplicate" %>
<% end %>
7 changes: 5 additions & 2 deletions app/views/vaccination_records/destroy.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
<%= render AppBacklinkComponent.new(@return_to, name: "patient") %>
<% end %>

<% page_title = "Are you sure you want to delete this vaccination record?" %>
<% page_title = "Are you sure you want to archive this vaccination record?" %>

<%= h1 page_title do %>
<span class="nhsuk-caption-l">
<%= @patient.full_name %>
</span>
<%= page_title %>
<span class="nhsuk-caption-l">
This vaccination record may be removed from other NHS systems, and the child’s parents will receive a notification that the vaccination did not take place. Mavis will keep a record of this vaccination should it get imported again at a later date.
</span>
<% end %>

<%= form_with url: vaccination_record_path, method: :delete do |f| %>
<%= f.hidden_field :return_to, value: @return_to %>
<div class="app-button-group">
<%= f.govuk_submit "Yes, delete this vaccination record", warning: true %>
<%= f.govuk_submit "Yes, archive this vaccination record", warning: true %>
<%= govuk_link_to "No, return to patient", @return_to %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/vaccination_records/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<% end %>

<% if policy(@vaccination_record).destroy? %>
<%= govuk_link_to "Delete vaccination record",
<%= govuk_link_to "Archive vaccination record",
destroy_vaccination_record_path(@vaccination_record) %>
<% end %>
</div>
Expand Down
18 changes: 18 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,24 @@ en:
other: Why are they refusing to give consent?
personal_choice: Why are they refusing to give consent?
will_be_vaccinated_elsewhere: Where will their child get their vaccination?
import_duplicate_form:
options:
label:
existing:
apply: Use uploaded %{type} record
discard: Keep existing %{type} record
keep_both: Keep both %{type} records
archived:
apply: Use uploaded %{type} record
discard: Ignore the uploaded %{type} record
hint:
existing:
apply: The uploaded record will replace the existing record
discard: The existing record will be kept and the uploaded record will be deleted
keep_both: The existing record will stay in Mavis and the uploaded record will be added
archived:
apply: The uploaded record will replace the archived record, which will be reinstated with any changes
discard: The archived record will remain archived and the uploaded record will be deleted
hosting_environment: This is a %{name} environment. Do not use it to make clinical decisions.
imports:
index:
Expand Down
13 changes: 0 additions & 13 deletions config/locales/helpers.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,11 @@ en:
legend:
import_duplicate_form:
apply_changes: Which record do you want to keep?

hint:
import_duplicate_form:
apply_changes_options:
apply: The duplicate record will replace the existing record.
discard: The existing record will be kept and the duplicate record will be discarded.
keep_both: The new and existing records will both be kept.

label:
draft_vaccination_record:
full_dose_options:
true: Yes, they got the full dose
false: No, they got half a dose
import_duplicate_form:
apply_changes_options:
apply: Use duplicate record
discard: Keep previously uploaded record
keep_both: Keep both records
triage_form:
status_and_vaccine_method_options:
delay_vaccination: No, delay vaccination (and invite to clinic)
Expand Down
2 changes: 1 addition & 1 deletion spec/components/app_activity_log_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
programme: "HPV"

include_examples "card",
title: "Vaccination record deleted",
title: "Vaccination record archived",
date: "31 May 2025 at 2:00pm",
programme: "HPV"
end
Expand Down
Loading