@@ -28,7 +28,7 @@ def find_by_nhs_number(self, nhs_number: str) -> Optional[bool]:
2828 return None
2929 return True
3030
31- def create_pi_subject (self , pio_id : int , pi_subject : " PISubject" ) -> Optional [int ]:
31+ def create_pi_subject (self , pio_id : int , pi_subject : PISubject ) -> Optional [int ]:
3232 """
3333 Creates a new screening subject, returning the contact id.
3434
@@ -54,7 +54,7 @@ def create_pi_subject(self, pio_id: int, pi_subject: "PISubject") -> Optional[in
5454
5555 return self .process_pi_subject (pio_id , pi_subject )
5656
57- def process_pi_subject (self , pio_id : int , pi_subject : " PISubject" ) -> Optional [int ]:
57+ def process_pi_subject (self , pio_id : int , pi_subject : PISubject ) -> Optional [int ]:
5858 """
5959 Processes a PI subject using the PKG_SSPI.p_process_pi_subject stored procedure.
6060
@@ -98,7 +98,7 @@ def process_pi_subject(self, pio_id: int, pi_subject: "PISubject") -> Optional[i
9898
9999 return new_contact_id
100100
101- def update_pi_subject (self , pi_subject : " PISubject" ) -> None :
101+ def update_pi_subject (self , pi_subject : PISubject ) -> None :
102102 """
103103 Updates an existing screening subject.
104104
@@ -134,14 +134,14 @@ def get_active_gp_practice_in_hub_and_sc(
134134 Returns:
135135 Optional[str]: GP practice org code.
136136 """
137- query = (
138- " SELECT gp.org_code AS gp_code "
139- " FROM org gp "
140- " INNER JOIN gp_practice_current_links gpl ON gpl.gp_practice_id = gp.org_id "
141- " INNER JOIN org hub ON hub.org_id = gpl.hub_id "
142- " INNER JOIN org sc ON sc.org_id = gpl.sc_id "
143- " WHERE hub.org_code = :hub_code AND sc.org_code = :sc_code"
144- )
137+ query = """
138+ SELECT gp.org_code AS gp_code
139+ FROM org gp
140+ INNER JOIN gp_practice_current_links gpl ON gpl.gp_practice_id = gp.org_id
141+ INNER JOIN org hub ON hub.org_id = gpl.hub_id
142+ INNER JOIN org sc ON sc.org_id = gpl.sc_id
143+ WHERE hub.org_code = :hub_code AND sc.org_code = :sc_code
144+ """
145145 df = self .oracle_db .execute_query (
146146 query , {"hub_code" : hub_code , "sc_code" : screening_centre_code }
147147 )
@@ -156,12 +156,12 @@ def get_inactive_gp_practice(self) -> Optional[str]:
156156 Returns:
157157 Optional[str]: GP practice org code.
158158 """
159- query = (
160- " SELECT gp.org_code AS gp_code "
161- " FROM org gp "
162- " LEFT OUTER JOIN gp_practice_current_links gpl ON gpl.gp_practice_id = gp.org_id "
163- " WHERE gp.org_type_id = 1009 AND gpl.gp_practice_id IS NULL"
164- )
159+ query = """
160+ SELECT gp.org_code AS gp_code
161+ FROM org gp
162+ LEFT OUTER JOIN gp_practice_current_links gpl ON gpl.gp_practice_id = gp.org_id
163+ WHERE gp.org_type_id = 1009 AND gpl.gp_practice_id IS NULL
164+ """
165165 df = self .oracle_db .execute_query (query )
166166 if df .empty :
167167 return None
@@ -177,15 +177,15 @@ def get_latest_gp_practice_for_subject(self, nhs_number: str) -> Optional[str]:
177177 Returns:
178178 Optional[str]: GP practice org code.
179179 """
180- query = (
181- " SELECT gp.org_code AS gp_code "
182- " FROM sd_contact_t c "
183- " INNER JOIN subject_in_org sio ON sio.contact_id = c.contact_id "
184- " INNER JOIN org gp ON gp.org_id = sio.org_id "
185- " WHERE c.nhs_number = :nhs_number "
186- " AND sio.org_type_id = 1009 "
187- " AND sio.sio_id = (SELECT MAX(siox.sio_id) FROM subject_in_org siox WHERE siox.contact_id = c.contact_id AND siox.org_type_id = 1009)"
188- )
180+ query = """
181+ SELECT gp.org_code AS gp_code
182+ FROM sd_contact_t c
183+ INNER JOIN subject_in_org sio ON sio.contact_id = c.contact_id
184+ INNER JOIN org gp ON gp.org_id = sio.org_id
185+ WHERE c.nhs_number = :nhs_number
186+ AND sio.org_type_id = 1009
187+ AND sio.sio_id = (SELECT MAX(siox.sio_id) FROM subject_in_org siox WHERE siox.contact_id = c.contact_id AND siox.org_type_id = 1009)
188+ """
189189 df = self .oracle_db .execute_query (query , {"nhs_number" : nhs_number })
190190 if df .empty :
191191 return None
0 commit comments