@@ -16,10 +16,7 @@ def initialize(
1616 consents :,
1717 triages :,
1818 attendance_record :,
19- vaccination_records :,
20- parents :,
21- consent_notifications :,
22- notify_log_entries :
19+ vaccination_records :
2320 )
2421 @programme_type = programme_type
2522 @academic_year = academic_year
@@ -28,10 +25,6 @@ def initialize(
2825 @consents = consents
2926 @triages = triages
3027 @attendance_record = attendance_record
31- @vaccination_records = vaccination_records
32- @parents = parents
33- @consent_notifications = consent_notifications
34- @notify_log_entries = notify_log_entries
3528
3629 @vaccination_criteria =
3730 VaccinationCriteria . new (
@@ -61,10 +54,6 @@ def status
6154 :cannot_vaccinate_absent
6255 elsif should_be_cannot_vaccinate_do_not_vaccinate?
6356 :cannot_vaccinate_do_not_vaccinate
64- elsif should_be_needs_consent_no_contact_details?
65- :needs_consent_no_contact_details
66- elsif should_be_needs_consent_request_failed?
67- :needs_consent_request_failed
6857 elsif should_be_needs_consent_no_response?
6958 :needs_consent_no_response
7059 elsif should_be_cannot_vaccinate_delay_vaccination?
@@ -79,6 +68,8 @@ def status
7968 :has_refusal_consent_refused
8069 elsif should_be_needs_consent_follow_up_requested?
8170 :needs_consent_follow_up_requested
71+ elsif should_be_needs_consent_request_failed?
72+ :needs_consent_request_failed
8273 elsif should_be_needs_consent_request_scheduled?
8374 :needs_consent_request_scheduled
8475 elsif should_be_needs_consent_request_not_scheduled?
@@ -169,10 +160,7 @@ def consent_vaccine_methods
169160 :consents ,
170161 :triages ,
171162 :attendance_record ,
172- :vaccination_criteria ,
173- :parents ,
174- :consent_notifications ,
175- :notify_log_entries
163+ :vaccination_criteria
176164
177165 delegate :vaccinated? ,
178166 :vaccinated_vaccination_record ,
@@ -207,8 +195,7 @@ def should_be_cannot_vaccinate_do_not_vaccinate?
207195 end
208196
209197 def should_be_needs_consent_no_response?
210- is_eligible? && consent_notifications_requested? &&
211- consent_status == :no_response
198+ is_eligible? && consent_status == :no_response
212199 end
213200
214201 def should_be_cannot_vaccinate_delay_vaccination?
@@ -234,49 +221,15 @@ def should_be_needs_consent_follow_up_requested?
234221 end
235222
236223 def should_be_needs_consent_request_failed?
237- is_eligible? && consent_request_failed?
224+ false # TODO: Implement this status.
238225 end
239226
240227 def should_be_needs_consent_request_scheduled?
241- is_eligible? && parents_contactable? && !consent_notifications_requested? &&
242- sessions . any? { it . send_consent_requests_at &.present? }
228+ false # TODO: Implement this status.
243229 end
244230
245231 def should_be_needs_consent_request_not_scheduled?
246- is_eligible? && parents_contactable? && !consent_notifications_requested? &&
247- ( sessions . empty? || sessions . any? { it . send_consent_requests_at . nil? } )
248- end
249-
250- def should_be_needs_consent_no_contact_details?
251- is_eligible? && !parents_contactable?
252- end
253-
254- def parents_contactable? = parents . any?
255-
256- def consent_notifications_requested?
257- @consent_notifications_requested ||=
258- consent_notifications . any? do |notification |
259- notification . programme_types . include? ( programme . type ) &&
260- notification . session &.team_location &.academic_year == academic_year
261- end
262- end
263-
264- def consent_request_failed?
265- date_range = academic_year . to_academic_year_date_range
266-
267- notify_log_entries . any? do |entry |
268- next false unless entry . patient_id == patient . id
269- next false unless date_range . cover? ( entry . created_at . to_date )
270- next false unless notify_log_entry_matches_programme_type? ( entry )
271-
272- entry . delivery_status . to_s . include? ( "failure" )
273- end
274- end
275-
276- def notify_log_entry_matches_programme_type? ( entry )
277- entry . notify_log_entry_programmes . any? do |programme |
278- programme . programme_type == programme_type
279- end
232+ false # TODO: Implement this status.
280233 end
281234
282235 def year_group = patient . year_group ( academic_year :)
@@ -341,16 +294,4 @@ def triage_generator
341294 vaccination_records :
342295 )
343296 end
344-
345- def sessions
346- @sessions ||=
347- patient_locations . flat_map do |patient_location |
348- patient_location
349- . location
350- . team_locations
351- . select { it . academic_year == academic_year }
352- . flat_map ( &:sessions )
353- . select { it . programme_types . include? ( programme_type ) }
354- end
355- end
356297end
0 commit comments