Example #1
0
def add_data(conn, cursor, file_number, user_name):
    #file_row(cursor, file_number)
    table = "hormonetherapy_survival"
    enter = ask.ask_y_n("Enter Hormone Therapy Details?")
    if enter:
        col_list = names.names_longterm(module_name="hormone")
        data = hormone(file_number)
        update_multiple(conn, cursor, table, col_list, file_number, data)
    enter = ask.ask_y_n("Enter Recurrence and follow-up status?")
    if enter:
        col_list = names.names_longterm(module_name="metastasis")
        data = metastasis(file_number, user_name)
        update_multiple(conn, cursor, table, col_list, file_number, data)
Example #2
0
def edit_data(conn, cursor, file_number, user_name):
    table = "hormonetherapy_survival"
    print("Hormone Therapy Details")
    col_list = names.names_longterm(module_name="hormone")
    enter = review_data(conn, cursor, table, file_number, col_list)
    if enter:
        data = hormone(file_number)
        update_multiple(conn, cursor, table, col_list, file_number, data)
    print("Recurrence and follow-up status")
    col_list = names.names_longterm(module_name="metastasis")
    enter = review_data(conn, cursor, table, file_number, col_list)
    if enter:
        data = metastasis(file_number, user_name)
        update_multiple(conn, cursor, table, col_list, file_number, data)
Example #3
0
def metastasis(file_number, user_name):
    check = False
    while not check:
        met_has = ask.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 = ask.check_date("Date of last follow-up: ")
        recur = ask.ask_y_n("Has the patient experienced a recurrence?")
        if recur:
            time_recur = input("Time to disease recurrence: ")
            nature_recur = ask.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()
        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
Example #4
0
def db_dict(table, module):
    db_tables = {
        "patient_information_history": names.names_info(module),
        "radiology": names.names_radio(module),
        'pet_reports': names.names_pet(module),
        'biopsy_path_report_data': names.names_biopsy(module),
        "neo_adjuvant_therapy": names.names_nact(module),
        "surgery_report": names.names_surgery_information(module),
        'surgery_path_report_data': names.names_surgery(module),
        "adjuvant_chemotherapy": names.names_chemotherapy(module),
        "radiotherapy": names.names_radiation(),
        "hormonetherapy_survival": names.names_longterm(module),
        "follow_up_data": names.name_follow_up(),
        'block_list': names.block_list(module)
    }

    cols = db_tables.get(table)
    return cols
ex_file = 'Output_radiology_12062018.xlsx'
path = os.path.join(folders, file)
ex_path = os.path.join(folders, ex_file)
conn = sqlite3.connect(path)

table = "radiotherapy"
col_list = ["File_number"] + names.names_radiation()
sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
writer = pd.ExcelWriter(ex_path, engine='xlsxwriter')
df.to_excel(writer, sheet_name=table)

table = "hormonetherapy_recurrence_survival"
col_list = [
    "File_number"
] + names.names_longterm("hormone") + names.names_longterm("metastasis")
sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
df.to_excel(writer, sheet_name="Hormone_RecurrenceSurvival")

table = "follow_up_data"
col_list = ["File_number"] + names.name_follow_up()
sql = ('SELECT ' + ", ".join(col_list[:-2]) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
df.to_excel(writer, sheet_name=table)

table = "patient_information_history"
col_list_bio = names.names_info("bio_info")

col_list = ["File_number"] + col_list_bio + names.names_info("phys_act") + names.names_info("habits") + \
           names.names_info("nut_supplements") + names.names_info("family_details") + names.names_info("med_history") + \
Example #6
0
                                                        nf=cols_file))

table = "follow_up_data"
if table_check(cursor_all, table) == 0:
    column = ", ".join(pccm_names.name_follow_up())
    cols_file = "file_number, " + column
    cursor_all.execute('CREATE TABLE {tn}({nf})'.format(tn=table,
                                                        nf=cols_file))

table = "hormonetherapy_recurrence_survival"
if table_check(cursor_all, table) == 0:
    column = "file_number"
    cursor_all.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=column))
    module_names = ["hormone", "metastasis"]
    for index in module_names:
        col_name = pccm_names.names_longterm(index)
        add_columns(cursor_all, table, col_name)

table = "General_Medical_History"
if table_check(cursor_all, table) == 0:
    columns2 = "file_number, Condition, Diagnosis_date, Treatment"
    cursor_all.execute('CREATE TABLE {tn}({nf})' \
                   .format(tn=table, nf=columns2))

table = "Family_Cancer_History"
if table_check(cursor_all, table) == 0:
    columns3 = 'file_number, Type_Cancer, Relation_to_Patient, Type_Relation, Age_at_detection_yrs'
    cursor_all.execute('CREATE TABLE {tn}({nf})' \
                   .format(tn=table, nf=columns3))

table = "Previous_Cancer_History"
Example #7
0
def hormone(file_number):
    check = False
    while not check:
        hormone = ask.ask_y_n("Hormone therapy indicated?")
        if not hormone:
            hormone = "Hormone therapy not indicated"
            hormone_recieved, hormone_date, hormone_type, hormone_duration, hormone_disc, hormone_ovary,hormone_outcome, \
            hormone_follow_up, hormone_recur = ("NA", )*9
        else:
            hormone = "Hormone therapy indicated"
            hormone_recieved = ask.ask_y_n("Was Hormone therapy recieved?")
            if hormone_recieved:
                hormone_recieved = "Hormone therapy recieved"
                hormone_date = ask.check_date(
                    "Date of starting hormone therapy: ")
                hormone_type = ask.ask_option("Type of hormone therapy", [
                    "Tamoxifen", "Anastrazole", "Injectables", "Letrozole",
                    "Others"
                ])
                if hormone_type == "Injectables":
                    details = input(
                        "Please provide details of injectables recieved: ")
                    hormone_type = hormone_type + ": " + details
                hormone_duration = input(
                    "Duration of hormone therapy (years): ")
                hormone_disc = ask.ask_option(
                    "What is the current status of hormone therapy. "
                    "Give specific reasons if discontinued prematurely "
                    "(or not taken at all)", [
                        'Therapy is ongoing', "Completion of planned course",
                        "Adverse Effects", "Stopped by patient",
                        "Progression of disease", "Other"
                    ])
                ovary = ask.ask_y_n_na("Has ovarian surpression been used?")
                if ovary == 'Yes':
                    hormone_ovary = ask.ask_option(
                        "Type of ovarian surpression used",
                        ["Surgery", "Drug"])
                    if hormone_ovary == "Drug":
                        details = input(
                            "Please provide details of drug used: ")
                        hormone_ovary = hormone_ovary + ": " + details
                else:
                    hormone_ovary = ovary
                hormone_outcome = input("Outcome of hormone therapy: ")
                hormone_follow_up = input("Follow up after hormone therapy: ")
                hormone_recur = ask.ask_y_n(
                    "Was there recurrence after hormone therapy?",
                    "Recurrence", "No recurrence")
            else:
                hormone_recieved = "No hormone therapy recieved"
                hormone_date, hormone_type, hormone_duration, hormone_disc, hormone_ovary, hormone_outcome, \
                hormone_follow_up, hormone_recur = ("NA", )*8
        data_list = [
            hormone, hormone_recieved, hormone_date, hormone_type,
            hormone_duration, hormone_disc, hormone_ovary, hormone_outcome,
            hormone_follow_up, hormone_recur
        ]
        col_list = names.names_longterm("hormone")
        check = review_input(file_number, col_list, data_list)
    return data_list
    def makedb(self):
        db_create = CreateTable(self.cursor)
        file_number = "file_number"
        table = "patient_information_history"
        module_list = [
            "bio_info", "phys_act", "habits", "nut_supplements",
            "family_details", "med_history", "cancer_history", 'family_cancer',
            'det_by', "breast_symptoms", 'other_test'
        ]
        col_names = [pccm_names.names_info(module) for module in module_list]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number=file_number,
                               col_names=col_list)

        table = "biopsy_path_report"
        module_list = [
            "biopsy_report_info", "biopsy_details", 'ihc_biopsy_data',
            'review_biopsy'
        ]
        col_names = [pccm_names.names_biopsy(module) for module in module_list]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table_pk(table, col_list)

        table = 'surgery_path_report_data'
        module_list = [
            "surgery_block_information_0", "surgery_block_information_1",
            "surgery_block_information_2", "surgery_block_information_3"
        ]
        col_names = [
            pccm_names.names_surgery(module) for module in module_list
        ]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table_pk(table, col_list, pk='fk')

        table = "block_data"
        col_names = pccm_names.names_surgery('block_data')[1:]
        db_create.create_table_pk(table, col_names, pk='fk')

        table = "mammography"
        col_names = pccm_names.names_radio(table)
        db_create.create_table_pk(table, col_names)

        table = 'abvs'
        col_names = pccm_names.names_radio(table)
        db_create.create_table_pk(table, col_names)

        table = 'ultrasound'
        col_names = pccm_names.names_radio(table)
        db_create.create_table_pk(table, col_names)

        table = 'mri'
        col_names = pccm_names.names_radio(table)
        db_create.create_table_pk(table, col_names)

        table = 'pet_reports'
        module_list = [
            'pet_report_identifier', 'pet_report_findings', 'pet_breast_cancer'
        ]
        col_names = [pccm_names.names_pet(module) for module in module_list]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table_pk(table, col_list)

        table = "surgery_report"
        module_list = ["surgery_information", "node_excision", "post_surgery"]
        col_names = [
            pccm_names.names_surgery_information(module)
            for module in module_list
        ]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_list)

        table = "general_medical_history"
        col_names = ['condition', 'diagnosis_date', 'treatment']
        # col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "family_cancer_history"
        col_names = [
            'type_cancer', 'relation_to_patient', 'type_relation',
            'age_at_detection_yrs'
        ]
        # col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "previous_cancer_history"
        col_names = [
            'type_cancer', 'year_diagnosis', 'surgery', 'type_surgery',
            'duration_surgery', 'radiation', 'type_radiation',
            'duration_radiation', 'chemotherapy', 'type_chemotherapy',
            'duration_chemotherapy', 'hormone', 'type_hormone',
            'duration_hormone', 'alternative', 'type_alternative',
            'duration_alternative', 'homeremedy', 'type_homeremedy',
            'duration_homeremedy'
        ]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_list)

        table = "nutritional_supplements"
        col_names = [
            'type_nutritional_supplements',
            'quantity_nutritional_supplements_per_day',
            'duration_nutritional_supplements'
        ]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_list)

        table = "physical_activity"
        col_names = ['type_activity', 'frequency_activity']
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_list)

        table = "breast_feeding"
        col_names = [
            'child_number', 'feeding_duration', 'breast_usage_feeding'
        ]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_list)

        table = "nact_tox_table"
        col_names = pccm_names.names_nact(table)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "nact_drug_table"
        col_names = pccm_names.names_nact(table)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "neo_adjuvant_therapy"
        module_list = ["neo_adjuvant_therapy", "clip_information"]
        col_names = [pccm_names.names_nact(module) for module in module_list]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_list)

        table = "adjuvant_chemotherapy"
        col_names = pccm_names.names_chemotherapy(table)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "chemo_tox_table"
        col_names = pccm_names.names_chemotherapy(table)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "chemo_drug_table"
        col_names = pccm_names.names_chemotherapy(table)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "radiotherapy"
        col_names = pccm_names.names_radiation()
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "follow_up_data"
        col_names = pccm_names.name_follow_up()
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_names)

        table = "hormonetherapy_survival"
        module_list = ["hormone", "metastasis"]
        col_names = [
            pccm_names.names_longterm(module) for module in module_list
        ]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number='file_number',
                               col_names=col_list)

        table = 'block_list'
        col_names = pccm_names.block_list('all')
        db_create.create_table_pk(table, col_names=col_names, pk='pk')

        table = "clinical_exam"
        module_list = ['clinical_exam_initial', 'nipple_cytology']
        col_names = [
            pccm_names.name_clinical(module) for module in module_list
        ]
        col_list = ask.flatten_nested_list(col_names)
        db_create.create_table(table,
                               file_number=file_number,
                               col_names=col_list)

        self.conn.commit()
        print(self.path + " file created")
        self.conn.close()