コード例 #1
0
def db_dict(table, module):
    db_tables = {
        "Patient_Information_History": names.names_info(module),
        "Biopsy_Report_Data": names.names_biopsy_new(module),
        "Radiology": names.names_radio(module),
        "Neo_Adjuvant_Therapy": names.names_nact(module),
        "Surgery_Report": names.names_surgery_information(module),
        "Surgery_Block_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()
    }
    cols = db_tables.get(table)
    return cols
コード例 #2
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
コード例 #3
0
        add_columns(cursor, table, col_name)
    print(table + ' created')

table = "block_data"
if table_check(cursor, table) == 0:
    cursor.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf='fk'))
    col_name = pccm_names.names_surgery('block_data')[1:]
    add_columns(cursor, table, col_name)
    print(table + ' created')

table = "radiology"
if table_check(cursor, table) == 0:
    module_names = ["mammography", "abvs", "sonomammo", "mri_breast"]
    cursor.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf=file_number))
    for index in module_names:
        col_name = pccm_names.names_radio(index)
        add_columns(cursor, table, col_name)
    print(table + ' created')

table = 'pet_reports'
if table_check(cursor, table) == 0:
    cursor.execute('CREATE TABLE {tn}({nf})'.format(tn=table, nf='pk'))
    module_names = [
        'pet_report_identifier', 'pet_report_findings', 'pet_breast_cancer'
    ]
    for index in module_names:
        col_name = pccm_names.names_pet(index)
        add_columns(cursor, table, col_name)
    print(table + ' created')

table = "surgery_report"
コード例 #4
0
sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
df.to_excel(writer, sheet_name=table, index=False)
writer.save()

table = "Radiology"
sql = "SELECT File_number FROM '" + table + "'"
df = pd.read_sql(sql, conn)
df_list = list(df['File_number'])

module_names = [
    "mammography", "tomosynthesis", "abvs", "sonomammo", "mri_breast"
]
col_list = ["File_number"]
for index in module_names:
    col_list = col_list + names.names_radio(index)
sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
df.to_excel(writer, sheet_name=table, index=False)
writer.save()

table = "Surgery_Report"
sql = "SELECT File_number FROM '" + table + "'"
df = pd.read_sql(sql, conn)
df_list = list(df['File_number'])
module_names = ["surgery_information", "node_excision", "post_surgery"]
col_list = ["File_number"]
for index in module_names:
    col_list = col_list + names.names_surgery_information(index)
sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
コード例 #5
0
ファイル: radio_table_old.py プロジェクト: dakelkar/db_flask
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)
コード例 #6
0
ファイル: radio_table_old.py プロジェクト: dakelkar/db_flask
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)