示例#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
示例#2
0
 def rb_lb_data(df, cols):
     data_all = []
     for col in cols:
         data = list(df[col])
         data_all.append(data)
     if list(df.shape)[0] == 2:
         for data in data_all:
             data[0] = 'RB: ' + data[0]
             data[1] = 'LB: ' + data[1]
     data_list = ask.join_lists(data_all, "| ")
     return data_list
示例#3
0
def follow_up(file_number, user_name):
    follow = True
    follow_index = 0
    col_list = ["File_number"] + names.name_follow_up()
    follow_up_data = pd.DataFrame(columns=col_list)
    while follow:
        check = False
        while not check:
            time_follow = ask_y_n_statement.ask_option("Follow-up Period", [
                "3 months", "6 months", "9 months", "1 year",
                "1 year, 3 months", "1 year, 6 months", "1 year, 9 months",
                "2 years", "2 years, 6 months", "3 years", "3 years, 6 months",
                "4 years", "4 years, 6 months", "5 years", "6 years",
                "7 years", "8 years", "9 years", "10 years", "Other"
            ])
            follow_notes = input("Details of follow up information: ")
            follow_report = ask_y_n_statement.ask_y_n(
                "Does follow-up contain other reports (USG/Mammography)?")
            follow_mammo, follow_usg = ("NA", ) * 2
            if follow_report:
                follow_mammo = input("Results of Mammography: ")
                follow_usg = input("Results of USG abdomen/Pelvis: ")
            follow_other = ask_y_n_statement.ask_y_n(
                "Are there other reports in follow-up?")
            if not follow_other:
                other_type, other_result = ("NA", ) * 2
            else:
                other_type_list = []
                other_result_list = []
                while follow_other:
                    other_type = input("Type of other report: ")
                    other_result = input("Result of " + other_type + ": ")
                    other_type_list.append(other_type)
                    other_result_list.append(other_result)
                    follow_other = ask_y_n_statement.ask_y_n(
                        "Add more reports?")
                all_data = [other_type_list, other_result_list]
                all_data = ask_y_n_statement.join_lists(all_data, "; ")
                other_type, other_result = all_data
            last_update = datetime.now().strftime("%Y-%b-%d %H:%M")
            data_list = [
                file_number, time_follow, follow_notes, follow_mammo,
                follow_usg, other_type, other_result, user_name, last_update
            ]
            follow_up_data.loc[follow_index] = data_list
            check = review_df(follow_up_data.loc[follow_index])
        follow_index = follow_index + 1
        follow_up_period = list(follow_up_data.loc[:, "Follow_up_Period"])
        print("Follow up periods added: " + "; ".join(follow_up_period))
        follow = ask_y_n_statement.ask_y_n("Add another follow-up period?")
    return follow_up_data
示例#4
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)
示例#5
0
def feed_duration(conn, cursor, file_number, children_number):
    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 Breast", "Left Breast", "Both Breasts", "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)
    data_list = [child_list, feeding_duration_list, feeding_details_list]
    data_return = join_lists(data_list, "; ")
    return (data_return)
示例#6
0
 def surgery_block_information_2(self):
     module_name = self.module_list[1]
     check = False
     while not check:
         no_blocks = sql.get_value(
             col_name='Number_Blocks_Surgery_Block',
             table=self.table,
             file_number=self.file_number,
             cursor=self.cursor,
             error_statement=
             "Please input number of blocks (if block information is not available "
             "please enter 0: ")
         block_id = sql.get_value(col_name='Block_ID_Surgery_Block',
                                  table=self.table,
                                  file_number=self.file_number,
                                  cursor=self.cursor,
                                  error_statement="Please input block id: ")
         blocks = BlockDescription(self.file_number, block_id, no_blocks)
         block_desc_df, block_data_all = blocks.block_description()
         breast_cancer_yes_no = sql.get_value(
             col_name='Breast_Cancer_Yes_No_Surgery_Block',
             table=self.table,
             file_number=self.file_number,
             cursor=self.cursor,
             error_statement=
             'Is this a case of breast cancer if yes answer if yes '
             'answer breast cancer_yes and if no answer '
             'breast cancer_no')
         tumour_size, tumour_unit, tumour_grade, surg_diag, dcis_yes_no, dcis_type, dcis_percent, tumour_invasion, \
         per_inv, necrosis, percent_vasc_invasion, percent_lymph_invasion, percent_stroma, margin, margin_id, \
         margin_type = (breast_cancer_yes_no, )*16
         if breast_cancer_yes_no == 'breast cancer_yes':
             tumour_size = input(
                 "Tumour size (please input dimension only, e.g, 1 x 3 x 4): "
             )
             tumour_unit = ask.ask_option("Tumour size unit", ['mm', 'cm'])
             tumour_grade = ask.ask_option("Tumour Grade",
                                           ["I", "II", "III"])
             surg_diag = ask.ask_option("Surgery Diagnosis",
                                        names('diagnosis'))
             dcis_yes_no = ask.ask_y_n_na('Is DCIS present',
                                          yes_ans='dcis_yes',
                                          no_ans='dcis_no',
                                          na_ans='Data not in Report')
             dcis_type, dcis_percent = (dcis_yes_no, ) * 2
             if dcis_yes_no == 'dcis_yes':
                 dcis_type = input(
                     'Enter type of DCIS if textual description given (else enter NA): '
                 )
                 dcis_percent = input("Percent DCIS (number only): ")
             tumour_invasion = ask.ask_option(
                 "Type of Tumour Invasion",
                 ['Microinvasion', 'Macroinvasion'])
             per_inv = ask.ask_y_n_na(question="Perineural Invasion",
                                      yes_ans='perineural_invasion_yes',
                                      no_ans='perineural_invasion_no',
                                      na_ans='Data not in Report')
             necrosis = ask.ask_y_n_na("Necrosis",
                                       yes_ans='necrosis_yes',
                                       no_ans='necrosis_no',
                                       na_ans='Data not in Report')
             percent_vasc_invasion = input(
                 "Percent Vascular Invasion "
                 "Enter number only; Enter 'Data not in report' if not available: "
             )
             percent_lymph_invasion = input(
                 "Percent Lymphocyte Invasion "
                 "Enter number only; Enter 'Data not in report' if not available: "
             )
             percent_stroma = input(
                 "Percent Stroma "
                 "Enter number only; Enter 'Data not in report' if not available: "
             )
             margin = ask.ask_option("Margins", [
                 "Surgery_Block_Margins_involved",
                 "Surgery_Block_Margins_free"
             ])
             margin_id, margin_type = ('NA', ) * 2
             if margin == 'Surgery_Block_Margins_involved':
                 margin_id = input('Margin that is involved: ')
                 margin_type = input('Margin type: ')
         tumour_block_ref, node_block_ref, ad_normal_block_ref, red_tissue_block_ref \
             = ask.join_lists(block_data_all, sep="; ")
         data_list = [
             tumour_block_ref, node_block_ref, ad_normal_block_ref,
             red_tissue_block_ref, tumour_size, tumour_unit, tumour_grade,
             surg_diag, dcis_yes_no, dcis_type, dcis_percent,
             tumour_invasion, per_inv, necrosis, percent_vasc_invasion,
             percent_lymph_invasion, percent_stroma, margin, margin_id,
             margin_type
         ]
         columns_list = names(module_name)
         check = sql.review_input(self.file_number, columns_list, data_list)
     return (tuple(data_list), block_desc_df)
示例#7
0
def chemotherapy(file_number, user_name):
    col_drug = names("Chemo_Drug_Table")
    drug_table = pd.DataFrame(columns=col_drug)
    col_tox = names('Chemo_Tox_table')
    toxicity = pd.DataFrame(columns=col_tox)
    check = False
    while not check:
        chemo = ask_y_n_statement.ask_y_n_na(
            "Has adjuvant chemotherapy been done for the patient?")
        if chemo == 'Yes':
            place_chemo = ask_y_n_statement.ask_y_n_na(
                "Has Adjuvant Chemotherapy been done at PCCM?", "At PCCM",
                "Outside", "Not Certain, requires follow-up")
            details_chemo = ask_y_n_statement.ask_y_n(
                "Are Adjuvant Chemotherapy details available?",
                "Details Available", "Follow-up required")
            chemo = "Adjuvant Chemotherapy given"
            if details_chemo == "Follow-up required":
                plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, tox_type, tox_grade, \
                tox_treat, tox_response, tox_cycle, change_tox,chemo_response_by, chemo_response, chemo_size, \
                chemo_size_date, trast_chemo, trast_regime, trast_courses,date_complete, reason_incomplete, \
                hormone_therapy, therapy_type, therapy_duration, therapy_side, ovary_status, patient_wt, drug_freq\
                    = (details_chemo,)*28
            elif details_chemo == "Details Available":
                plan_chemo = input(
                    "What is the plan of Adjuvant Chemotherapy (for eg., "
                    "4 cycles AC followed by 12 cycles Paclitaxel):")
                date_start_chemo = ask_y_n_statement.check_date(
                    "Date of starting Adjuvant Chemotherapy: ")
                patient_wt = input(
                    "Weight of patient at start of therapy (in kgs): ")
                check_wt = ask_y_n_statement.ask_y_n(
                    "Is weight at any other time point mentioned in report?")
                while check_wt:
                    other_wt = input("Time point at which weight mentioned: ")
                    other_wt = other_wt + " " + input("Weight of patient at " +
                                                      other_wt + ": ")
                    patient_wt = patient_wt + "; " + other_wt
                    check_wt = ask_y_n_statement.ask_y_n(
                        "Is weight at any other time point mentioned in report "
                        "(with date, if given)?")
                drug_table = drug_table_enter(file_number, drug_table)
                data_drug = col_drug[1:]
                data_drug_list = []
                for index in data_drug:
                    data_drug = "; ".join(list(drug_table.loc[:, index]))
                    data_drug_list.append(data_drug)
                drug_cyc, cyc_number, drug_freq, drug_doses, drug_units = data_drug_list
                check_drug_tox = False
                while not check_drug_tox:
                    toxicity = tox_table(file_number, drug_cyc, toxicity)
                    check_drug_tox = review_df(toxicity)
                columns = col_tox
                tox_details = []
                for column in columns:
                    tox_detail = toxicity.loc[:, column].drop_duplicates()
                    tox_details.append(list(tox_detail))
                tox_details = ask_y_n_statement.join_lists(tox_details, "; ")
                file_number_tox, drug_tox, tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox \
                    = tox_details
                trast_chemo = ask_y_n_statement.ask_y_n("Trastuzumab used?")
                if trast_chemo:
                    trast_regime = ask_y_n_statement.ask_option(
                        "Trastuzumab use was", ["Sequential", "Concurrent"])
                    trast_chemo = "Trastuzumab used"
                    trast_courses = input(
                        "Number of courses of trastuzumab/herceptin taken: ")
                else:
                    trast_chemo, trast_regime, trast_courses, therapy_side = (
                        "Trastuzumab not used", ) * 4
                date_complete = ask_y_n_statement.check_date(
                    "Date of completion of Adjuvant Chemotherapy: ")
                complete_chemo = ask_y_n_statement.ask_y_n(
                    "Was Adjuvant Chemotherapy completed as per schedule?")
                if complete_chemo:
                    reason_incomplete = "Adjuvant Chemotherapy completed as per schedule"
                else:
                    reason_incomplete = ask_y_n_statement.ask_option(
                        "Reason for discontinuation", [
                            "Toxicity", "Reluctance of patient",
                            "Progression on chemotherapy",
                            "Advised by treating doctor",
                            "Death due to toxicity",
                            "Death due to progressive disease",
                            "Preferred treatment at another centre",
                            "Death due to unrelated cause",
                            "Patient was unable to afford treatment"
                        ])
                    reason_incomplete = "Adjuvant Chemotherapy incomplete: " + reason_incomplete
                menopause = ask_y_n_statement.ask_option(
                    "Menopausal Status", [
                        "Pre-menopausal", "Peri-menopausal", "Post-Menopausal",
                        "Other"
                    ])
                if menopause in {"Pre-menopausal", "Peri-menopausal"}:
                    ovary_status = ask_y_n_statement.ask_option(
                        "Status of ovarian function after Chemotherapy", [
                            "Menses ongoing", "Amenorrhoea on Chemo",
                            "Amenorrhoea post Chemotherapy"
                        ])
                else:
                    ovary_status = menopause
                #hormone_therapy, therapy_type, therapy_duration, therapy_side = hormone_therapy_chemo()
                hormone_therapy, therapy_type, therapy_duration, therapy_side = (
                    'NA', ) * 4
            else:
                plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, drug_freq,tox_type, \
                tox_grade, tox_treat, tox_response, tox_cycle, change_tox,chemo_response_by, chemo_response, \
                chemo_size, chemo_size_date, trast_chemo, trast_regime, trast_courses, hormone_therapy,  therapy_type, \
                therapy_duration, therapy_side, date_complete, reason_incomplete,ovary_status, patient_wt \
                    = (details_chemo,)*28
        elif chemo == 'No':
            place_chemo, plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, \
            drug_freq,tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox, chemo_response_by, \
            chemo_response, chemo_size, chemo_size_date, trast_chemo, trast_regime, trast_courses, hormone_therapy, \
            therapy_type, therapy_duration, therapy_side, date_complete, reason_incomplete, details_chemo, chemo, \
            ovary_status, patient_wt = ("Adjuvant Chemotherapy not given",)*31
        else:
            place_chemo, plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, drug_freq, \
            tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox, chemo_response_by, chemo_response, \
            chemo_size, chemo_size_date, trast_chemo, trast_regime, trast_courses, hormone_therapy, therapy_type, \
            therapy_duration,ovary_status, therapy_side, date_complete, reason_incomplete, details_chemo, patient_wt \
                = (chemo,)*30
        last_update = datetime.now().strftime("%Y-%b-%d %H:%M")
        data_list = [
            chemo, place_chemo, details_chemo, plan_chemo, date_start_chemo,
            patient_wt, drug_cyc, cyc_number, drug_freq, drug_doses,
            drug_units, tox_type, tox_grade, tox_treat, tox_response,
            tox_cycle, change_tox, reason_incomplete, date_complete,
            trast_chemo, trast_regime, trast_courses, ovary_status,
            hormone_therapy, therapy_type, therapy_duration, therapy_side,
            user_name, last_update
        ]
        col_list = names("Adjuvant_ChemoTherapy")
        check = review_input(file_number, col_list, data_list)
    return data_list, drug_table, toxicity
示例#8
0
def nact_test(file_number, user_name):
    col_drug = names("NACT_Drug_Table")
    drug_table = pd.DataFrame(columns=col_drug)
    col_tox = names('NACT_Tox_table')
    toxicity = pd.DataFrame(columns=col_tox)
    check = False
    while not check:
        nact = ask_y_n_statement.ask_y_n_na("Has neo adjuvant therapy been done for the patient (Please check for "
                                            "chemotherapy and/hormone therapy)?")
        if nact == 'Yes':
            place_nact = ask_y_n_statement.ask_y_n_na("Has neo adjuvant therapy been done at PCCM?", "At PCCM",
                                                      "Outside", "Not Certain, requires follow-up")
            details_nact = ask_y_n_statement.ask_y_n("Are neo adjuvant therapy details available?", "Details Available",
                                                     "Follow-up required")
            if details_nact == "Follow-up required":
                plan_nact, date_start_nact, patient_wt, cyc_number, drug_cyc, drug_doses, drug_units, drug_freq, \
                tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox,nact_response_by, nact_response, \
                nact_size, nact_size_unit, nact_size_date, trast_nact, trast_regime, trast_courses, date_complete, \
                reason_incomplete, hormone_therapy,  therapy_type, therapy_duration, therapy_side = (details_nact,)*28
            elif details_nact == "Details Available":
                plan_nact = input("What is the plan of NACT (for eg., 4 cycles AC followed by 12 cycles Paclitaxel; "
                                  "Include hormone therapy plan here):")
                date_start_nact = ask_y_n_statement.check_date("Date of starting neo-adjuvant therapy: ")
                patient_wt = input("Weight of patient at start of therapy (in kgs): ")
                check_wt = ask_y_n_statement.ask_y_n("Is weight at any other time point mentioned in report "
                                                     "(with date, if given)?")
                while check_wt:
                    other_wt = input("Time point at which weight mentioned: ")
                    other_wt = other_wt + " " + input("Weight of patient at " + other_wt + ": ")
                    patient_wt = patient_wt + "; " + other_wt
                    check_wt = ask_y_n_statement.ask_y_n("Is weight at any other time point mentioned in report "
                                                         "(with date, if given)?")
                drug_admin = drug_table_enter(file_number, drug_table)
                data_drug = ['Number_cycle', 'Drug', 'Drug_dose', 'Dose_unit', 'Cycle_frequency_per_week']
                data_drug_list = []
                for index in data_drug:
                    data_drug = "; ".join(list(drug_admin.loc[:, index]))
                    data_drug_list.append(data_drug)
                cyc_number, drug_cyc, drug_doses, drug_units, drug_freq = data_drug_list
                check_drug_tox = False
                while not check_drug_tox:
                    toxicity = tox_table(file_number, drug_cyc, toxicity)
                    check_drug_tox = review_df(toxicity)
                columns = col_tox
                tox_details = []
                for column in columns:
                    tox_detail = toxicity.loc[:, column].drop_duplicates()
                    tox_details.append(list(tox_detail))
                tox_details = ask_y_n_statement.join_lists(tox_details, "; ")
                file_number_tox, drug_tox, tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox \
                    = tox_details
                nact_response_by = ask_y_n_statement.ask_option("Response to NACT measured by", ['Mammography',
                                                                                                 'SonoMammography'])
                if nact_response_by == "Data not in Report" or nact_response_by == "Requires Follow-up":
                    nact_response, nact_size, nact_size_unit, nact_size_date = (nact_response_by,)*4
                else:
                    nact_response = ask_y_n_statement.ask_option("Response of tumour",
                                                                 ["Partial", "Complete", "No Effect", "Other"])
                    nact_size = input("Tumour size (without unit, e.g., 2 x 4 x 5) after treatment: ")
                    nact_size_unit = ask_y_n_statement.ask_option("Tumour size unit", ['mm', 'cm'])
                    nact_size_date = ask_y_n_statement.check_date("Date tumour size checked: ")
                trast_nact = ask_y_n_statement.ask_y_n("Trastuzumab used?")
                if trast_nact:
                    trast_regime = ask_y_n_statement.ask_option("Trastuzumab use was", ["Sequential", "Concurrent"])
                    trast_nact = "Trastuzumab used"
                    trast_courses = input("Number of courses of trastuzumab/herceptin taken: ")
                else:
                    trast_nact, trast_regime, trast_courses, therapy_side = ("Trastuzumab not used", )*4
                date_complete = ask_y_n_statement.check_date("Date of completion of NACT: ")
                complete_nact = ask_y_n_statement.ask_y_n("Was NACT completed as per schedule? ")
                if complete_nact:
                    reason_incomplete = "NACT completed as per schedule"
                else:
                    reason_incomplete = ask_y_n_statement.ask_option("Reason for discontinuation",
                                                                     ["Toxicity", "Reluctance of patient",
                                                                      "Progression on chemotherapy",
                                                                      "Advised by treating doctor",
                                                                      "Death due to toxicity",
                                                                      "Death due to progressive disease",
                                                                      "Preferred treatment at another centre",
                                                                      "Death due to unrelated cause",
                                                                      "Patient was unable to afford treatment"])
                    reason_incomplete = "NACT incomplete: " + reason_incomplete
                hormone_therapy = ask_y_n_statement.ask_y_n_na("Was hormone therapy given?")
                if hormone_therapy == 'Yes':
                    hormone_therapy = "Hormone therapy given"
                    therapy_type = ask_y_n_statement.ask_option("Hormone therapy type", ["Sequential", "Concurrent"])
                    therapy_duration = input("What was the duration of therapy? ")
                    therapy_side = ask_y_n_statement.ask_y_n_na("Were any side effects observed ?")
                    if therapy_side == 'Yes':
                        therapy_side = input("Please give details of side effects observed: ")
                    nact_naht = ask_y_n_statement.ask_y_n('Was chemotherapy given in addition to hormone therapy?')
                    if nact_naht:
                        nact = 'NACT and NAHT given'
                    else:
                        nact = 'NAHT given'
                elif hormone_therapy == 'No':
                    hormone_therapy = "No hormone therapy given"
                    nact = "NACT given"
                    therapy_type, therapy_duration, therapy_side = (hormone_therapy,) * 3
                else:
                    therapy_type, therapy_duration, therapy_side = (hormone_therapy,) * 3
                    nact = "NACT given"
            else:
                plan_nact, date_start_nact, cyc_number, drug_cyc, drug_doses, drug_units, drug_freq, tox_type, \
                tox_grade, tox_treat, tox_response, tox_cycle, change_tox, nact_response_by, nact_response, nact_size, \
                nact_size_unit, nact_size_date, trast_nact, trast_regime, trast_courses, hormone_therapy,  \
                therapy_type, therapy_duration, therapy_side, date_complete, reason_incomplete, patient_wt \
                    = (details_nact,)*28
        elif nact == 'No':
            place_nact, plan_nact, date_start_nact, cyc_number, drug_cyc, drug_doses, drug_units, drug_freq, tox_type, \
            tox_grade, tox_treat, tox_response, tox_cycle, change_tox, nact_response_by, nact_response, \
            nact_size, nact_size_unit, nact_size_date, trast_nact, trast_regime, trast_courses, hormone_therapy,  \
            therapy_type, therapy_duration, therapy_side, date_complete, reason_incomplete, details_nact, nact, \
            patient_wt = ("NACT/NAHT not given",)*31
        else:
            place_nact, plan_nact, date_start_nact, cyc_number, drug_cyc, drug_doses, drug_units,  drug_freq, tox_type,\
            tox_grade, tox_treat, tox_response, tox_cycle, change_tox, nact_response_by, nact_response, \
            nact_size, nact_size_unit, nact_size_date, trast_nact, trast_regime, trast_courses, hormone_therapy,  \
            therapy_type, therapy_duration, therapy_side, date_complete, reason_incomplete, details_nact, patient_wt \
                = (nact,)*30

        last_update = datetime.now().strftime("%Y-%b-%d %H:%M")
        data_list = [nact,  place_nact,  details_nact,  plan_nact,  date_start_nact, patient_wt, drug_cyc,
                     cyc_number, drug_freq, drug_doses,  drug_units, tox_type, tox_grade, tox_treat, tox_response,
                     tox_cycle,  change_tox, nact_response_by, nact_response, nact_size, nact_size_unit, nact_size_date,
                     reason_incomplete, date_complete, trast_nact, trast_regime, trast_courses, hormone_therapy,
                     therapy_type, therapy_duration, therapy_side, user_name, last_update]
        col_list = names("Neo_Adjuvant_Therapy")
        check = review_input(file_number, col_list, data_list)
    return data_list, drug_table, toxicity
示例#9
0
def post_surgery(file_number, user_name):
    check = False
    while not check:
        check_drain = ask_y_n('Was drain inserted post surgery?')
        drain, total_drain = ('No drain used', ) * 2
        if check_drain:
            drain = input("Drain removal date: ")
            total_drain = input("Total drain days: ")
        post_comp = ask_y_n("Did post-surgery complications occur?")
        if post_comp:
            df_complications_col = ["Day", "Complication", "Treatment"]
            df_complications = pd.DataFrame(columns=df_complications_col)
            day_add = True
            index = 0
            while day_add:
                comp = surgery_tables.surg_complications("post_surgery_comp")
                day = "Day " + input("Days post surgery: ")
                treatment_list = []
                complication = []
                for i in comp:
                    data = ask_y_n("On " + str(day) +
                                   " did post surgery complication " + i +
                                   " occur?")
                    if data:
                        complication.append(i)
                        treatment = ask_option(
                            "What treatment was done for " + str(i),
                            surgery_tables.surg_complications(
                                "surgical_treatment"))
                        if treatment == 'Non surgical treatment':
                            treatment = input(
                                "What type of non surgical treatment was used?"
                            )
                        else:
                            treatment = "Surgical treatment - " + treatment
                        treatment_list.append(treatment)
                complication = "; ".join(complication)
                treatment_list = "; ".join(treatment_list)
                data = [day, complication, treatment_list]
                df_complications.loc[index] = data
                index = index + 1
                day_add = ask_y_n(
                    "Add another day for post surgery complications? ")
            all_data = []
            for index in df_complications_col:
                data = "; ".join(list(df_complications.loc[:, index]))
                all_data.append(data)
            days, complications, treatments = all_data
        else:
            days, complications, treatments = (
                "No post surgical complications", ) * 3
        chemo = ask_option_y_n("Is chemotherapy planned?",
                               "Chemotherapy planned", "No Chemotherapy")
        radio = ask_option_y_n("Is radiotherapy planned?",
                               "Radiotherapy planned", "No Radiotherapy")
        other = ask_option_y_n("Are there any other post-surgery plans")
        if other == 'Yes':
            other = input("Please specify other post-surgery plans: ")
        elif other == 'No':
            other = "No other post surgery plans"
        recur = ask_option_y_n("Did recurrence occur post surgery?")
        if recur == 'Yes':
            recurs = []
            days_recurs = []
            late_add = True
            recur = surgery_tables.surg_complications("recurrence_sites")
            while late_add:
                day = "Day " + input("Days post surgery: ")
                for i in recur:
                    data = ask_y_n("On " + str(day) + " did " + i +
                                   " recurrence occur?")
                    if data:
                        recurs.append(i)
                if recurs == []:
                    recurs = "No recurrence post surgery"
                days_recurs.append(day)
                late_add = ask_y_n(
                    "Add another day for post surgery recurrence? ")
            all_data = [days_recurs, recurs]
            days_recurs, recurs = join_lists(all_data, "; ")
        elif recur == 'No':
            days_recurs, recurs = ("No recurrence post surgery", ) * 2
        else:
            days_recurs, recurs = (recur, ) * 2
        opd = input("Please input OPD notes (if any): ")
        last_update = datetime.now().strftime("%Y-%b-%d %H:%M")
        data_list = [
            chemo, radio, other, drain, total_drain, days, complications,
            treatments, days_recurs, recurs, opd, user_name, last_update
        ]
        col_list = names("post_surgery")
        check = add_update_sql.review_input(file_number, col_list, data_list)
    return data_list
示例#10
0
def multiple_mass(table, conn, cursor, file_number):
    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

    mass_number = int(input("Number of masses detected: "))
    if table == "SonnoMammography_Multiple_Mass":
        sonno_quad, sonno_location, sonno_clock, sonno_shape,  sonno_depth, sonno_distance, sonno_pect,sonno_orientation,\
        sonno_margin, sonno_echo, sonno_posterior = [list([]) for _ in range(11)]
    if table == "Mammography_Multiple_Mass":
        location, quad, pect, depth, distance, shape, margin, density = [
            list([]) for _ in range(8)
        ]
    if table == "MRI_Multiple_Mass":
        location, quad, shape, margin, internal = [list([]) for _ in range(5)]
    for index in range(0, mass_number):
        check = False
        while not check:
            mass_id = index + 1
            if table == "Mammography_Multiple_Mass":
                mass_location = ask_y_n_statement.ask_option(
                    "Location of mass " + str(mass_id),
                    ["Right Breast", "Left Breast"])
                location_quad = lesion_location(mass_location)
                mass_depth = ask_y_n_statement.ask_option(
                    "Depth of " + str(mass_id),
                    ["Anterior", "Middle", "Posterior", "Other"])
                mass_dist = ask_y_n_statement.ask_option(
                    "Distance from nipple", ["<0.5 cm", ">0.5 cm", "Other"])
                pect_check = ask_y_n_statement.ask_y_n(
                    "Is distance from Pectoralis Major described for " +
                    str(mass_id))
                if pect_check:
                    mass_pect = input("Distance from Pectoralis Major (cm): ")
                else:
                    mass_pect = "Distance from Pectoralis Major not described"
                depth.append(mass_depth)
                location.append(mass_location)
                distance.append(mass_dist)
                quad.append(location_quad)
                pect.append(mass_pect)
                mammo_mass_shape = ask_y_n_statement.ask_option(
                    "Shape of mass", ["Oval", "Round", "Irregular", "Other"])
                shape.append(mammo_mass_shape)
                mammo_mass_margin = ask_y_n_statement.ask_option(
                    "Margins of mass", [
                        "Circumscribed", "Obscured", "Microlobulated",
                        "Indistinct", "Spiculated", "Other"
                    ])
                margin.append(mammo_mass_margin)
                mammo_mass_density = ask_y_n_statement.ask_option(
                    "Density of mass", [
                        "High density", "Equal density", "Low density",
                        "Fat-containing", "Other"
                    ])
                density.append(mammo_mass_density)
                mass_id = "Mass " + str(index + 1)
                data_list = [
                    file_number, mass_id, mass_location, location_quad,
                    mass_depth, mass_dist, mass_pect, mammo_mass_shape,
                    mammo_mass_margin, mammo_mass_density
                ]
            elif table == "MRI_Multiple_Mass":
                mass_location = ask_y_n_statement.ask_option(
                    "Location of mass " + str(mass_id),
                    ["Right Breast", "Left Breast"])
                location.append(mass_location)
                location_quad = lesion_location(mass_location)
                quad.append(location_quad)
                mri_mass_shape = ask_y_n_statement.ask_option(
                    "Shape of mass", ["Oval", "Round", "Irregular", "Other"])
                shape.append(mri_mass_shape)
                mri_mass_margin = ask_y_n_statement.ask_option(
                    "Margins of mass",
                    ["Circumscribed", "Not circumscribed", "Other"])
                if mri_mass_margin == "Not circumscribed":
                    mri_mass_notc = ask_y_n_statement.ask_option(
                        "Not circumscribed margins of mass",
                        ["Irregular", "Spiculated"])
                    mri_mass_margin = mri_mass_margin + ": " + mri_mass_notc

                margin.append(mri_mass_margin)
                mri_mass_internal = ask_y_n_statement.ask_option(
                    "Internal enhancement characteristics", [
                        "Homogeneous", "Heterogeneous", "Rim enhancement",
                        "Dark internal septations"
                    ])
                internal.append(mri_mass_internal)
                mass_id = "Mass " + str(index + 1)
                data_list = [
                    file_number, mass_id, mass_location, location_quad,
                    mri_mass_shape, mri_mass_margin, mri_mass_internal
                ]
            elif table == "SonnoMammography_Multiple_Mass":
                mass_location = ask_y_n_statement.ask_option(
                    "Location of mass " + str(mass_id),
                    ["Right Breast", "Left Breast"])
                sonno_location.append(mass_location)
                location_quad = lesion_location(mass_location)
                sonno_quad.append(location_quad)
                location_clock = input("What is the clock position of mass " +
                                       str(mass_id) + "?")
                location_clock = location_clock + " o'clock"
                sonno_clock.append(location_clock)
                mass_shape = ask_y_n_statement.ask_option(
                    "Shape of mass " + str(mass_id),
                    ["Oval", "Round", "Irregular", "Other"])
                mass_depth = input("Depth of mass " + str(mass_id) + "(cm): ")
                mass_dist = ask_y_n_statement.ask_option(
                    "Distance from nipple", ["<0.5 cm", ">0.5 cm", "Other"])
                pect_check = ask_y_n_statement.ask_y_n(
                    "Is distance from Pectoralis Major described for mass " +
                    str(mass_id))
                if pect_check:
                    mass_pect = input("Distance from Pectoralis Major (cm): ")
                else:
                    mass_pect = "NA"
                sonno_depth.append(mass_depth)
                sonno_distance.append(mass_dist)
                sonno_pect.append(mass_pect)
                sonno_shape.append(mass_shape)
                mass_orientation = ask_y_n_statement.ask_option(
                    "Orientation of mass " + str(mass_id),
                    ["Parallel", "Not parallel"])
                sonno_orientation.append(mass_orientation)
                mass_margin = ask_y_n_statement.ask_option(
                    "Margin of mass " + str(mass_id),
                    ["Circumscribed", "Not circumscribed"])
                if mass_margin == "Not circumscribed":
                    mass_margin = ask_y_n_statement.ask_option(
                        "Is Not circumscribed margin", [
                            "Indistinct", "Angular", "Microlobulated",
                            "Spiculated"
                        ])
                sonno_margin.append(mass_margin)
                mass_echo = ask_y_n_statement.ask_option(
                    "Echo pattern of mass " + str(mass_id), [
                        "Anechoic", "Hyperechoic", "Complex cystic "
                        "and solid", "Hypoechoic", "Isoechoic",
                        "Heterogeneous", "Other"
                    ])
                sonno_echo.append(mass_echo)
                mass_posterior = ask_y_n_statement.ask_option(
                    "Posterior Acoustic features", [
                        "No posterior features", "Enhancement", "Shadowing",
                        "Combined pattern", "Other"
                    ])
                sonno_posterior.append(mass_posterior)
                mass_id = "Mass " + str(index + 1)
                data_list = [
                    file_number, mass_id, mass_location, location_quad,
                    location_clock, mass_depth, mass_location, mass_dist,
                    mass_shape, mass_orientation, mass_margin, mass_echo,
                    mass_posterior
                ]
            col_list = pccm_names.names_radio(table)
            check = add_update_sql.review_input(file_number, col_list,
                                                data_list)
        columns = ", ".join(col_list)
        add_update_sql.insert(conn, cursor, table, columns, tuple(data_list))
    if table == "SonnoMammography_Multiple_Mass":
        all_data = [[str(mass_number)], sonno_quad, sonno_location,
                    sonno_clock, sonno_depth, sonno_distance, sonno_pect,
                    sonno_shape, sonno_orientation, sonno_margin, sonno_echo,
                    sonno_posterior]
    elif table == "Mammography_Multiple_Mass":
        all_data = [[str(mass_number)], location, quad, depth, distance, pect,
                    shape, margin, density]
    elif table == "MRI_Multiple_Mass":
        all_data = [[str(mass_number)], location, quad, shape, margin,
                    internal]
    else:
        all_data = []
    data_return = ask_y_n_statement.join_lists(all_data, "; ")
    return tuple(data_return)
示例#11
0
def cal_table(file_number, conn, cursor):
    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 = int(input("Number of groups of calcifications detected? "))
    location, quad, depth, dist, pect, type, calc_type, calc_diag, distribution = [
        list([]) for _ in range(9)
    ]
    for index in range(0, mass_number):
        check = False
        while not check:
            mass_id = index + 1
            mass_location = ask_y_n_statement.ask_option(
                "Location of calcification group " + str(mass_id),
                ["Right Breast", "Left Breast"])
            location.append(mass_location)
            location_quad = lesion_location(mass_location)
            quad.append(location_quad)
            calc_depth = ask_y_n_statement.ask_option(
                "Depth of group " + str(mass_id),
                ["Anterior", "Middle", "Posterior", "Other"])
            calc_dist = ask_y_n_statement.ask_option(
                "Distance from nipple of group " + str(mass_id),
                ["<0.5 cm", ">0.5 cm", "Other"])
            pect_check = ask_y_n_statement.ask_y_n(
                "Is distance from Pectoralis Major described for  group " +
                str(mass_id))
            if pect_check:
                calc_pect = input(
                    "Distance from Pectoralis Major (cm) of group " +
                    str(mass_id) + ": ")
            else:
                calc_pect = "NA"
            depth.append(calc_depth)
            dist.append(calc_dist)
            pect.append(calc_pect)
            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)
            if mammo_calcification in {
                    "Skin", "Vascular", "Coarse or 'Popcorn-like'",
                    "Large Rod-like", "Round and punctate", "Eggshell or Rim",
                    "Dystrophic", "Suture"
            }:
                mammo_calcification_type = "Typically Benign"
                print("Calcification Type is " + mammo_calcification_type)
                check = ask_y_n_statement.ask_y_n(
                    "Is Calcification type correct?")
            elif mammo_calcification in {
                    "Amorphous", "Coarse Heterogeneous", "Fine Pleomorphic",
                    "Fine Linear or Fine Linear Branching"
            }:
                mammo_calcification_type = "Suspicious Morphology"
                print("Calcification Type is " + mammo_calcification_type)
                check = ask_y_n_statement.ask_y_n(
                    "Is Calcification type correct?")
            else:
                mammo_calcification_type = input("Calcification type " +
                                                 mammo_calcification + "? ")
            if not check:
                mammo_calcification_type = input("Calcification type " +
                                                 mammo_calcification + "? ")
            calc_diag.append(mammo_calcification_type)

            mammo_calcification_distribution = ask_y_n_statement.ask_option(
                "Distribution of calcification",
                ["Diffuse", "Regional", "Grouped", "Linear", "Segmental"])
            distribution.append(mammo_calcification_distribution)
            mass_id = "Group " + str(index + 1)
            data_list = [
                file_number, mass_id, mass_location, location_quad, calc_depth,
                calc_dist, calc_pect, mammo_calcification,
                mammo_calcification_type, mammo_calcification_distribution
            ]
            col_list = pccm_names.names_radio(table)
            check = add_update_sql.review_input(file_number, col_list,
                                                data_list)
        add_update_sql.update_multiple(conn, cursor, table, col_list,
                                       file_number, data_list)
    all_data = [[str(mass_number)], location, quad, depth, dist, pect,
                calc_type, calc_diag, distribution]
    data_return = ask_y_n_statement.join_lists(all_data, "; ")
    return tuple(data_return)
示例#12
0
def multiple_mass(table, mammo_breast="Right 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
    import pandas as pd
    number_mass = input("Number of masses detected: ")
    try:
        mass_number = int(number_mass)
    except:
        mass_number = 1
    col_list = pccm_names.names_radio_df(table)
    mass_df = pd.DataFrame(columns=col_list)
    for index in range(0, mass_number):
        mass_id = index + 1
        if table == "Mammography_Mass":
            check = False
            while not check:
                if mammo_breast == "Bilateral":
                    mass_location = ask_y_n_statement.ask_option(
                        "Location of mass " + str(mass_id),
                        ["Right Breast", "Left Breast"])
                else:
                    mass_location = mammo_breast
                location_quad = lesion_location(mass_location)
                mammo_mass_shape = ask_y_n_statement.ask_option(
                    "Shape of mass", ["Oval", "Round", "Irregular", "Other"])
                mammo_mass_margin = ask_y_n_statement.ask_option(
                    "Margins of mass", [
                        "Circumscribed", "Obscured", "Microlobulated",
                        "Indistinct", "Spiculated", "Other"
                    ])
                mass_nipple = input("Distance from nipple (cm): ")
                mass_size = input("Mass dimensions (without unit): ")
                mass_size_unit = input("Mass dimensions unit")
                mass_id = "Mass " + str(index + 1)
                data_list = [
                    mass_id, location_quad, mammo_mass_shape,
                    mammo_mass_margin, mass_nipple, mass_size, mass_size_unit
                ]
                mass_df.loc[index] = data_list
                check, mass_df = add_update_sql.review_df_row(mass_df)
            data_list = []
            for index in col_list:
                data_mass = "; ".join(list(mass_df.loc[:, index]))
                data_list.append([data_mass])
            data_df = ask_y_n_statement.join_lists(data_list, "; ")
            mass_id_, location_quad, mammo_mass_shape, mammo_mass_margin, mass_nipple, \
            mass_size, mass_size_unit  = data_df
            data_return = number_mass, location_quad, mammo_mass_shape, mammo_mass_margin, mass_nipple, mass_size, mass_size_unit
        elif table == "SonnoMammography_Mass":
            check = False
            while not check:
                if mammo_breast == "Bilateral":
                    mass_location = ask_y_n_statement.ask_option(
                        "Location of mass " + str(mass_id),
                        ["Right Breast", "Left Breast"])
                else:
                    mass_location = mammo_breast
                location_clock = input("What is the clock position of mass " +
                                       str(mass_id) + "?")
                location_clock = location_clock + " o'clock"
                mass_shape = ask_y_n_statement.ask_option(
                    "Shape of mass " + str(mass_id),
                    ["Oval", "Round", "Irregular", "Other"])
                mass_size = input("Mass dimensions (without unit: ")
                mass_size_unit = input("Mass dimensions unit")
                mass_margin = ask_y_n_statement.ask_option(
                    "Margin of mass " + str(mass_id), [
                        "Circumscribed", "Indistinct", "Angular",
                        "Microlobulated"
                    ])
                mass_echo = ask_y_n_statement.ask_option(
                    "Echo pattern of mass " + str(mass_id), [
                        "Anechoic", "Hyperechoic", "Complex cystic "
                        "and solid", "Hypoechoic", "Isoechoic",
                        "Heterogeneous", "Other"
                    ])
                mass_id = "Mass " + str(index + 1)
                data_list = [
                    mass_id, mass_location, location_clock, mass_shape,
                    mass_margin, mass_echo, mass_size, mass_size_unit
                ]
                mass_df.loc[index] = data_list
                check, mass_df = add_update_sql.review_df_row(mass_df)
            data_list = []
            for index in col_list:
                data_mass = "; ".join(list(mass_df.loc[:, index]))
                data_list.append([data_mass])
            data_df = ask_y_n_statement.join_lists(data_list, "; ")
            mass_id_, mass_location, location_clock, mass_shape, mass_margin, mass_echo, mass_size, mass_size_unit = data_df
            if mammo_breast != 'Bilateral':
                mass_location = mammo_breast
            data_return = number_mass, mass_location, location_clock, mass_shape, mass_margin, mass_echo, mass_size, mass_size_unit
        elif table == "MRI_Mass":
            check = False
            while not check:
                if mammo_breast == "Bilateral":
                    mass_location = ask_y_n_statement.ask_option(
                        "Location of mass " + str(mass_id),
                        ["Right Breast", "Left Breast"])
                else:
                    mass_location = mammo_breast
                mri_mass_shape = ask_y_n_statement.ask_option(
                    "Shape of mass", ["Oval", "Round", "Irregular", "Other"])
                mri_mass_margin = ask_y_n_statement.ask_option(
                    "Margins of mass",
                    ["Circumscribed", "Irregular", "Spiculated"])

                mri_mass_internal = ask_y_n_statement.ask_option(
                    "Internal enhancement characteristics", [
                        "Homogeneous", "Heterogeneous", "Rim enhancement",
                        "Dark internal septations"
                    ])
                mass_id = "Mass " + str(index + 1)
                data_list = [
                    str(mass_id), mass_location, mri_mass_shape,
                    mri_mass_margin, mri_mass_internal
                ]
                mass_df.loc[index] = data_list
                check, mass_df = add_update_sql.review_df_row(mass_df)
            data_list = []
            for index in col_list:
                data_mass = "; ".join(list(mass_df.loc[:, index]))
                data_list.append([data_mass])
            data_df = ask_y_n_statement.join_lists(data_list, "; ")
            mass_id_, mass_location, mri_mass_shape, mri_mass_margin, mri_mass_internal = data_df
            if mammo_breast != 'Bilateral':
                mass_location = mammo_breast
            data_return = number_mass, mass_location, mri_mass_shape, mri_mass_margin, mri_mass_internal
        else:
            data_return = "Table does not exist"
    return data_return