Esempio n. 1
0
def tox_table(file_number, cyc_name, week, drug_cyc):
    import modules.ask_y_n_statement as ask_y_n_statement
    import additional_tables.chemo as chemo
    import pandas as pd
    import modules.pccm_names as names
    from sql.add_update_sql import review_df as review
    tox_all = pd.DataFrame(columns=names.names_nact("Tox_table"))
    tox_index = 0
    drugs = "/".join(drug_cyc)
    check_tox = False
    while not check_tox:
        tox = ask_y_n_statement.ask_y_n("Were there any toxic effects in  " +
                                        week + " of " + cyc_name)
        tox_grade_list, tox_list, tox_treatment, resp_treatment_list = [
            list([]) for _ in range(4)
        ]
        if tox:
            for index in chemo.toxicity():
                tox_grade = ask_y_n_statement.ask_option(
                    ("the grade of " + index + " in " + cyc_name + "? "),
                    ["Mild", "Moderate", "Severe", "Not Present", "Other"])
                if tox_grade not in {"Not Present"}:
                    tox = index
                    check = False
                    while not check:
                        treatment = input("Treatment given for " + tox_grade +
                                          " " + index +
                                          " (include all details): ")
                        resp_treatment = ask_y_n_statement.ask_option(
                            ("Response to treatment given for " + tox_grade +
                             " " + index),
                            ["Partial", "Complete", "No Effect", "Other"])
                        data = [
                            file_number, week, cyc_name, drugs, tox, tox_grade,
                            treatment, resp_treatment
                        ]
                        tox_all.loc[tox_index] = data
                        check = review(tox_all.loc[tox_index])
                    tox_grade_list.append(tox_grade)
                    tox_list.append(index)
                    tox_treatment.append(treatment)
                    resp_treatment_list.append(resp_treatment)
                    tox_index = tox_index + 1
        else:
            tox = "No Toxicity"
            tox_grade, treatment, resp_treatment = ("NA", ) * 3
            tox_list = ["No Toxicity"]
            tox_grade_list, tox_treatment, resp_treatment_list = [["NA"]] * 3
            data = [
                file_number, week, cyc_name, drugs, tox, tox_grade, treatment,
                resp_treatment
            ]
            tox_all.loc[tox_index] = data

        all_data = [
            tox_grade_list, tox_list, tox_treatment, resp_treatment_list
        ]
        response = ask_y_n_statement.join_lists(all_data, "; ")
        check_tox = review(tox_all)
    return response
Esempio n. 2
0
def abvs(file_number):
    module_name = "abvs"
    check = False
    while not check:
        abvs = ask_y_n_statement.ask_y_n("Automated Breast Volume Scanner (ABVS) done?")
        if abvs:
            abvs = "Automated Breast Volume Scanner done"
            abvs_date = input("Date of examination of ABVS: ")
            abvs_acc = input("Accession number of ABVS: ")
            abvs_lesion = ask_y_n_statement.ask_option("Location of lesion",
                                                       ["Right Breast", "Left Breast", "Both", "Not present"])
            if abvs_lesion in {"Right Breast", "Left Breast", "Both"}:
                abvs_lesion_data = radio_tables_old.lesion_location(abvs_lesion)
            else:
                abvs_lesion_data = "NA"
            abvs_size = ask_y_n_statement.ask_option("Size of lesion", ["<2 cm", "2-5 cm", ">5 cm", "Other"])
            abvs_dist = ask_y_n_statement.ask_option("Distance from Skin (cm)", ["<0.5 cm", ">0.5 cm", "Other"])
            abvs_pect = input("Distance from Pectoralis Major (cm): ")
            abvs_diagnosis = ask_y_n_statement.ask_option("ABVS Diagnosis",
                                                          ["Normal", "Benign", "Suspicious", "Diagnostic for Cancer"])
        else:
            abvs = "Automated Breast Volume Scanner done"
            abvs_date, abvs_acc, abvs_lesion, abvs_lesion_data, abvs_size, abvs_dist, abvs_pect, \
            abvs_diagnosis = ("NA",) * 8

        data_list = [abvs, abvs_date, abvs_acc, abvs_lesion, abvs_lesion_data, abvs_size, abvs_dist, abvs_pect,
                     abvs_diagnosis]
        columns_list = names(module_name)
        check = add_update_sql.review_input(file_number, columns_list, data_list)
    return (tuple(data_list))
Esempio n. 3
0
def mammo_arch():
    import modules.ask_y_n_statement as ask_y_n_statement
    mammo_arch = ask_y_n_statement.ask_y_n(
        "Is Architectural distortion present")
    if mammo_arch:
        mammo_arch = "Architectural distortion present"
        arch_loc = ask_y_n_statement.ask_option(
            "Location of Distortion", ["Right Breast", "Left Breast", "Both"])
        arch_quad = lesion_location(arch_loc)
        arch_depth = ask_y_n_statement.ask_option(
            "Depth of Architectural Distortion",
            ["Anterior", "Middle", "Posterior", "Other"])
        arch_dist = ask_y_n_statement.ask_option(
            "Distance from nipple of Architectural Distortion",
            ["<0.5 cm", ">0.5 cm", "Other"])
        pect_check = ask_y_n_statement.ask_y_n(
            "Is distance from Pectoralis Major described for "
            "Architectural Distortion")
        if pect_check:
            arch_pect = input("Distance from Pectoralis Major (cm): ")
        else:
            arch_pect = "NA"
    else:
        mammo_arch = "Architectural distortion not present"
        arch_loc = "Not Present"
        arch_quad, arch_depth, arch_dist, arch_pect = ("Not Present", ) * 4
    data_list = [
        mammo_arch, arch_loc, arch_quad, arch_depth, arch_dist, arch_pect
    ]
    return data_list
Esempio n. 4
0
def mammo_asym():
    import modules.ask_y_n_statement as ask_y_n_statement
    asym = ask_y_n_statement.ask_y_n("Is asymmetry present")
    if asym:
        asym_loc = ask_y_n_statement.ask_option(
            "Location of Asymmetry", ["Right Breast", "Left Breast", "Both"])
        asym_quad = lesion_location(asym_loc)
        asym_depth = ask_y_n_statement.ask_option(
            "Depth of Asymmetry", ["Anterior", "Middle", "Posterior", "Other"])
        asym_dist = ask_y_n_statement.ask_option(
            "Distance from nipple of Asymmetry",
            ["<0.5 cm", ">0.5 cm", "Other"])
        pect_check = ask_y_n_statement.ask_y_n(
            "Is distance from Pectoralis Major described for Asymmetry")
        if pect_check:
            asym_pect = input("Distance from Pectoralis Major (cm): ")
        else:
            asym_pect = "NA"
        mammo_asymm = lesion_location(asym_loc, [
            "Type of Asymmetry in Right Breast",
            "Type of Asymmetry in Left Breast"
        ], [
            "Asymmetry", "Global asymmetry", "Focal asymmetry",
            "Developing asymmetry", "Other"
        ])
    else:
        asym_quad, asym_depth, asym_dist, asym_pect, mammo_asymm = ("NA", ) * 5
        asym_loc = "Not Present"
    data_list = [
        asym_loc, asym_quad, asym_depth, asym_dist, asym_pect, mammo_asymm
    ]
    return data_list
Esempio n. 5
0
 def ihc_report():
     tumour_er = ask.ask_option("ER Status", ["ER_positive", "ER_negative"])
     if tumour_er == "ER_positive":
         tumour_er_percent = input(
             "ER Percent (number only), Enter 'Data not in Report' if %age not available: "
         )
     else:
         tumour_er_percent = tumour_er
     tumour_pr = ask.ask_option("PR Status", ["PR_positive", "PR_negative"])
     if tumour_pr == "PR_positive":
         tumour_pr_percent = input(
             "PR Percent (number only), Enter 'Data not in Report' if %age not available: "
         )
     else:
         tumour_pr_percent = tumour_pr
     tumour_her2 = ask.ask_option(
         "HER2 Status",
         ["HER2_positive", "HER2_negative", "HER2_equivocal"])
     tumour_her2_grade = input("HER2 Grade: ")
     tumour_fish = ask.ask_option(
         "FISH", ["FISH_positive", "FISH_negative", "FISH Not Done"])
     tumour_ki67 = input(
         "Ki67 Percent, Number only, Enter 'Not Done' if test not done: ")
     data = tumour_er, tumour_er_percent, tumour_pr, tumour_pr_percent, tumour_her2, tumour_her2_grade, tumour_fish,\
            tumour_ki67
     return data
Esempio n. 6
0
def tox_table(file_number, drug_cyc, tox_all):
    tox_index = 0
    check_tox = False
    while not check_tox:
        tox = ask_y_n_statement.ask_y_n(
            "Were there any toxic effects in  administration of " + drug_cyc)
        if tox:
            add_tox = True
            while add_tox:
                tox_present = ask_y_n_statement.ask_option(
                    "Toxic effects of type", chemo.toxicity())
                tox_grade = ask_y_n_statement.ask_option(
                    ("the grade of " + tox_present + "? "),
                    ["Mild", "Moderate", "Severe", "Other"])
                treatment = input("Treatment given for " + tox_grade + " " +
                                  tox_present + " (include all details): ")
                resp_treatment = ask_y_n_statement.ask_option(
                    ("Response to treatment given for " + tox_grade + " " +
                     tox_present),
                    ["Partial", "Complete", "No Effect", "Other"])
                cyc_tox = input("Cycle at which toxicity occurred: ")
                change_tox = ask_y_n_statement.ask_option(
                    "Changes to treatment", [
                        "No change", "Therapy changed due to toxicity",
                        "Therapy stopped  due to toxicity",
                        "Therapy changed due to other reasons",
                        "Therapy stopped due to other reasons"
                    ])
                if change_tox == "Therapy changed due to toxicity" or change_tox == "Therapy changed due to other "\
                                                                                    "reasons":
                    change = input("Please describe changes to Therapy: ")
                    change_tox = change_tox + ": " + change
                check = False
                while not check:
                    data = [
                        file_number, drug_cyc, tox_present, tox_grade,
                        treatment, resp_treatment, cyc_tox, change_tox
                    ]
                    tox_all.loc[tox_index] = data
                    check = review_df_row(tox_all)
                tox_index = tox_index + 1
                add_tox = ask_y_n_statement.ask_y_n(
                    'Add another toxicity type?')
        else:
            tox_present, tox_grade, treatment, resp_treatment, cyc_tox, change_tox = (
                "No Toxicity", ) * 6
            data = [
                file_number, drug_cyc, tox_present, tox_grade, treatment,
                resp_treatment, cyc_tox, change_tox
            ]
            tox_all.loc[tox_index] = data
        check_tox = review_df(tox_all)
    return tox_all
def habits(file_number):
    module_name = "habits"
    check = False
    while not check:
        category = "Diet"
        options = ["Vegetarian", "Non-Vegetarian", "Ovo-Vegetarian", "Other"]
        diet = ask_option(category, options)
        alcohol = ask_y_n("Alcohol consumption")
        if alcohol:
            alcohol_consump = "Alcohol Consumption"
            alcohol_age = input("Consumption of alcohol from which age (yrs): ")
            alcohol_quant = input("Quantity of alcohol consumed per week: ")
            alcohol_duration = input("Duration of alcohol consumption: ")
            alcohol_comments = input("Additional comments for alcohol consumption: ")
        else:
            alcohol_consump = "No Alcohol Consumption"
            alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments = ("NA",) * 4
        data_list_alc = [diet, alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments]
        tobacco = ask_y_n("Tobacco exposure (Passive and/or Active)")
        if tobacco:
            tobacco = "Tobacco consumption"
            exposure_type = ask_option("Mode of exposure to Tobacco", ["Passive", "Active", "Other"])
            if exposure_type =="Passive":
                tobacco_type_partic = ask_option("Mode of passive consumption", ["Home", "Work", "Commute",
                                                                                 "Social Interactions"])
                if tobacco_type_partic == "Home":
                    tobacco_type_who = input ("What is the specific source?")
                    tobacco_passive = tobacco_type_partic + (" : ") + tobacco_type_who

                else:
                    tobacco_passive = tobacco_type_partic
            else:
                tobacco_passive = "NA"
            tobacco_type = ask_option("Type of tobacco use", ["Cigarette", "Beedi", "Gutkha", "Pan Masala",
                                                              "Jarda/Maava", "Hookah", "Nicotine Patch", "Mishri",
                                                              "Other"])
            tobacco_age = input("Consumption of tobacco from which age (yrs): ")
            tobacco_freq = input ("Frequency of tobacco consumption: ")
            tobacco_quant = input("Quantity of tobacco consumed per week: ")
            tobacco_duration = input("Duration of tobacco consumption: ")
            tobacco_comments = input("Additional comments for tobacco consumption: ")
        else:
            tobacco = "No Tobacco Consumption"
            exposure_type, tobacco_type, tobacco_passive, tobacco_age, tobacco_freq, tobacco_quant, tobacco_duration, \
            tobacco_comments = ("NA",) * 8
        other_del_habits = input("Other Deleterious Habits (if present give details): ")
        data_list_tob = [tobacco, exposure_type, tobacco_passive,tobacco_type, tobacco_age, tobacco_freq,
                         tobacco_quant, tobacco_duration, tobacco_comments, other_del_habits]
        columns_list = pccm_names.names_info(module_name)
        data_list = data_list_alc + data_list_tob
        check = review_input(file_number, columns_list, data_list)
    return (tuple(data_list))
Esempio n. 8
0
def bio_info(file_number):
    module_name = "bio_info"
    check = False
    while not check:
        mr_number = input('MR number :')
        name = input('Name :')
        aadhaar_card = input("Aadhaar card number (if available): ")
        date_first = check_date("Date of first visit: ")
        permanent_address = input('Permanent Address :')
        current_address_check = ask_option('Current Address',
                                           ["Same as Permanent", "Different"])
        if current_address_check == "Different":
            current_address = input("Current Address: ")
        else:
            current_address = permanent_address
        phone = input('Phone :')
        email_id = input('Email_ID :')
        gender = ask_option('Gender', ["Female", "Male", "Other"])
        age_yrs = input('Age at first visit (yrs) :')
        age_diag = input('Age at diagnosis (yrs): ')
        date_of_birth = check_date('Date of Birth (dd/mm/yyyy):')
        place_birth = input('Place of Birth :')
        height = ask_option("Height unit",
                            ["cm", "feet/inches", "Height not available"])
        if height == "Height not available":
            height_cm = "NA"
            weight_kg = input('Weight (kg) (if available else enter NA) :')
            BMI = "NA"
        else:
            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) (if available else enter NA) :')
            try:
                weight = float(weight_kg)
                height = float(height_cm) / 100
                BMI = str(round(weight / (height * height)))
            except ValueError:
                BMI = 'NA'
        columns_list = pccm_names.names_info(module_name)
        new_data = [
            mr_number, name, aadhaar_card, date_first, permanent_address,
            current_address, phone, email_id, gender, age_yrs, age_diag,
            date_of_birth, place_birth, height_cm, weight_kg, BMI
        ]
        check = review_input(file_number, columns_list, new_data)
    return (tuple(new_data))
Esempio n. 9
0
 def tumour_biopsy_data(self):
     module_name = "tumour_biopsy_data"
     columns_list = names(module_name)
     df_cols = columns_list[:-2]
     data_list_df = pd.DataFrame(columns=df_cols)
     try:
         ihc_biopsy = sql.get_value(col_name='IHC_report_PCCM_yes_no', table=self.table,
                                    file_number=self.file_number, cursor=self.cursor)
     except sqlite3.Error:
         ihc_biopsy = ask.ask_y_n_na("Is the IHC report available?", yes_ans="IHC_report_PCCM_yes",
                                     no_ans="IHC_report_PCCM_no", na_ans="IHC Not Done")
     check = False
     while not check:
         try:
             breast_biopsy = sql.get_value(col_name='Breast_Biopsy', table=self.table,
                                           file_number=self.file_number, cursor=self.cursor)
         except sqlite3.Error:
             breast_biopsy = ask.ask_option('Breast that biopsy has been done for',
                                            ['Right Breast', 'Left Breast', 'Unilateral', "Bilateral"])
         breasts = BlockDescription.breast_list(breast_biopsy)
         for breast in breasts:
             check_breast = False
             while not check_breast:
                 print('Please input all data for ' + breast + ' block only')
                 tumour_er, tumour_er_percent, tumour_pr, tumour_pr_percent, tumour_her2, tumour_her2_grade, \
                 tumour_fish, tumour_ki67 = (ihc_biopsy, )* 8
                 if ihc_biopsy == 'IHC_report_PCCM_yes':
                     ihc_data = BlockDescription.ihc_report()
                     tumour_er, tumour_er_percent, tumour_pr, tumour_pr_percent, tumour_her2, tumour_her2_grade, \
                     tumour_fish, tumour_ki67 = ihc_data
                 fnac = ask.ask_y_n_na(question=("Lymph Node biopsy FNAC for " + breast),
                                       yes_ans="Lymph_Node_biopsy_FNAC_yes",
                                       no_ans="Lymph_Node_biopsy_FNAC_no", na_ans="Data not in report")
                 fnac_location, fnac_diagnosis = (fnac,) * 2
                 if fnac == "Lymph_Node_biopsy_FNAC_yes":
                     fnac_location = input("Please enter lymph node biopsy location: ")
                     fnac_diagnosis = ask.ask_option("Lymph Node biopsy diagnosis",
                                                     ["Lymph_Node_biopsy_malignant",
                                                      "Lymph_Node_biopsy_non_malignant",
                                                      "Data not in report"])
                 df_data = [tumour_er, tumour_er_percent, tumour_pr, tumour_pr_percent, tumour_her2,
                                    tumour_her2_grade, tumour_fish, tumour_ki67, fnac, fnac_location, fnac_diagnosis]
                 print('Data entered for ' + breast + 'is as follows:\n')
                 check_breast = sql.review_input(self.file_number, df_cols, df_data)
                 data_list_df.loc[breast] = df_data
             data_list = BlockDescription.rb_lb_data(data_list_df, df_cols)
         check = sql.review_input(self.file_number, columns_list, data_list)
     last_update = datetime.now().strftime("%Y-%b-%d %H:%M")
     data_list = data_list+[last_update]+[self.user_name]
     return data_list
Esempio n. 10
0
def drug_add(file_number, cyc_name, cycle_number, week, patient_wt,
             drug_per_week, drug_index):
    import modules.ask_y_n_statement as ask
    from sql.add_update_sql import review_df as review
    import additional_tables.chemo as chemo
    drug_add = True
    drug_cyc = []
    while drug_add:
        check_drug = False
        while not check_drug:
            drug = ask.ask_option("Drug used for therapy " + cyc_name,
                                  chemo.drug_list())
            dose = input("Dose of " + drug + " in " + week + " of " +
                         cyc_name + ": ")
            dose_unit = input("Dose unit: ")
            cyc_freq = input("Cycle Frequency: ")
            data_week = [
                file_number, cycle_number, week, patient_wt, drug,
                float(dose), dose_unit, cyc_freq
            ]
            drug_per_week.loc[drug_index] = data_week
            check_drug = review(drug_per_week.loc[drug_index])
            drug_cyc.append(drug)
            drug_index = drug_index + 1
        drug_add = ask.ask_y_n("Add another drug")
    return drug_per_week, drug_cyc, drug_index
Esempio n. 11
0
def drug_table_enter(file_number, drug_table):
    drug_add = True
    drug_index = 0
    while drug_add:
        check_drug= False
        while not check_drug:
            drug = ask_y_n_statement.ask_option("Drug used for therapy", chemo.drug_list())
            try:
                dose = input("Dose of " + drug  +" (actual dose ammount without unit, numbers only): ")
                dose_x = float(dose)
            except:
                print ('ERROR: enter numbers only')
                dose = input("Dose of " + drug  +" (actual dose ammount without unit, numbers only): ")
            dose_unit = input("Dose unit: ")
            cyc_freq_week = input("Cycle Frequency (frequency per week, so three weekly is 3 and weekly is 1): ")
            try:
                number_cycle = input("Number of cycles actually given: ")
                dose_x = int(number_cycle)
            except:
                print('ERROR: enter numbers only')
                number_cycle = input("Number of cycles actually given: ")
            try:
                drug_dose = float(dose) * int(number_cycle)
            except:
                drug_dose = 'PLEASE RE-ENTER DATA, DOSE AND NUMBER OF CYCLES MUST BE DIGITS ONLY'
            data_drug = [file_number, number_cycle, drug, str(drug_dose), dose_unit, cyc_freq_week]
            drug_table.loc[drug_index] = data_drug
            check_drug, drug_table = review_df_row(drug_table)
            drug_index = drug_index + 1
        drug_add = ask_y_n_statement.ask_y_n("Add another drug")
    return drug_table
Esempio n. 12
0
def patient_status():
    status = ask_y_n_statement.ask_option(
        "Status at last follow up",
        ["Survivor", "Deceased", "Lost to follow-up", "Other"])
    if status == "Survivor":
        type_survivor = ask_y_n_statement.ask_option("the Survivor is ", [
            "disease Free", "with recurrence",
            "disease free with no known recurrence", "with disease"
        ])
        status = status + ": " + type_survivor
    if status == "Deceased":
        type_death = ask_y_n_statement.ask_option(
            "Cause of death",
            ["due to disease", "due to unrelated causes", "not known"])
        status = status + ": " + type_death
    return status
Esempio n. 13
0
def birads():
    import modules.ask_y_n_statement as ask_y_n_statement

    mammo_birads = ask_y_n_statement.ask_option(
        "BI-RADS",
        ["0", "I", "II", "III", "IV", "IVA", "IVB", "IVC", "V", "Other"])
    check = False
    while not check:
        if mammo_birads == "0":
            mammo_birads_det = "Incomplete – Need Additional Imaging Evaluation"
        elif mammo_birads == "I":
            mammo_birads_det = "Negative"
        elif mammo_birads == "II":
            mammo_birads_det = "Benign"
        elif mammo_birads == "III":
            mammo_birads_det = "Probably Benign"
        elif mammo_birads == "IV":
            mammo_birads_det = "Suspicious"
        elif mammo_birads == "IVA":
            mammo_birads_det = "Low suspicion for malignancy"
        elif mammo_birads == "IVB":
            mammo_birads_det = "Moderate suspicion for malignancy"
        elif mammo_birads == "IVC":
            mammo_birads_det = "High suspicion for malignancy"
        elif mammo_birads == "V":
            mammo_birads_det = "Highly Suggestive of Malignancy"
        else:
            mammo_birads_det = input("Details of BI-RADS category: ")
        print("BI-RAD " + mammo_birads + ": " + mammo_birads_det)
        check = ask_y_n_statement.ask_y_n("Is this correct?")
    data_list = [mammo_birads, mammo_birads_det]
    return tuple(data_list)
Esempio n. 14
0
def clinical_tests(test):
    import modules.ask_y_n_statement as ask_y_n_statement
    test_name = test[0]
    data_list = []
    test_done = ask_y_n_statement.ask_y_n("Has " + test_name + " been done?")
    if test_done:
        test_done = test_name + " done"
        data_list.append(test_done)
        for index in range(1, len(test)):
            abnormal = test[index]
            test_diag = ask_y_n_statement.ask_option("Diagnosis",
                                                     ["Normal", abnormal])
            data_list.append(test_diag)
            if test_diag == abnormal:
                test_details = input("Please provide details of " + abnormal +
                                     " diagnosis: ")
            else:
                test_details = "NA"
            data_list.append(test_details)
    else:
        test_done = test_name + " not done"
        data_list.append(test_done)
        for index in range(1, len(test)):
            not_done = ("NA", ) * 2
            data_list.append(not_done)
    return data_list
Esempio n. 15
0
def metastasis(file_number, user_name):
    check = False
    while not check:
        met_has = ask_y_n_statement.ask_y_n(
            "Has the patient been examined for metastatic disease?")
        if not met_has:
            met_has = "Not examined for metastatic disease"
        else:
            met_has = "Examined for metastatic disease"
        date_last = input("Date of last follow-up: ")
        recur = ask_y_n_statement.ask_y_n(
            "Has the patient experienced a recurrence?")
        if recur:
            time_recur = input("Time to disease recurrence: ")
            nature_recur = ask_y_n_statement.ask_option(
                "Nature of recurrence", ["Distant", "Local", "Other"])
            if nature_recur == "Distant":
                distant_site = input("Site of distant recurrence: ")
            else:
                distant_site = "NA"
        else:
            time_recur, nature_recur, distant_site = ("NA", ) * 3
        status = patient_status()
        last_update = datetime.now().strftime("%Y-%b-%d %H:%M")
        data_list = [
            met_has, date_last, time_recur, nature_recur, distant_site, status,
            user_name, last_update
        ]
        col_list = names.names_longterm("metastasis")
        check = review_input(file_number, col_list, data_list)
    return data_list
Esempio n. 16
0
def edit_data(conn, cursor, file_number, user_name):
    table = "Follow_up_Data"
    col_list = names.name_follow_up()
    enter = view_multiple(conn, table, col_list, file_number)
    if enter == "Add data":
        data = follow_up(file_number, user_name)
        data.to_sql("Follow_up_Data", conn, index=False, if_exists="append")
    if enter == "Re-enter data":
        table = "Follow_up_Data"
        col_list = ["File_number"] + names.name_follow_up()
        sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table +
               "' WHERE File_number = '" + file_number + "'")
        df = pd.read_sql(sql, conn)
        follow_up_period = list(df.loc[:, "Follow_up_Period"])
        delete_data = True
        while delete_data:
            check_delete = False
            while not check_delete:
                col_data = ask_y_n_statement.ask_option(
                    "Which entry do you want to modify?", follow_up_period)
                check_delete = ask_y_n_statement.ask_y_n(
                    "Are you sure you want to delete data for follow-up period "
                    + col_data)
            delete_rows(cursor, table, "Follow_up_Period", col_data)
            add_data(conn, file_number, user_name)
            delete_data = ask_y_n_statement.ask_y_n(
                "Do you want to re-enter another follow up period")
Esempio n. 17
0
def define_path():
    folder_db, db_name, output_folder, output_name = (
        'D:/repos/pccm_db/main/DB', "PCCM_BreastCancerDB_all_data.db",
        'D:/repos/pccm_db/main/DB', 'Output_' + str(date.today()) + '.xlsx')
    check_folder = None
    while check_folder != 'All are correct':
        print('\nFolder location of database file is set as: \n' + folder_db +
              '\n')
        print('Database file name is set as: \n' + db_name + '\n')
        print('Output file destination is set as \n' + output_folder + '\n')
        print('Output file name is set as \n' + output_name + '\n')
        check_folder = ask_option("Do you want to change any options?", [
            'Database Folder', 'Database File', 'Output File Destination',
            'Output File Name', 'All are correct'
        ])
        if check_folder == 'Database Folder':
            print('Folder location of database file is set as: \n' +
                  folder_db + '\n')
            folder_db = input("Please enter destination folder: ")
        elif check_folder == 'Database File':
            print('Database file name is set as: \n' + db_name + '\n')
            db_name = input("Please input correct database file name: ")
        elif check_folder == 'Output File Destination':
            print('Output file destination is set as: \n' + output_folder +
                  '\n')
            output_folder = input(
                "Please input correct output file destination: ")
        elif check_folder == 'Output File Name':
            print('Output file name is set as: \n' + output_name + '\n')
            file_name = input(
                "Please input correct output file name (without date and .xlsx): "
            )
            output_name = file_name + '_' + str(date.today()) + '.xlsx'
    data_location_name = folder_db, db_name, output_folder, output_name
    return data_location_name
Esempio n. 18
0
 def edit_table(df, id_col, df_col):
     rows = df.shape[0]
     for row in range(0, rows):
         print(df.iloc[row].to_string() + '\n')
     to_correct = ask.ask_y_n("Are entries correct?")
     if not to_correct:
         to_correct = ask.ask_y_n("Re-enter entire table?")
         if to_correct:
             return to_correct, df
         else:
             change_row = True
             while change_row:
                 id_list = list(df[id_col])
                 print(id_list)
                 id_change = input("Enter " + id_col + " to change: ")
                 index = id_list.index(id)
                 to_do = True
                 while to_do:
                     print(df.loc[index, :])
                     col_change = ask.ask_option("Name of column to change", df_col)
                     old_val = df.loc[index, col_change]
                     print(old_val + '\n')
                     new_val = input("Enter correct value for " + col_change + ' for ' + id_change + ": ")
                     df.loc[index, col_change] = new_val
                     print(df.iloc[index].to_string() + '\n')
                     to_do = ask.ask_y_n("Make more changes to " + id_col + ' ' + id_change + '?')
                 ReviewSQL.print_df(df)
                 change_row = ask.ask_y_n("Change another row?")
             to_correct = False
     return to_correct, df
Esempio n. 19
0
def birads():
    import modules.ask_y_n_statement as ask_y_n_statement

    check = False
    while not check:
        mammo_birads = ask_y_n_statement.ask_option("BI-RADS Category", [
            "Category 0", "Category 1", "Category 2", "Category 3",
            "Category 4", "Category 4A", "Category 4B", "Category 4C",
            "Category 5", "Other"
        ])
        if mammo_birads == "Category 0":
            mammo_birads_det = "Incomplete – Need Additional Imaging Evaluation"
        elif mammo_birads == "Category 1":
            mammo_birads_det = "Negative"
        elif mammo_birads == "Category 2":
            mammo_birads_det = "Benign"
        elif mammo_birads == "Category 3":
            mammo_birads_det = "Probably Benign"
        elif mammo_birads == "Category 4":
            mammo_birads_det = "Suspicious"
        elif mammo_birads == "Category 4A":
            mammo_birads_det = "Low suspicion for malignancy"
        elif mammo_birads == "Category 4B":
            mammo_birads_det = "Moderate suspicion for malignancy"
        elif mammo_birads == "Category 4C":
            mammo_birads_det = "High suspicion for malignancy"
        elif mammo_birads == "Category 5":
            mammo_birads_det = "Highly Suggestive of Malignancy"
        else:
            mammo_birads_det = input("Details of BI-RADS category: ")
        birad = mammo_birads + ": " + mammo_birads_det
        print(birad)
        check = ask_y_n_statement.ask_y_n("Is this correct?")
    data_list = birad
    return data_list
Esempio n. 20
0
def family_cancer_table(conn, cursor, file_number):
    add_family = True
    type_cancer_list, relation_degree_list, type_relation_list, age_detect_list = [], [], [], []
    all_data = []
    while add_family:
        type_of_cancer = input("Type of Cancer: ")
        type_cancer_list.append(type_of_cancer)
        relation_to_patient = ask_option(
            "Relation to patient",
            ["Immediate Family", "Maternal Family", "Paternal Family"])
        relation_degree_list.append(relation_to_patient)
        type_relation = input("Specific Relationship:")
        type_relation_list.append(type_relation)
        age_at_detection_yrs = input('Age at detection (yrs) :')
        age_detect_list.append(age_at_detection_yrs)
        family_history = file_number, type_of_cancer, relation_to_patient, type_relation, age_at_detection_yrs
        family_history_list = "; ".join([
            type_of_cancer, relation_to_patient, type_relation,
            age_at_detection_yrs
        ])
        all_data.append(family_history_list)
        columns = 'File_number, Type_Cancer, Relation_to_Patient, Type_Relation, Age_at_detection_yrs'
        table = "Family_Cancer_History"
        insert(conn, cursor, table, columns, family_history)
        add_family = ask_y_n("Add more family cancer history? ")
    all_data_flat = "|".join(all_data)
    return (all_data_flat)
Esempio n. 21
0
def check_file(conn, cursor, table, file_number, user_name, folders):
    import modules.ask_y_n_statement as ask_y_n_statement
    import add_edit.add_new as add_new
    import add_edit.edit_record as edit_record
    sql = "SELECT rowid FROM " + table + " WHERE File_number = ?"
    cursor.execute(sql, (file_number, ))
    data = cursor.fetchall()
    if len(data) == 0:
        if table != "Follow_up_Data":
            cursor.execute("INSERT INTO " + table + "(File_number) VALUES ('" +
                           file_number + "')")
        print(file_number + " does not exist in table " + table +
              ". Enter new record")
        add_new.add_new(conn, cursor, file_number, table, user_name, folders)
    else:
        todo = ask_y_n_statement.ask_option(
            file_number + " already exists in table " + table + ".", [
                "Edit record", "Add new record for same file number",
                "Edit None"
            ])
        if todo == "Edit record":
            edit_record.edit_record(conn, cursor, file_number, table,
                                    user_name, folders)
        elif todo == "Add new record for same file number":
            print("Add additional record module TBD")
    ask = ask_y_n_statement.ask_y_n("Add another table?")
    return ask
Esempio n. 22
0
def metastasis(file_number, user_name):
    check = False
    while not check:
        met_has = ask_y_n_statement.ask_y_n(
            "Has the patient been examined for metastatic disease?")
        if not met_has:
            met_has = "Not examined for metastatic disease"
        else:
            met_has = "Examined for metastatic disease"
        date_last = input("Date of last follow-up: ")
        recur = ask_y_n_statement.ask_y_n(
            "Has the patient experienced a recurrence?")
        if recur:
            time_recur = input("Time to disease recurrence: ")
            nature_recur = ask_y_n_statement.ask_option(
                "Nature of recurrence", ["Distant", "Local", "Other"])
            if nature_recur == "Distant":
                distant_site = input("Site of distant recurrence: ")
            else:
                distant_site = "NA"
        else:
            time_recur, nature_recur, distant_site = ("NA", ) * 3
        status = ask_y_n_statement.ask_option(
            "Status at last follow up",
            ["Survivor", "Deceased", "Lost to follow-up", "Other"])
        if status == "Survivor":
            type_survivor = ask_y_n_statement.ask_option(
                "the Survivor is ", [
                    "disease Free", "with recurrence",
                    "disease free with no known recurrence", "with disease"
                ])
            status = status + ": " + type_survivor
        if status == "Deceased":
            type_death = ask_y_n_statement.ask_option(
                "Cause of death",
                ["due to disease", "due to unrelated causes", "not known"])
            status = status + ": " + type_death
        last_update = datetime.now().strftime("%Y-%b-%d %H:%M")
        data_list = [
            met_has, date_last, time_recur, nature_recur, distant_site, status,
            user_name, last_update
        ]
        col_list = names.names_longterm("metastasis")
        check = review_input(file_number, col_list, data_list)
    return data_list
Esempio n. 23
0
 def view_multiple(self):
     sql_view = ('SELECT ' + ", ".join(self.column) + ' FROM ' +
                 self.table + " WHERE File_number = '" + self.file_number +
                 "'")
     df = pd.read_sql(sql_view, self.conn)
     print_df(df)
     enter = ask.ask_option("Do you want to add or edit data",
                            ["Add data", 'Edit data'])
     return enter
Esempio n. 24
0
def nipple_cytology (file_number):
    module_name = "nipple_cytology"
    check = False
    while not check:
        cyto = ask_y_n_statement.ask_option("Nipple Cytology", ["Done", "Not Done"])
        if cyto == "Not Done":
            cyto_date, cyto_number, cyto_report = ("NA",)*3
        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_list = [cyto, cyto_date, cyto_number, cyto_report]
        columns_list = pccm_names.name_clinical(module_name)
        check = add_update_sql.review_input(file_number, columns_list, data_list)
    return (tuple(data_list))
Esempio n. 25
0
def view_multiple(conn, table, col_list, file_number):
    import pandas as pd
    from modules.ask_y_n_statement import ask_option
    sql = ('SELECT ' + ", ".join(col_list) + ' FROM ' + table +
           " WHERE File_number = '" + file_number + "'")
    df = pd.read_sql(sql, conn)
    print_df(df)
    enter = ask_option("Do you want to add or edit data",
                       ["Add data", 'Edit data', 'Do not add or edit'])
    return enter
Esempio n. 26
0
def lesion_location(
    lesion,
    category=["Location on Right Breast", "Location on Left Breast"],
    option=[
        "UOQ", "UIQ", "UCQ", "LOQ", "LIQ", "LCQ", "COQ", "CIQ", "CCQ",
        "Data not available", "Other"
    ]):
    import modules.ask_y_n_statement as ask_y_n_statement
    lesion_data = []
    if lesion in {"Right Breast", "Both"}:
        lesion_rb = ask_y_n_statement.ask_option(category[0], option)
        lesion_rb_data = "RB-" + lesion_rb
        lesion_data.append(lesion_rb_data)
    if lesion in {"Left Breast", "Both"}:
        lesion_lb = ask_y_n_statement.ask_option(category[1], option)
        lesion_lb_data = "LB-" + lesion_lb
        lesion_data.append(lesion_lb_data)
    lesion_data = "|".join(lesion_data)
    return lesion_data
Esempio n. 27
0
def ffpe_csv():
    folder_name, file_name, database_folder_name, database_name = (
        'D:/repos/pccm_db/main/DB', "FFPE_new_blocks.csv",
        'D:/repos/pccm_db/main/DB',
        'PCCM_BreastCancerDB_FFPE_dk_2018-11-20.db')
    check_folder = None
    while check_folder != 'All are correct':
        print('\nFolder location of FFPE new blocks data is set as: \n' +
              folder_name + '\n')
        print('File name of FFPE new blocks data is set as: \n' + file_name +
              '\n')
        print('Database file folder is set as \n' + database_folder_name +
              '\n')
        print('Database file name is set as \n' + database_name + '\n')
        check_folder = ask_option("Do you want to change any options?", [
            'FFPE File Folder', 'FFPE File Name', 'Database Folder',
            'Database Name', 'All are correct'
        ])
        if check_folder == 'FFPE File Folder':
            print('Folder location of FFPE new blocks data is set as \n' +
                  folder_name + '\n')
            folder_name = input(
                "Please enter folder location of FFPE new blocks data: ")
        elif check_folder == 'FFPE File Name':
            print('File name of FFPE new blocks data is set as: \n' +
                  file_name + '\n')
            file_name = input(
                "Please input correct File name of FFPE new blocks data (with .csv extension): "
            )
        elif check_folder == 'Database Folder':
            print('Database file folder is set as: \n' + database_folder_name +
                  '\n')
            database_folder_name = input(
                "Please input correct database file destination: ")
        elif check_folder == 'Database Name':
            print('Database file name is set as: \n' + database_name + '\n')
            database_name = input(
                "Please input correct database file name (with .db extension): "
            )
    conn_path = os.path.join(database_folder_name, database_name)
    conn = sqlite3.connect(conn_path)
    cursor = conn.cursor()
    ffpe_data = FFPECSVData(conn, cursor, folder_name, file_name)
    ffpe_df = ffpe_data.read_file()
    n_rows = ffpe_df.shape[1]
    print(str(n_rows) + ' block entries read from file uploaded')
    ffpe_str = ffpe_df.astype(dtype='str')
    ffpe_data.write_file(ffpe_str)
    print(
        str(n_rows) + ' block entries added to ' + database_name + ' database')
    output_file_name = 'Uploaded_Database_' + file_name + str(
        date.today()) + '.xlsx'
    file_information = database_folder_name, database_name, folder_name, output_file_name
    print_file = OutputData(file_information)
    print_file.output_data()
Esempio n. 28
0
def review_data(conn, cursor, table, file_number, col_list):
    import modules.ask_y_n_statement as ask
    sql = ('SELECT ' + ", ".join(col_list) + ' FROM ' + table +
           " WHERE File_number = '" + file_number + "'")
    data = cursor.execute(sql)
    data_list = data.fetchall()
    data_list = list(data_list[0])
    col_number = len(col_list)
    if data_list == [None] * len(data_list):
        print("This section of the database has not been entered")
        enter = ask.ask_y_n("Do you want to enter now")
        return enter
    if None in set(data_list):
        print("Some entries are missing from the database: ")
        for index in range(0, col_number):
            print(col_list[index] + " : " + str(data_list[index]))
        enter = ask.ask_option("Do you want to proceed?",
                               ["Edit all", "Add new data only"])
        if enter == "Edit all":
            return True
        else:
            edit_few(conn, cursor, table, col_list, file_number, data_list)
    else:
        print("Entries present in database are as follows : ")
        for index in range(0, col_number):
            print(col_list[index] + " : " + str(data_list[index]))
        enter = ask.ask_option("Do you want to",
                               ["Edit all", "Edit some entries", "Edit None"])
        if enter == "Edit some entries":
            for index in range(0, col_number):
                print(col_list[index] + " : " + str(data_list[index]))
                edit = ask.ask_y_n("Edit")
                if edit:
                    data = input("Data for " + col_list[index] + ": ")
                    update_single(conn, cursor, table, col_list[index],
                                  file_number, data)
            return False
        elif enter == "Edit all":
            return True
        else:
            return False
Esempio n. 29
0
 def biopsy_details(self, df_cols):
     data_list_df = pd.DataFrame(columns=df_cols)
     breast_biopsy = ask.ask_option('Breast that biopsy has been done for',
                                    ['Right Breast', 'Left Breast', 'Unilateral', "Bilateral"])
     breasts = BlockDescription.breast_list(breast_biopsy)
     for breast in breasts:
         check_breast = False
         while not check_breast:
             print('Please input all data for ' + breast + ' report only')
             block_sr, block_location, block_id, block_number = ('block_not_available',) * 4
             block_check = ask.ask_y_n('Are the biopsy blocks available?')
             if block_check:
                 block_sr = input("Biopsy Block Serial Number: ")
                 block_location = BlockDescription.block_location()
                 block_id = input("Biopsy Block ID (include series identifiers): ")
                 block_number = input("Number of blocks: ")
             biopsy_date = ask.check_date("Date of Biopsy: ")
             biopsy_lab_id = input("Biopsy Lab ID/SID: ")
             print('Please input all data for ' + breast + ' block only')
             biopsy_type = ask.ask_option("Biopsy Type",
                                          ["Direct", "USG Guided", "VAB", "Tru-cut", "Steriotactic", 'Core',
                                           'Excision', 'FNAC', "Other"])
             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.ask_option(category, options)
             tumour_grade = ask.ask_option("Tumour Biopsy Diagnosis", ["I", "II", "III"])
             lymph_emboli = ask.ask_y_n_na(question="Are Lymphovascular emboli seen?",
                                           yes_ans='Lymphovascular_emboli_biopsy_yes',
                                           no_ans='Lymphovascular_emboli_biopsy_no', na_ans='Data not in report')
             dcis_biopsy = ask.ask_y_n_na(question="Does the biopsy show DCIS", yes_ans="DCIS_biopsy_yes",
                                          no_ans="DCIS_biopsy_no", na_ans="Data not in report")
             df_data = [block_sr, block_location, block_id, block_number, biopsy_date, biopsy_lab_id, biopsy_type,
                        tumour_diagnosis, tumour_grade, lymph_emboli, dcis_biopsy]
             print('Data entered for ' + breast + ' is as follows:\n')
             check_breast = sql.review_input(self.file_number, df_cols, df_data)
         data_list_df.loc[breast] = df_data
     return data_list_df, breast_biopsy
Esempio n. 30
0
def cal_table(file_number, mammo_breast):
    import modules.ask_y_n_statement as ask_y_n_statement
    import sql.add_update_sql as add_update_sql
    import modules.pccm_names as pccm_names
    table = "Calcification_Mammography"
    mass_number = input("Number of groups of calcifications detected? ")
    try:
        number_calc = int(mass_number)
    except:
        number_calc = 1
    location, calc_type = [list([]) for _ in range(2)]
    for index in range(0, number_calc):
        check = False
        while not check:
            mass_id = index + 1
            if mammo_breast == "Bilateral":
                mass_location = ask_y_n_statement.ask_option(
                    "Location of calcification group " + str(mass_id),
                    ["Right Breast", "Left Breast"])
                location.append(mass_location)
            else:
                mass_location = mammo_breast
            mammo_calcification = ask_y_n_statement.ask_option(
                "Calcification Type ", [
                    "Skin", "Vascular", "Coarse or 'Popcorn-like'",
                    "Large Rod-like", "Round and punctate", "Eggshell or Rim",
                    "Dystrophic", "Suture", "Amorphous",
                    "Coarse Heterogeneous", "Fine Pleomorphic",
                    "Fine Linear or Fine Linear Branching", "Other"
                ])
            calc_type.append(mammo_calcification)
            mass_id = "Group " + str(index + 1)
            data_list = [
                file_number, mass_id, mass_location, mammo_calcification
            ]
            col_list = pccm_names.names_radio_df(table)
            check = add_update_sql.review_input(file_number, col_list,
                                                data_list)
    all_data = [[str(mass_number)], location, calc_type]
    data_return = ask_y_n_statement.join_lists(all_data, "; ")
    return tuple(data_return)