def edit_data(conn, cursor, file_number, user_name): table = "Follow_up_Data" col_list = names.name_follow_up() enter = view_multiple(conn, table, col_list, file_number) if enter == "Add data": data = follow_up(file_number, user_name) data.to_sql("Follow_up_Data", conn, index=False, if_exists="append") if enter == "Re-enter data": table = "Follow_up_Data" col_list = ["File_number"] + names.name_follow_up() sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table + "' WHERE File_number = '" + file_number + "'") df = pd.read_sql(sql, conn) follow_up_period = list(df.loc[:, "Follow_up_Period"]) delete_data = True while delete_data: check_delete = False while not check_delete: col_data = ask_y_n_statement.ask_option( "Which entry do you want to modify?", follow_up_period) check_delete = ask_y_n_statement.ask_y_n( "Are you sure you want to delete data for follow-up period " + col_data) delete_rows(cursor, table, "Follow_up_Period", col_data) add_data(conn, file_number, user_name) delete_data = ask_y_n_statement.ask_y_n( "Do you want to re-enter another follow up period")
def mammo_asym(): import modules.ask_y_n_statement as ask_y_n_statement asym = ask_y_n_statement.ask_y_n("Is asymmetry present") if asym: asym_loc = ask_y_n_statement.ask_option( "Location of Asymmetry", ["Right Breast", "Left Breast", "Both"]) asym_quad = lesion_location(asym_loc) asym_depth = ask_y_n_statement.ask_option( "Depth of Asymmetry", ["Anterior", "Middle", "Posterior", "Other"]) asym_dist = ask_y_n_statement.ask_option( "Distance from nipple of Asymmetry", ["<0.5 cm", ">0.5 cm", "Other"]) pect_check = ask_y_n_statement.ask_y_n( "Is distance from Pectoralis Major described for Asymmetry") if pect_check: asym_pect = input("Distance from Pectoralis Major (cm): ") else: asym_pect = "NA" mammo_asymm = lesion_location(asym_loc, [ "Type of Asymmetry in Right Breast", "Type of Asymmetry in Left Breast" ], [ "Asymmetry", "Global asymmetry", "Focal asymmetry", "Developing asymmetry", "Other" ]) else: asym_quad, asym_depth, asym_dist, asym_pect, mammo_asymm = ("NA", ) * 5 asym_loc = "Not Present" data_list = [ asym_loc, asym_quad, asym_depth, asym_dist, asym_pect, mammo_asymm ] return data_list
def create_block_id(self): block_id_list = [] block_no = int(self.block_no) block_id_chunks = list(divmod(block_no, 26)) chunk = block_id_chunks[0] suffix = [i for i in range(chunk)] if chunk == 0: for j in range(block_id_chunks[1]): alph_list = string.ascii_uppercase[j] block_id_list.append(alph_list) else: for i in range(chunk): if i == chunk - 1: for j in range(block_id_chunks[1]): alph_list = string.ascii_uppercase[j] + str(i) block_id_list.append(alph_list) else: for j in range(26): alph_list = string.ascii_uppercase[j] + suffix[i] block_id_list.append(alph_list) print((", ").join(block_id_list)) check_list = ask.ask_y_n("Is block list correct?") while not check_list: block_id_list = [] for i in range(block_no): id = input('Block id of block number ' + str(i + 1) + ': ') block_id_list.append(id) print((", ").join(block_id_list)) check_list = ask.ask_y_n("Is block list correct?") return block_id_list
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 mammo_arch(): import modules.ask_y_n_statement as ask_y_n_statement mammo_arch = ask_y_n_statement.ask_y_n( "Is Architectural distortion present") if mammo_arch: mammo_arch = "Architectural distortion present" arch_loc = ask_y_n_statement.ask_option( "Location of Distortion", ["Right Breast", "Left Breast", "Both"]) arch_quad = lesion_location(arch_loc) arch_depth = ask_y_n_statement.ask_option( "Depth of Architectural Distortion", ["Anterior", "Middle", "Posterior", "Other"]) arch_dist = ask_y_n_statement.ask_option( "Distance from nipple of Architectural Distortion", ["<0.5 cm", ">0.5 cm", "Other"]) pect_check = ask_y_n_statement.ask_y_n( "Is distance from Pectoralis Major described for " "Architectural Distortion") if pect_check: arch_pect = input("Distance from Pectoralis Major (cm): ") else: arch_pect = "NA" else: mammo_arch = "Architectural distortion not present" arch_loc = "Not Present" arch_quad, arch_depth, arch_dist, arch_pect = ("Not Present", ) * 4 data_list = [ mammo_arch, arch_loc, arch_quad, arch_depth, arch_dist, arch_pect ] return data_list
def add_data(self): enter = ask.ask_y_n("Enter Surgery Block information?") if enter: data = SurgeryBlockData.surgery_block_information_1(self) col_list = names(self.module_list[0]) sql.update_multiple(self.conn, self.cursor, self.table, col_list, self.file_number, data) enter = ask.ask_y_n( "Enter Surgery Block information (Tumour Details) ?") if enter: col_list = names(self.module_list[1]) data, block_data_df = SurgeryBlockData.surgery_block_information_2( self) sql.update_multiple(self.conn, self.cursor, self.table, col_list, self.file_number, data) block_data_df.to_sql("block_data", self.conn, index=False, if_exists="append") enter = ask.ask_y_n("Enter Surgery Block information (Node Details)?") if enter: col_list = names(self.module_list[2]) data = SurgeryBlockData.surgery_block_information_3(self) sql.update_multiple(self.conn, self.cursor, self.table, col_list, self.file_number, data) enter = ask.ask_y_n("Enter Pathological Stage?") if enter: col_list = names(self.module_list[3]) data = SurgeryBlockData.path_stage(self) sql.update_multiple(self.conn, self.cursor, self.table, col_list, self.file_number, data)
def cancer_table(conn, cursor, file_number): table_cancer = "Previous_Cancer_History" type_of_cancer_list = [] year_diagnosis_list = [] treat_all = [] type_all = [] duration_all = [] data_return = [] add_cancer = True while add_cancer: type_of_cancer = input("Type of Cancer: ") type_of_cancer_list.append(type_of_cancer) year_diagnosis = input("Year of diagnosis: ") year_diagnosis_list.append(year_diagnosis) col = ("File_number, Type_Cancer, Year_diagnosis") data = file_number, type_of_cancer, year_diagnosis insert(conn, cursor, table_cancer, col, data) print("Please enter the type of treatment used: ") treatment = [ "Surgery", "Radiation", "Chemotherapy", "Hormone", "Alternative", "HomeRemedy" ] treat_list = [] type_list = [] duration_list = [] treated, type, duration = ("NA", ) * 3 for index in treatment: treat = ask_y_n(index) if treat: treat_list.append(index) type_treat = input("Type of " + index) type_list.append(type_treat) duration_treat = input("Duration of " + index) duration_list.append(duration_treat) data = index, type_treat, duration_treat columns = [index, ("Type_" + index), ("Duration_" + index)] treated = "; ".join(treat_list) type = "; ".join(type_list) duration = "; ".join(duration_list) update_multiple(conn, cursor, table_cancer, columns, file_number, data) elif not treat: index_no = "No " + index type_treat, duration_treat = ("NA", ) * 2 data = index_no, type_treat, duration_treat columns = [index, ("Type_" + index), ("Duration_" + index)] update_multiple(conn, cursor, table_cancer, columns, file_number, data) treat_all.append(treated) type_all.append(type) duration_all.append(duration) add_cancer = ask_y_n("Additional cancer history") all_data = [ type_of_cancer_list, year_diagnosis_list, treat_all, type_all, duration_all ] for index in all_data: data_joint = "|".join(index) data_return.append(data_joint) return tuple(data_return)
def edit_table(df, id_col, df_col): rows = df.shape[0] for row in range(0, rows): print(df.iloc[row].to_string() + '\n') to_correct = ask.ask_y_n("Are entries correct?") if not to_correct: to_correct = ask.ask_y_n("Re-enter entire table?") if to_correct: return to_correct, df else: change_row = True while change_row: id_list = list(df[id_col]) print(id_list) id_change = input("Enter " + id_col + " to change: ") index = id_list.index(id) to_do = True while to_do: print(df.loc[index, :]) col_change = ask.ask_option("Name of column to change", df_col) old_val = df.loc[index, col_change] print(old_val + '\n') new_val = input("Enter correct value for " + col_change + ' for ' + id_change + ": ") df.loc[index, col_change] = new_val print(df.iloc[index].to_string() + '\n') to_do = ask.ask_y_n("Make more changes to " + id_col + ' ' + id_change + '?') ReviewSQL.print_df(df) change_row = ask.ask_y_n("Change another row?") to_correct = False return to_correct, df
def add_data(self): enter = ask.ask_y_n("Enter Biopsy Block Report information?") if enter: data = BiopsyData.biopsy_report_info(self) sql.update_multiple(self.conn, self.cursor, self.table, names("biopsy_report_info"), self.file_number, data) enter = ask.ask_y_n("Enter Tumour Biopsy data?") if enter: data = BiopsyData.tumour_biopsy_data(self) sql.update_multiple(self.conn, self.cursor, self.table, names("tumour_biopsy_data"), self.file_number, data)
def tox_table(file_number, drug_cyc, tox_all): tox_index = 0 check_tox = False while not check_tox: tox = ask_y_n_statement.ask_y_n( "Were there any toxic effects in administration of " + drug_cyc) if tox: add_tox = True while add_tox: tox_present = ask_y_n_statement.ask_option( "Toxic effects of type", chemo.toxicity()) tox_grade = ask_y_n_statement.ask_option( ("the grade of " + tox_present + "? "), ["Mild", "Moderate", "Severe", "Other"]) treatment = input("Treatment given for " + tox_grade + " " + tox_present + " (include all details): ") resp_treatment = ask_y_n_statement.ask_option( ("Response to treatment given for " + tox_grade + " " + tox_present), ["Partial", "Complete", "No Effect", "Other"]) cyc_tox = input("Cycle at which toxicity occurred: ") change_tox = ask_y_n_statement.ask_option( "Changes to treatment", [ "No change", "Therapy changed due to toxicity", "Therapy stopped due to toxicity", "Therapy changed due to other reasons", "Therapy stopped due to other reasons" ]) if change_tox == "Therapy changed due to toxicity" or change_tox == "Therapy changed due to other "\ "reasons": change = input("Please describe changes to Therapy: ") change_tox = change_tox + ": " + change check = False while not check: data = [ file_number, drug_cyc, tox_present, tox_grade, treatment, resp_treatment, cyc_tox, change_tox ] tox_all.loc[tox_index] = data check = review_df_row(tox_all) tox_index = tox_index + 1 add_tox = ask_y_n_statement.ask_y_n( 'Add another toxicity type?') else: tox_present, tox_grade, treatment, resp_treatment, cyc_tox, change_tox = ( "No Toxicity", ) * 6 data = [ file_number, drug_cyc, tox_present, tox_grade, treatment, resp_treatment, cyc_tox, change_tox ] tox_all.loc[tox_index] = data check_tox = review_df(tox_all) return tox_all
def habits(file_number): module_name = "habits" check = False while not check: category = "Diet" options = ["Vegetarian", "Non-Vegetarian", "Ovo-Vegetarian", "Other"] diet = ask_option(category, options) alcohol = ask_y_n("Alcohol consumption") if alcohol: alcohol_consump = "Alcohol Consumption" alcohol_age = input("Consumption of alcohol from which age (yrs): ") alcohol_quant = input("Quantity of alcohol consumed per week: ") alcohol_duration = input("Duration of alcohol consumption: ") alcohol_comments = input("Additional comments for alcohol consumption: ") else: alcohol_consump = "No Alcohol Consumption" alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments = ("NA",) * 4 data_list_alc = [diet, alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments] tobacco = ask_y_n("Tobacco exposure (Passive and/or Active)") if tobacco: tobacco = "Tobacco consumption" exposure_type = ask_option("Mode of exposure to Tobacco", ["Passive", "Active", "Other"]) if exposure_type =="Passive": tobacco_type_partic = ask_option("Mode of passive consumption", ["Home", "Work", "Commute", "Social Interactions"]) if tobacco_type_partic == "Home": tobacco_type_who = input ("What is the specific source?") tobacco_passive = tobacco_type_partic + (" : ") + tobacco_type_who else: tobacco_passive = tobacco_type_partic else: tobacco_passive = "NA" tobacco_type = ask_option("Type of tobacco use", ["Cigarette", "Beedi", "Gutkha", "Pan Masala", "Jarda/Maava", "Hookah", "Nicotine Patch", "Mishri", "Other"]) tobacco_age = input("Consumption of tobacco from which age (yrs): ") tobacco_freq = input ("Frequency of tobacco consumption: ") tobacco_quant = input("Quantity of tobacco consumed per week: ") tobacco_duration = input("Duration of tobacco consumption: ") tobacco_comments = input("Additional comments for tobacco consumption: ") else: tobacco = "No Tobacco Consumption" exposure_type, tobacco_type, tobacco_passive, tobacco_age, tobacco_freq, tobacco_quant, tobacco_duration, \ tobacco_comments = ("NA",) * 8 other_del_habits = input("Other Deleterious Habits (if present give details): ") data_list_tob = [tobacco, exposure_type, tobacco_passive,tobacco_type, tobacco_age, tobacco_freq, tobacco_quant, tobacco_duration, tobacco_comments, other_del_habits] columns_list = pccm_names.names_info(module_name) data_list = data_list_alc + data_list_tob check = review_input(file_number, columns_list, data_list) return (tuple(data_list))
def stage(pt, pn, m): path_stage = "pT" + pt + "N" + pn + 'M' + m clinical_stage = 'NA' print("Pathological Stage: " + path_stage) check = ask.ask_y_n("Is pathological stage correct") if not check: path_stage = input("Please enter correct pathological stage: ") if m in {"1", "2", "3"}: clinical_stage = "IV" elif m == "0": if pn == "3": clinical_stage = "IIIC" elif pn == "2": if pt == "4": clinical_stage = "IIIB" else: clinical_stage = "IIIA" elif pn == "1mi": clinical_stage = "IB" elif pn == "1": if pt == "0" or pt == "1": clinical_stage = "IIA" elif pt == "2": clinical_stage = "IIB" elif pt == "3": clinical_stage = "IIIA" elif pt == "4": clinical_stage = "IIIB" else: clinical_stage = input("Clinical Staging: ") elif pn == "0": if pt == "is": clinical_stage = "0" elif pt == "1": clinical_stage = "IA" elif pt == "2": clinical_stage = "IIA" elif pt == "3": clinical_stage = "IIB" elif pt == "4": clinical_stage = "IIIB" else: clinical_stage = input("Clinical Staging: ") print("Clinical stage " + clinical_stage) print( "Based on TNM status", path_stage, "and TABLE 2 of Giuliano et al., 2017, CA CANCER J " "CLIN 2017;67:290–303") check = ask.ask_y_n("Is clinical stage correct") if not check: clinical_stage = input("Please enter correct clinical stage: ") return path_stage, clinical_stage
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 follow_up(file_number, user_name): follow = True follow_index = 0 col_list = ["File_number"] + names.name_follow_up() follow_up_data = pd.DataFrame(columns=col_list) while follow: check = False while not check: time_follow = ask_y_n_statement.ask_option("Follow-up Period", [ "3 months", "6 months", "9 months", "1 year", "1 year, 3 months", "1 year, 6 months", "1 year, 9 months", "2 years", "2 years, 6 months", "3 years", "3 years, 6 months", "4 years", "4 years, 6 months", "5 years", "6 years", "7 years", "8 years", "9 years", "10 years", "Other" ]) follow_notes = input("Details of follow up information: ") follow_report = ask_y_n_statement.ask_y_n( "Does follow-up contain other reports (USG/Mammography)?") follow_mammo, follow_usg = ("NA", ) * 2 if follow_report: follow_mammo = input("Results of Mammography: ") follow_usg = input("Results of USG abdomen/Pelvis: ") follow_other = ask_y_n_statement.ask_y_n( "Are there other reports in follow-up?") if not follow_other: other_type, other_result = ("NA", ) * 2 else: other_type_list = [] other_result_list = [] while follow_other: other_type = input("Type of other report: ") other_result = input("Result of " + other_type + ": ") other_type_list.append(other_type) other_result_list.append(other_result) follow_other = ask_y_n_statement.ask_y_n( "Add more reports?") all_data = [other_type_list, other_result_list] all_data = ask_y_n_statement.join_lists(all_data, "; ") other_type, other_result = all_data last_update = datetime.now().strftime("%Y-%b-%d %H:%M") data_list = [ file_number, time_follow, follow_notes, follow_mammo, follow_usg, other_type, other_result, user_name, last_update ] follow_up_data.loc[follow_index] = data_list check = review_df(follow_up_data.loc[follow_index]) follow_index = follow_index + 1 follow_up_period = list(follow_up_data.loc[:, "Follow_up_Period"]) print("Follow up periods added: " + "; ".join(follow_up_period)) follow = ask_y_n_statement.ask_y_n("Add another follow-up period?") return follow_up_data
def family_cancer_table(conn, cursor, file_number): add_family = True type_cancer_list, relation_degree_list, type_relation_list, age_detect_list = [], [], [], [] all_data = [] while add_family: type_of_cancer = input("Type of Cancer: ") type_cancer_list.append(type_of_cancer) relation_to_patient = ask_option( "Relation to patient", ["Immediate Family", "Maternal Family", "Paternal Family"]) relation_degree_list.append(relation_to_patient) type_relation = input("Specific Relationship:") type_relation_list.append(type_relation) age_at_detection_yrs = input('Age at detection (yrs) :') age_detect_list.append(age_at_detection_yrs) family_history = file_number, type_of_cancer, relation_to_patient, type_relation, age_at_detection_yrs family_history_list = "; ".join([ type_of_cancer, relation_to_patient, type_relation, age_at_detection_yrs ]) all_data.append(family_history_list) columns = 'File_number, Type_Cancer, Relation_to_Patient, Type_Relation, Age_at_detection_yrs' table = "Family_Cancer_History" insert(conn, cursor, table, columns, family_history) add_family = ask_y_n("Add more family cancer history? ") all_data_flat = "|".join(all_data) return (all_data_flat)
def clinical_tests(test): import modules.ask_y_n_statement as ask_y_n_statement test_name = test[0] data_list = [] test_done = ask_y_n_statement.ask_y_n("Has " + test_name + " been done?") if test_done: test_done = test_name + " done" data_list.append(test_done) for index in range(1, len(test)): abnormal = test[index] test_diag = ask_y_n_statement.ask_option("Diagnosis", ["Normal", abnormal]) data_list.append(test_diag) if test_diag == abnormal: test_details = input("Please provide details of " + abnormal + " diagnosis: ") else: test_details = "NA" data_list.append(test_details) else: test_done = test_name + " not done" data_list.append(test_done) for index in range(1, len(test)): not_done = ("NA", ) * 2 data_list.append(not_done) return data_list
def birads(): import modules.ask_y_n_statement as ask_y_n_statement mammo_birads = ask_y_n_statement.ask_option( "BI-RADS", ["0", "I", "II", "III", "IV", "IVA", "IVB", "IVC", "V", "Other"]) check = False while not check: if mammo_birads == "0": mammo_birads_det = "Incomplete – Need Additional Imaging Evaluation" elif mammo_birads == "I": mammo_birads_det = "Negative" elif mammo_birads == "II": mammo_birads_det = "Benign" elif mammo_birads == "III": mammo_birads_det = "Probably Benign" elif mammo_birads == "IV": mammo_birads_det = "Suspicious" elif mammo_birads == "IVA": mammo_birads_det = "Low suspicion for malignancy" elif mammo_birads == "IVB": mammo_birads_det = "Moderate suspicion for malignancy" elif mammo_birads == "IVC": mammo_birads_det = "High suspicion for malignancy" elif mammo_birads == "V": mammo_birads_det = "Highly Suggestive of Malignancy" else: mammo_birads_det = input("Details of BI-RADS category: ") print("BI-RAD " + mammo_birads + ": " + mammo_birads_det) check = ask_y_n_statement.ask_y_n("Is this correct?") data_list = [mammo_birads, mammo_birads_det] return tuple(data_list)
def tox_table(file_number, cyc_name, week, drug_cyc): import modules.ask_y_n_statement as ask_y_n_statement import additional_tables.chemo as chemo import pandas as pd import modules.pccm_names as names from sql.add_update_sql import review_df as review tox_all = pd.DataFrame(columns=names.names_nact("Tox_table")) tox_index = 0 drugs = "/".join(drug_cyc) check_tox = False while not check_tox: tox = ask_y_n_statement.ask_y_n("Were there any toxic effects in " + week + " of " + cyc_name) tox_grade_list, tox_list, tox_treatment, resp_treatment_list = [ list([]) for _ in range(4) ] if tox: for index in chemo.toxicity(): tox_grade = ask_y_n_statement.ask_option( ("the grade of " + index + " in " + cyc_name + "? "), ["Mild", "Moderate", "Severe", "Not Present", "Other"]) if tox_grade not in {"Not Present"}: tox = index check = False while not check: treatment = input("Treatment given for " + tox_grade + " " + index + " (include all details): ") resp_treatment = ask_y_n_statement.ask_option( ("Response to treatment given for " + tox_grade + " " + index), ["Partial", "Complete", "No Effect", "Other"]) data = [ file_number, week, cyc_name, drugs, tox, tox_grade, treatment, resp_treatment ] tox_all.loc[tox_index] = data check = review(tox_all.loc[tox_index]) tox_grade_list.append(tox_grade) tox_list.append(index) tox_treatment.append(treatment) resp_treatment_list.append(resp_treatment) tox_index = tox_index + 1 else: tox = "No Toxicity" tox_grade, treatment, resp_treatment = ("NA", ) * 3 tox_list = ["No Toxicity"] tox_grade_list, tox_treatment, resp_treatment_list = [["NA"]] * 3 data = [ file_number, week, cyc_name, drugs, tox, tox_grade, treatment, resp_treatment ] tox_all.loc[tox_index] = data all_data = [ tox_grade_list, tox_list, tox_treatment, resp_treatment_list ] response = ask_y_n_statement.join_lists(all_data, "; ") check_tox = review(tox_all) return response
def drug_add(file_number, cyc_name, cycle_number, week, patient_wt, drug_per_week, drug_index): import modules.ask_y_n_statement as ask from sql.add_update_sql import review_df as review import additional_tables.chemo as chemo drug_add = True drug_cyc = [] while drug_add: check_drug = False while not check_drug: drug = ask.ask_option("Drug used for therapy " + cyc_name, chemo.drug_list()) dose = input("Dose of " + drug + " in " + week + " of " + cyc_name + ": ") dose_unit = input("Dose unit: ") cyc_freq = input("Cycle Frequency: ") data_week = [ file_number, cycle_number, week, patient_wt, drug, float(dose), dose_unit, cyc_freq ] drug_per_week.loc[drug_index] = data_week check_drug = review(drug_per_week.loc[drug_index]) drug_cyc.append(drug) drug_index = drug_index + 1 drug_add = ask.ask_y_n("Add another drug") return drug_per_week, drug_cyc, drug_index
def birads(): import modules.ask_y_n_statement as ask_y_n_statement check = False while not check: mammo_birads = ask_y_n_statement.ask_option("BI-RADS Category", [ "Category 0", "Category 1", "Category 2", "Category 3", "Category 4", "Category 4A", "Category 4B", "Category 4C", "Category 5", "Other" ]) if mammo_birads == "Category 0": mammo_birads_det = "Incomplete – Need Additional Imaging Evaluation" elif mammo_birads == "Category 1": mammo_birads_det = "Negative" elif mammo_birads == "Category 2": mammo_birads_det = "Benign" elif mammo_birads == "Category 3": mammo_birads_det = "Probably Benign" elif mammo_birads == "Category 4": mammo_birads_det = "Suspicious" elif mammo_birads == "Category 4A": mammo_birads_det = "Low suspicion for malignancy" elif mammo_birads == "Category 4B": mammo_birads_det = "Moderate suspicion for malignancy" elif mammo_birads == "Category 4C": mammo_birads_det = "High suspicion for malignancy" elif mammo_birads == "Category 5": mammo_birads_det = "Highly Suggestive of Malignancy" else: mammo_birads_det = input("Details of BI-RADS category: ") birad = mammo_birads + ": " + mammo_birads_det print(birad) check = ask_y_n_statement.ask_y_n("Is this correct?") data_list = birad return data_list
def abvs(file_number): module_name = "abvs" check = False while not check: abvs = ask_y_n_statement.ask_y_n("Automated Breast Volume Scanner (ABVS) done?") if abvs: abvs = "Automated Breast Volume Scanner done" abvs_date = input("Date of examination of ABVS: ") abvs_acc = input("Accession number of ABVS: ") abvs_lesion = ask_y_n_statement.ask_option("Location of lesion", ["Right Breast", "Left Breast", "Both", "Not present"]) if abvs_lesion in {"Right Breast", "Left Breast", "Both"}: abvs_lesion_data = radio_tables_old.lesion_location(abvs_lesion) else: abvs_lesion_data = "NA" abvs_size = ask_y_n_statement.ask_option("Size of lesion", ["<2 cm", "2-5 cm", ">5 cm", "Other"]) abvs_dist = ask_y_n_statement.ask_option("Distance from Skin (cm)", ["<0.5 cm", ">0.5 cm", "Other"]) abvs_pect = input("Distance from Pectoralis Major (cm): ") abvs_diagnosis = ask_y_n_statement.ask_option("ABVS Diagnosis", ["Normal", "Benign", "Suspicious", "Diagnostic for Cancer"]) else: abvs = "Automated Breast Volume Scanner done" abvs_date, abvs_acc, abvs_lesion, abvs_lesion_data, abvs_size, abvs_dist, abvs_pect, \ abvs_diagnosis = ("NA",) * 8 data_list = [abvs, abvs_date, abvs_acc, abvs_lesion, abvs_lesion_data, abvs_size, abvs_dist, abvs_pect, abvs_diagnosis] columns_list = names(module_name) check = add_update_sql.review_input(file_number, columns_list, data_list) return (tuple(data_list))
def print_table(self, writer, table): modules = table_dicts.table_module_dict(table) if table == 'Patient_Information_History': output_type = ask_y_n('Do you want a research print out for ' + table + '?') if output_type: modules = table_dicts.table_module_research(table) columns = [] if not modules: modules = 'no_modules' columns = table_dicts.db_dict(table, modules) else: for module in modules: cols = table_dicts.db_dict(table, module) columns = columns + cols if table != 'Block_list': col_list = table_dicts.create_col_list(columns) else: col_list = columns sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'") df = pd.read_sql(sql, self.conn) number = df.shape[0] df.to_excel(writer, sheet_name=table, startrow=0, index=False, header=True) return number
def drug_table_enter(file_number, drug_table): drug_add = True drug_index = 0 while drug_add: check_drug= False while not check_drug: drug = ask_y_n_statement.ask_option("Drug used for therapy", chemo.drug_list()) try: dose = input("Dose of " + drug +" (actual dose ammount without unit, numbers only): ") dose_x = float(dose) except: print ('ERROR: enter numbers only') dose = input("Dose of " + drug +" (actual dose ammount without unit, numbers only): ") dose_unit = input("Dose unit: ") cyc_freq_week = input("Cycle Frequency (frequency per week, so three weekly is 3 and weekly is 1): ") try: number_cycle = input("Number of cycles actually given: ") dose_x = int(number_cycle) except: print('ERROR: enter numbers only') number_cycle = input("Number of cycles actually given: ") try: drug_dose = float(dose) * int(number_cycle) except: drug_dose = 'PLEASE RE-ENTER DATA, DOSE AND NUMBER OF CYCLES MUST BE DIGITS ONLY' data_drug = [file_number, number_cycle, drug, str(drug_dose), dose_unit, cyc_freq_week] drug_table.loc[drug_index] = data_drug check_drug, drug_table = review_df_row(drug_table) drug_index = drug_index + 1 drug_add = ask_y_n_statement.ask_y_n("Add another drug") return drug_table
def review_input(self): col_number = len(self.data) print("Entries for database are as follows : ") for index in range(0, col_number): print(self.columns[index] + ": " + self.data[index]) ans = ask.ask_y_n("Are entries for file " + self.file_number + " correct ?", True, False) return ans
def check_file(conn, cursor, table, file_number, user_name, folders): import modules.ask_y_n_statement as ask_y_n_statement import add_edit.add_new as add_new import add_edit.edit_record as edit_record sql = "SELECT rowid FROM " + table + " WHERE File_number = ?" cursor.execute(sql, (file_number, )) data = cursor.fetchall() if len(data) == 0: if table != "Follow_up_Data": cursor.execute("INSERT INTO " + table + "(File_number) VALUES ('" + file_number + "')") print(file_number + " does not exist in table " + table + ". Enter new record") add_new.add_new(conn, cursor, file_number, table, user_name, folders) else: todo = ask_y_n_statement.ask_option( file_number + " already exists in table " + table + ".", [ "Edit record", "Add new record for same file number", "Edit None" ]) if todo == "Edit record": edit_record.edit_record(conn, cursor, file_number, table, user_name, folders) elif todo == "Add new record for same file number": print("Add additional record module TBD") ask = ask_y_n_statement.ask_y_n("Add another table?") return ask
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 review_df_row(df): check_row = len(df) - 1 print(df.iloc[check_row].to_string()) check = ask.ask_y_n("Is data entered correct?") if check: return check, df else: df = df.drop(df.index[check_row]) return check, df
def add_data(conn, cursor, file_number, user_name): table = "Clinical_Exam" #file_row(cursor, file_number) enter =ask_y_n_statement.ask_y_n("Enter Clinical Examination information") if enter: data = clinical_exam_initial(file_number, user_name) add_update_sql.update_multiple(conn, cursor, table, pccm_names.name_clinical("clinical_exam_initial"), file_number, data) enter = ask_y_n_statement.ask_y_n("Enter Nipple Cytology report?") if enter: data = nipple_cytology(file_number) add_update_sql.update_multiple(conn, cursor, table, pccm_names.name_clinical("nipple_cytology"), file_number, data) enter = ask_y_n_statement.ask_y_n("Enter results of other clinical tests?") if enter: data = other_test(file_number) add_update_sql.update_multiple(conn, cursor, table, pccm_names.name_clinical("other_test"), file_number, data)
def review_input(file_number, columns, data): import modules.ask_y_n_statement as ask_y_n_statement col_number = len(data) print("Entries for database are as follows : ") for index in range(0, col_number): print(columns[index] + ": " + data[index]) ans = ask_y_n_statement.ask_y_n( "Are entries for file " + file_number + " correct ?", True, False) return ans
def review_data(conn, cursor, table, file_number, col_list): import modules.ask_y_n_statement as ask sql = ('SELECT ' + ", ".join(col_list) + ' FROM ' + table + " WHERE File_number = '" + file_number + "'") data = cursor.execute(sql) data_list = data.fetchall() data_list = list(data_list[0]) col_number = len(col_list) if data_list == [None] * len(data_list): print("This section of the database has not been entered") enter = ask.ask_y_n("Do you want to enter now") return enter if None in set(data_list): print("Some entries are missing from the database: ") for index in range(0, col_number): print(col_list[index] + " : " + str(data_list[index])) enter = ask.ask_option("Do you want to proceed?", ["Edit all", "Add new data only"]) if enter == "Edit all": return True else: edit_few(conn, cursor, table, col_list, file_number, data_list) else: print("Entries present in database are as follows : ") for index in range(0, col_number): print(col_list[index] + " : " + str(data_list[index])) enter = ask.ask_option("Do you want to", ["Edit all", "Edit some entries", "Edit None"]) if enter == "Edit some entries": for index in range(0, col_number): print(col_list[index] + " : " + str(data_list[index])) edit = ask.ask_y_n("Edit") if edit: data = input("Data for " + col_list[index] + ": ") update_single(conn, cursor, table, col_list[index], file_number, data) return False elif enter == "Edit all": return True else: return False