1010
1111
1212class SSPIChangeSteps :
13+ def __init__ (self ) -> None :
14+ self .subject_repo = SubjectRepository ()
15+
1316 def sspi_update_to_change_dob_received (
1417 self , nhs_no : str , age_to_change_to : int
1518 ) -> None :
@@ -45,7 +48,6 @@ def process_sspi_deduction_by_code(self, nhs_no: str, deduction_code: str) -> No
4548 if DeductionReasonType .by_deduction_code (deduction_code ) is None :
4649 raise ValueError (f"Unknown Deduction Code: { deduction_code } " )
4750
48- subject_repo = SubjectRepository ()
4951 pi_subject = PISubject ().from_subject (subject )
5052
5153 if subject is not None :
@@ -67,7 +69,7 @@ def process_sspi_deduction_by_code(self, nhs_no: str, deduction_code: str) -> No
6769 elif deduction_code in ["LDN" , "R/C" ]:
6870 # Logical deletion requires a "superseded by" NHS number
6971 subject_criteria : Dict [str , str ] = {"Screening Status" : "Call" }
70- superseded_subject = subject_repo .get_matching_subject (
72+ superseded_subject = self . subject_repo .get_matching_subject (
7173 subject_criteria , Subject (), User ()
7274 )
7375 if not superseded_subject :
@@ -100,12 +102,11 @@ def reregister_subject_with_latest_gp_practice(self, nhs_no) -> None:
100102 method_name = "reregister_subject_with_latest_gp_practice"
101103 logging .debug (f"start: { method_name } ()" )
102104
103- subject_repo = SubjectRepository ()
104105 subject = Subject ().populate_subject_object_from_nhs_no (nhs_no )
105106 pi_subject = PISubject ().from_subject (subject )
106107
107108 if subject is not None :
108- gp_code = subject_repo .get_latest_gp_practice_for_subject (nhs_no )
109+ gp_code = self . subject_repo .get_latest_gp_practice_for_subject (nhs_no )
109110 logging .debug (f"Set GP code to { gp_code } and remove all deduction details" )
110111
111112 pi_subject .gp_practice_code = gp_code
@@ -132,13 +133,12 @@ def handle_update(
132133 """
133134 logging .debug ("start: handle_update(Subject, date)" )
134135
135- subject_repo = SubjectRepository ()
136136 pi_subject .pi_reference = "AUTOMATED TEST"
137137 # Check if a date of birth change needs to be made first
138138 if birth_date is not None :
139139 pi_subject .birth_date = birth_date
140140
141141 # Run the update into the DB (SSPI updates are always run as automated process user 2)
142- subject_repo .update_pi_subject (2 , pi_subject )
142+ self . subject_repo .update_pi_subject (2 , pi_subject )
143143
144144 logging .debug ("exit: handle_update()" )
0 commit comments