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 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 physical_activity_table(conn, cursor, file_number, mr_number, name):
    from add_update_sql import insert
    table_act = "Physical_Activity"
    columns = "File_number, MR_number, Name, Type_activity, Frequency_activity"
    add_act = "y"
    while str.lower(add_act) == "y":
        type_phys_act = input("Type of physical activity: ")
        freq_phys_act = input("Frequency of physical activity: ")
        data = file_number, mr_number, name, type_phys_act, freq_phys_act
        insert(conn, cursor, table_act, columns, data)
        print("Add further activities?")
        add_act = input("(y/n): ")
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 med_history_table(conn, cursor, file_number, mr_number, name):
    from add_update_sql import insert
    add_history = "y"
    while (str.lower(add_history) == "y"):
        condition = input("Condition : ")
        diagnosis_date = input("Date of diagnosis: ")
        treatment = input("Treatment: ")
        history = file_number, mr_number, name, condition, diagnosis_date, treatment
        table_med = "General_Medical_History"
        columns = "File_number, MR_number, Name, Condition, Diagnosis_date, Treatment"
        insert(conn, cursor, table_med, columns, history)
        print('Add more history')
        add_history = input('y/n: ')
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 feed_duration (conn, cursor, file_number, children_number):
    from ask_y_n_statement import ask_option
    from add_update_sql import insert
    table = "Breast_Feeding"
    child_number = int(children_number)
    for index in range(0, child_number):
        kid = str(index+1)
        feeding_duration = input("Breast feeding duration for child "+ kid +" (months) ?")
        category = "Breast feeding for child " + kid
        options = ["Right", "Left", "Both", "Other"]
        feeding_details = ask_option(category, options)
        columns = 'File_number, Child_number, Feeding_duration, Breast_usage_feeding'
        data = file_number, kid, feeding_duration, feeding_details
        insert (conn, cursor, table, columns, data)
def nut_supp_table(conn, cursor, file_number, mr_number, name):
    from add_update_sql import insert
    add_supp = "y"
    table_nut = "Nutritional_Supplements"
    columns = "File_number, MR_number, Name, Type_nutritional_supplements, Quantity_nutritional_supplements_per_day, " \
              "Duration_nutritional_supplements"
    while str.lower(add_supp) == "y":
        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, mr_number, name, nut_supplements_type, nut_supplements_quant, nut_supplements_duration
        insert(conn, cursor, table_nut, columns, new_data)
        print('Add more nutritional supplements')
        add_supp = input('y/n: ')
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_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 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_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)
def feed_duration(conn, cursor, file_number, children_number):
    from ask_y_n_statement import ask_option
    from add_update_sql import insert
    table = "Breast_Feeding"
    child_list, feeding_duration_list, feeding_details_list = [], [], []
    child_number = int(children_number)
    for index in range(0, child_number):
        kid = str(index + 1)
        kid_add = "Child " + kid
        child_list.append(kid_add)
        feeding_duration = input("Breast feeding duration for " + kid_add +
                                 " (months) ?")
        feeding_duration_list.append(feeding_duration)
        category = "Breast feeding for child " + kid
        options = ["Right", "Left", "Both", "Other"]
        feeding_details = ask_option(category, options)
        feeding_details_list.append(feeding_details)
        columns = 'File_number, Child_number, Feeding_duration, Breast_usage_feeding'
        data = file_number, kid, feeding_duration, feeding_details
        insert(conn, cursor, table, columns, data)
    child = '; '.join(child_list)
    duration = '; '.join(feeding_duration_list)
    feed = "; ".join(feeding_details_list)
    return (child, duration, feed)
def cancer_table(conn, cursor, file_number):
    # add yes_no and NA. Remove yes no column
    from add_update_sql import insert
    from ask_y_n_statement import ask_y_n
    table_cancer = "Previous_Cancer_History"
    add_cancer = True
    while add_cancer:
        type_of_cancer = input("Type of Cancer: ")
        year_diagnosis = input("Year of diagnosis: ")
        columns = ("File_number, Type_Cancer, Year_diagnosis")
        data = file_number, type_of_cancer, year_diagnosis
        insert(conn, cursor, table_cancer, columns, data)
        surgery_y_n = ask_y_n("Surgical treatment?", "y", "NA")
        type_surgery = None
        if surgery_y_n == "y":
            # surgery_y_n = "Surgical treatment"
            type_surgery = input("Type of surgery: ")
        radiation_y_n = input("Radiation Treatment (y/n): ")
        type_radiation = None
        duration_radiation = None
        if str.lower(radiation_y_n) == "y":
            # radiation_y_n = "Radiation Treatment"
            type_radiation = input("Type of radiation: ")
            duration_radiation = input("Duration of treatment: ")
        chemotherapy_y_n = input("Chemotherapy Treatment (y/n): ")
        type_chemotherapy = None
        duration_chemotherapy = None
        if str.lower(chemotherapy_y_n) == "y":
            # chemotherapy_y_n = "Chemotherapy Treatment"
            type_chemotherapy = input("Type of chemotherapy: ")
            duration_chemotherapy = input("Duration of treatment: ")
        hormone_y_n = input("Hormone Treatment (y/n): ")
        type_hormone = None
        duration_hormone = None
        if str.lower(hormone_y_n) == "y":
            # hormone_y_n = "Hormone Treatment"
            type_hormone = input("Type of hormone: ")
            duration_hormone = input("Duration of treatment: ")
        alternative_y_n = input("Alternative Treatment (y/n): ")
        type_alternative = None
        duration_alternative = None
        if str.lower(alternative_y_n) == "y":
            # alternative_y_n = "Alternative Treatment"
            type_alternative = input("Type of alternative medication: ")
            duration_alternative = input("Duration of treatment: ")
        home_y_n = input("Home Remedy (y/n): ")
        type_home = None
        duration_home = None
        if str.lower(home_y_n) == "y":
            # home_y_n = "Home Remedy Treatment"
            type_home = input("Type of home remedy: ")
            duration_home = input("Duration of treatment: ")
        columns = "File_number, Type_Cancer, Year_diagnosis, Type_Surgery," \
                  "Type_Radiation,Duration_Radiation,Type_Chemotherapy,Duration_Chemotherapy," \
                  "Type_Hormone, Duration_Hormone,Type_Alternative_Treatment, " \
                  "Duration_Alternative_Treatment, Type_Home_Remedy, Duration_Home_Remedy"
        new_data = file_number, type_of_cancer, year_diagnosis, type_surgery, \
                   type_radiation, duration_radiation, type_chemotherapy, \
                   duration_chemotherapy, type_hormone, duration_hormone, \
                   type_alternative, duration_alternative, type_home, duration_home
        insert(conn, cursor, table_cancer, columns, new_data)
        add_cancer = ask_y_n("Additional cancer history")
def cancer_table(conn, cursor, file_number, mr_number, name):
    #add yes_no and NA. Remove yes no column
    from add_update_sql import insert
    table_cancer = "Previous_Cancer_History"
    add_cancer = "y"
    while str.lower(add_cancer) == "y":
        type_of_cancer = input("Type of Cancer: ")
        year_diagnosis = input("Year of diagnosis: ")
        columns = ("File_number, MR_number, Name, Type_Cancer, Year_diagnosis")
        data = file_number, mr_number, name, type_of_cancer, year_diagnosis
        insert(conn, cursor, table_cancer, columns, data)
        surgery_y_n = input("Surgical treatment (y/n)?")
        type_surgery = "No Surgery"
        if str.lower(surgery_y_n) == "y":
            surgery_y_n = "Surgical treatment"
            type_surgery = input("Type of surgery: ")
        radiation_y_n = input("Radiation Treatment (y/n): ")
        type_radiation = "No Radiation"
        duration_radiation = "No Radiation"
        if str.lower(radiation_y_n) == "y":
            radiation_y_n = "Radiation Treatment"
            type_radiation = input("Type of radiation: ")
            duration_radiation = input("Duration of treatment: ")
        chemotherapy_y_n = input("Chemotherapy Treatment (y/n): ")
        type_chemotherapy = "No Chemotherapy"
        duration_chemotherapy = "No Chemotherapy"
        if str.lower(chemotherapy_y_n) == "y":
            chemotherapy_y_n = "Chemotherapy Treatment"
            type_chemotherapy = input("Type of chemotherapy: ")
            duration_chemotherapy = input("Duration of treatment: ")
        hormone_y_n = input("Hormone Treatment (y/n): ")
        type_hormone = "No Hormone Treatment"
        duration_hormone = "No Hormone Treatment"
        if str.lower(hormone_y_n) == "y":
            hormone_y_n = "Hormone Treatment"
            type_hormone = input("Type of hormone: ")
            duration_hormone = input("Duration of treatment: ")
        alternative_y_n = input("Alternative Treatment (y/n): ")
        type_alternative = "No Alternative Treatment"
        duration_alternative = "No Alternative Treatment"
        if str.lower(alternative_y_n) == "y":
            alternative_y_n = "Alternative Treatment"
            type_alternative = input("Type of alternative medication: ")
            duration_alternative = input("Duration of treatment: ")
        home_y_n = input("Home Remedy (y/n): ")
        type_home = "No Home Remedy Treatment"
        duration_home = "No Home Remedy Treatment"
        if str.lower(home_y_n) == "y":
            home_y_n = "Home Remedy Treatment"
            type_home = input("Type of home remedy: ")
            duration_home = input("Duration of treatment: ")
        columns = "File_number, MR_number, Name, Type_Cancer, Year_diagnosis, Surgery, Type_Surgery,Radiation," \
                  "Type_Radiation,Duration_Radiation, Chemotherapy, Type_Chemotherapy,Duration_Chemotherapy, Hormone, " \
                  "Type_Hormone, Duration_Hormone, Alternative_Treatment,Type_Alternative_Treatment, " \
                  "Duration_Alternative_Treatment, Home_Remedy,Type_Home_Remedy, Duration_Home_Remedy"
        new_data = file_number, mr_number, name, type_of_cancer, year_diagnosis, surgery_y_n, type_surgery, \
                   radiation_y_n, type_radiation, duration_radiation, chemotherapy_y_n, type_chemotherapy, \
                   duration_chemotherapy, hormone_y_n, type_hormone, duration_hormone, alternative_y_n, \
                   type_alternative, duration_alternative, home_y_n, type_home, duration_home
        insert(conn, cursor, table_cancer, columns, new_data)
        print("Additional cancer history")
        add_cancer = input("y/n: ")
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)