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 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
if table_check(cursor, table) == 0: cursor.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf='pk')) module_names = [ 'pet_report_identifier', 'pet_report_findings', 'pet_breast_cancer' ] for index in module_names: col_name = pccm_names.names_pet(index) add_columns(cursor, table, col_name) print(table + ' created') table = "surgery_report" if table_check(cursor, table) == 0: module_names = ["surgery_information", "node_excision", "post_surgery"] cursor.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=file_number)) for index in module_names: col_name = pccm_names.names_surgery_information(index) add_columns(cursor, table, col_name) print(table + ' created') table = "general_medical_history" if table_check(cursor, table) == 0: columns2 = "file_number, Condition, Diagnosis_date, Treatment" cursor.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=columns2)) print(table + ' created') table = "family_cancer_history" if table_check(cursor, table) == 0: columns3 = 'file_number, type_cancer, relation_to_patient, type_relation, age_at_detection_yrs' cursor.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=columns3)) print(table + ' created')
df.to_excel(writer, sheet_name=table, index=False) writer.save() table = "Radiology" sql = "SELECT File_number FROM '" + table + "'" df = pd.read_sql(sql, conn) df_list = list(df['File_number']) module_names = [ "mammography", "tomosynthesis", "abvs", "sonomammo", "mri_breast" ] col_list = ["File_number"] for index in module_names: col_list = col_list + names.names_radio(index) sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'") df = pd.read_sql(sql, conn) df.to_excel(writer, sheet_name=table, index=False) writer.save() table = "Surgery_Report" sql = "SELECT File_number FROM '" + table + "'" df = pd.read_sql(sql, conn) df_list = list(df['File_number']) module_names = ["surgery_information", "node_excision", "post_surgery"] col_list = ["File_number"] for index in module_names: col_list = col_list + names.names_surgery_information(index) sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'") df = pd.read_sql(sql, conn) df.to_excel(writer, sheet_name=table, index=False) writer.save()