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 update_record(conn, cursor, file_number, table): from ask_y_n_statement import ask_y_n import gen_info_tables print("Update record for General Information") enter = ask_y_n("Enter Patient Biographical Information") if enter: gen_info_tables.bio_info(conn, cursor, file_number, table) enter = ask_y_n("Enter Patient habits") if enter: gen_info_tables.phys_act(conn, cursor, file_number, table) gen_info_tables.habits(conn, cursor, file_number, table) gen_info_tables.nut_supplements(conn, cursor, file_number, table) enter = ask_y_n("Enter Patient family and reproductive details?") if enter: gen_info_tables.family_details(conn, cursor, file_number, table) gen_info_tables.repro_details(conn, cursor, file_number, table) enter = ask_y_n("Enter Patient and family medical history?") if enter: gen_info_tables.med_history(conn, cursor, file_number, table) gen_info_tables.cancer_history(conn, cursor, file_number, table) gen_info_tables.family_cancer(conn, cursor, file_number, table) enter = ask_y_n("Enter Patient Symptoms?") if enter: gen_info_tables.det_by(conn, cursor, table, file_number) gen_info_tables.breast_symptoms(conn, cursor, file_number, table) gen_info_tables.metastasis_symp(conn, cursor, file_number, table)
def metastasis_symp (conn, cursor, file_number, table): from add_update_sql import update_single, review_input from ask_y_n_statement import ask_y_n check = False while not check: met = [] met_bone = ask_y_n("Bone Pain") if met_bone: met.append(["Bone Pain"]) met_cough = ask_y_n("Cough") if met_cough: met.append(["Cough"]) met_jaundice = ask_y_n("Jaundice") if met_jaundice: met.append(["Jaundice"]) met_headache = ask_y_n("Headache") if met_headache: met.append(["Headache"]) met_weight = ask_y_n("Weight loss") if met_weight: met.append(["WeightLoss"]) met_flat = [item for sublist in met for item in sublist] data_met = "; ".join(met_flat) if met_flat == []: data_met = "No Metastatis Symptoms" check = review_input(file_number, ["Metastasis_Symptoms"], [data_met]) update_single(conn, cursor, table, "Metatasis_Symptoms", file_number, data_met)
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 family_cancer_table(conn, cursor, file_number): from ask_y_n_statement import ask_option, ask_y_n from add_update_sql import insert 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 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 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 review_input(file_number, columns, data): from ask_y_n_statement import ask_y_n col_number = len(data) for index in range(0, col_number): print(columns[index] + ": " + data[index]) ans = ask_y_n("Are entries for file " + file_number + " correct ?", True, False) return ans
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 phys_act(conn, cursor, file_number, table): from breast_cancer_tables import physical_activity_table from add_update_sql import update_single from ask_y_n_statement import ask_y_n phys_act = ask_y_n("Any Physical Activities ?") if phys_act: physical_activity_table(conn, cursor, file_number) phys_act = "Physical Activities Performed" else: phys_act = "No Physical Activities" update_single(conn, cursor, table, "Physical_Activity_y_n", file_number, phys_act)
def physical_activity_table(conn, cursor, file_number): from add_update_sql import insert from ask_y_n_statement import ask_y_n table_act = "Physical_Activity" columns = "File_number, Type_activity, Frequency_activity" add_act = True while add_act: type_phys_act = input("Type of physical activity: ") freq_phys_act = input("Frequency of physical activity: ") data = file_number, type_phys_act, freq_phys_act insert(conn, cursor, table_act, columns, data) add_act = ask_y_n("Add further activities?")
def family_cancer(conn, cursor, file_number, table): from add_update_sql import update_single from breast_cancer_tables import family_cancer_table from ask_y_n_statement import ask_y_n family_cancer_history_y_n = ask_y_n('Cancer history in Family') if family_cancer_history_y_n: 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" update_single(conn, cursor, table, "FamilyCancer_history_y_n", file_number, family_cancer_history_y_n)
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_single medical_history_y_n = ask_y_n("Other Medical History ?") if medical_history_y_n: 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" update_single(conn, cursor, table, "Any_Other_Medical_History_y_n", file_number, medical_history_y_n)
def cancer_history(conn, cursor, file_number, table): from breast_cancer_tables import cancer_table from add_update_sql import update_single from ask_y_n_statement import ask_y_n previous_cancer_history_y_n = ask_y_n("Previous history of cancer ?") if previous_cancer_history_y_n: 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" update_single(conn, cursor, table, "Previous_Cancer_History_y_n", file_number, previous_cancer_history_y_n)
def nut_supplements(conn, cursor, file_number, table): from add_update_sql import update_single from breast_cancer_tables import nut_supp_table from ask_y_n_statement import ask_y_n nut_supplements = ask_y_n("Nutritional supplements taken") if nut_supplements: nut_supp_table(conn, cursor, file_number) nut_supplements = "Nutritional supplements taken" else: nut_supplements = "No nutritional supplements taken" update_single(conn, cursor, table, "Nutritional_supplements_y_n", file_number, nut_supplements)
def metastasis_symp(conn, cursor, file_number, table): from add_update_sql import update_single from ask_y_n_statement import ask_y_n met_none = ask_y_n("Metastatis Symptoms Present?") met = [] if not met_none: met = [["No Metastatis Symptoms"]] else: met_bone = ask_y_n("Bone Pain") if met_bone: met.append(["Bone Pain"]) met_cough = ask_y_n("Cough") if met_cough: met.append(["Cough"]) met_jaundice = ask_y_n("Jaundice") if met_jaundice: met.append(["Jaundice"]) met_headache = ask_y_n("Headache") if met_headache: met.append(["Headache"]) met_weight = ask_y_n("Weight loss") if met_weight: met.append(["WeightLoss"]) met_flat = [item for sublist in met for item in sublist] data_met = "; ".join(met_flat) update_single(conn, cursor, table, "Metatasis_Symptoms", file_number, data_met)
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 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 med_history_table(conn, cursor, file_number): from add_update_sql import insert from ask_y_n_statement import ask_y_n add_history = True while add_history: condition = input("Condition : ") diagnosis_date = input("Date of diagnosis: ") treatment = input("Treatment: ") history = file_number, condition, diagnosis_date, treatment table_med = "General_Medical_History" columns = "File_number, Condition, Diagnosis_date, Treatment" insert(conn, cursor, table_med, columns, history) add_history = ask_y_n ('Add more history')
def display_data(cursor, table, file_number, columns, section_number): import ask_y_n_statement section = ", ".join(columns) sql = "SELECT " + section + " FROM " + table + " WHERE File_number = ?" cursor.execute(sql, (file_number, )) data = cursor.fetchall() data_list = list(data[0]) col_number = len(columns) print("Available data in database") for index in range((section_number - 1), col_number): print(columns[index] + ": " + data_list[index]) enter = ask_y_n_statement.ask_y_n("Enter " + section_name) return enter
def nut_supp_table(conn, cursor, file_number): from add_update_sql import insert from ask_y_n_statement import ask_y_n add_supp = True table_nut = "Nutritional_Supplements" columns = "File_number, Type_nutritional_supplements, Quantity_nutritional_supplements_per_day, " \ "Duration_nutritional_supplements" while add_supp: nut_supplements_type = input("Type of nutritional supplements taken: ") nut_supplements_quant = input("Quantity of nutritional supplements taken per day: ") nut_supplements_duration = input("Duration of nutritional supplements use: ") new_data = file_number, nut_supplements_type, nut_supplements_quant, nut_supplements_duration insert(conn, cursor, table_nut, columns, new_data) add_supp = ask_y_n('Add more nutritional supplements?')
def other_symp(conn, cursor, file_number, table): from add_update_sql import update_multiple from ask_y_n_statement import get_rb_lb, ask_y_n # data = file_number, mr_number, name add_symp = True all_data = [] while add_symp: 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) add_symp = ask_y_n("Include more symptoms?") 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] 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) return (new_data)
def physical_activity_table(conn, cursor, file_number): from add_update_sql import insert from ask_y_n_statement import ask_y_n table_act = "Physical_Activity" columns = "File_number, Type_activity, Frequency_activity" add_act = True type_phys_list, freq_phys_list = [], [] while add_act: type_phys_act = input("Type of physical activity: ") type_phys_list.append(type_phys_act) freq_phys_act = input("Frequency of physical activity: ") freq_phys_list.append(freq_phys_act) data = file_number, type_phys_act, freq_phys_act insert(conn, cursor, table_act, columns, data) add_act = ask_y_n("Add further activities?") type_phys = '; '.join(type_phys_list) freq_phys = '; '.join(freq_phys_list) return (type_phys, freq_phys)
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 family_cancer_table(conn, cursor, file_number): from ask_y_n_statement import ask_option, ask_y_n from add_update_sql import insert add_family = True all_data = [] while add_family: type_of_cancer = input("Type of Cancer: ") category = ("Relation to patient") options = ["Immediate Family", "Maternal Family", "Paternal Family"] relation_to_patient = ask_option(category, options) type_relation = input("Specific Relationship:") age_at_detection_yrs = input('Age at detection (yrs) :') family_history = file_number, type_of_cancer, relation_to_patient, type_relation, age_at_detection_yrs #family_history_list = [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? ")
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 med_history_table(conn, cursor, file_number): from add_update_sql import insert from ask_y_n_statement import ask_y_n add_history = True diagnosis_date_list, treatment_list, condition_list = [], [], [] while add_history: condition = input("Condition : ") condition_list.append(condition) diagnosis_date = input("Date of diagnosis: ") diagnosis_date_list.append(diagnosis_date) treatment = input("Treatment: ") treatment_list.append(treatment) history = file_number, condition, diagnosis_date, treatment table_med = "General_Medical_History" columns = "File_number, Condition, Diagnosis_date, Treatment" insert(conn, cursor, table_med, columns, history) add_history = ask_y_n('Add more history') condition_hist = '; '.join(condition_list) treatment_hist = '; '.join(treatment_list) diagnosis_date_hist = "; ".join(diagnosis_date_list) return (condition_hist, diagnosis_date_hist, treatment_hist)
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 nut_supp_table(conn, cursor, file_number): from add_update_sql import insert from ask_y_n_statement import ask_y_n type_nut_list, quant_nut_list, duration_nut_list = [], [], [] add_supp = True table_nut = "Nutritional_Supplements" columns = "File_number, Type_nutritional_supplements, Quantity_nutritional_supplements_per_day, " \ "Duration_nutritional_supplements" while add_supp: nut_supplements_type = input("Type of nutritional supplements taken: ") type_nut_list.append(nut_supplements_type) nut_supplements_quant = input( "Quantity of nutritional supplements taken per day: ") quant_nut_list.append(nut_supplements_quant) nut_supplements_duration = input( "Duration of nutritional supplements use: ") duration_nut_list.append(nut_supplements_duration) new_data = file_number, nut_supplements_type, nut_supplements_quant, nut_supplements_duration insert(conn, cursor, table_nut, columns, new_data) add_supp = ask_y_n('Add more nutritional supplements?') type_nut = '; '.join(type_nut_list) quant_nut = '; '.join(quant_nut_list) duration_nut = "; ".join(duration_nut_list) return (type_nut, quant_nut, duration_nut)