Ejemplo n.º 1
0
 def add_data(self):
     block_list_table = BlockInformation(self.conn, self.cursor,
                                         self.file_number)
     enter = ask.ask_y_n("Enter Biopsy Report information?")
     if enter:
         data = self.biopsy_report_info()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 names.names_biopsy("biopsy_report_info"),
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
     enter = ask.ask_y_n("Enter Biopsy data?")
     if enter:
         data = self.biopsy_details()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 names.names_biopsy("biopsy_details"),
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
         data = self.ihc_biopsy_data()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 names.names_biopsy("ihc_biopsy_data"),
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
         data = self.review_biopsy()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 names.names_biopsy("review_biopsy"),
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
         is_surgery = ask.ask_y_n(
             'Is a surgery associated with this biopsy?')
         if is_surgery:
             surgery_block_id, surgery_number_of_blocks = block_list_table.get_block_id(
                 'surgery')
         else:
             surgery_block_id = 'NA'
         sql.update_single_key(self.conn,
                               self.cursor,
                               self.table_name,
                               'surgery_block_id',
                               key_name='pk',
                               key_value=self.pk,
                               var=surgery_block_id)
Ejemplo n.º 2
0
 def review_biopsy(self):
     review_biopsy_date, review_biopsy_source, review_biopsy_diagnosis, review_biopsy_diagnosis_comment, \
     review_biopsy_block_id, review_biopsy_er, review_biopsy_er_percent, review_biopsy_pr, review_biopsy_pr_percent, \
     review_biopsy_her2, review_biopsy_her2_grade, review_biopsy_fish, review_biopsy_ki67 = ['NA', ] * 13
     data_list = [
         'NA',
     ] * 13
     check = False
     while not check:
         review = ask.ask_y_n(
             'Has a review (of diagnosis or IHC details) been done of this biopsy block?'
         )
         if review:
             review_biopsy_date = ask.check_date(
                 'Date of review biopsy (if multiple dates?): ')
             review_biopsy_source = input(
                 'Name of Review Biopsy Laboratory (Enter multiple if required Lab_test): '
             )
             review_biopsy_diagnosis = input(
                 'Enter diagnosis of review biopsy: ')
             review_biopsy_diagnosis_comment = input(
                 'Additional comments for biopsy review diagnosis: ')
             review_biopsy_block_id = self.biopsy_block_id
             block_id = ask.ask_y_n(
                 'Has the block been relabelled in the review biopsy?')
             if block_id:
                 old_block_id = input('Please enter old block id: ')
                 new_block_id = input('Please enter new block id: ')
                 review_biopsy_block_id = old_block_id + ' relabelled to ' + new_block_id
             review_ihc = ask.ask_y_n(
                 'Has the IHC result for any marker been reviewed by another lab?'
             )
             if review_ihc:
                 review_biopsy_er, review_biopsy_er_percent, review_biopsy_pr, review_biopsy_pr_percent, \
                 review_biopsy_her2, review_biopsy_her2_grade, review_biopsy_fish, review_biopsy_ki67  = \
                     BlockDescription.ihc_report('review_biopsy')
         data_list = [
             review_biopsy_date, review_biopsy_source,
             review_biopsy_diagnosis, review_biopsy_diagnosis_comment,
             review_biopsy_block_id, review_biopsy_er,
             review_biopsy_er_percent, review_biopsy_pr,
             review_biopsy_pr_percent, review_biopsy_her2,
             review_biopsy_her2_grade, review_biopsy_fish,
             review_biopsy_ki67
         ]
         col_list = names.names_biopsy('review_biopsy')
         check = sql.review_input(self.file_number, col_list[:-2],
                                  data_list)
     data = data_list + [self.user_name, sql.last_update()]
     return data
Ejemplo n.º 3
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
Ejemplo n.º 4
0
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") + \
           names.names_info("cancer_history") + names.names_info("family_cancer") + names.names_info("breast_symptoms")
sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
df.to_excel(writer, sheet_name=table)
writer.save()

#######################################33

table = "Biopsy_Report_Data"
module_names = ["biopsy_report_info", "tumour_biopsy_data", "lymphnode_biopsy"]
col_list = ["File_number"]
for index in module_names:
    col_list = col_list + names.names_biopsy(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_Block_Report_Data"
module_names = [
    "surgery_block_information_1", "surgery_block_information_2",
    "surgery_block_information_3", "path_stage"
]
col_list = ["File_number"]
for index in module_names:
    col_list = col_list + names.names_surgery(index)
sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'")
df = pd.read_sql(sql, conn)
Ejemplo n.º 5
0
 def ihc_biopsy_data(self):
     col_list = names.names_biopsy('ihc_biopsy_data')
     try:
         columns = names.names_biopsy('biopsy_report_info')
         biopsy_ihc_report_pccm = sql.extract_select_column_key(
             conn=self.conn,
             columns=columns,
             table=self.table_name,
             key_name='pk',
             key_value=self.pk,
             col_select='biopsy_ihc_report_pccm')
     except ValueError:
         biopsy_ihc_report_pccm = ask.ask_list(
             "Is the biopsy IHC report available?", [
                 "biopsy_ihc_report_pccm_yes", "biopsy_ihc_report_pccm_no",
                 'doctors_notes_available', 'path_history_notes_'
                 'available', 'requires_specialist_input'
             ])
     data_list = ['NAv'] * 11
     try:
         columns = names.names_biopsy('biopsy_details')
         benign = sql.extract_select_column_key(conn=self.conn,
                                                columns=columns,
                                                table=self.table_name,
                                                key_name='pk',
                                                key_value=self.pk,
                                                col_select='benign')
         # print('Diagnosis is :', benign)
         if benign.lower() == 'false':
             benign = False
         elif benign.lower() == 'true':
             benign = True
         else:
             benign = ask.ask_y_n("Is the diagnosis for this block benign?")
     except ValueError:
         benign = ask.ask_y_n("Is the diagnosis for this block benign?")
     check = False
     while not check:
         if benign:
             # print(str(benign))
             print('Diagnosis is benign so IHC has not been considered')
             biopsy_er, biopsy_er_percent, biopsy_pr, biopsy_pr_percent, biopsy_her2, biopsy_her2_grade, biopsy_fish,\
             biopsy_ki67, biopsy_subtype = ['NA'] * 9
         else:
             print('biopsy_ihc_report_pccm: ' + biopsy_ihc_report_pccm)
             if biopsy_ihc_report_pccm[0] != 'biopsy_ihc_report_pccm_no':
                 print('Please input all data for ' + self.biopsy_block_id +
                       ' block only')
                 biopsy_er, biopsy_er_percent, biopsy_pr, biopsy_pr_percent, biopsy_her2, biopsy_her2_grade, \
                 biopsy_fish, biopsy_ki67 = BlockDescription.ihc_report('biopsy')
             else:
                 biopsy_er, biopsy_er_percent, biopsy_pr, biopsy_pr_percent, biopsy_her2, biopsy_her2_grade, \
                 biopsy_fish, biopsy_ki67 = ['NAv'] * 8
             biopsy_subtype = breast_cancer_subtype('biopsy', biopsy_er,
                                                    biopsy_pr, biopsy_her2,
                                                    biopsy_her2_grade,
                                                    biopsy_fish)
         fnac_lymph_node = ask.ask_list(
             "Lymph Node FNAC",
             ask.create_yes_no_options('Lymph Node FNAC'))
         fnac_lymph_node_location, fnac_lymph_node_diagnosis = (
             fnac_lymph_node, ) * 2
         if fnac_lymph_node == "lymph_node_fnac_yes":
             fnac_lymph_node_location = input(
                 "Please enter lymph node biopsy location: ")
             fnac_lymph_node_diagnosis = ask.ask_list(
                 "Lymph Node FNAC diagnosis",
                 ask.create_yes_no_options('Lymph Node FNAC '
                                           'diagnosis',
                                           yes='malignant',
                                           no='non_malignant'))
         data_list = [
             biopsy_er, biopsy_er_percent, biopsy_pr, biopsy_pr_percent,
             biopsy_her2, biopsy_her2_grade, biopsy_fish, biopsy_ki67,
             biopsy_subtype, fnac_lymph_node, fnac_lymph_node_location,
             fnac_lymph_node_diagnosis
         ]
         check = sql.review_input(self.file_number, col_list[:-2],
                                  data_list)
     data = data_list + [self.user_name, sql.last_update()]
     return data
Ejemplo n.º 6
0
 def edit_data(self):
     print("Block Report information")
     col_list = names.names_biopsy("biopsy_report_info")
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 key_name='pk',
                                 key_value=self.pk,
                                 columns=col_list,
                                 col_name='biopsy_block_id',
                                 col_value=self.biopsy_block_id)
     if enter:
         # sql.add_pk_fk_to_table(self.conn, self.cursor, self.table_name, col_filter='pk', pk=self.pk)
         data = self.biopsy_report_info()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 col_list,
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
     print("Biopsy Tumour data")
     col_list = names.names_biopsy("biopsy_details")
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 key_name='pk',
                                 key_value=self.pk,
                                 columns=col_list,
                                 col_name='biopsy_block_id',
                                 col_value=self.biopsy_block_id)
     if enter:
         data = self.biopsy_details()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 col_list,
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
     print("Biopsy IHC data")
     col_list = names.names_biopsy("ihc_biopsy_data")
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 key_name='pk',
                                 key_value=self.pk,
                                 columns=col_list,
                                 col_name='biopsy_block_id',
                                 col_value=self.biopsy_block_id)
     if enter:
         data = self.ihc_biopsy_data()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 col_list,
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
     print('Review Biopsy data')
     col_list = names.names_biopsy("review_biopsy")
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 key_name='pk',
                                 key_value=self.pk,
                                 columns=col_list,
                                 col_name='biopsy_block_id',
                                 col_value=self.biopsy_block_id)
     if enter:
         data = self.review_biopsy()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 col_list,
                                 key_name='pk',
                                 key_value=self.pk,
                                 data=data)
     surgery_block_id = sql.get_value(
         col_name='surgery_block_id',
         table=self.table_name,
         pk=self.pk,
         pk_name='pk',
         cursor=self.cursor,
         error_statement='Please enter surgery block id associated '
         'with this biopsy entry: ')
     print('Surgery block id associated with this biopsy is ' +
           str(surgery_block_id))
     block = ask.ask_y_n('Is this block id correct?')
     if not block:
         surgery_block_id = input(
             'Please enter surgery block id associated with this biopsy entry: '
         )
         sql.update_single_key(self.conn,
                               self.cursor,
                               self.table_name,
                               'surgery_block_id',
                               key_name='pk',
                               key_value=self.pk,
                               var=surgery_block_id)
Ejemplo n.º 7
0
 def biopsy_report_info(self):
     module = 'biopsy_report_info'
     col_list = names.names_biopsy(module)
     check = False
     data_list = [self.file_number] + (['To be done'] * 18)
     while not check:
         block_list_table = BlockInformation(self.conn, self.cursor,
                                             self.file_number)
         block_data = [
             'block_sr_number', 'block_location', 'current_block_location',
             'blocks_received_at_pccm', 'block_series'
         ]
         block_sr_number, block_location, current_block_location, blocks_received_at_pccm, biopsy_block_series = \
             block_list_table.get_block_information(block_id=self.biopsy_block_id, block_data=block_data)
         fnac = ask.ask_list('FNAC done for breast lesion?',
                             ['fnac_breast_yes', 'fnac_breast_no'])
         if fnac == 'fnac_breast_no':
             fnac_breast, fnac_breast_date, fnac_slide_id, fnac_diagnosis, fnac_diagnosis_comments = (
                 fnac, ) * 5
         else:
             fnac_breast = ask.ask_list('FNAC location', [
                 'left_breast', 'right_breast', 'requires_specialist_input'
             ])
             fnac_breast_date = ask.check_date('Date of FNAC test: ')
             fnac_slide_id = input('Enter FNAC slide ID: ')
             fnac_diagnosis = input(
                 'Enter diagnosis for FNAC breast as given in report: ')
             fnac_diagnosis_comments = input(
                 'Enter additional comments for FNAC diagnosis: ')
         biopsy_date = ask.check_date('Date of Biopsy: ')
         reason_path_report = ask.ask_list('Reason for pathology report', [
             'diagnosis', 'bilateral_diagnosis', 'review_biopsy',
             'nact_follow up', 'recurrence_diagnosis', 'revision_surgery',
             'requires_specialist_input'
         ])
         biopsy_site = ask.ask_list('Biopsy_site', [
             'left_breast', 'right_breast', 'left_axilla', 'right_axilla',
             'requires_specialist_input'
         ])
         biopsy_report_pccm = ask.ask_list(
             "Is the biopsy report available?", [
                 "biopsy_report_pccm_yes", "biopsy_report_pccm_no",
                 'doctors_notes_available', 'path_history_notes',
                 'requires_specialist_input'
             ])
         if biopsy_report_pccm != 'biopsy_report_pccm_no':
             biopsy_block_source = ask.ask_option('Source of Biopsy Block',
                                                  PathReports.path_labs)
             biopsy_lab_id = input("Biopsy Lab ID/SID: ")
         else:
             biopsy_block_source, biopsy_lab_id = ('NAv', ) * 2
         biopsy_ihc_report_pccm = ask.ask_list(
             "Is the IHC report available?", [
                 "biopsy_ihc_report_pccm_yes", "biopsy_ihc_report_pccm_no",
                 'doctors_notes_available', 'path_history_notes_available',
                 'requires_specialist_input'
             ])
         data_list = [
             self.file_number, block_sr_number, block_location,
             current_block_location, blocks_received_at_pccm, fnac_breast,
             fnac_breast_date, fnac_slide_id, fnac_diagnosis,
             fnac_diagnosis_comments, reason_path_report, biopsy_site,
             biopsy_report_pccm, biopsy_ihc_report_pccm,
             self.biopsy_block_id, self.biopsy_number_of_blocks,
             biopsy_block_series, biopsy_date, biopsy_block_source,
             biopsy_lab_id
         ]
         print(data_list)
         check = sql.review_input(self.file_number, col_list, data_list)
     data = data_list
     return data
Ejemplo n.º 8
0
    def biopsy_details(self):
        col_list = names.names_biopsy('biopsy_details')
        try:
            columns = names.names_biopsy('biopsy_report_info')
            biopsy_report_pccm = sql.extract_select_column_key(
                conn=self.conn,
                columns=columns,
                table=self.table_name,
                key_name='pk',
                key_value=self.pk,
                col_select='biopsy_report_pccm')
        except ValueError:
            biopsy_report_pccm = ask.ask_list(
                "Is the biopsy report available?", [
                    "biopsy_report_pccm_yes", "biopsy_report_pccm_no",
                    'doctors_notes_available', 'path_history_notes',
                    'requires_specialist_input'
                ])
        data_list = ['NAv'] * 3 + ['False'] + ['NAv'] * 3
        if biopsy_report_pccm != 'biopsy_report_pccm_no':
            check = False
            while not check:
                print('Please input all data for ' + self.biopsy_block_id +
                      ' report only')
                biopsy_type = ask.ask_list("Biopsy Type",
                                           PathReports.biopsy_type)
                biopsy_diagnosis = ask.ask_list("Biopsy Diagnosis: ",
                                                PathReports.diagnosis)
                biopsy_comments = input(
                    'Enter any additional comments on the diagnosis: ')
                benign = ask.ask_y_n('Is the diagnosis of ' +
                                     str(biopsy_diagnosis) +
                                     ' describing a benign condition ('
                                     'If diagnosis is not available '
                                     'enter NO here)')
                if benign:
                    biopsy_tumour_grade, biopsy_lymph_emboli, dcis_biopsy = [
                        'benign condition'
                    ] * 3
                else:
                    biopsy_tumour_grade = ask.ask_option(
                        "Tumour Biopsy Grade", PathReports.grade)
                    biopsy_lymph_emboli = ask.ask_list(
                        "Are Lymphovascular emboli seen?",
                        ask.create_yes_no_options(
                            'Lymphovascular emboli Biopsy',
                            not_cancer='requires_follow_up'))
                    dcis_biopsy = ask.ask_list(
                        "Does the biopsy show DCIS",
                        ask.create_yes_no_options(
                            'dcis biopsy', not_cancer='requires_follow_up'))

                data_list = [
                    biopsy_type, biopsy_diagnosis, biopsy_comments,
                    str(benign), biopsy_tumour_grade, biopsy_lymph_emboli,
                    dcis_biopsy
                ]
                check = sql.review_input(self.file_number, col_list, data_list)
        else:
            print(
                '\nBiopsy report is not available. Data for biopsy_type, biopsy_diagnosis, biopsy_comments, '
                'tumour_grade, lymph_emboli, dcis_biopsy has been entered as NAv\n'
            )
        return data_list
Ejemplo n.º 9
0
    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()
Ejemplo n.º 10
0
#create new table
path_all = 'D:/repos/pccm_db/main/DB/DB_with_real_data/PCCM_BreastCancerDB_all_data.db'
os.path.isfile(path_all)
conn_all = sqlite3.connect(path_all)
cursor_all = conn_all.cursor()
table = "Biopsy_Report_Data"
file_number = "File_number"
if sql.table_check(cursor_all, table) == 0:
    cursor_all.execute('CREATE TABLE {tn}({nf})'.format(tn=table,
                                                        nf=file_number))
    module_names = [
        "biopsy_report_info", "tumour_biopsy_data", "lymphnode_biopsy"
    ]
    for index in module_names:
        col_name = pccm_names.names_biopsy(index)
        sql.add_columns(cursor_all, table, col_name)

#read from excel with same col names and distribution as in table

file_to_read = "D:/Documents/IISER/Prashanti_docs/Breast_Cancer_FFPE_blocks_database_Biopsy_dk08062018.xlsx"
data = pd.read_excel(file_to_read, header=1, dtype='object', usecols='A:AB')
update_by = "dk from ruhi/shaheen data"
module_names = ["biopsy_report_info", "tumour_biopsy_data", "lymphnode_biopsy"]
col_list = ["File_number"]
for index in module_names:
    col_list = col_list + pccm_names.names_biopsy(index)
columns = ", ".join(col_list)
for index in range(0, len(data)):
    data_list = list(data.loc[index])
    data_list.append(update_by)