Skip to content

Commit e320665

Browse files
authored
Merge pull request #5313 from nhsuk/next
2 parents 05dc8fe + b2f921c commit e320665

File tree

179 files changed

+2598
-1511
lines changed

Some content is hidden

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

179 files changed

+2598
-1511
lines changed

Gemfile.lock

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,17 @@ GEM
130130
aws-sdk-ec2 (1.582.0)
131131
aws-sdk-core (~> 3, >= 3.239.1)
132132
aws-sigv4 (~> 1.5)
133-
aws-sdk-ecr (1.114.0)
134-
aws-sdk-core (~> 3, >= 3.234.0)
133+
aws-sdk-ecr (1.115.0)
134+
aws-sdk-core (~> 3, >= 3.239.1)
135135
aws-sigv4 (~> 1.5)
136136
aws-sdk-iam (1.136.0)
137137
aws-sdk-core (~> 3, >= 3.239.1)
138138
aws-sigv4 (~> 1.5)
139139
aws-sdk-kms (1.118.0)
140140
aws-sdk-core (~> 3, >= 3.239.1)
141141
aws-sigv4 (~> 1.5)
142-
aws-sdk-rds (1.299.0)
143-
aws-sdk-core (~> 3, >= 3.234.0)
142+
aws-sdk-rds (1.300.0)
143+
aws-sdk-core (~> 3, >= 3.239.1)
144144
aws-sigv4 (~> 1.5)
145145
aws-sdk-s3 (1.205.0)
146146
aws-sdk-core (~> 3, >= 3.234.0)
@@ -277,7 +277,7 @@ GEM
277277
raabro (~> 1.4)
278278
globalid (1.3.0)
279279
activesupport (>= 6.1)
280-
govuk-components (5.13.0)
280+
govuk-components (5.13.1)
281281
html-attributes-utils (~> 1.0.0, >= 1.0.0)
282282
pagy (>= 6, < 10)
283283
view_component (>= 4.0, < 4.2)
@@ -409,7 +409,7 @@ GEM
409409
logger
410410
rack (>= 2.2.3)
411411
rack-protection
412-
omniauth-rails_csrf_protection (1.0.2)
412+
omniauth-rails_csrf_protection (2.0.0)
413413
actionpack (>= 4.2)
414414
omniauth (~> 2.0)
415415
omniauth_openid_connect (0.8.0)
@@ -440,7 +440,7 @@ GEM
440440
racc
441441
pg (1.6.2-arm64-darwin)
442442
pg (1.6.2-x86_64-linux)
443-
phonelib (0.10.13)
443+
phonelib (0.10.14)
444444
pp (0.6.3)
445445
prettyprint
446446
prettier_print (1.2.1)
@@ -734,7 +734,8 @@ GEM
734734
validate_url (1.0.15)
735735
activemodel (>= 3.0.0)
736736
public_suffix
737-
view_component (4.1.0)
737+
view_component (4.1.1)
738+
actionview (>= 7.1.0, < 8.2)
738739
activesupport (>= 7.1.0, < 8.2)
739740
concurrent-ruby (~> 1)
740741
warden (1.2.9)

app/components/app_activity_log_component.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,7 @@ def initialize(team:, patient:, session: nil)
5858
@patient
5959
.notify_log_entries
6060
.includes(:sent_by)
61-
.then do |scope|
62-
if session
63-
scope.where(programme_types: session.programme_types)
64-
else
65-
scope
66-
end
67-
end
61+
.then { |scope| session ? scope.for_session(session) : scope }
6862

6963
@patient_locations =
7064
@patient

app/components/app_import_review_component.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def call
5151
) do
5252
render(
5353
AppImportReviewIssuesSummaryComponent.new(
54-
changesets: @import_issues
54+
import: @import,
55+
records: @import_issues
5556
)
5657
)
5758
end,
@@ -104,9 +105,16 @@ def import_issues_message
104105

105106
def school_moves_message
106107
count = @school_moves.count
107-
"This upload includes #{count > 1 ? "children" : "child"} with a different school to " \
108-
"the one on their Mavis record. If you approve the upload, these will be flagged as " \
109-
"school moves needing review."
108+
if @import.is_a?(ClassImport)
109+
"This upload will change the school of the #{count > 1 ? "children" : "child"} listed below. " \
110+
"Children present in the class list will be moved into the school, and those who are not in the " \
111+
"class list will be moved out of the school. If you approve the upload, these will be flagged as " \
112+
"school moves needing review."
113+
else
114+
"This upload includes #{count} #{count > 1 ? "children" : "child"} with a different school to " \
115+
"the one on their Mavis record. If you approve the upload, these will be flagged as " \
116+
"school moves needing review."
117+
end
110118
end
111119

112120
def cancel_button_text
Lines changed: 133 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# frozen_string_literal: true
22

33
class AppImportReviewIssuesSummaryComponent < ViewComponent::Base
4-
def initialize(changesets: nil)
5-
@changesets = changesets.sort_by(&:row_number) || []
4+
def initialize(import: nil, records: nil, show_actions: false)
5+
@import = import
6+
@records = Array(records).sort_by { it.try(:row_number) || 0 }
7+
@show_actions = show_actions
68
end
79

810
def call
@@ -15,57 +17,145 @@ def call
1517
head.with_row do |row|
1618
row.with_cell(text: "Name and NHS number")
1719
row.with_cell(text: "Issue to review")
20+
row.with_cell(text: "Actions") if @show_actions
1821
end
1922
end
20-
2123
table.with_body do |body|
22-
@changesets.each do |changeset|
24+
@records.each do |record|
2325
body.with_row do |row|
24-
row.with_cell do
25-
heading =
26-
tag.span(
27-
"Name and NHS number",
28-
class: "nhsuk-table-responsive__heading"
29-
)
26+
row.with_cell { render_name_cell(record) }
27+
row.with_cell { render_issue_cell(record) }
28+
row.with_cell { render_action_cell(record) } if @show_actions
29+
end
30+
end
31+
end
32+
end
33+
end
3034

31-
helpers.safe_join(
32-
[
33-
heading,
34-
tag.span(
35-
FullNameFormatter.call(changeset, context: :internal)
36-
),
37-
tag.br,
38-
tag.span(
39-
helpers.format_nhs_number(changeset.nhs_number),
40-
class: "nhsuk-u-secondary-text-colour nhsuk-u-font-size-16"
41-
)
42-
]
43-
)
44-
end
35+
private
4536

46-
row.with_cell do
47-
heading =
48-
tag.span(
49-
"Issue to review",
50-
class: "nhsuk-table-responsive__heading"
51-
)
37+
def render_name_cell(record)
38+
heading =
39+
tag.span("Name and NHS number", class: "nhsuk-table-responsive__heading")
40+
name = format_name(record)
41+
nhs_number = format_nhs_number(record)
5242

53-
pending_changes = changeset.review_data["pending_changes"] || {}
54-
issue_groups = helpers.issue_categories_for(pending_changes.keys)
43+
helpers.safe_join(
44+
[
45+
heading,
46+
tag.span(name),
47+
tag.br,
48+
tag.span(
49+
nhs_number,
50+
class: "nhsuk-u-secondary-text-colour nhsuk-u-font-size-16"
51+
)
52+
]
53+
)
54+
end
5555

56-
issue_text =
57-
if changeset.matched_on_nhs_number?
58-
"Matched on NHS number. " \
59-
"#{issue_groups.to_sentence.capitalize} #{issue_groups.size == 1 ? "does not" : "do not"} match."
60-
else
61-
"Possible match found. Review and confirm."
62-
end
56+
def render_issue_cell(record)
57+
heading =
58+
tag.span("Issue to review", class: "nhsuk-table-responsive__heading")
59+
issue_text = determine_issue_text(record)
60+
helpers.safe_join([heading, tag.span(issue_text)])
61+
end
6362

64-
helpers.safe_join([heading, tag.span(issue_text)])
65-
end
66-
end
67-
end
63+
def render_action_cell(record)
64+
heading = tag.span("Actions", class: "nhsuk-table-responsive__heading")
65+
action_link = generate_action_link(record)
66+
helpers.safe_join([heading, action_link])
67+
end
68+
69+
def format_name(record)
70+
case record
71+
when PatientChangeset
72+
FullNameFormatter.call(record, context: :internal)
73+
when Patient
74+
record.full_name
75+
when VaccinationRecord
76+
record.patient&.full_name || "Unknown"
77+
else
78+
raise "Unknown record type: #{record.class.name}"
79+
end
80+
end
81+
82+
def format_nhs_number(record)
83+
case record
84+
when PatientChangeset
85+
helpers.format_nhs_number(record.nhs_number)
86+
when Patient
87+
helpers.format_nhs_number(record.nhs_number)
88+
when VaccinationRecord
89+
helpers.format_nhs_number(record.patient&.nhs_number)
90+
else
91+
raise "Unknown record type: #{record.class.name}"
92+
end
93+
end
94+
95+
def determine_issue_text(record)
96+
case record
97+
when PatientChangeset, Patient
98+
patient_import_issue_text(record)
99+
when VaccinationRecord
100+
"Imported record closely matches an existing record. Review and confirm."
101+
else
102+
raise "Unknown record type: #{record.class.name}"
103+
end
104+
end
105+
106+
def patient_import_issue_text(record)
107+
pending_changes =
108+
if record.is_a?(PatientChangeset)
109+
record.review_data["patient"]["pending_changes"] || {}
110+
else
111+
record.pending_changes || {}
112+
end
113+
issue_groups = helpers.issue_categories_for(pending_changes.keys)
114+
115+
if issue_groups.any? && matched_on_nhs_number?(record)
116+
"Matched on NHS number. " \
117+
"#{issue_groups.to_sentence.capitalize} #{issue_groups.size == 1 ? "does not" : "do not"} match."
118+
else
119+
"Possible match found. Review and confirm."
120+
end
121+
end
122+
123+
def matched_on_nhs_number?(record)
124+
if record.is_a?(PatientChangeset)
125+
record.matched_on_nhs_number?
126+
elsif record.is_a?(Patient)
127+
@import
128+
&.changesets
129+
&.find_by(patient_id: record.id)
130+
&.matched_on_nhs_number?
131+
end
132+
end
133+
134+
def generate_action_link(record)
135+
case record
136+
when Patient
137+
helpers.link_to(imports_issue_path(record, type: "patient")) do
138+
helpers.safe_join(
139+
[
140+
"Review ",
141+
tag.span(record.full_name, class: "nhsuk-u-visually-hidden")
142+
]
143+
)
144+
end
145+
when VaccinationRecord
146+
helpers.link_to(imports_issue_path(record, type: "vaccination-record")) do
147+
helpers.safe_join(
148+
[
149+
"Review ",
150+
tag.span(
151+
record.patient&.full_name,
152+
class: "nhsuk-u-visually-hidden"
153+
)
154+
]
155+
)
68156
end
157+
else
158+
""
69159
end
70160
end
71161
end

app/components/app_import_status_component.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def status_text
1515
"pending_import" => "Processing",
1616
"rows_are_invalid" => "Invalid",
1717
"changesets_are_invalid" => "Failed",
18-
"in_review" => "Needs review",
18+
"in_review" => "Review and approve",
1919
"calculating_re_review" => "Processing",
20-
"in_re_review" => "Needs re-review",
20+
"in_re_review" => "Review",
2121
"committing" => "Importing",
2222
"processed" => "Completed",
2323
"partially_processed" => "Partially completed",
@@ -31,9 +31,9 @@ def status_color
3131
"pending_import" => "blue",
3232
"rows_are_invalid" => "red",
3333
"changesets_are_invalid" => "red",
34-
"in_review" => "yellow",
34+
"in_review" => "blue",
3535
"calculating_re_review" => "blue",
36-
"in_re_review" => "yellow",
36+
"in_re_review" => "blue",
3737
"committing" => "blue",
3838
"processed" => "green",
3939
"partially_processed" => "green",
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<%= render AppCardComponent.new do |card| %>
2+
<% card.with_heading(level: 2) { "Details" } %>
3+
4+
<%= helpers.govuk_summary_list do |summary_list| %>
5+
<%= summary_list.with_row do |row| %>
6+
<%= row.with_key { "Uploaded by" } %>
7+
<%= row.with_value { import.uploaded_by.full_name } %>
8+
<% end %>
9+
10+
<% if import.show_approved_reviewers? %>
11+
<%= summary_list.with_row do |row| %>
12+
<%= row.with_key { "Approved by" } %>
13+
<%= row.with_value { approved_reviewers_text } %>
14+
<% end %>
15+
<% end %>
16+
17+
<% if import.show_cancelled_reviewer? %>
18+
<%= summary_list.with_row do |row| %>
19+
<%= row.with_key { cancelled_reviewer_label } %>
20+
<%= row.with_value { cancelled_reviewer_text } %>
21+
<% end %>
22+
<% end %>
23+
24+
<%= summary_list.with_row do |row| %>
25+
<%= row.with_key { "File" } %>
26+
<%= row.with_value { import.csv_filename } %>
27+
<% end %>
28+
29+
<%= summary_list.with_row do |row| %>
30+
<%= row.with_key { "Type" } %>
31+
<%= row.with_value { import.type_label } %>
32+
<% end %>
33+
34+
<%= summary_list.with_row do |row| %>
35+
<%= row.with_key { "Status" } %>
36+
<%= row.with_value { render AppImportStatusComponent.new(import:) } %>
37+
<% end %>
38+
39+
<% if import.is_a?(ClassImport) %>
40+
<%= summary_list.with_row do |row| %>
41+
<%= row.with_key { "School" } %>
42+
<%= row.with_value { import.location.name } %>
43+
<% end %>
44+
45+
<%= summary_list.with_row do |row| %>
46+
<%= row.with_key { "Year groups" } %>
47+
<%= row.with_value { import.year_groups.map { helpers.format_year_group(it) }.to_sentence } %>
48+
<% end %>
49+
<% end %>
50+
51+
<% if import.records_count && import.records_count.positive? %>
52+
<%= summary_list.with_row do |row| %>
53+
<%= row.with_key { "Records" } %>
54+
<%= row.with_value { import.records_count.to_s } %>
55+
<% end %>
56+
<% end %>
57+
<% end %>
58+
<% end %>

0 commit comments

Comments
 (0)