def med_history(conn, cursor, file_number, table): from breast_cancer_tables import med_history_table from ask_y_n_statement import ask_y_n from add_update_sql import update_multiple, review_input check = False while not check: medical_history_y_n = ask_y_n("Other Medical History ?") if medical_history_y_n: med_hist = med_history_table(conn, cursor, file_number) medical_history_y_n = "Previous medical history present" else: medical_history_y_n = "No previous medical history present" med_hist = ("NA", ) * 3 condition_hist, diagnosis_date_hist, treatment_hist = med_hist data_list = [ medical_history_y_n, condition_hist, diagnosis_date_hist, treatment_hist ] columns_list = [ "Any_Other_Medical_History_y_n", "Type_Any_Other_Medical_History", "Diagnosis_Date_Any_Other_Medical_History", "Treatment_Any_Other_Medical_History" ] check = review_input(file_number, columns_list, data_list) data = medical_history_y_n, condition_hist, diagnosis_date_hist, treatment_hist columns = "Any_Other_Medical_History_y_n", "Type_Any_Other_Medical_History", "Diagnosis_Date_Any_Other_Medical_History", "Treatment_Any_Other_Medical_History" update_multiple(conn, cursor, table, columns, file_number, data)
def node_block(conn, cursor, file_number, table): from ask_y_n_statement import ask_option from add_update_sql import update_multiple sent_data = node_details("Sentinel") sentinel, sent_number_rem, sent_number_pos, sent_number = sent_data print("Sentinel Node " + sent_number) ax_data = node_details("Axillary") ax, ax_number_rem, ax_number_pos, ax_number = ax_data print("Axillary Node " + ax_number) ap_data = node_details("Apical") ap, ap_number_rem, ap_number_pos, ap_number = ap_data print("Apical Node " + ap_number) category = "Perinodal Spread" options = ["Yes", "No"] per_spread = ask_option(category, options) category = "Supraclavicular Node Involvment" options = ["Yes", "No"] supra_inv = ask_option(category, options) data = sentinel, sent_number_rem, sent_number_pos, sent_number, ax, ax_number_rem, ax_number_pos, ax_number, ap, \ ap_number_rem, ap_number_pos, ap_number, per_spread, supra_inv columns = "Sentinel_Node_Block_Report", "Sentinel_Node_Number_Removed", "Sentinel_Node_Number_Positive", \ "Sentinel_Node_Block_Report_Number", "Axillary_Node_Block_Report", "Axillary_Node_Number_Removed", \ "Axillary_Node_Number_Positive", "Axillary_Node_Block_Report_Number", "Apical_Node_Block_Report", \ "Apical_Node_Number_Removed", "Apical_Node_Number_Positive", "Apical_Node_Block_Report_Number", \ "Perinodal_Spread_Node_Block_Report", "Supraclavicular_Involved_Node_Block_Report" update_multiple(conn, cursor, table, columns, file_number, data)
def breast_symptoms(conn, cursor, file_number, table): from ask_y_n_statement import get_symptom, get_rb_lb, ask_y_n from add_update_sql import update_multiple from breast_cancer_tables import other_symp symp_state = "Pain or tenderness", "Lumps", "Nipple Discharge", "Nipple Retraction", "Dimpling", \ "Discolouration", "Ulceration", "Eczema" symptoms = get_symptom(symp_state) rb = get_rb_lb(symptoms, 0) rb_symp = list(filter(None, get_rb_lb(rb, 0))) rb_dur = list(filter(None, get_rb_lb(rb, 1))) lb = get_rb_lb(symptoms, 1) lb_symp = list(filter(None, get_rb_lb(lb, 0))) lb_dur = list(filter(None, get_rb_lb(lb, 1))) data = [rb_symp, rb_dur, lb_symp, lb_dur] for index in range(0, len(data)): if not data[index]: data[index] = ["NA"] else: data[index] = ["; ".join(data[index])] data_flat = [item for sublist in data for item in sublist] new_data = tuple(data_flat) columns = "RB_symptoms", "RB_symptoms_duration", "LB_symptoms", "LB_symptoms_duration" update_multiple(conn, cursor, table, columns, file_number, new_data) other_symptom = ask_y_n("Other Symptoms?", True, False) if other_symptom: other_symp(conn, cursor, file_number, table) else: other_symptom = "No other symptoms" other_symp_dur = "NA" data = (other_symptom, other_symp_dur, other_symptom, other_symp_dur) columns = "RB_Other_Symptoms", "RB_Other_Symptoms_duration", "LB_Other_Symptoms", "RB_Other_Symptoms_duration" update_multiple(conn, cursor, table, columns, file_number, data)
def cancer_history(conn, cursor, file_number, table): from breast_cancer_tables import cancer_table from add_update_sql import update_multiple, review_input from ask_y_n_statement import ask_y_n check = False while not check: previous_cancer_history_y_n = ask_y_n("Previous history of cancer ?") if previous_cancer_history_y_n: previous_cancer = cancer_table(conn, cursor, file_number) previous_cancer_history_y_n = "Previous history of cancer" else: previous_cancer_history_y_n = "No previous history of cancer" previous_cancer = ("NA", ) * 5 type_of_cancer_list, year_diagnosis_list, treat_all, type_all, duration_all = previous_cancer data_list = [ previous_cancer_history_y_n, type_of_cancer_list, year_diagnosis_list, treat_all, type_all, duration_all ] columns_list = ["Previous_Cancer_History_y_n", "Type_Previous_Cancer", "Year_Diagnosed_Previous_Cancer", \ "Treatment_Previous_Cancer", "Treatment_Type_Previous_Cancer", "Treatment_Duration_Previous_Cancer"] check = review_input(file_number, columns_list, data_list) data = previous_cancer_history_y_n, type_of_cancer_list, year_diagnosis_list, treat_all, type_all, duration_all columns = "Previous_Cancer_History_y_n", "Type_Previous_Cancer", "Year_Diagnosed_Previous_Cancer", \ "Treatment_Previous_Cancer", "Treatment_Type_Previous_Cancer", "Treatment_Duration_Previous_Cancer" update_multiple(conn, cursor, table, columns, file_number, data)
def family_details(conn, cursor, file_number, table): from add_update_sql import update_multiple, review_input from ask_y_n_statement import ask_y_n check = False while not check: marital_status = input('Marital Status :') siblings = ask_y_n('Siblings') if siblings: siblings_number = input("Number of siblings: ") sisters = input('Sisters :') brothers = input('Brothers :') else: siblings_number, sisters, brothers = "No Siblings", "0", "0" children_y_n = ask_y_n('Children') if children_y_n: children_number = input("Number of children: ") daughters = input('Daughters :') sons = input('Sons :') else: children_number, daughters, sons = "No Children", "0", "0" columns_list = ["Marital_Status", "Siblings", "Sisters", "Brothers", "Children", "Daughters", "Sons"] data_list = [marital_status, siblings_number, sisters, brothers, children_number, daughters, sons] check = review_input(file_number, columns_list, data_list) columns = "Marital_Status", "Siblings", "Sisters", "Brothers", "Children", "Daughters", "Sons" new_data = marital_status, siblings_number, sisters, brothers, children_number, daughters, sons update_multiple(conn, cursor, table, columns, file_number, new_data)
def breast_symptoms(conn, cursor, file_number, table, symp_state): from ask_y_n_statement import get_symptom, get_rb_lb from add_update_sql import update_multiple from breast_cancer_tables import other_symp symptoms = get_symptom(symp_state) rb = get_rb_lb(symptoms, 0) rb_symp = list(filter(None, get_rb_lb(rb, 0))) rb_dur = list(filter(None, get_rb_lb(rb, 1))) lb = get_rb_lb(symptoms, 1) lb_symp = list(filter(None, get_rb_lb(lb, 0))) lb_dur = list(filter(None, get_rb_lb(lb, 1))) data = [rb_symp, rb_dur, lb_symp, lb_dur] for index in range(0, len(data)): if not data[index]: data[index] = ["NA"] else: data[index] = ["; ".join(data[index])] data_flat = [item for sublist in data for item in sublist] new_data = tuple(data_flat) columns = "RB_symptoms", "RB_symptoms_duration", "LB_symptoms", "LB_symptoms_duration" update_multiple(conn, cursor, table, columns, file_number, new_data) other_symptom = input("Other Symptoms? (y/n) ") if str.lower(other_symptom) == "y": other_symp(conn, cursor, file_number, table) else: other_symptom = "No other symptoms" other_symp_dur = "NA" data = (other_symptom, other_symp_dur, other_symptom, other_symp_dur) columns = "RB_Other_Symptoms", "RB_Other_Symptoms_duration", "LB_Other_Symptoms", "RB_Other_Symptoms_duration" update_multiple(conn, cursor, table, columns, file_number, data)
def surgery_info(conn, cursor, file_number, table): from ask_y_n_statement import ask_option, ask_y_n from add_update_sql import update_multiple surg_block_id = input("Surgical Block ID: ") surg_location = input("Location of surgery block id " + surg_block_id) surg_no_block = input("Number of Blocks: ") surg_block_source = input("Surgery Block Source: ") surg_tumour_block = input("Tumour Block Reference: ") surg_node_block = input("Nodes Block Reference: ") surg_normal_block = input("Adjacent Normal Block Reference: ") surg_red_block = input("Reduction Tissue Block Reference: ") surg_date = input("Date of Surgery: ") surg_name = input("Name of surgeon: ") surg_hosp_id = input("Hospital ID: ") #can add review statement here. lesion_side = () lesion_side_rb_y_n = ask_y_n("Lesion Side RB") if lesion_side_rb_y_n: category = "Lesion Side RB" options = ["UOQ", "UIQ", "C", "UCQ", "LCQ", "LOQ", "LIQ"] lesion_side_rb = ask_option(category, options) lesion_side_rb_data = "RB-" + lesion_side_rb lesion_side_lb_y_n = ask_y_n("Lesion Side LB") if lesion_side_lb_y_n: category = "Lesion Side LB" options = ["UOQ", "UIQ", "C", "UCQ", "LCQ", "LOQ", "LIQ"] lesion_side_lb = ask_option(category, options) lesion_side_lb_data = "LB-" + lesion_side_lb if lesion_side_rb_y_n and lesion_side_lb_y_n: lesion_side = lesion_side_rb_data + "; " + lesion_side_lb_data elif lesion_side_rb_y_n: lesion_side = lesion_side_rb_data elif lesion_side_lb_y_n: lesion_side = lesion_side_lb_data print("Lesion side " + lesion_side) category = "Type Surgery" options = [ "Reconstruction", "Breast Conservation Surgery (BCS)", "Therapeutic Mammoplasty", "Reduction Mammoplasty", "Wide Local Excision", "Other" ] surg_type = ask_option(category, options) if surg_type == "Reconstruction": category = "Type Reconstruction" options = ["Mastectomy/Modified Radical Mastectomy", "Implant"] surg_type = ask_option(category, options) category = "Response to Surgery" options = [ "Complete_Remission/No Residual Tumor", "Progressing", "Partial", "Static", "Other" ] surg_response = ask_option(category, options) data = surg_block_id, surg_no_block, surg_block_source, surg_tumour_block, surg_node_block, surg_normal_block, \ surg_red_block, surg_date, surg_name, surg_hosp_id, lesion_side, surg_type, surg_response surgery_info = "Surgical_Block_ID", "Surgery_Block_Location", "Surgery_No_of_blocks", "Block_Source", "Tumor_block_ref", "Nodes_block_ref", \ "Ad_Normal_block_ref", "Reduction_tissue_block_ref", "Date_of_Surgery", "Name_Surgeon", "Hospital_ID", \ "Lesion_Side", "Type_surgery", "Response_surgery" update_multiple(conn, cursor, table, surgery_info, file_number, data)
def repro_details(conn, cursor, file_number, table): from add_update_sql import update_multiple menarche = input('Age at menarche (yrs): ') menopause = input('Menopausal status (pre/peri/post): ') menopause_age = menopause + " menopausal" if str.lower(menopause) == "post": menopause_age = input('Age at menopause (yrs): ') lmp = "Last menstrual period " + menopause_age + " yrs" menopause = menopause + " menopausal" else: menopause = menopause + " menopausal" lmp = input("Date of last menstrual period: ") number_pregnancy = input("Number of pregnancies: ") number_term = input( "Pregnancy carried to term (include abortion after 6 months): )") number_abortion = input("Number of abortions: ") sql = ( 'SELECT Children FROM Patient_Information_History WHERE File_number = \'' + file_number + "'") cursor.execute(sql) kids = cursor.fetchall() children_number = kids[0][0] if children_number == 'No Children': age_first = 'No Children' age_last = 'No Children' else: age_first = input("Age of first child: ") if int(children_number) > 1: age_last = input("Age of last child: ") else: age_last = age_first age_first_preg = input("Age at first pregnancy: ") age_last_preg = input("Age at last pregnancy: ") twice_birth = input("Two births in a year (not twins) y/n: ") if str.lower(twice_birth) == "y": twice_birth = "Two births in a year" else: twice_birth = "No two births in a year" breast_feeding = input("Breast feeding y/n: ") if str.lower(breast_feeding) == "y": breast_feeding = "Breast feeding" feeding_details = input("Feeding from right, left or both breasts? ") else: breast_feeding = "No breast feeding" feeding_details = "NA" type_birth_control = input("Type of birth control used: ") detail_birth_control = input("Details of birth control used: ") duration_birth_control = input("Duration of birth control use: ") new_data = menarche, menopause, menopause_age, lmp, number_pregnancy, number_term, number_abortion, \ age_first, age_first_preg, age_last,age_last_preg, twice_birth, breast_feeding, feeding_details, \ type_birth_control,detail_birth_control, duration_birth_control columns = "Menarche_yrs", "Menopause_Status", "Age_at_Menopause_yrs", "Date_last_menstrual_period", \ "Number_pregnancies", "Pregnancy_to_term", "Number_abortions", "Age_first_child", "Age_first_pregnancy", \ "Age_last_child", "Age_last_pregnancy", "Two_births_in_year", "Breast_feeding_y_n", "Breast_usage_feeding",\ "Type_birth_control_used", "Details_birth_control", "Duration_birth_control" update_multiple(conn, cursor, table, columns, file_number, new_data)
def block_report_info (conn, cursor, file_number, table): from add_update_sql import update_multiple block_sr = input("Block Serial Number: ") block_id = input ("Biopsy Block ID: ") block_number = input("No of blocks: ") block_date = input("Date of Biopsy: ") lab_id = input("Lab ID: ") biopsy_type = input("Biopsy Type: ") columns = "Block_SR_Number", "Biopsy_Block_ID", "No_of_blocks", "Date_of_Biopsy", "Lab_ID", "Biopsy_Type" data = block_sr, block_id, block_number, block_date, lab_id,biopsy_type update_multiple(conn, cursor, table, columns, file_number, data)
def bio_info(conn, cursor, file_number, table): import add_update_sql import ask_y_n_statement check = False while not check: mr_number = input('MR_number :') name = input('Name :') consent = ask_y_n_statement.ask_y_n( "Is consent form with signature present in file", "Consent Taken", "Consent form not present") aadhaar_card = input("Aadhaar card number (if available): ") date_first = input("Date of first visit: ") permanent_address = input('Permanent_Address :') current_address = input('Current_Address :') phone = input('Phone :') email_id = input('Email_ID :') gender = input('Gender :') age_yrs = input('Age (yrs) :') date_of_birth = input('Date of Birth :') place_birth = input('Place of Birth :') height = ask_y_n_statement.ask_option("Height unit", ["cm", "feet/inches"]) if height == "cm": height_cm = input('Height (cm) :') else: height_feet = float(input("Height (feet)")) height_inch = float(input("Height (inches)")) height_inch = height_inch + 12 * height_feet height_cm = str(height_inch * 2.54) weight_kg = input('Weight (kg) :') height = float(height_cm) / 100 weight = float(weight_kg) BMI = str(round(weight / (height * height))) columns_list = [ "MR_number", "Name", "Consent", "Aadhaar_Card", "FirstVisit_Date", "Permanent_Address", "Current_Address", "Phone", "Email_ID", "Gender", "Age_yrs", "Date_of_Birth", "Place_Birth", "Height_cm", "Weight_kg", "BMI" ] new_data = [ mr_number, name, consent, aadhaar_card, date_first, permanent_address, current_address, phone, email_id, gender, age_yrs, date_of_birth, place_birth, height_cm, weight_kg, BMI ] check = add_update_sql.review_input(file_number, columns_list, new_data) columns = "MR_number", "Name", "Consent", "Aadhaar_Card", "FirstVisit_Date", "Permanent_Address", "Current_Address", \ "Phone", "Email_ID", "Gender", "Age_yrs", "Date_of_Birth", "Place_Birth", "Height_cm", "Weight_kg", "BMI" data = mr_number, name, consent, aadhaar_card, date_first, permanent_address, current_address, phone, email_id, \ gender, age_yrs, date_of_birth, place_birth, height_cm, weight_kg, BMI add_update_sql.update_multiple(conn, cursor, table, columns, file_number, data)
def det_by(conn, cursor, table, file_number): from add_update_sql import update_multiple from ask_y_n_statement import ask_option category = "Current Breast Cancer" options = ["Self", "Physician", "Screening Camp", "Other"] determined_by = ask_option(category, options) if determined_by == "Screening Camp": sc_id = input("Screening Camp ID: ") determined_by = "Screening Camp ID " + sc_id det_date = input("Date of current breast cancer detection: ") columns = "Current_Breast_Cancer_Detected_By", "Current_Breast_Cancer_Detected_Date" data = determined_by, det_date update_multiple(conn, cursor, table, columns, file_number, data)
def tumour_biopsy_data(conn, cursor, file_number, table): from ask_y_n_statement import ask_option, ask_y_n from add_update_sql import update_multiple category = "Tumour biopsy diagnosis" options = [ 'Benign', "Ductal carcinoma in situ(DCIS) with microinvasion", "Ductal carcinoma in situ(DCIS) without microinvasion", "Lobular Carcinoma in Situ (LCS)", "Invasive Ductal Carcinoma (IDC)", "Invasive Lobular Carcinoma (ILC)", "Granulamatous Mastitis", "Papillary Carcinoma", "Phylloid Carcinoma", "Invasive Mammary Carcinoma", "Invasive Breast Carcinoma", "Other" ] tumour_diagnosis = ask_option(category, options) category = "Tumour Biopsy Diagnosis" options = ["Grade 1", "Grade 2", "Grade 3", "Other"] tumour_grade = ask_option(category, options) category = "ER Status" options = ["Positive", "Negative"] tumour_er = ask_option(category, options) if (tumour_er == "Positive"): tumour_er_percent = input("ER Percent: ") else: tumour_er_percent = "NA" category = "PR Status" options = ["Positive", "Negative"] tumour_pr = ask_option(category, options) if (tumour_pr == "Positive"): tumour_pr_percent = input("PR Percent: ") else: tumour_pr_percent = "NA" category = "HER2 Status" options = ["Positive", "Equivocal", "Negative"] tumour_her2 = ask_option(category, options) if tumour_her2 == "Negative": tumour_her2_grade = "NA" tumour_fish = "NA" else: tumour_her2_grade = input("HER2 Grade: ") category = "FISH" options = ["Positive", "Negative"] tumour_fish = ask_option(category, options) tumour_ki67 = input("Ki67 Percent: ") data = tumour_diagnosis, tumour_grade, tumour_er ,tumour_er_percent ,tumour_pr, tumour_pr_percent, tumour_her2, tumour_her2_grade,\ tumour_fish, tumour_ki67 columns = "Tumour_biopsy_diagnosis", "Tumour_biopsy_diagnosis_grade", "Tumour_biopsy_ER", "Tumour_biopsy_ER_Percent",\ "Tumour_biopsy_PR", "Tumour_biopsy_PR_Percent", "Tumour_biopsy_HER2", "Tumour_biopsy_HER2_Grade", \ "Tumour_biopsy_FISH", "Tumour_biopsy_Ki67_Percent" update_multiple(conn, cursor, table, columns, file_number, data)
def block_report_info(conn, cursor, file_number, table): from add_update_sql import update_multiple from ask_y_n_statement import ask_option, ask_y_n block_sr = input("Block Serial Number: ") block_id = input("Biopsy Block ID: ") block_number = input("No of blocks: ") block_date = input("Date of Biopsy: ") lab_id = input("Lab ID: ") category = "Biopsy Type" options = [ "Direct", "USG Guided", "VAB", "True-cut", "Steriotactic", "Other" ] biopsy_type = ask_option(category, options) columns = "Block_SR_Number", "Biopsy_Block_ID", "No_of_blocks", "Date_of_Biopsy", "Lab_ID", "Biopsy_Type" data = block_sr, block_id, block_number, block_date, lab_id, biopsy_type update_multiple(conn, cursor, table, columns, file_number, data)
def nipple_cytology(conn, cursor, file_number, table): import ask_y_n_statement import add_update_sql cyto = ask_y_n_statement.ask_option("Nipple Cytology", ["Done", "Not Done"]) if cyto == "Not Done": cyto_date, cyto_number, cyto_report = "NA", "NA", "NA" else: cyto_date = input("Date of nipple cytology: ") cyto_number = input("Nipple Cytology number: ") cyto_report = ask_y_n_statement.ask_option( "Nipple Cytology report and interpretation", ["Normal", "Suspicious", "Diagnostic for Cancer", "Other"]) data = cyto, cyto_date, cyto_number, cyto_report columns = "Nipple_Cytology", "Date_Nipple_Cytology", "Number_Nipple_Cytology", "Report_Nipple_Cytology" add_update_sql.update_multiple(conn, cursor, table, columns, file_number, data)
def habits(conn, cursor, file_number, table): from add_update_sql import update_multiple, update_single from ask_y_n_statement import ask_option, ask_y_n 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 = "NA" alcohol_quant = "NA" alcohol_duration = "NA" alcohol_comments = "NA" columns = "Diet", "Alcohol_y_n", "Alcohol_Consumption_age_yrs", "Quantity_alcohol_per_week", "Duration_alcohol", "Comments_alcohol" new_data = diet, alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments update_multiple(conn, cursor, table, columns, file_number, new_data) tobacco = ask_y_n("Tobacco consumption") if tobacco: tobacco = "Tobacco consumption" tobacco_type = input("Type of tobacco consumption: ") tobacco_age = input("Consumption of tobacco from which age (yrs): ") 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" tobacco_type = "NA" tobacco_age = "NA" tobacco_quant = "NA" tobacco_duration = "NA" tobacco_comments = "NA" columns = "Tobacco_y_n", "Type_tobacco", "Tobacco_consumption_age_yrs", "Quantity_tobacco_per_week", "Duration_tobacco", "Comments_tobacco" new_data = tobacco, tobacco_type, tobacco_age, tobacco_quant, tobacco_duration, tobacco_comments update_multiple(conn, cursor, table, columns, file_number, new_data) other_del_habits = input( "Other Deleterious Habits (if present give details): ") update_single(conn, cursor, table, "Other_Deleterious_Habits", file_number, other_del_habits)
def other_symp(conn, cursor, file_number, table): from add_update_sql import update_multiple from ask_y_n_statement import get_rb_lb #data = file_number, mr_number, name add_symp = "y" all_data = [] while str.lower(add_symp) == "y": other_symp = input("Type of symptom: ") symp_breast_right = input("Right Breast y/n: ") if str.lower(symp_breast_right) == "y": symp_breast_right = other_symp symp_duration_right = input( "Duration of symptoms in right breast: ") else: symp_breast_right = None symp_duration_right = None symp_breast_left = input("Left Breast y/n: ") if str.lower(symp_breast_left) == "y": symp_breast_left = other_symp symp_duration_left = input("Duration of symptoms in left breast: ") else: symp_breast_left = None symp_duration_left = None RB = [symp_breast_right, symp_duration_right] LB = [symp_breast_left, symp_duration_left] data = [RB, LB] all_data.append(data) print("Include more symptoms?") add_symp = input("y/n: ") rb = get_rb_lb(all_data, 0) rb_symp = list(filter(None, get_rb_lb(rb, 0))) rb_dur = list(filter(None, get_rb_lb(rb, 1))) lb = get_rb_lb(all_data, 1) lb_symp = list(filter(None, get_rb_lb(lb, 0))) lb_dur = list(filter(None, get_rb_lb(lb, 1))) data = [rb_symp, rb_dur, lb_symp, lb_dur] data = [rb_symp, rb_dur, lb_symp, lb_dur] for index in range(0, len(data)): if not data[index]: data[index] = ["No other symptoms"] else: data[index] = ["; ".join(data[index])] data_flat = [item for sublist in data for item in sublist] new_data = tuple(data_flat) columns = "RB_Other_Symptoms", "RB_Other_Symptoms_duration", "LB_Other_Symptoms", "RB_Other_Symptoms_duration" update_multiple(conn, cursor, table, columns, file_number, new_data)
def tumour_biopsy_data(conn, cursor, file_number, table): from ask_y_n_statement import ask_option from add_update_sql import update_multiple category = "Tumour biopsy diagnosis" options = ['Benign', "Ductal carcinoma in situ(DCIS) with microinvasion", "Ductal carcinoma in situ(DCIS) without microinvasion", "Lobular Carcinoma in Situ (LCS)", "Invasive Ductal Carcinoma (IDC)", "Invasive Lobular Carcinoma (ILC)", "Granulamatous Mastitis", "Papillary Carcinoma", "Phylloid Carcinoma", "Other"] tumour_diagnosis = ask_option(category, options) if tumour_diagnosis == 'Other': tumour_diagnosis = input ('Detail of other diagnosis: ') check = False while not check: tumour_grade = input("Tumour_biopsy_diagnosis_grade (1, 2 or 3): ") val = ["1", "2", "3"] check = tumour_grade in val category = "ER Status" options = ["Positive", "Negative"] tumour_er= ask_option(category, options) if (tumour_er == "Positive"): tumour_er_percent = input ("ER Percent: ") else: tumour_er_percent = "NA" category = "PR Status" options = ["Positive", "Negative"] tumour_pr = ask_option(category, options) if (tumour_pr == "Positive"): tumour_pr_percent = input ("PR Percent: ") else: tumour_pr_percent = "NA" category = "HER2 Status" options = ["Positive", "Negative"] tumour_her2 = ask_option(category, options) if (tumour_her2 == "Positive"): tumour_her2_percent = input ("HER2 Percent: ") else: tumour_her2_percent = "NA" category = "FISH" options = ["Positive", "Negative"] tumour_fish = ask_option(category, options) tumour_ki67 = input("Ki67 Percent") data = tumour_diagnosis,tumour_er ,tumour_er_percent ,tumour_pr, tumour_pr_percent, tumour_her2, tumour_her2_percent,\ tumour_fish, tumour_ki67 columns = "Tumour_biopsy_diagnosis", "Tumour_biopsy_diagnosis_grade", "Tumour_biopsy_ER", "Tumour_biopsy_ER_Percent", "Tumour_biopsy_PR", "Tumour_biopsy_PR_Percent", "Tumour_biopsy_HER2", "Tumour_biopsy_HER2_Grade", "Tumour_biopsy_FISH", "Tumour_biopsy_Ki67_Percent" update_multiple(conn, cursor, table, columns, file_number, data)
def family_details(conn, cursor, file_number, table): from add_update_sql import update_multiple marital_status = input('Marital_Status :') siblings = input('Siblings y/n:') siblings_number, sisters, brothers = "No Siblings", "0", "0" if (str.lower(siblings) == "y"): siblings_number = input("Number of siblings: ") sisters = input('Sisters :') brothers = input('Brothers :') children_y_n = input('Children_y_n :') children_number, daughters, sons = "No Children", "0", "0" if str.lower(children_y_n) == "y": children_number = input("Number of children: ") daughters = input('Daughters :') sons = input('Sons :') columns = "Marital_Status", "Siblings", "Sisters", "Brothers", "Children", "Daughters", "Sons" new_data = marital_status, siblings_number, sisters, brothers, children_number, daughters, sons update_multiple(conn, cursor, table, columns, file_number, new_data)
def family_cancer(conn, cursor, file_number, table): from add_update_sql import update_multiple, review_input from breast_cancer_tables import family_cancer_table from ask_y_n_statement import ask_y_n check = False while not check: family_cancer_history_y_n = ask_y_n('Cancer history in Family') if family_cancer_history_y_n: family_cancer = family_cancer_table(conn, cursor, file_number) family_cancer_history_y_n = "Family History of Cancer" else: family_cancer_history_y_n = "No Family History of Cancer" family_cancer = "NA" data_list = [family_cancer_history_y_n, family_cancer] columns_list = ["FamilyCancer_history_y_n", "Type_DegreeRelation_TypeRelation_Age_FamilyCancer"] check = review_input(file_number, columns_list, data_list) data = family_cancer_history_y_n, family_cancer columns = "FamilyCancer_history_y_n", "Type_DegreeRelation_TypeRelation_Age_FamilyCancer" update_multiple(conn, cursor, table, columns, file_number, data)
def lymphnode_biopsy(conn, cursor, file_number, table): from ask_y_n_statement import ask_option from add_update_sql import update_multiple category = "Lymph Node biopsy FNAC" options = ["Done", "Not Done"] fnac = ask_option(category, options) if fnac == "Done": category = "Lymph Node biopsy location" options = ["Right", "Left", "Both"] fnac_location = ask_option(category, options) category = "Lymph Node biopsy diagnosis" options = ["Normal", "Benign", "Malignant"] fnac_diagnosis = ask_option(category, options) else: fnac_location = "NA" fnac_diagnosis = "NA" data = fnac, fnac_location, fnac_diagnosis columns = "Lymph_Node_biopsy_FNAC", "Lymph_Node_biopsy_location", "Lymph_Node_biopsy_diagnosis" update_multiple(conn, cursor, table, columns, file_number, data)
def phys_act(conn, cursor, file_number, table): from breast_cancer_tables import physical_activity_table from add_update_sql import update_multiple, review_input from ask_y_n_statement import ask_y_n check = False while not check: phys_act = ask_y_n("Any Physical Activities ?") if phys_act: phys = physical_activity_table(conn, cursor, file_number) phys_act = "Physical Activities Performed" phys_act_done, phys_act_freq = phys else: phys_act = "No Physical Activities" phys_act_done, phys_act_freq = ("NA",) * 2 data_list = [phys_act, phys_act_done, phys_act_freq] columns_list = ["Physical_Activity_y_n", "Type_Physical_Activity", "Frequency_Physical_Activity"] check = review_input(file_number, columns_list, data_list) data = phys_act, phys_act_done, phys_act_freq columns = "Physical_Activity_y_n", "Type_Physical_Activity", "Frequency_Physical_Activity" update_multiple(conn, cursor, table, columns, file_number, data)
def habits(conn, cursor, file_number, table): from add_update_sql import update_multiple, update_single alcohol = input("Alcohol consumption (y/n): ") alcohol_consump = "No Alcohol Consumption" alcohol_age = "No Alcohol Consumption" alcohol_quant = "No Alcohol Consumption" alcohol_duration = "No Alcohol Consumption" alcohol_comments = "No Alcohol Consumption" if str.lower(alcohol) == "y": 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: ") columns = "Alcohol_y_n", "Alcohol_Consumption_age_yrs", "Quantity_alcohol_per_week", "Duration_alcohol", "Comments_alcohol" new_data = alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments update_multiple(conn, cursor, table, columns, file_number, new_data) tobacco = input("Tobacco consumption (y/n)") tobacco_type = "No Tobacco Consumption" tobacco_age = "No Tobacco Consumption" tobacco_quant = "No Tobacco Consumption" tobacco_duration = "No Tobacco Consumption" tobacco_comments = "No Tobacco Consumption" if str.lower(tobacco) == "y": tobacco = ("Tobacco consumption") tobacco_type = input("Type of tobacco consumption: ") tobacco_age = input("Consumption of tobacco from which age (yrs): ") 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" columns = "Tobacco_y_n", "Type_tobacco", "Tobacco_consumption_age_yrs", "Quantity_tobacco_per_week", "Duration_tobacco", "Comments_tobacco" new_data = tobacco, tobacco_type, tobacco_age, tobacco_quant, tobacco_duration, tobacco_comments update_multiple(conn, cursor, table, columns, file_number, new_data) other_del_habits = input("Other Deleterious Habits: ") update_single(conn, cursor, table, "Other_Deleterious_Habits", file_number, other_del_habits)
def surgery_block(conn, cursor, file_number, table): from ask_y_n_statement import ask_option, ask_y_n from add_update_sql import update_multiple print("Surgery Block Report") tumour_size = input("Tumour size: ") category = "Tumour Grade" options = ["I", "II", "III", "Other"] tumour_grade = ask_option(category, options) category = "Surgery Diagnosis" options = [ "Ductal carcinoma in situ(DCIS)", "Invasive Ductal Carcinoma", "Other" ] surg_diag = ask_option(category, options) if (surg_diag == "Ductal carcinoma in situ(DCIS)"): dcis_percent = input("Percent DCIS: ") category = "DCIS Invasion" options = ['Microinvasion', 'Macroinvasion'] dcis_invasion = ask_option(category, options) else: dcis_percent = "NA" dcis_invasion = "NA" per_inv = ask_y_n("Perineural Invasion", "Perineural Invasion Present", "Perineural Invasion Absent") necrosis = ask_y_n("Necrosis", "Necrosis Present", "Necrosis Absent") lymph_invasion = ask_y_n("Lymphovascular invasion", "Lymphovascular invasion Present", "Lymphovascular invasion Absent") category = "Margins" options = ["Involved", "Free"] margin = ask_option(category, options) print("Surgery Block Report") category = "Pathological Complete Remission" options = ["Yes", "No", "Other"] report = ask_option(category, options) data = tumour_size, tumour_grade, surg_diag, dcis_percent, dcis_invasion, per_inv, necrosis, lymph_invasion, margin, report columns = "Tumour_size_Surgery_Block_Report", "Grade_Surgery_Block_Report", "Diagnosis_Surgery_Block_Report", \ "DCIS_Percent_Surgery_Block_Report", "DCIS_Invasion_Surgery_Block_Report", \ "Perineural_Invasion_Surgery_Block_Report", "Necrosis_Surgery_Block_Report", \ "Lymphovascular_Invasion_Surgery_Block_Report", "Margins_Surgery_Block_Report", "Surgery_Block_Report" update_multiple(conn, cursor, table, columns, file_number, data)
def nut_supplements(conn, cursor, file_number, table): from add_update_sql import update_multiple, review_input from breast_cancer_tables import nut_supp_table from ask_y_n_statement import ask_y_n check = False while not check: nut_supplements = ask_y_n("Nutritional supplements taken") if nut_supplements: nuts = nut_supp_table(conn, cursor, file_number) nut_supplements = "Nutritional supplements taken" else: nut_supplements = "No nutritional supplements taken" nuts = ("NA",) * 3 nuts_type, nuts_quant, nuts_dur = nuts data_list = [nut_supplements, nuts_type, nuts_quant, nuts_dur] columns_list = ["Nutritional_supplements_y_n", "Type_Nutritional_supplements", "Quantity_Nutritional_supplements", \ "Duration_Nutritional_supplements"] check = review_input(file_number, columns_list, data_list) data = nut_supplements, nuts_type, nuts_quant, nuts_dur columns = "Nutritional_supplements_y_n", "Type_Nutritional_supplements", "Quantity_Nutritional_supplements", \ "Duration_Nutritional_supplements" update_multiple(conn, cursor, table, columns, file_number, data)
def surgery_info (conn, cursor, file_number, table): from ask_y_n_statement import ask_option from add_update_sql import update_multiple surg_block_id = input("Surgical Block ID: ") surg_no_block = input("Number of Blocks: ") surg_block_source = input ("Surgery Block Source: ") surg_tumour_block = input ("Tumour Block Reference: ") surg_node_block = input ("Nodes Block Reference: ") surg_normal_block = input ("Adjacent Normal Block Reference: ") surg_red_block = input ("Reduction Tissue Block Reference: ") surg_date = input ("Date of Surgery: ") surg_name = input ("Name of surgeon: ") surg_hosp_id = input ("Hospital ID: ") category = "Lesion Side" options = ["RB-UOQ", "RB-UIQ", "RB-C", "RB-LOQ", "RB-LIQ", "LB-UOQ", "LB-UIQ", "LB-C", "LB-LOQ", "LB-LIQ"] lesion_side = ask_option(category, options) category = "Type Surgery" options = ["Reconstruction", "Breast Conservation Surgery (BCS)", "Therapeutic Mammoplasty"] surg_type = ask_option (category, options) if (surg_type == "Reconstruction"): category = "Type Reconstruction" options = ["Mastectomy/Modified Radical Mastectomy", "Implant"] surg_type = ask_option(category, options) elif (surg_type == "Breast Conservation Surgery"): category = "Type Breast Conservation Surgery" options = ["Therapeutic Mammoplasty/Reduction Mammoplasty", "Wide Local Excision"] surg_type = ask_option(category, options) category = "Response to Surgery" options = ["Complete_Remission/No Residual Tumor", "Progressing", "Partial", "Static"] surg_response = ask_option(category, options) data = surg_block_id, surg_no_block, surg_block_source, surg_tumour_block, surg_node_block, surg_normal_block, \ surg_red_block, surg_date, surg_name, surg_hosp_id, lesion_side, surg_type, surg_response columns = "Surgical_Block_ID", "Surgery_No_of_blocks", "Block_Source", "Tumor_block_ref", "Nodes_block_ref", \ "Ad_Normal_block_ref", "Reduction_tissue_block_ref", "Date_of_Surgery", "Name_Surgeon", "Hospital_ID", \ "Lesion_Side", "Type_surgery", "Response_surgery" update_multiple(conn, cursor, table, columns, file_number, data)
def repro_details(conn, cursor, file_number, table): from add_update_sql import update_multiple from breast_cancer_tables import feed_duration from ask_y_n_statement import ask_option, ask_y_n menarche = input('Age at menarche (yrs): ') category = "Menopausal Status" options = ["Pre-menopausal", "Peri-menopausal", "Post-Menopausal", "Other"] menopause = ask_option(category, options) menopause_age = menopause if menopause == "Post-Menopausal": menopause_age = input('Age at menopause (yrs): ') lmp = "Last menstrual period " + menopause_age + " yrs" period_type = "NA" else: lmp = input("Date of last menstrual period: ") category = "Period" options = ["Regular", "Irregular", "Other"] period_type = ask_option(category, options) number_pregnancy = input("Number of pregnancies: ") number_term = input( "Pregnancy carried to term (include abortion after 6 months): )") number_abortion = input("Number of abortions: ") sql = ( 'SELECT Children FROM Patient_Information_History WHERE File_number = \'' + file_number + "'") cursor.execute(sql) kids = cursor.fetchall() children_number = kids[0][0] sql = ( 'SELECT Age_yrs FROM Patient_Information_History WHERE File_number = \'' + file_number + "'") cursor.execute(sql) age = cursor.fetchall() age_mother = age[0][0] if children_number == 'No Children': age_first = 'NA' age_last = 'NA' else: age_first = input("Age of first child: ") if int(children_number) > 1: age_last = input("Age of last child: ") else: age_last = age_first age_first_preg = input("Age at first pregnancy: ") if str.lower(age_first_preg) == "na": age_first_preg = str(int(age_mother) - int(age_first)) age_last_preg = input("Age at last pregnancy: ") if str.lower(age_first_preg) == "na": age_last_preg = str(int(age_mother) - int(age_last)) twice_birth = ask_y_n("Two births in a year (not twins) y/n: ", "Two births in a year", "No two births in a year") breast_feeding = ask_y_n("Breast feeding?") if breast_feeding: breast_feeding = "Breast feeding" feed_duration(conn, cursor, file_number, children_number) else: breast_feeding = "No Breast feeding" type_birth_control = input("Type of birth control used: ") if str.lower(type_birth_control) == "na": detail_birth_control = "NA" duration_birth_control = "NA" else: detail_birth_control = input("Details of birth control used: ") duration_birth_control = input("Duration of birth control use: ") new_data = menarche, menopause, menopause_age, lmp, period_type, number_pregnancy, number_term, number_abortion, \ age_first, age_first_preg, age_last,age_last_preg, twice_birth, breast_feeding, \ type_birth_control,detail_birth_control, duration_birth_control columns = "Menarche_yrs", "Menopause_Status", "Age_at_Menopause_yrs", "Date_last_menstrual_period", "Period_Type", \ "Number_pregnancies", "Pregnancy_to_term", "Number_abortions", "Age_first_child", "Age_first_pregnancy",\ "Age_last_child", "Age_last_pregnancy", "Two_births_in_year", "Breast_feeding", \ "Type_birth_control_used", "Details_birth_control", "Duration_birth_control" update_multiple(conn, cursor, table, columns, file_number, new_data)
def breast_symptoms(conn, cursor, file_number, table): from ask_y_n_statement import ask_y_n from add_update_sql import update_multiple, review_input import textwrap check = False while not check: note = ("Pain or tenderness; Lumps, Nipple Discharge - Milky/water discharge on pressing nippple, Nipple Retraction - nipple reagion goes inside, Dimpling small pits anwywhere on breast, Discolouration, Ulceration (small boils on surface), Eczema - Reddish spots with without itching") wrapper = textwrap.TextWrapper(width=100) string = wrapper.fill(text=note) print(string) symp_state = ["Pain or tenderness", "Lumps", "Nipple Discharge", "Nipple Retraction", "Dimpling",\ "Discolouration", "Ulceration", "Eczema"] rb_symp_list = [] rb_dur_list= [] lb_symp_list = [] lb_dur_list = [] for index in symp_state: symp = ask_y_n("Is "+ index +" present") if symp: RB = ask_y_n(index + " in Right Breast?") if RB: rb_symp = index rb_dur = input ("Duration of "+ index+": ") rb_symp_list.append(rb_symp) rb_dur_list.append(rb_dur) LB = ask_y_n(index + " in Left Breast?") if LB: lb_symp = index lb_dur = input ("Duration of "+ index+": ") lb_symp_list.append(lb_symp) lb_dur_list.append(lb_dur) rb_symps = "; ".join(rb_symp_list) rb_duration = "; ".join(rb_dur_list) lb_symps = "; ".join(lb_symp_list) lb_duration = "; ".join(lb_dur_list) data_list = [rb_symps, rb_duration, lb_symps, lb_duration] for index in range(0, len(data_list)): if data_list[index] == '': data_list[index] = "NA" columns_list = ["RB_symptoms", "RB_symptoms_duration", "LB_symptoms", "LB_symptoms_duration"] check = review_input(file_number, columns_list, data_list) data = tuple(data_list) columns = "RB_symptoms", "RB_symptoms_duration", "LB_symptoms", "LB_symptoms_duration" update_multiple(conn,cursor, table, columns, file_number, data) check = False while not check: rb_symp_list = [] rb_dur_list = [] lb_symp_list = [] lb_dur_list = [] other_symptom = ask_y_n("Other Symptoms?") if other_symptom: check = True while check: type = input("Other Symptoms type? ") RB = ask_y_n(type + " in Right Breast?") if RB: rb_symp = type rb_dur = input("Duration of " + type) rb_symp_list.append(rb_symp) rb_dur_list.append(rb_dur) LB = ask_y_n(type + " in Left Breast?") if LB: lb_symp = type lb_dur = input("Duration of " + type) lb_symp_list.append(lb_symp) lb_dur_list.append(lb_dur) check = ask_y_n("Additional Symptoms?") rb_symps_other = "; ".join(rb_symp_list) rb_duration_other = "; ".join(rb_dur_list) lb_symps_other = "; ".join(lb_symp_list) lb_duration_other = "; ".join(lb_dur_list) data_list = [rb_symps_other, rb_duration_other , lb_symps_other , lb_duration_other] for index in range(0, len(data_list)): if data_list[index] == '': data_list[index] = "NA" columns_list = ["RB_Other_Symptoms", "RB_Other_Symptoms_duration", "LB_Other_Symptoms", "LB_Other_Symptoms_duration"] check = review_input(file_number, columns_list, data_list) data = tuple(data_list) columns = "RB_Other_Symptoms", "RB_Other_Symptoms_duration", "LB_Other_Symptoms", "LB_Other_Symptoms_duration" update_multiple(conn, cursor, table, columns, file_number, data)
def cancer_table(conn, cursor, file_number): from add_update_sql import insert, update_multiple from ask_y_n_statement import ask_y_n 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) columns = ("File_number, Type_Cancer, Year_diagnosis") data = file_number, type_of_cancer, year_diagnosis insert(conn, cursor, table_cancer, columns, 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 habits(conn, cursor, file_number, table): from add_update_sql import update_multiple, review_input from ask_y_n_statement import ask_option, ask_y_n check = False while not check: category = "Diet" print ("Note Ovo-Vegetarian is Egg + Veg eating. If eating patterms are only fish etc enter in Others") 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 columns_list = ["Diet", "Alcohol_y_n", "Alcohol_Consumption_age_yrs", "Quantity_alcohol_per_week", "Duration_alcohol", "Comments_alcohol"] data_list = [diet, alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments] check = review_input(file_number, columns_list, data_list) columns = "Diet", "Alcohol_y_n", "Alcohol_Consumption_age_yrs", "Quantity_alcohol_per_week", "Duration_alcohol", "Comments_alcohol" new_data = diet, alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments update_multiple(conn, cursor, table, columns, file_number, new_data) check = False while not check: print ("Note this question includes Gutkha, Pan Masala, Jarda/Maava, Hookah, Nicotine Patch, Mishri consumption") 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_passive, tobacco_type, tobacco_age, tobacco_freq, tobacco_quant, tobacco_duration, \ tobacco_comments = ("NA",) * 8 other_del_habits = input("Other Deleterious Habits (if present give details): ") columns_list = ["Tobacco_y_n", "Exposure_Mode", "Type_Passive", "Type_tobacco","Tobacco_consumption_age_yrs", "Tobacco_Frequency","Quantity_tobacco_per_week", "Duration_tobacco", "Comments_tobacco", "Other_Deleterious_Habits"] data_list = [tobacco, exposure_type, tobacco_passive,tobacco_type, tobacco_age, tobacco_freq, tobacco_quant, tobacco_duration, tobacco_comments, other_del_habits] check = review_input(file_number, columns_list, data_list) columns = "Tobacco_y_n", "Exposure_Mode", "Type_Passive", "Type_tobacco","Tobacco_consumption_age_yrs", \ "Tobacco_Frequency","Quantity_tobacco_per_week", "Duration_tobacco", "Comments_tobacco",\ "Other_Deleterious_Habits" data = tobacco, exposure_type,tobacco_passive, tobacco_type, tobacco_age, tobacco_freq, tobacco_quant, \ tobacco_duration, tobacco_comments, other_del_habits update_multiple(conn, cursor, table, columns, file_number, data)
def path_stage(conn, cursor, file_number, table): from add_update_sql import update_multiple from ask_y_n_statement import ask_option, ask_y_n category = "pT" options = ["is", "0", "1", "2", "3", "4", "Other"] pT = ask_option(category, options) category = "pN" options = ["0", "1", "2", "3", "4", "Other"] pN = ask_option(category, options) category = ("M") options = ["0", "x", "Present", "Other"] M = ask_option(category, options) path_stage = "pT" + pT + "N" + pN + "M" + M print("Pathological Stage: " + path_stage) check = input("Is patholgicial stage correct (y/n): ") if str.lower(check) == "n": path_stage = input("Please enter correct pathological stage: ") if M == "1": 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 = "IIIC" 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: ") else: clinical_stage = input("Clinical Staging: ") print("Clinical stage " + clinical_stage) print( "Based on TNM status", path_stage, "and data at https://emedicine.medscape.com/article/2007112-overview") check = ask_y_n("Is clinical stage correct", True, False) if not check: clinical_stage = input("Please enter correct clinical stage: ") data = pT, pN, M, path_stage, clinical_stage columns = "Pathological_Staging_pT", "Pathological_Staging_pN", "Pathological_Staging_M", \ "Pathological_Staging_P_Stage", "Clinical_Staging" update_multiple(conn, cursor, table, columns, file_number, data)