Skip to content

Commit 988162c

Browse files
authored
Merge pull request #4665 from nhsuk/next
Version 4.2.2
2 parents 470d11a + 605ffcd commit 988162c

153 files changed

Lines changed: 1938 additions & 2124 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.

Gemfile.lock

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ GEM
113113
ast (2.4.3)
114114
attr_required (1.0.2)
115115
aws-eventstream (1.4.0)
116-
aws-partitions (1.1159.0)
116+
aws-partitions (1.1161.0)
117117
aws-sdk-accessanalyzer (1.78.0)
118118
aws-sdk-core (~> 3, >= 3.231.0)
119119
aws-sigv4 (~> 1.5)
@@ -125,7 +125,7 @@ GEM
125125
bigdecimal
126126
jmespath (~> 1, >= 1.6.1)
127127
logger
128-
aws-sdk-ec2 (1.556.0)
128+
aws-sdk-ec2 (1.557.0)
129129
aws-sdk-core (~> 3, >= 3.231.0)
130130
aws-sigv4 (~> 1.5)
131131
aws-sdk-ecr (1.110.0)
@@ -387,9 +387,9 @@ GEM
387387
net-protocol
388388
nio4r (2.7.4)
389389
nkf (0.2.0)
390-
nokogiri (1.18.9-arm64-darwin)
390+
nokogiri (1.18.10-arm64-darwin)
391391
racc (~> 1.4)
392-
nokogiri (1.18.9-x86_64-linux-gnu)
392+
nokogiri (1.18.10-x86_64-linux-gnu)
393393
racc (~> 1.4)
394394
notifications-ruby-client (6.2.0)
395395
jwt (>= 1.5, < 3)
@@ -433,7 +433,7 @@ GEM
433433
prettyprint
434434
prettier_print (1.2.1)
435435
prettyprint (0.2.0)
436-
prism (1.4.0)
436+
prism (1.5.1)
437437
propshaft (1.2.1)
438438
actionpack (>= 7.0.0)
439439
activesupport (>= 7.0.0)
@@ -513,7 +513,7 @@ GEM
513513
rb-fsevent (0.11.2)
514514
rb-inotify (0.11.1)
515515
ffi (~> 1.0)
516-
rbs (3.6.1)
516+
rbs (3.9.5)
517517
logger
518518
rdoc (6.14.2)
519519
erb
@@ -522,15 +522,15 @@ GEM
522522
redis-client (0.25.2)
523523
connection_pool
524524
redis-prescription (2.6.0)
525-
regexp_parser (2.11.2)
525+
regexp_parser (2.11.3)
526526
reline (0.6.2)
527527
io-console (~> 0.5)
528528
responders (3.1.1)
529529
actionpack (>= 5.2)
530530
railties (>= 5.2)
531531
reverse_markdown (3.0.0)
532532
nokogiri
533-
rexml (3.4.2)
533+
rexml (3.4.4)
534534
rladr (1.2.0)
535535
rspec (3.13.1)
536536
rspec-core (~> 3.13.0)
@@ -645,7 +645,7 @@ GEM
645645
simplecov_json_formatter (~> 0.1)
646646
simplecov-html (0.12.3)
647647
simplecov_json_formatter (0.1.4)
648-
solargraph (0.56.2)
648+
solargraph (0.57.0)
649649
backport (~> 1.2)
650650
benchmark (~> 0.4)
651651
bundler (~> 2.0)
@@ -658,16 +658,17 @@ GEM
658658
ostruct (~> 0.6)
659659
parser (~> 3.0)
660660
prism (~> 1.4)
661-
rbs (~> 3.6.1)
661+
rbs (>= 3.6.1, <= 4.0.0.dev.4)
662662
reverse_markdown (~> 3.0)
663-
rubocop (~> 1.38)
663+
rubocop (~> 1.76)
664664
thor (~> 1.0)
665665
tilt (~> 2.0)
666666
yard (~> 0.9, >= 0.9.24)
667+
yard-activesupport-concern (~> 0.0)
667668
yard-solargraph (~> 0.1)
668-
solargraph-rails (1.2.3)
669+
solargraph-rails (1.2.4)
669670
activesupport
670-
solargraph (>= 0.48.0, < 0.57)
671+
solargraph (>= 0.48.0, <= 0.57)
671672
splunk-sdk-ruby (1.0.5)
672673
stackprof (0.2.27)
673674
stringio (3.1.7)
@@ -704,9 +705,9 @@ GEM
704705
tzinfo (2.0.6)
705706
concurrent-ruby (~> 1.0)
706707
uk_postcode (2.1.8)
707-
unicode-display_width (3.1.5)
708-
unicode-emoji (~> 4.0, >= 4.0.4)
709-
unicode-emoji (4.0.4)
708+
unicode-display_width (3.2.0)
709+
unicode-emoji (~> 4.1)
710+
unicode-emoji (4.1.0)
710711
uri (1.0.3)
711712
useragent (0.16.11)
712713
validate_url (1.0.15)
@@ -744,6 +745,8 @@ GEM
744745
xpath (3.2.0)
745746
nokogiri (~> 1.8)
746747
yard (0.9.37)
748+
yard-activesupport-concern (0.0.1)
749+
yard (>= 0.8)
747750
yard-solargraph (0.1.0)
748751
yard (~> 0.9)
749752
zeitwerk (2.7.3)

app/components/app_activity_log_component.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ def initialize(team:, patient:, session: nil)
6363
session ? scope.where(programme_ids: session.programmes.ids) : scope
6464
end
6565

66-
@patient_sessions =
66+
@patient_locations =
6767
@patient
68-
.patient_sessions
69-
.includes_programmes
70-
.includes(session: :location)
71-
.then { |scope| session ? scope.where(session:) : scope }
68+
.patient_locations
69+
.includes(:location)
70+
.then do |scope|
71+
session ? scope.where(location: session.location) : scope
72+
end
7273

7374
@patient_specific_directions =
7475
@patient
@@ -105,7 +106,7 @@ def initialize(team:, patient:, session: nil)
105106
:notes,
106107
:notify_log_entries,
107108
:patient,
108-
:patient_sessions,
109+
:patient_locations,
109110
:patient_specific_directions,
110111
:pre_screenings,
111112
:attendance_records,
@@ -346,15 +347,11 @@ def pre_screening_events
346347
end
347348

348349
def session_events
349-
patient_sessions.map do |patient_session|
350-
patient = patient_session.patient
351-
session = patient_session.session
352-
350+
patient_locations.map do |patient_location|
353351
[
354352
{
355-
title: "Added to the session at #{session.location.name}",
356-
at: patient_session.created_at,
357-
programmes: session.programmes_for(patient:)
353+
title: "Added to the session at #{patient_location.location.name}",
354+
at: patient_location.created_at
358355
}
359356
]
360357
end

app/components/app_imports_navigation_component.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# frozen_string_literal: true
22

33
class AppImportsNavigationComponent < ViewComponent::Base
4-
def initialize(active:)
4+
def initialize(active:, team:)
55
@active = active
6+
@team = team
67
end
78

89
def call
@@ -31,18 +32,22 @@ def call
3132

3233
private
3334

34-
attr_reader :active
35+
attr_reader :active, :team
3536

36-
delegate :import_issues_count, :policy, :policy_scope, to: :helpers
37+
delegate :policy, :policy_scope, to: :helpers
3738

3839
def issues_text
39-
safe_join(
40-
["Import issues", " ", render(AppCountComponent.new(import_issues_count))]
41-
)
40+
count = TeamCachedCounts.new(team).import_issues
41+
text_with_count("Import issues", count)
4242
end
4343

4444
def notices_text
4545
count = ImportantNotices.call(patient_scope: policy_scope(Patient)).length
46-
safe_join(["Important notices", " ", render(AppCountComponent.new(count))])
46+
47+
text_with_count("Important notices", count)
48+
end
49+
50+
def text_with_count(text, count)
51+
safe_join([text, " ", render(AppCountComponent.new(count))])
4752
end
4853
end

app/components/app_patient_pds_discrepancy_table_component.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ def initialize(discrepancies:, current_user:)
1212

1313
delegate :format_nhs_number, :govuk_table, to: :helpers
1414

15-
def can_link_to?(record)
16-
allowed_ids.include?(record.id)
17-
end
15+
def can_link_to?(record) = allowed_ids.include?(record.id)
1816

1917
def allowed_ids
2018
@allowed_ids ||= PatientPolicy::Scope.new(current_user, Patient).resolve.ids

app/components/app_patient_programmes_table_component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def vaccination_records_for(programme:, academic_year: nil)
258258
end
259259

260260
def eligible_year_groups_for(programme:)
261-
location_ids = patient.patient_sessions.joins(:session).select(:location_id)
261+
location_ids = patient.patient_locations.select(:location_id)
262262

263263
LocationProgrammeYearGroup
264264
.where(location_id: location_ids)

app/components/app_programme_session_table_component.rb

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
# frozen_string_literal: true
22

33
class AppProgrammeSessionTableComponent < ViewComponent::Base
4-
def initialize(sessions, programme:)
4+
def initialize(sessions, programme:, academic_year:)
55
@sessions = sessions
66
@programme = programme
7+
@academic_year = academic_year
78
end
89

910
private
1011

11-
attr_reader :sessions, :programme
12+
attr_reader :sessions, :programme, :academic_year
1213

1314
delegate :govuk_table, to: :helpers
1415

1516
def cohort_count(session:)
16-
format_number(patient_sessions(session:).count)
17+
format_number(patients(session:).count)
1718
end
1819

1920
def no_response_scope(session:)
20-
patient_sessions(session:).has_consent_status(:no_response, programme:)
21+
patients(session:).has_consent_status(
22+
:no_response,
23+
programme:,
24+
academic_year:
25+
)
2126
end
2227

2328
def no_response_count(session:)
@@ -27,13 +32,17 @@ def no_response_count(session:)
2732
def no_response_percentage(session:)
2833
format_percentage(
2934
no_response_scope(session:).count,
30-
patient_sessions(session:).count
35+
patients(session:).count
3136
)
3237
end
3338

3439
def triage_needed_count(session:)
3540
format_number(
36-
patient_sessions(session:).has_triage_status(:required, programme:).count
41+
patients(session:).has_triage_status(
42+
:required,
43+
programme:,
44+
academic_year:
45+
).count
3746
)
3847
end
3948

@@ -48,15 +57,22 @@ def vaccinated_count(session:)
4857
def vaccinated_percentage(session:)
4958
format_percentage(
5059
vaccinated_scope(session:).count,
51-
patient_sessions(session:).count
60+
patients(session:).count
61+
)
62+
end
63+
64+
def patients(session:)
65+
@patients ||= {}
66+
@patients[session] = session.patients.where(
67+
birth_academic_year: birth_academic_years(session:)
5268
)
5369
end
5470

55-
def patient_sessions(session:)
56-
session
57-
.patient_sessions
58-
.joins(:patient, :session)
59-
.appear_in_programmes([programme])
71+
def birth_academic_years(session:)
72+
@birth_academic_years ||= {}
73+
@birth_academic_years[session] = session.programme_birth_academic_years[
74+
programme
75+
]
6076
end
6177

6278
def format_number(count) = count.to_s

app/components/app_session_actions_component.rb

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ def render? = rows.any?
1919
delegate :govuk_summary_list, to: :helpers
2020
delegate :academic_year, :programmes, to: :session
2121

22-
def patient_sessions
23-
session
24-
.patient_sessions
25-
.joins(:patient, :session)
26-
.appear_in_programmes(programmes)
27-
end
22+
def patients = session.patients
2823

2924
def rows
3025
@rows ||= [
@@ -38,16 +33,15 @@ def rows
3833
end
3934

4035
def no_nhs_number_row
41-
count = patient_sessions.merge(Patient.without_nhs_number).count
36+
count = patients.without_nhs_number.count
4237
href = session_patients_path(session, missing_nhs_number: true)
4338

4439
generate_row(:children_without_nhs_number, count:, href:)
4540
end
4641

4742
def no_consent_response_row
4843
status = "no_response"
49-
count =
50-
patient_sessions.has_consent_status(status, programme: programmes).count
44+
count = session.patients_with_no_consent_response_count
5145
href = session_consent_path(session, consent_statuses: [status])
5246
actions = [
5347
{
@@ -61,7 +55,11 @@ def no_consent_response_row
6155
def conflicting_consent_row
6256
status = "conflicts"
6357
count =
64-
patient_sessions.has_consent_status(status, programme: programmes).count
58+
patients.has_consent_status(
59+
status,
60+
programme: programmes,
61+
academic_year:
62+
).count
6563
href = session_consent_path(session, consent_statuses: [status])
6664

6765
generate_row(:children_with_conflicting_consent_response, count:, href:)
@@ -70,7 +68,11 @@ def conflicting_consent_row
7068
def triage_required_row
7169
status = "required"
7270
count =
73-
patient_sessions.has_triage_status(status, programme: programmes).count
71+
patients.has_triage_status(
72+
status,
73+
programme: programmes,
74+
academic_year:
75+
).count
7476
href = session_triage_path(session, triage_status: status)
7577

7678
generate_row(:children_requiring_triage, count:, href:)
@@ -80,7 +82,7 @@ def register_attendance_row
8082
return nil unless session.requires_registration? && session.today?
8183

8284
status = "unknown"
83-
count = patient_sessions.has_registration_status(status).count
85+
count = patients.has_registration_status(status, session:).count
8486
href = session_register_path(session, register_status: status)
8587

8688
generate_row(:children_to_register, count:, href:)
@@ -91,13 +93,11 @@ def ready_for_vaccinator_row
9193

9294
counts_by_programme =
9395
session.programmes.index_with do |programme|
94-
patient_sessions
95-
.has_registration_status(%w[attending completed])
96-
.includes(
97-
patient: %i[consent_statuses triage_statuses vaccination_statuses]
98-
)
99-
.count do |patient_session|
100-
patient_session.patient.consent_given_and_safe_to_vaccinate?(
96+
patients
97+
.has_registration_status(%w[attending completed], session:)
98+
.includes(:consent_statuses, :triage_statuses, :vaccination_statuses)
99+
.count do |patient|
100+
patient.consent_given_and_safe_to_vaccinate?(
101101
programme:,
102102
academic_year:
103103
)

0 commit comments

Comments
 (0)