def add_data(conn, cursor, file_number, user_name): #file_row(cursor, file_number) table = "HormoneTherapy_Survival" enter = ask_y_n_statement.ask_y_n("Enter Hormone Therapy Details?") if enter: col_list = names.names_longterm(module_name="hormone") data = hormone(file_number) update_multiple(conn, cursor, table, col_list, file_number, data) enter = ask_y_n_statement.ask_y_n("Enter Recurrence and follow-up status?") if enter: col_list = names.names_longterm(module_name="metastasis") data = metastasis(file_number, user_name) update_multiple(conn, cursor, table, col_list, file_number, data)
def edit_data(conn, cursor, file_number, user_name): table = "HormoneTherapy_Survival" print("Hormone Therapy Details") col_list = names.names_longterm(module_name="hormone") enter = review_data(conn, cursor, table, file_number, col_list) if enter: data = hormone(file_number) update_multiple(conn, cursor, table, col_list, file_number, data) print("Recurrence and follow-up status") col_list = names.names_longterm(module_name="metastasis") enter = review_data(conn, cursor, table, file_number, col_list) if enter: data = metastasis(file_number, user_name) update_multiple(conn, cursor, table, col_list, file_number, data)
def metastasis(file_number, user_name): check = False while not check: met_has = ask_y_n_statement.ask_y_n( "Has the patient been examined for metastatic disease?") if not met_has: met_has = "Not examined for metastatic disease" else: met_has = "Examined for metastatic disease" date_last = input("Date of last follow-up: ") recur = ask_y_n_statement.ask_y_n( "Has the patient experienced a recurrence?") if recur: time_recur = input("Time to disease recurrence: ") nature_recur = ask_y_n_statement.ask_option( "Nature of recurrence", ["Distant", "Local", "Other"]) if nature_recur == "Distant": distant_site = input("Site of distant recurrence: ") else: distant_site = "NA" else: time_recur, nature_recur, distant_site = ("NA", ) * 3 status = patient_status() last_update = datetime.now().strftime("%Y-%b-%d %H:%M") data_list = [ met_has, date_last, time_recur, nature_recur, distant_site, status, user_name, last_update ] col_list = names.names_longterm("metastasis") check = review_input(file_number, col_list, data_list) return data_list
def db_dict(table, module): db_tables = { "Patient_Information_History": names.names_info(module), "Biopsy_Report_Data": names.names_biopsy_new(module), "Radiology": names.names_radio(module), "Neo_Adjuvant_Therapy": names.names_nact(module), "Surgery_Report": names.names_surgery_information(module), "Surgery_Block_Report_Data": names.names_surgery(module), "Adjuvant_ChemoTherapy": names.names_chemotherapy(module), "Radiotherapy": names.names_radiation(), "HormoneTherapy_Survival": names.names_longterm(module), "Follow_up_Data": names.name_follow_up() } cols = db_tables.get(table) return cols
def metastasis(file_number, user_name): check = False while not check: met_has = ask_y_n_statement.ask_y_n( "Has the patient been examined for metastatic disease?") if not met_has: met_has = "Not examined for metastatic disease" else: met_has = "Examined for metastatic disease" date_last = input("Date of last follow-up: ") recur = ask_y_n_statement.ask_y_n( "Has the patient experienced a recurrence?") if recur: time_recur = input("Time to disease recurrence: ") nature_recur = ask_y_n_statement.ask_option( "Nature of recurrence", ["Distant", "Local", "Other"]) if nature_recur == "Distant": distant_site = input("Site of distant recurrence: ") else: distant_site = "NA" else: time_recur, nature_recur, distant_site = ("NA", ) * 3 status = ask_y_n_statement.ask_option( "Status at last follow up", ["Survivor", "Deceased", "Lost to follow-up", "Other"]) if status == "Survivor": type_survivor = ask_y_n_statement.ask_option( "the Survivor is ", [ "disease Free", "with recurrence", "disease free with no known recurrence", "with disease" ]) status = status + ": " + type_survivor if status == "Deceased": type_death = ask_y_n_statement.ask_option( "Cause of death", ["due to disease", "due to unrelated causes", "not known"]) status = status + ": " + type_death last_update = datetime.now().strftime("%Y-%b-%d %H:%M") data_list = [ met_has, date_last, time_recur, nature_recur, distant_site, status, user_name, last_update ] col_list = names.names_longterm("metastasis") check = review_input(file_number, col_list, data_list) return data_list
def db_dict(table, module): db_tables = { "patient_information_history": names.names_info(module), "radiology": names.names_radio(module), 'pet_reports': names.names_pet(module), 'biopsy_path_report_data': names.names_biopsy(module), "neo_adjuvant_therapy": names.names_nact(module), "surgery_report": names.names_surgery_information(module), 'surgery_path_report_data': names.names_surgery(module), "adjuvant_chemotherapy": names.names_chemotherapy(module), "radiotherapy": names.names_radiation(), "hormonetherapy_survival": names.names_longterm(module), "follow_up_data": names.name_follow_up(), 'block_list': names.block_list(module) } cols = db_tables.get(table) return cols
def hormone(file_number): check = False while not check: hormone = ask_y_n_statement.ask_y_n("Hormone therapy indicated?") if not hormone: hormone = "Hormone therapy not indicated" hormone_recieved, hormone_date, hormone_type, hormone_duration, hormone_disc, hormone_ovary,hormone_outcome, \ hormone_follow_up, hormone_recur = ("NA", )*9 else: hormone = "Hormone therapy indicated" hormone_recieved = ask_y_n_statement.ask_y_n( "Was Hormone therapy recieved?") if hormone_recieved: hormone_recieved = "Hormone therapy recieved" hormone_date = input("Date of starting hormone therapy: ") hormone_type = ask_y_n_statement.ask_option( "Type of hormone therapy", [ "Tamoxifen", "Anastrazole", "Injectables", "Letrozole", "Others" ]) if hormone_type == "Injectables": details = input( "Please provide details of injectables recieved: ") hormone_type = hormone_type + ": " + details hormone_duration = input( "Duration of hormone therapy (years): ") hormone_disc = ask_y_n_statement.ask_option( "What is the current status of hormone therapy. " "Give specific reasons if discontinued prematurely " "(or not taken at all)", [ 'Therapy is ongoing', "Completion of planned course", "Adverse Effects", "Stopped by patient", "Progression of disease", "Other" ]) ovary = ask_y_n_statement.ask_y_n_na( "Has ovarian surpression been used?") if ovary == 'Yes': hormone_ovary = ask_y_n_statement.ask_option( "Type of ovarian surpression used", ["Surgery", "Drug"]) if hormone_ovary == "Drug": details = input( "Please provide details of drug used: ") hormone_ovary = hormone_ovary + ": " + details else: hormone_ovary = ovary hormone_outcome = input("Outcome of hormone therapy: ") hormone_follow_up = input("Follow up after hormone therapy: ") hormone_recur = ask_y_n_statement.ask_y_n( "Was there recurrence after hormone therapy?", "Recurrence", "No recurrence") else: hormone_recieved = "No hormone therapy recieved" hormone_date, hormone_type, hormone_duration, hormone_disc, hormone_ovary, hormone_outcome, \ hormone_follow_up, hormone_recur = ("NA", )*8 data_list = [ hormone, hormone_recieved, hormone_date, hormone_type, hormone_duration, hormone_disc, hormone_ovary, hormone_outcome, hormone_follow_up, hormone_recur ] col_list = names.names_longterm("hormone") check = review_input(file_number, col_list, data_list) return data_list
cols_file = "File_number, "+column cursor_all.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=cols_file)) table = "Follow_up_Data" if table_check(cursor_all, table) == 0: column = ", ".join(pccm_names.name_follow_up()) cols_file = "File_number, " + column cursor_all.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=cols_file)) table = "HormoneTherapy_Recurrence_Survival" if table_check(cursor_all, table) == 0: column = "File_number" cursor_all.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=column)) module_names = ["hormone", "metastasis"] for index in module_names: col_name = pccm_names.names_longterm(index) add_columns(cursor_all, table, col_name) table = "General_Medical_History" if table_check(cursor_all, table) == 0: columns2 = "File_number, Condition, Diagnosis_date, Treatment" cursor_all.execute('CREATE TABLE {tn}({nf})' \ .format(tn=table, nf=columns2)) table = "Family_Cancer_History" if table_check(cursor_all, table) == 0: columns3 = 'File_number, Type_Cancer, Relation_to_Patient, Type_Relation, Age_at_detection_yrs' cursor_all.execute('CREATE TABLE {tn}({nf})' \ .format(tn=table, nf=columns3)) table = "Previous_Cancer_History"
ex_file = 'Output_radiology_12062018.xlsx' path = os.path.join(folders, file) ex_path = os.path.join(folders, ex_file) conn = sqlite3.connect(path) table = "Radiotherapy" col_list = ["File_number"] + names.names_radiation() sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table + "'") df = pd.read_sql(sql, conn) writer = pd.ExcelWriter(ex_path, engine='xlsxwriter') df.to_excel(writer, sheet_name=table) table = "HormoneTherapy_Recurrence_Survival" col_list = [ "File_number" ] + names.names_longterm("hormone") + names.names_longterm("metastasis") sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table + "'") df = pd.read_sql(sql, conn) df.to_excel(writer, sheet_name="Hormone_RecurrenceSurvival") table = "Follow_up_Data" col_list = ["File_number"] + names.name_follow_up() sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table + "'") df = pd.read_sql(sql, conn) df.to_excel(writer, sheet_name=table) table = "Patient_Information_History" col_list_bio = names.names_info("bio_info") col_list = ["File_number"] + col_list_bio + names.names_info("phys_act") + names.names_info("habits") + \ names.names_info("nut_supplements") + names.names_info("family_details") + names.names_info("med_history") + \