Skip to content

Commit e0361af

Browse files
Adressing comment on PR#6: oracle.py lines 23-25
1 parent 56b9819 commit e0361af

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

pages/batch_list_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ def __init__(self, page):
5858

5959
class ArchivedBatchList(BatchList):
6060
def __init__(self, page):
61-
super().__init__(page)
61+
super().__init__(page)

utils/oracle/oracle.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ def exec_bcss_timed_events(self, nhs_number_df): # Executes bcss_timed_events w
2727
conn = self.connect_to_db()
2828
try:
2929
for index, row in nhs_number_df.iterrows():
30-
logging.info(f"Attempting to get subject_id from nhs number: {row["subject_nhs_number"]}")
31-
cursor = conn.cursor()
32-
cursor.execute(
33-
f"SELECT SCREENING_SUBJECT_ID FROM SCREENING_SUBJECT_T WHERE SUBJECT_NHS_NUMBER = {int(row["subject_nhs_number"])}")
34-
result = cursor.fetchall()
35-
subject_id = result[0][0]
36-
logging.info(f"Able to extract subject ID: {subject_id}")
30+
subject_id = self.get_subject_id_from_nhs_number(row["subject_nhs_number"])
3731
try:
3832
logging.info(
3933
f"Attempting to execute stored procedure: {f"'bcss_timed_events', [{subject_id},'Y']"}")
@@ -49,6 +43,17 @@ def exec_bcss_timed_events(self, nhs_number_df): # Executes bcss_timed_events w
4943
conn.close()
5044
logging.info("Connection closed")
5145

46+
def get_subject_id_from_nhs_number(self, nhs_number) -> str:
47+
conn = self.connect_to_db()
48+
logging.info(f"Attempting to get subject_id from nhs number: {nhs_number}")
49+
cursor = conn.cursor()
50+
cursor.execute(
51+
f"SELECT SCREENING_SUBJECT_ID FROM SCREENING_SUBJECT_T WHERE SUBJECT_NHS_NUMBER = {int(nhs_number)}")
52+
result = cursor.fetchall()
53+
subject_id = result[0][0]
54+
logging.info(f"Able to extract subject ID: {subject_id}")
55+
return subject_id
56+
5257
def populate_ui_approved_users_table(self, user: str): # To add users to the UI_APPROVED_USERS table
5358
conn = self.connect_to_db()
5459
try:
@@ -93,7 +98,7 @@ def execute_query(self, query: str) -> pd.DataFrame: # To use when "select xxxx
9398
if conn is not None:
9499
conn.close()
95100
logging.info("Connection Closed - Returning results")
96-
return df
101+
return df
97102

98103
def execute_stored_procedure(self, procedure: str): # To use when "exec xxxx" (stored procedures)
99104
conn = self.connect_to_db()

utils/oracle/oracle_specific_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def get_nhs_no_from_batch_id(batch_id) -> pd.DataFrame:
2929
AND ss.screening_status_id != 4008
3030
ORDER BY ss.subject_nhs_number
3131
""")
32-
return nhs_number_df
32+
return nhs_number_df

0 commit comments

Comments
 (0)