@@ -298,19 +298,19 @@ def get_early_subject_to_be_invited_for_surveillance(
298298 FROM screening_subject_t ss
299299 INNER JOIN sd_contact_t c ON ss.subject_nhs_number = c.nhs_number
300300 WHERE c.responsible_sc_id = :screeningCentreId
301- AND c.deduction_reason IS NULL
302- AND c.date_of_death IS NULL
303- AND TRUNC (ss.surveillance_screen_due_date) <= TO_DATE(:sDueCountDate, 'DD/MM/YYYY')
304- AND ss.screening_status_id = 4006
305- AND c.date_of_death IS NULL
306- AND NOT EXISTS (
307- SELECT 1
308- FROM ep_subject_episode_t ep
309- WHERE ep.screening_subject_id = ss.screening_subject_id
310- AND ep.episode_status_id IN (11352, 11354)
311- )
312- ORDER BY TRUNC(ss.surveillance_screen_due_date)
313- FETCH FIRST 1 ROW ONLY
301+ AND c.deduction_reason IS NULL
302+ AND c.date_of_death IS NULL
303+ AND TRUNC (ss.surveillance_screen_due_date) <= TO_DATE(:sDueCountDate, 'DD/MM/YYYY')
304+ AND ss.screening_status_id = 4006
305+ AND c.date_of_death IS NULL
306+ AND NOT EXISTS (
307+ SELECT 1
308+ FROM ep_subject_episode_t ep
309+ WHERE ep.screening_subject_id = ss.screening_subject_id
310+ AND ep.episode_status_id IN (11352, 11354)
311+ )
312+ ORDER BY TRUNC(ss.surveillance_screen_due_date)
313+ FETCH FIRST 1 ROW ONLY
314314 """
315315 parameters = {
316316 "screeningCentreId" : int (screening_centre_id ),
0 commit comments