Skip to content

Commit c4199a9

Browse files
authored
Merge pull request #6030 from nhsuk/next
v6.19.0
2 parents fc35d10 + 2cc738c commit c4199a9

90 files changed

Lines changed: 3190 additions & 959 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/components/app_import_review_school_moves_summary_component.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@
3737
<%= destination_school_name(changeset) %>
3838
</span>
3939
<% if school_move_across_teams?(changeset) %>
40+
<% source_team = changeset.patient.teams_via_patient_locations.first %>
4041
<div class="nhsuk-u-margin-top-1">
4142
<%= render(
4243
AppStatusComponent.new(
43-
text: "This child is moving in from #{changeset.patient.school.teams.first.name}'s area",
44+
text: "This child is moving in from #{source_team.name}'s area",
4445
small: true,
4546
classes: "nhsuk-u-margin-top-1 nhsuk-u-margin-bottom-0",
4647
)

app/components/app_import_review_school_moves_summary_component.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ def destination_school(changeset)
3030
end
3131

3232
def school_move_across_teams?(changeset)
33-
patient = changeset.patient
3433
dest_school = destination_school(changeset)
3534

36-
dest_school && patient.school && patient.school.teams.any? &&
37-
(dest_school.teams & patient.school.teams).empty?
35+
current_teams = changeset.patient.teams_via_patient_locations
36+
return false if current_teams.empty?
37+
38+
new_teams = dest_school&.teams || [changeset.import.team]
39+
40+
(new_teams & current_teams).empty?
3841
end
3942
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
class AppImportStatisticsComponent < ViewComponent::Base
4+
erb_template <<-ERB
5+
<p><strong>Out of <%= pluralize(@import.records_count, "record") %> found in the file:</strong></p>
6+
<ul>
7+
<li><%= pluralize(@import.new_record_count, "new record") %> imported</li>
8+
<li><%= pluralize(@import.exact_duplicate_record_count, "duplicate") %> not imported</li>
9+
<li><%= pluralize(@import.ignored_record_count, "'not vaccinated' record") %> not imported</li>
10+
</ul>
11+
ERB
12+
13+
def initialize(import:)
14+
@import = import
15+
end
16+
end

app/components/app_import_summary_component.html.erb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,18 @@
4848
<% end %>
4949
<% end %>
5050

51-
<% if import.records_count && import.records_count.positive? %>
51+
<% if import.records_count && import.status == "processed" %>
52+
<% if import.is_a?(ImmunisationImport) && import.type == "national_reporting" %>
5253
<%= summary_list.with_row do |row| %>
53-
<%= row.with_key { "Records" } %>
54-
<%= row.with_value { import.records_count.to_s } %>
54+
<%= row.with_key { "Import summary" } %>
55+
<%= row.with_value { render AppImportStatisticsComponent.new(import: import) } %>
5556
<% end %>
57+
<% elsif import.records_count.positive? %>
58+
<%= summary_list.with_row do |row| %>
59+
<%= row.with_key { "Records" } %>
60+
<%= row.with_value { import.records_count.to_s } %>
61+
<% end %>
62+
<% end %>
5663
<% end %>
5764
<% end %>
5865

app/components/app_imports_table_component.html.erb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
<% table.with_head do |head| %>
1010
<% head.with_row do |row| %>
1111
<% row.with_cell(text: "Imported on") %>
12-
<% row.with_cell(text: "Type") %>
12+
<% unless @team.has_national_reporting_access? %>
13+
<% row.with_cell(text: "Type") %>
14+
<% end %>
1315
<% row.with_cell(text: "Status") %>
1416
<% row.with_cell(text: "Records", numeric: true) unless @uploaded_files %>
1517
<% end %>
@@ -26,14 +28,16 @@
2628
<%= import.csv_filename %>
2729
</span>
2830
<% end %>
29-
<% row.with_cell do %>
30-
<span class="nhsuk-table-responsive__heading">Type</span>
31-
<%= record_type(import) %>
32-
<% if import.is_a?(ClassImport) %>
33-
<br />
34-
<span class="nhsuk-u-secondary-text-colour nhsuk-u-font-size-16">
35-
<%= import.location.name %>
36-
</span>
31+
<% unless @team.has_national_reporting_access? %>
32+
<% row.with_cell do %>
33+
<span class="nhsuk-table-responsive__heading">Type</span>
34+
<%= record_type(import) %>
35+
<% if import.is_a?(ClassImport) %>
36+
<br />
37+
<span class="nhsuk-u-secondary-text-colour nhsuk-u-font-size-16">
38+
<%= import.location.name %>
39+
</span>
40+
<% end %>
3741
<% end %>
3842
<% end %>
3943
<% row.with_cell do %>

app/components/app_patient_card_component.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,13 @@ def gillick_no_notify_notices
9292
end
9393

9494
def team_changed_notices
95-
return unless patient.school
96-
9795
valid_notices =
9896
patient
9997
.important_notices
10098
.team_changed
10199
.includes(:school_move_log_entry)
102100
.where(team: current_team)
103-
.where.not(team: patient.school.teams)
101+
.where.not(team: patient.teams_via_patient_locations)
104102

105103
valid_notices.map(&:message)
106104
end

app/components/app_vaccination_record_summary_component.rb

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ def call
234234
end
235235
end
236236

237-
if @vaccination_record.performed_by.present?
237+
if @vaccination_record.performed_by.present? ||
238+
Flipper.enabled?(:already_vaccinated)
238239
summary_list.with_row do |row|
239240
row.with_key { "Vaccinator" }
240241
row.with_value { vaccinator_value }
@@ -293,12 +294,29 @@ def call
293294
end
294295
end
295296

297+
if Flipper.enabled?(:already_vaccinated) &&
298+
@vaccination_record.reported_by.present?
299+
summary_list.with_row do |row|
300+
row.with_key { "Reported by" }
301+
row.with_value { @vaccination_record.reported_by&.full_name }
302+
end
303+
end
304+
305+
if Flipper.enabled?(:already_vaccinated) &&
306+
@vaccination_record.reported_at.present?
307+
summary_list.with_row do |row|
308+
row.with_key { "Reported on" }
309+
row.with_value { @vaccination_record.reported_at.to_fs(:long) }
310+
end
311+
end
312+
296313
correct_feature_flags_enabled =
297-
Programme.all.any? { Flipper.enabled?(:imms_api_sync_job, it) } &&
298-
Flipper.enabled?(:imms_api_integration)
314+
Programme.all_as_variants.any? do
315+
Flipper.enabled?(:imms_api_sync_job, it)
316+
end && Flipper.enabled?(:imms_api_integration)
299317
if @vaccination_record.respond_to?(:sync_status) &&
300318
correct_feature_flags_enabled &&
301-
@vaccination_record&.correct_source_for_nhs_immunisations_api?
319+
@vaccination_record.correct_source_for_nhs_immunisations_api?
302320
summary_list.with_row do |row|
303321
row.with_key { "Synced with NHS England?" }
304322
row.with_value do
@@ -327,10 +345,16 @@ def source_value
327345
end
328346

329347
def outcome_value
330-
highlight_if(
331-
VaccinationRecord.human_enum_name(:outcome, @vaccination_record.outcome),
332-
@vaccination_record.outcome_changed?
333-
)
348+
outcome =
349+
VaccinationRecord.human_enum_name(:outcome, @vaccination_record.outcome)
350+
351+
if Flipper.enabled?(:already_vaccinated) &&
352+
@vaccination_record.already_had? &&
353+
@vaccination_record.reported_as_already_vaccinated?
354+
outcome = VaccinationRecord.human_enum_name(:outcome, "administered")
355+
end
356+
357+
highlight_if(outcome, @vaccination_record.outcome_changed?)
334358
end
335359

336360
def programme_value
@@ -418,8 +442,10 @@ def vaccinator_value
418442
value =
419443
if @vaccination_record.performed_by == @current_user
420444
"You (#{@current_user.full_name})"
421-
else
445+
elsif @vaccination_record.performed_by
422446
@vaccination_record.performed_by&.full_name
447+
else
448+
"Unknown"
423449
end
424450

425451
highlight_if(

app/controllers/api/reporting/totals_controller.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
2828

2929
METRIC_HEADERS = {
3030
cohort: "Cohort",
31-
vaccinated: "Vaccinated",
32-
not_vaccinated: "Not Vaccinated"
31+
no_consent: "No Consent",
32+
consent_no_response: "Consent No Response",
33+
consent_refused: "Consent Refused",
34+
consent_conflicts: "Consent Conflicts",
35+
consent_given: "Consent Given",
36+
not_vaccinated: "Not Vaccinated",
37+
vaccinated: "Vaccinated"
3338
}.freeze
3439

3540
FLU_SPECIFIC_METRIC_HEADERS = {}.freeze
@@ -139,7 +144,12 @@ def grouped_record_json(record, groups)
139144
.merge(
140145
cohort: record.cohort,
141146
vaccinated: record.vaccinated,
142-
not_vaccinated: record.not_vaccinated
147+
not_vaccinated: record.not_vaccinated,
148+
consent_given: record.consent_given,
149+
no_consent: record.no_consent,
150+
consent_no_response: record.consent_no_response,
151+
consent_refused: record.consent_refused,
152+
consent_conflicts: record.consent_conflicts
143153
)
144154
end
145155

@@ -151,15 +161,17 @@ def render_totals_json
151161
cohort:,
152162
vaccinated:,
153163
not_vaccinated: cohort - vaccinated,
164+
consent_given: @totals_scope.consent_given_count,
165+
no_consent: @totals_scope.no_consent_count,
166+
consent_no_response: @totals_scope.consent_no_response_count,
167+
consent_refused: @totals_scope.consent_refused_count,
168+
consent_conflicts: @totals_scope.consent_conflicts_count,
154169
vaccinated_by_sais: @scope.vaccinated_by_sais_count,
155170
vaccinated_elsewhere_declared: @scope.vaccinated_elsewhere_declared_count,
156171
vaccinated_elsewhere_recorded: @scope.vaccinated_elsewhere_recorded_count,
157172
vaccinated_previously: @scope.vaccinated_previously_count,
158173
vaccinations_given: @base_scope.vaccinations_given_count,
159174
monthly_vaccinations_given: @base_scope.monthly_vaccinations_given,
160-
consent_given: @scope.consent_given_count,
161-
consent_no_response: @scope.consent_no_response_count,
162-
consent_conflicts: @scope.consent_conflicts_count,
163175
parent_refused_consent: @scope.parent_refused_consent_count,
164176
child_refused_vaccination: @scope.child_refused_vaccination_count,
165177
refusal_reasons: consent_refusal_reasons,

app/controllers/draft_vaccination_records_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def update
7070

7171
def validate_params
7272
if current_step == :date_and_time
73+
TimeParamsNormalizer.call!(
74+
params: params[:draft_vaccination_record],
75+
field_name: :performed_at_time
76+
)
77+
7378
date_validator =
7479
DateParamsValidator.new(
7580
field_name: :performed_at_date,
@@ -142,7 +147,8 @@ def handle_mmr_or_mmrv
142147
end
143148

144149
def handle_location
145-
if @draft_vaccination_record.national_reporting_user_and_record?
150+
if @session&.generic_clinic? ||
151+
@draft_vaccination_record.national_reporting_user_and_record?
146152
location_id = update_params[:location_id]
147153

148154
if location_id == "unknown"

app/controllers/patient_sessions/programmes_controller.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,36 @@ def record_already_vaccinated
1818
DraftVaccinationRecord.new(request_session: session, current_user:)
1919

2020
draft_vaccination_record.clear_attributes
21+
22+
first_active_wizard_step =
23+
if Flipper.enabled?(:already_vaccinated)
24+
eligible_for_mmr_or_mmrv? ? :mmr_or_mmrv : :date_and_time
25+
else
26+
:confirm
27+
end
28+
2129
draft_vaccination_record.update!(
22-
first_active_wizard_step: :confirm,
30+
dose_sequence: (dose_sequence if Flipper.enabled?(:already_vaccinated)),
31+
first_active_wizard_step:,
2332
location_id: nil,
2433
location_name: "Unknown",
2534
outcome: :already_had,
2635
patient: @patient,
27-
performed_at: Time.current,
28-
performed_by_user_id: current_user.id,
36+
performed_at: (Time.current unless Flipper.enabled?(:already_vaccinated)),
37+
performed_by_user_id:
38+
(current_user.id unless Flipper.enabled?(:already_vaccinated)),
2939
performed_ods_code: current_team.organisation.ods_code,
3040
programme: @programme,
41+
reported_by_id:
42+
(current_user.id if Flipper.enabled?(:already_vaccinated)),
43+
reported_at: (Time.current if Flipper.enabled?(:already_vaccinated)),
3144
session: @session,
3245
source: "service"
3346
)
3447

35-
redirect_to draft_vaccination_record_path("confirm")
48+
redirect_to draft_vaccination_record_path(
49+
first_active_wizard_step.to_s.dasherize
50+
)
3651
end
3752

3853
private

0 commit comments

Comments
 (0)