Skip to content

Commit 279bcbe

Browse files
authored
Format full names as SURNAME, Firstname (#2980)
This updates how the full names are formatted to use the format `SURNAME, Firstname` if we're rendering a patient name in the context of the service used by nurses, and we keep the existing `Firstname Surname` format when displaying a patient name in the context of comms sent to parents. ## Screenshots ![Screenshot 2025-02-26 at 08 21 54](https://github.com/user-attachments/assets/d8477585-cc19-42e5-b178-2ec1d1ce85fb) ![Screenshot 2025-02-26 at 08 22 00](https://github.com/user-attachments/assets/19308e83-261b-45e8-ba3b-338ebc572aab) ![Screenshot 2025-02-26 at 08 22 10](https://github.com/user-attachments/assets/10beb98a-2451-42c7-bc80-49b4a87a0632) ![Screenshot 2025-02-26 at 08 23 35](https://github.com/user-attachments/assets/edef4dc5-b308-44a0-a34b-664ce05c9b07)
2 parents 504b17f + 95e8f34 commit 279bcbe

File tree

52 files changed

+299
-188
lines changed

Some content is hidden

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

52 files changed

+299
-188
lines changed

app/components/app_consent_confirmation_component.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ def title
3737

3838
private
3939

40-
delegate :full_name,
41-
:chosen_programmes,
40+
delegate :chosen_programmes,
4241
:not_chosen_programmes,
4342
:response,
4443
:parent_email,
4544
to: :@consent_form
4645

46+
def full_name
47+
@consent_form.full_name(context: :parents)
48+
end
49+
4750
def panel_text
4851
case response
4952
when "given", "given_one"

app/components/app_simple_status_banner_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def call
3030
delegate :patient, :session, to: :patient_session
3131

3232
def status
33-
@status ||= @patient_session.status(programme:)
33+
@status ||= patient_session.status(programme:)
3434
end
3535

3636
def colour

app/lib/full_name_formatter.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
class FullNameFormatter
4+
def self.call(nameable, context:, parts_prefix: nil)
5+
parts_prefix = "#{parts_prefix}_" if parts_prefix.present?
6+
7+
given_name =
8+
nameable.try(:"#{parts_prefix}given_name").presence ||
9+
nameable.send(:given_name)
10+
family_name =
11+
nameable.try(:"#{parts_prefix}family_name").presence ||
12+
nameable.send(:family_name)
13+
14+
case context
15+
when :internal
16+
"#{family_name.upcase}, #{given_name.upcase_first}"
17+
when :parents
18+
"#{given_name.upcase_first} #{family_name.upcase_first}"
19+
else
20+
raise "Unknown context: #{context}"
21+
end
22+
end
23+
end

app/lib/govuk_notify_personalisation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def day_month_year_of_vaccination
120120
end
121121

122122
def full_and_preferred_patient_name
123-
(consent_form || patient).full_name_with_known_as
123+
(consent_form || patient).full_name_with_known_as(context: :parents)
124124
end
125125

126126
def host

app/models/concerns/full_name_concern.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@ module FullNameConcern
88
-> { order("LOWER(family_name)", "LOWER(given_name)") }
99
end
1010

11-
def full_name
12-
[given_name, family_name].join(" ")
11+
def full_name(context: :internal)
12+
FullNameFormatter.call(self, context:)
1313
end
1414

1515
def has_preferred_name?
1616
preferred_given_name.present? || preferred_family_name.present?
1717
end
1818

19-
def preferred_full_name
20-
[
21-
preferred_given_name.presence || given_name,
22-
preferred_family_name.presence || family_name
23-
].join(" ")
19+
def preferred_full_name(context: :internal)
20+
FullNameFormatter.call(self, context:, parts_prefix: :preferred)
2421
end
2522

2623
def preferred_full_name_changed?
2724
preferred_given_name_changed? || preferred_family_name_changed?
2825
end
2926

30-
def full_name_with_known_as
27+
def full_name_with_known_as(context: :internal)
3128
if has_preferred_name?
32-
"#{full_name} (known as #{preferred_full_name})"
29+
"#{full_name(context:)} (known as #{preferred_full_name(context: :parents)})"
3330
else
34-
full_name
31+
full_name(context:)
3532
end
3633
end
3734

app/models/concerns/vaccination_record_performed_by_concern.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ module VaccinationRecordPerformedByConcern
1111
}
1212
end
1313

14+
PerformedBy =
15+
Struct.new(:given_name, :family_name) do
16+
def full_name
17+
FullNameFormatter.call(self, context: :internal)
18+
end
19+
end
20+
1421
def performed_by
1522
return performed_by_user if performed_by_user
1623

1724
if performed_by_given_name.present? || performed_by_family_name.present?
18-
OpenStruct.new(
25+
PerformedBy.new(
1926
given_name: performed_by_given_name,
20-
family_name: performed_by_family_name,
21-
full_name: [
22-
performed_by_given_name,
23-
performed_by_family_name
24-
].compact_blank.join(" ")
27+
family_name: performed_by_family_name
2528
)
2629
end
2730
end

app/views/parent_interface/consent_forms/confirm.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
<%= govuk_summary_list do |summary_list|
140140
summary_list.with_row do |row|
141141
row.with_key { "Child’s name" }
142-
row.with_value { @consent_form.full_name }
142+
row.with_value { @consent_form.full_name(context: :parents) }
143143
row.with_action(text: "Change",
144144
href: change_link[:name],
145145
visually_hidden_text: "child’s name")
@@ -148,7 +148,7 @@
148148
if @consent_form.use_preferred_name
149149
summary_list.with_row do |row|
150150
row.with_key { "Also known as" }
151-
row.with_value { @consent_form.preferred_full_name }
151+
row.with_value { @consent_form.preferred_full_name(context: :parents) }
152152
row.with_action(text: "Change",
153153
href: change_link[:name],
154154
visually_hidden_text: "common name")

spec/components/app_activity_log_component_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
title: "Vaccinated with Gardasil 9",
144144
date: "31 May 2024 at 12:00pm",
145145
notes: "Some notes",
146-
by: "Nurse Joy",
146+
by: "JOY, Nurse",
147147
programme: "HPV"
148148

149149
include_examples "card",
@@ -155,14 +155,14 @@
155155
include_examples "card",
156156
title: "Triaged decision: Safe to vaccinate",
157157
date: "30 May 2024 at 2:30pm",
158-
by: "Nurse Joy",
158+
by: "JOY, Nurse",
159159
programme: "HPV"
160160

161161
include_examples "card",
162162
title: "Triaged decision: Keep in triage",
163163
date: "30 May 2024 at 2:00pm",
164164
notes: "Some notes",
165-
by: "Nurse Joy",
165+
by: "JOY, Nurse",
166166
programme: "HPV"
167167

168168
include_examples "card",
@@ -173,7 +173,7 @@
173173
include_examples "card",
174174
title: "Consent given by Jane Doe (Mum)",
175175
date: "30 May 2024 at 12:00pm",
176-
by: "Nurse Joy",
176+
by: "JOY, Nurse",
177177
programme: "HPV"
178178

179179
include_examples "card",
@@ -184,7 +184,7 @@
184184
title: "Consent school request hpv sent",
185185
date: "10 May 2024 at 12:00am",
186186
notes: "test@example.com",
187-
by: "Nurse Joy",
187+
by: "JOY, Nurse",
188188
programme: "HPV"
189189
end
190190

@@ -207,7 +207,7 @@
207207
title: "Vaccination not given: Unwell",
208208
date: "31 May 2024 at 1:00pm",
209209
notes: "Some notes.",
210-
by: "Nurse Joy",
210+
by: "JOY, Nurse",
211211
programme: "HPV"
212212
end
213213

@@ -228,7 +228,7 @@
228228
include_examples "card",
229229
title: "Vaccinated with Gardasil 9",
230230
date: "31 May 2024 at 1:00pm",
231-
by: "Nurse Joy",
231+
by: "JOY, Nurse",
232232
programme: "HPV"
233233

234234
include_examples "card",
@@ -251,7 +251,7 @@
251251

252252
include_examples "card",
253253
title:
254-
"Consent given by Sarah Doe (Child (Gillick competent))",
254+
"Consent given by DOE, Sarah (Child (Gillick competent))",
255255
date: "30 May 2024 at 12:00pm",
256256
programme: "HPV"
257257
end
@@ -290,7 +290,7 @@
290290
title:
291291
"Consent response manually matched with child record",
292292
date: "30 May 2024 at 1:00pm",
293-
by: "Nurse Joy"
293+
by: "JOY, Nurse"
294294
end
295295

296296
describe "withdrawn consent" do
@@ -370,15 +370,15 @@
370370
title: "Completed Gillick assessment as Gillick competent",
371371
notes: "First notes",
372372
date: "1 June 2024 at 12:00pm",
373-
by: "Nurse Joy",
373+
by: "JOY, Nurse",
374374
programme: "Td/IPV"
375375

376376
include_examples "card",
377377
title:
378378
"Updated Gillick assessment as not Gillick competent",
379379
notes: "Second notes",
380380
date: "1 June 2024 at 1:00pm",
381-
by: "Nurse Joy",
381+
by: "JOY, Nurse",
382382
programme: "Td/IPV"
383383
end
384384

@@ -400,6 +400,6 @@
400400
title: "Completed pre-screening checks",
401401
notes: "Some notes",
402402
date: "1 June 2024 at 12:00pm",
403-
by: "Nurse Joy"
403+
by: "JOY, Nurse"
404404
end
405405
end

spec/components/app_child_summary_component_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
it { should have_content("123\u00A0\u200D456\u00A0\u200D7890") }
4343

4444
it { should have_content("Full name") }
45-
it { should have_content("John Doe") }
45+
it { should have_content("DOE, John") }
4646

4747
it { should have_content("Known as") }
48-
it { should have_content("Johnny Doe") }
48+
it { should have_content("DOE, Johnny") }
4949

5050
it { should have_content("Date of birth") }
5151
it { should have_content("1 January 2000") }
@@ -83,7 +83,7 @@
8383
context "with pending changes" do
8484
let(:component) { described_class.new(patient.with_pending_changes) }
8585

86-
it { should have_css(".app-highlight", text: "Jane Doe") }
86+
it { should have_css(".app-highlight", text: "DOE, Jane") }
8787
it { should have_css(".app-highlight", text: "1 January 2001") }
8888
it { should have_css(".app-highlight", text: "SW1A 2AA") }
8989
it { should_not have_css(".app-highlight", text: "Male") }
@@ -103,6 +103,6 @@
103103
create(:consent_form, :recorded, given_name: "John", family_name: "Doe")
104104
end
105105

106-
it { should have_text("John Doe") }
106+
it { should have_text("DOE, John") }
107107
end
108108
end

spec/components/app_compare_consent_form_and_patient_component_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
)
3535
end
3636

37-
it { should have_text("Full name\nJohn Doe").twice }
37+
it { should have_text("Full name\nDOE, John").twice }
3838
it { should have_text("Date of birth\n1 January 2000").twice }
3939
it { should have_text("Address\n1 Main StreetAreaSome TownSW11 1AA").twice }
4040
it { should have_text("School\nWaterloo Road").twice }
@@ -55,8 +55,8 @@
5555
)
5656
end
5757

58-
it { should have_text("Full name\nJohn Doe").once }
59-
it { should have_text("Full name\nJane Doe").once }
58+
it { should have_text("Full name\nDOE, John").once }
59+
it { should have_text("Full name\nDOE, Jane").once }
6060

6161
it { should have_text("Date of birth\n1 January 2000").once }
6262
it { should have_text("Date of birth\n2 January 2000").once }

0 commit comments

Comments
 (0)