Skip to content

Commit 4133714

Browse files
authored
Merge pull request #5152 from nhsuk/next
Version 5.6.0
2 parents 2ae9d6d + 686f393 commit 4133714

321 files changed

Lines changed: 2758 additions & 1101 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.

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Layout/EmptyLineAfterMagicComment:
1919
Enabled: true
2020

2121
Layout/LineLength:
22-
AllowedPatterns: [idx_on,index_]
22+
AllowedPatterns: [idx_on,index_,idx_]
2323
Exclude:
2424
- db/schema.rb
2525

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ group :test do
112112
gem "capybara-screenshot"
113113
gem "climate_control"
114114
gem "cuprite"
115+
gem "database_cleaner-active_record"
115116
gem "its"
116117
gem "rack_session_access"
117118
gem "rspec"

Gemfile.lock

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
GIT
22
remote: https://github.com/citizensadvice/capybara_accessible_selectors.git
3-
revision: bd3019acc7be517423b97e8cd71bc3cff06f2cce
3+
revision: 5b9ce7840d04270e99f4f0cb03989e05437326a6
44
specs:
5-
capybara_accessible_selectors (0.14.0)
5+
capybara_accessible_selectors (0.15.0)
66
capybara (~> 3.36)
77

88
GIT
@@ -115,8 +115,8 @@ GEM
115115
ast (2.4.3)
116116
attr_required (1.0.2)
117117
aws-eventstream (1.4.0)
118-
aws-partitions (1.1179.0)
119-
aws-sdk-accessanalyzer (1.80.0)
118+
aws-partitions (1.1181.0)
119+
aws-sdk-accessanalyzer (1.81.0)
120120
aws-sdk-core (~> 3, >= 3.234.0)
121121
aws-sigv4 (~> 1.5)
122122
aws-sdk-core (3.236.0)
@@ -127,7 +127,7 @@ GEM
127127
bigdecimal
128128
jmespath (~> 1, >= 1.6.1)
129129
logger
130-
aws-sdk-ec2 (1.569.0)
130+
aws-sdk-ec2 (1.571.0)
131131
aws-sdk-core (~> 3, >= 3.234.0)
132132
aws-sigv4 (~> 1.5)
133133
aws-sdk-ecr (1.112.0)
@@ -142,7 +142,7 @@ GEM
142142
aws-sdk-rds (1.297.0)
143143
aws-sdk-core (~> 3, >= 3.234.0)
144144
aws-sigv4 (~> 1.5)
145-
aws-sdk-s3 (1.202.0)
145+
aws-sdk-s3 (1.203.0)
146146
aws-sdk-core (~> 3, >= 3.234.0)
147147
aws-sdk-kms (~> 1)
148148
aws-sigv4 (~> 1.5)
@@ -159,7 +159,7 @@ GEM
159159
bindex (0.8.1)
160160
bootsnap (1.18.6)
161161
msgpack (~> 1.2)
162-
brakeman (7.1.0)
162+
brakeman (7.1.1)
163163
racc
164164
builder (3.3.0)
165165
capybara (3.40.0)
@@ -200,6 +200,10 @@ GEM
200200
cuprite (0.17)
201201
capybara (~> 3.0)
202202
ferrum (~> 0.17.0)
203+
database_cleaner-active_record (2.2.2)
204+
activerecord (>= 5.a)
205+
database_cleaner-core (~> 2.0)
206+
database_cleaner-core (2.0.1)
203207
date (3.5.0)
204208
date_time_precision (0.8.1)
205209
debug (1.11.0)
@@ -611,9 +615,9 @@ GEM
611615
ruby-prof (1.7.2)
612616
base64
613617
ruby-progressbar (1.13.0)
614-
rubyXL (3.4.33)
618+
rubyXL (3.4.35)
615619
nokogiri (>= 1.10.8)
616-
rubyzip (>= 1.3.0)
620+
rubyzip (>= 3.2.2)
617621
rubyntlm (0.6.5)
618622
base64
619623
rubyzip (3.2.2)
@@ -800,6 +804,7 @@ DEPENDENCIES
800804
cssbundling-rails
801805
csv
802806
cuprite
807+
database_cleaner-active_record
803808
debug
804809
devise
805810
discard

app/components/app_session_actions_component.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,7 @@ def ready_for_vaccinator_row
130130
count:,
131131
programme: programme.name_in_sentence
132132
)
133-
href =
134-
session_record_path(
135-
session,
136-
search_form: {
137-
programme_types: [programme.type]
138-
}
139-
)
133+
href = session_record_path(session, programme_types: [programme.type])
140134
count.positive? ? helpers.link_to(text, href) : text
141135
end
142136
end

app/components/app_session_dates_table_component.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ def tally_vaccination_counts_for_date(session_date)
6060

6161
def count_by_vaccine_method(vaccination_records)
6262
nasal_spray_count =
63-
vaccination_records.count { it.vaccine.method == "nasal" }
64-
injection_count =
65-
vaccination_records.count { it.vaccine.method == "injection" }
63+
vaccination_records.count(&:delivery_method_nasal_spray?)
64+
injection_count = vaccination_records.count(&:delivery_method_injection?)
6665
[nasal_spray_count, injection_count]
6766
end
6867

@@ -79,11 +78,12 @@ def compute_total_tallies
7978
def vaccination_records_by_date(programme)
8079
@vaccination_records_by_date ||= {}
8180
@vaccination_records_by_date[programme.id] ||= VaccinationRecord
81+
.administered
82+
.kept
8283
.where(
8384
programme:,
8485
session:,
85-
patient_id: patients_for_programme(programme),
86-
outcome: :administered
86+
patient_id: patients_for_programme(programme)
8787
)
8888
.group_by { |record| record.performed_at.to_date }
8989
end

app/components/app_session_overview_tallies_component.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@
6868
</div>
6969
<% end %>
7070
</section>
71+
7172
<section>
7273
<%= render AppCardComponent.new do |card| %>
7374
<% card.with_heading(level: 3) { "Action required" } %>
7475
<%= render AppSessionActionsComponent.new(session, show_heading: false) %>
7576
<% end %>
7677
</section>
78+
7779
<section>
7880
<%= render AppCardComponent.new do |card| %>
7981
<% card.with_heading(level: 3) { session.clinic? ? "About this clinic" : "About this school" } %>

app/components/app_session_overview_tallies_component.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,25 @@ def cards_for_programme(programme)
4444
.map do |key, value|
4545
string_key = key.to_s
4646
{
47-
heading: card_heading_for(string_key),
47+
heading: card_heading_for(string_key, programme:),
4848
colour: card_colour_for(string_key),
4949
count: value.to_s,
5050
link_to: card_link_to_for(string_key, programme:)
5151
}
5252
end
5353
end
5454

55-
def card_heading_for(key)
55+
def card_heading_for(key, programme:)
5656
if key.starts_with?("consent_")
5757
I18n.t(key[8..], scope: %i[status consent label])
5858
elsif key == "vaccinated"
59-
I18n.t("status.vaccination.label.vaccinated")
59+
if programme.mmr?
60+
# TODO: Apply this to all multi-dose programmes (Td/IPV) once we
61+
# have confidence in the change.
62+
"Fully vaccinated"
63+
else
64+
I18n.t("status.vaccination.label.vaccinated")
65+
end
6066
end
6167
end
6268

app/controllers/api/reporting/totals_controller.rb

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
66
academic_year: :academic_year,
77
programme: :programme_type,
88
organisation_id: :organisation_id,
9-
gender: :patient_gender_code,
9+
gender: :patient_gender,
1010
year_group: :patient_year_group,
1111
school_local_authority: :patient_school_local_authority_code,
1212
local_authority: :patient_local_authority_code
@@ -16,14 +16,14 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
1616
local_authority: :patient_local_authority_code,
1717
school: :patient_school_name,
1818
year_group: :patient_year_group,
19-
gender: :patient_gender_code
19+
gender: :patient_gender
2020
}.freeze
2121

2222
GROUP_HEADERS = {
2323
patient_local_authority_code: "Local Authority",
2424
patient_school_name: "School",
2525
patient_year_group: "Year Group",
26-
patient_gender_code: "Gender"
26+
patient_gender: "Gender"
2727
}.freeze
2828

2929
METRIC_HEADERS = {
@@ -33,7 +33,12 @@ class API::Reporting::TotalsController < API::Reporting::BaseController
3333
vaccinated_by_sais: "Vaccinated by SAIS",
3434
vaccinated_elsewhere_declared: "Vaccinated Elsewhere (Declared)",
3535
vaccinated_elsewhere_recorded: "Vaccinated Elsewhere (Recorded)",
36-
vaccinated_previously: "Vaccinated Previously"
36+
vaccinated_previously: "Vaccinated Previously",
37+
consent_given: "Consent Given",
38+
consent_no_response: "No Consent Response",
39+
consent_conflicts: "Conflicting Consent",
40+
parent_refused_consent: "Parent Refused Consent",
41+
child_refused_vaccination: "Child Refused Vaccination"
3742
}.freeze
3843

3944
before_action :set_default_filters, :set_filters, :set_scope
@@ -119,7 +124,14 @@ def render_format_json
119124
@scope.vaccinated_elsewhere_recorded_count,
120125
vaccinated_previously: @scope.vaccinated_previously_count,
121126
vaccinations_given: @scope.vaccinations_given_count,
122-
monthly_vaccinations_given: @scope.monthly_vaccinations_given
127+
monthly_vaccinations_given: @scope.monthly_vaccinations_given,
128+
consent_given: @scope.consent_given_count,
129+
consent_no_response: @scope.consent_no_response_count,
130+
consent_conflicts: @scope.consent_conflicts_count,
131+
parent_refused_consent: @scope.parent_refused_consent_count,
132+
child_refused_vaccination: @scope.child_refused_vaccination_count,
133+
refusal_reasons: consent_refusal_reasons,
134+
consent_routes: consent_routes_breakdown
123135
}
124136
end
125137

@@ -155,4 +167,34 @@ def apply_default_year_group_filter
155167

156168
@scope = @scope.where(Arel::Nodes::Exists.new(subquery))
157169
end
170+
171+
def consent_refusal_reasons
172+
Consent
173+
.joins(:patient)
174+
.where(
175+
patient_id: @scope.select(:patient_id),
176+
programme_id: @scope.select(:programme_id).distinct,
177+
academic_year: @scope.select(:academic_year).distinct,
178+
response: :refused
179+
)
180+
.not_invalidated
181+
.not_withdrawn
182+
.group(:reason_for_refusal)
183+
.count
184+
end
185+
186+
def consent_routes_breakdown
187+
Consent
188+
.joins(:patient)
189+
.where(
190+
patient_id: @scope.select(:patient_id),
191+
programme_id: @scope.select(:programme_id).distinct,
192+
academic_year: @scope.select(:academic_year).distinct
193+
)
194+
.not_invalidated
195+
.not_withdrawn
196+
.response_provided
197+
.group(:route)
198+
.count
199+
end
158200
end

app/controllers/api/testing/reporting_refresh_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class API::Testing::ReportingRefreshController < API::Testing::BaseController
44
def create
5-
ReportingAPI::PatientProgrammeStatus.refresh!
6-
redirect_to "/reports"
5+
ReportingAPI::RefreshJob.perform_later
6+
render status: :accepted
77
end
88
end

app/controllers/application_controller.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ApplicationController < ActionController::Base
2323
before_action :set_app_navigation
2424

2525
after_action :verify_policy_scoped, if: -> { Rails.env.local? }
26+
after_action :set_navigation_counts_cookie
2627

2728
class UnprocessableEntity < StandardError
2829
end
@@ -99,4 +100,19 @@ def set_privacy_policy_url
99100
def set_sentry_user
100101
Sentry.set_user(id: current_user&.id)
101102
end
103+
104+
# Used by Reporting to display counts in their header
105+
def set_navigation_counts_cookie
106+
return unless current_user
107+
108+
unmatched_consent_responses = cached_counts.unmatched_consent_responses || 0
109+
school_moves = cached_counts.school_moves || 0
110+
imports = cached_counts.import_issues || 0
111+
112+
cookies[:mavis_navigation_counts] = {
113+
unmatched_consent_responses:,
114+
school_moves:,
115+
imports:
116+
}.to_json
117+
end
102118
end

0 commit comments

Comments
 (0)