Skip to content

Commit b3527ad

Browse files
authored
Merge pull request #6449 from NHSDigital/needs-consent-sub-statuses-attempt-no-contact-details
Add `needs_consent_no_contact_details` status and supporting logic
2 parents 00fc9d0 + f2736e3 commit b3527ad

24 files changed

Lines changed: 164 additions & 42 deletions

app/components/app_patient_session_consent_component.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
<p><%= who_refused %> refused to give consent.</p>
2020
<% elsif consent_status_generator.status == :given %>
2121
<p><%= patient.full_name %> is ready for the vaccinator.</p>
22+
<% elsif consent_status_value == :no_contact_details %>
23+
<p>We cannot send consent requests because we have no parent contact details.</p>
2224
<% end %>
2325

2426
<div class="nhsuk-button-group">

app/components/app_patient_session_consent_component.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ def initialize(patient:, session:, programme:)
55
@patient = patient
66
@session = session
77
@programme = programme
8+
@parents = patient.parents
89
end
910

1011
private
1112

12-
attr_reader :patient, :session, :programme
13+
attr_reader :patient, :session, :programme, :parents
1314

1415
delegate :academic_year, :team, to: :session
1516

@@ -61,7 +62,8 @@ def consent_status_generator
6162
academic_year:,
6263
patient:,
6364
consents:,
64-
vaccination_records:
65+
vaccination_records:,
66+
parents:
6567
)
6668
end
6769

@@ -73,7 +75,8 @@ def triage_status_generator
7375
patient:,
7476
consents:,
7577
triages:,
76-
vaccination_records:
78+
vaccination_records:,
79+
parents:
7780
)
7881
end
7982

@@ -116,7 +119,7 @@ def vaccination_records
116119
def can_send_consent_request?
117120
consent_status_value == :no_response &&
118121
patient.send_notifications?(team: @session.team) &&
119-
session.can_receive_consent? && patient.parents.any?
122+
session.can_receive_consent? && patient.parents.any?(&:contactable?)
120123
end
121124

122125
def grouped_consents

app/components/app_patient_session_triage_component.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def initialize(
1313
@programme = programme
1414
@current_user = current_user
1515
@triage_form = triage_form || default_triage_form
16+
@parents = patient.parents
1617
end
1718

1819
def render?
@@ -22,7 +23,12 @@ def render?
2223

2324
private
2425

25-
attr_reader :patient, :session, :programme, :current_user, :triage_form
26+
attr_reader :patient,
27+
:session,
28+
:programme,
29+
:current_user,
30+
:triage_form,
31+
:parents
2632

2733
delegate :academic_year, :team, to: :session
2834

@@ -70,7 +76,8 @@ def triage_status_generator
7076
patient:,
7177
consents:,
7278
triages:,
73-
vaccination_records:
79+
vaccination_records:,
80+
parents:
7481
)
7582
end
7683

@@ -81,7 +88,8 @@ def consent_status_generator
8188
academic_year:,
8289
patient:,
8390
consents:,
84-
vaccination_records:
91+
vaccination_records:,
92+
parents:
8593
)
8694
end
8795

app/forms/triage_form.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ def consent_status_generator
129129
academic_year:,
130130
patient:,
131131
consents: patient.consents,
132-
vaccination_records: []
132+
vaccination_records: [],
133+
parents: []
133134
)
134135
end
135136

app/lib/patient_status_updater.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def update_programme_statuses!
4848
:patient,
4949
:patient_locations,
5050
:triages,
51-
:vaccination_records
51+
:vaccination_records,
52+
:parents
5253
)
5354
.find_in_batches(batch_size: 10_000) do |batch|
5455
batch.each(&:assign)

app/lib/status_generator/consent.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ def initialize(
66
academic_year:,
77
patient:,
88
consents:,
9-
vaccination_records:
9+
vaccination_records:,
10+
parents:
1011
)
1112
@programme_type = programme_type
1213
@academic_year = academic_year
1314
@patient = patient
1415
@consents = consents
1516
@vaccination_records = vaccination_records
17+
@parents = parents
1618
end
1719

1820
def programme
@@ -28,6 +30,8 @@ def status
2830
:follow_up_requested
2931
elsif status_should_be_conflicts?
3032
:conflicts
33+
elsif status_should_be_no_contact_details?
34+
:no_contact_details
3135
elsif status_should_be_no_response?
3236
:no_response
3337
else
@@ -57,7 +61,8 @@ def disease_types
5761
:academic_year,
5862
:patient,
5963
:consents,
60-
:vaccination_records
64+
:vaccination_records,
65+
:parents
6166

6267
def vaccinated?
6368
return @vaccinated if defined?(@vaccinated)
@@ -122,6 +127,10 @@ def status_should_be_conflicts?
122127

123128
def status_should_be_no_response? = !vaccinated?
124129

130+
def status_should_be_no_contact_details?
131+
parents.none?(&:contactable?)
132+
end
133+
125134
def agreed_vaccine_methods
126135
@agreed_vaccine_methods ||=
127136
consents_for_status.map(&:vaccine_methods).inject(&:intersection)

app/lib/status_generator/programme.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def initialize(
1616
consents:,
1717
triages:,
1818
attendance_record:,
19-
vaccination_records:
19+
vaccination_records:,
20+
parents:
2021
)
2122
@programme_type = programme_type
2223
@academic_year = academic_year
@@ -25,6 +26,8 @@ def initialize(
2526
@consents = consents
2627
@triages = triages
2728
@attendance_record = attendance_record
29+
@vaccination_records = vaccination_records
30+
@parents = parents
2831

2932
@vaccination_criteria =
3033
VaccinationCriteria.new(
@@ -54,6 +57,8 @@ def status
5457
:cannot_vaccinate_absent
5558
elsif should_be_cannot_vaccinate_do_not_vaccinate?
5659
:cannot_vaccinate_do_not_vaccinate
60+
elsif should_be_needs_consent_no_contact_details?
61+
:needs_consent_no_contact_details
5762
elsif should_be_needs_consent_no_response?
5863
:needs_consent_no_response
5964
elsif should_be_cannot_vaccinate_delay_vaccination?
@@ -166,7 +171,8 @@ def consent_vaccine_methods
166171
:consents,
167172
:triages,
168173
:attendance_record,
169-
:vaccination_criteria
174+
:vaccination_criteria,
175+
:parents
170176

171177
delegate :vaccinated?,
172178
:vaccinated_vaccination_record,
@@ -238,6 +244,10 @@ def should_be_needs_consent_request_not_scheduled?
238244
false # TODO: Implement this status.
239245
end
240246

247+
def should_be_needs_consent_no_contact_details?
248+
is_eligible? && consent_status == :no_contact_details
249+
end
250+
241251
def year_group = patient.year_group(academic_year:)
242252

243253
def is_eligible?
@@ -285,7 +295,8 @@ def consent_generator
285295
academic_year:,
286296
patient:,
287297
consents:,
288-
vaccination_records:
298+
vaccination_records:,
299+
parents:
289300
)
290301
end
291302

@@ -297,7 +308,8 @@ def triage_generator
297308
patient:,
298309
consents:,
299310
triages:,
300-
vaccination_records:
311+
vaccination_records:,
312+
parents:
301313
)
302314
end
303315
end

app/lib/status_generator/triage.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ def initialize(
77
patient:,
88
consents:,
99
triages:,
10-
vaccination_records:
10+
vaccination_records:,
11+
parents:
1112
)
1213
@programme_type = programme_type
1314
@academic_year = academic_year
1415
@patient = patient
1516
@consents = consents
1617
@triages = triages
1718
@vaccination_records = vaccination_records
19+
@parents = parents
1820
end
1921

2022
def programme
@@ -77,7 +79,8 @@ def vaccination_history_requires_triage?
7779
:patient,
7880
:consents,
7981
:triages,
80-
:vaccination_records
82+
:vaccination_records,
83+
:parents
8184

8285
def vaccinated?
8386
return @vaccinated if defined?(@vaccinated)
@@ -129,7 +132,8 @@ def consent_generator
129132
academic_year:,
130133
patient:,
131134
consents:,
132-
vaccination_records:
135+
vaccination_records:,
136+
parents:
133137
)
134138
end
135139

app/models/draft_vaccination_record.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ def vaccine_method_matches_consent_and_triage?
351351
academic_year:,
352352
patient:,
353353
consents: patient.consents,
354-
vaccination_records: []
354+
vaccination_records: [],
355+
parents: []
355356
)
356357

357358
triage_generator =
@@ -361,7 +362,8 @@ def vaccine_method_matches_consent_and_triage?
361362
patient:,
362363
consents: patient.consents,
363364
triages: patient.triages,
364-
vaccination_records: []
365+
vaccination_records: [],
366+
parents: []
365367
)
366368

367369
approved_vaccine_methods =

app/models/patient/programme_status.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class Patient::ProgrammeStatus < ApplicationRecord
6363
through: :patient,
6464
source: :attendance_records
6565

66+
has_many :parents, through: :patient
67+
6668
GROUPS = %w[
6769
not_eligible
6870
needs_consent
@@ -80,7 +82,8 @@ class Patient::ProgrammeStatus < ApplicationRecord
8082
"needs_consent_request_scheduled" => 11,
8183
"needs_consent_request_failed" => 12,
8284
"needs_consent_no_response" => 13,
83-
"needs_consent_follow_up_requested" => 14
85+
"needs_consent_follow_up_requested" => 14,
86+
"needs_consent_no_contact_details" => 15
8487
}.freeze
8588

8689
HAS_REFUSAL_STATUSES = {
@@ -126,7 +129,8 @@ class Patient::ProgrammeStatus < ApplicationRecord
126129
refused: 2,
127130
conflicts: 3,
128131
not_required: 4,
129-
follow_up_requested: 5
132+
follow_up_requested: 5,
133+
no_contact_details: 6
130134
},
131135
default: :no_response,
132136
prefix: :consent,
@@ -195,7 +199,8 @@ def generator
195199
consents:,
196200
triages:,
197201
attendance_record:,
198-
vaccination_records:
202+
vaccination_records:,
203+
parents:
199204
)
200205
end
201206
end

0 commit comments

Comments
 (0)