Skip to content

Commit 0c545ec

Browse files
committed
Revert "Merge pull request #5272 from nhsuk/imports-redesign"
This reverts commit ae4ef00, reversing changes made to 0f4e2dd.
1 parent f57dd96 commit 0c545ec

39 files changed

Lines changed: 475 additions & 518 deletions

app/components/app_import_review_component.rb

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

106105
def school_moves_message
107106
count = @school_moves.count
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
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."
118110
end
119111

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

33
class AppImportReviewIssuesSummaryComponent < ViewComponent::Base
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
4+
def initialize(changesets: nil)
5+
@changesets = changesets.sort_by(&:row_number) || []
86
end
97

108
def call
@@ -17,145 +15,57 @@ def call
1715
head.with_row do |row|
1816
row.with_cell(text: "Name and NHS number")
1917
row.with_cell(text: "Issue to review")
20-
row.with_cell(text: "Actions") if @show_actions
2118
end
2219
end
20+
2321
table.with_body do |body|
24-
@records.each do |record|
22+
@changesets.each do |changeset|
2523
body.with_row do |row|
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
34-
35-
private
36-
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)
42-
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
55-
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
62-
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
24+
row.with_cell do
25+
heading =
26+
tag.span(
27+
"Name and NHS number",
28+
class: "nhsuk-table-responsive__heading"
29+
)
8130

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
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
9445

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
46+
row.with_cell do
47+
heading =
48+
tag.span(
49+
"Issue to review",
50+
class: "nhsuk-table-responsive__heading"
51+
)
10552

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)
53+
pending_changes = changeset.review_data["pending_changes"] || {}
54+
issue_groups = helpers.issue_categories_for(pending_changes.keys)
11455

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
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
13363

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-
)
64+
helpers.safe_join([heading, tag.span(issue_text)])
65+
end
66+
end
67+
end
15668
end
157-
else
158-
""
15969
end
16070
end
16171
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" => "Review and approve",
18+
"in_review" => "Needs review",
1919
"calculating_re_review" => "Processing",
20-
"in_re_review" => "Review",
20+
"in_re_review" => "Needs re-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" => "blue",
34+
"in_review" => "yellow",
3535
"calculating_re_review" => "blue",
36-
"in_re_review" => "blue",
36+
"in_re_review" => "yellow",
3737
"committing" => "blue",
3838
"processed" => "green",
3939
"partially_processed" => "green",

app/components/app_import_summary_component.html.erb

Lines changed: 0 additions & 58 deletions
This file was deleted.

app/components/app_import_summary_component.rb

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)