Esempio n. 1
0
 def add_data(self):
     col_list = names(self.module_list[0])
     enter = ask.ask_y_n("Enter " + self.print_statements[0])
     if enter:
         data = self.surgery_block_information_0()
         sql.update_multiple_key(self.conn, self.cursor, self.table_name, col_list, key_name='fk', key_value=self.fk,
                                 data=data)
     col_list = names(self.module_list[1])
     enter = ask.ask_y_n("Enter " + self.print_statements[1])
     if enter:
         data, block_desc_df = self.surgery_block_information_1
         sql.update_multiple_key(self.conn, self.cursor, self.table_name, col_list, key_name='fk', key_value=self.fk,
                                 data=data)
         block_desc_df.to_sql("block_data", self.conn, index=False, if_exists="append")
     col_list = names(self.module_list[2])
     enter = ask.ask_y_n("Enter " + self.print_statements[2])
     if enter:
         data = self.surgery_block_information_2()
         sql.update_multiple_key(self.conn, self.cursor, self.table_name, col_list, key_name='fk', key_value=self.fk,
                                 data=data)
     col_list = names(self.module_list[3])
     enter = ask.ask_y_n("Enter " + self.print_statements[3])
     if enter:
         data = self.surgery_block_information_3()
         sql.update_multiple_key(self.conn, self.cursor, self.table_name, col_list, key_name='fk', key_value=self.fk,
                                 data=data)
Esempio n. 2
0
 def add_new_pk(self, file_number, block_type):
     data, pk = self.update_block_id(file_number, block_type)
     sql.add_pk_fk_to_table(self.conn,
                            self.cursor,
                            self.table_name,
                            col_name='pk',
                            pk=pk)
     sql.update_multiple_key(self.conn,
                             self.cursor,
                             self.table_name,
                             columns=self.columns,
                             key_name='pk',
                             key_value=pk,
                             data=data)
Esempio n. 3
0
 def add_data(self):
     pk = uuid.uuid4().hex
     sql.add_pk_fk_to_table(self.conn,
                            self.cursor,
                            self.table_name,
                            col_name='pk',
                            pk=pk)
     pet_present = ask.ask_y_n(
         "Does the patient file contain a PET/CT report to be entered?")
     if not pet_present:
         data_length = len(self.col_list_all) - 3
         data = [self.file_number
                 ] + ['pet_report_not_present'] * data_length + [
                     self.user_name, sql.last_update()
                 ]
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 self.col_list_all,
                                 key_name='pk',
                                 key_value=pk,
                                 data=data)
     else:
         print(self.print_statements[0])
         col_list = names(self.module_list[0])
         enter = ask.ask_y_n("Enter " + self.print_statements[0])
         if enter:
             data = self.pet_report_identifier()
             sql.update_multiple_key(self.conn,
                                     self.cursor,
                                     self.table_name,
                                     col_list,
                                     key_name='pk',
                                     key_value=pk,
                                     data=data)
         col_list = names(self.module_list[1])
         enter = ask.ask_y_n("Enter " + self.print_statements[1])
         if enter:
             data = self.pet_report_findings()
             sql.update_multiple_key(self.conn,
                                     self.cursor,
                                     self.table_name,
                                     col_list,
                                     key_name='pk',
                                     key_value=pk,
                                     data=data)
         enter = ask.ask_y_n("Enter " + self.print_statements[2])
         col_list = names(self.module_list[2])
         if enter:
             data = self.pet_breast_cancer()
             sql.update_multiple_key(self.conn,
                                     self.cursor,
                                     self.table_name,
                                     col_list,
                                     key_name='pk',
                                     key_value=pk,
                                     data=data)
Esempio n. 4
0
 def add_data(self, file_number):
     add_block = True
     while add_block:
         data, pk = self.add_block_id(file_number)
         sql.add_pk_fk_to_table(self.conn,
                                self.cursor,
                                self.table_name,
                                col_name='pk',
                                pk=pk)
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 columns=self.columns,
                                 key_name='pk',
                                 key_value=pk,
                                 data=data)
         add_block = ask.ask_y_n('Add another block?')
Esempio n. 5
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)
Esempio n. 6
0
 def edit_data_pk(self, pk, value_row_to_edit, table):
     col_list = names(table)
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 table,
                                 key_name='pk',
                                 key_value=pk,
                                 columns=col_list,
                                 col_name='report_date',
                                 col_value=value_row_to_edit)
     if enter:
         data = self.table_fx().get(table)
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 table,
                                 col_list,
                                 key_name='pk',
                                 key_value=pk,
                                 data=data)
Esempio n. 7
0
 def get_consent(self, file_number):
     consent_discussed = sql.get_value_no_error('consent_discussed',
                                                self.table_name,
                                                file_number, 'file_number',
                                                self.cursor)
     consent = sql.get_value_no_error('consent', self.table_name,
                                      file_number, 'file_number',
                                      self.cursor)
     if not consent_discussed:
         consent_discussed = ask.ask_y_n(
             'Has the consent form been discussed with the patient/family? '
         )
     if not consent and consent_discussed:
         consent = ask.ask_y_n('Did patient give consent?',
                               yes_ans='consent_given',
                               no_ans='consent_not_given')
     elif not consent and not consent_discussed:
         consent = 'consent_TBD'
     print('consent_discussed: ' + str(consent_discussed),
           'consent: ' + consent)
     check = ask.ask_y_n('Is this correct?')
     if not check:
         check_review = False
         data = [str(consent_discussed), consent]
         col_list = ['consent_discussed', 'consent']
         while not check_review:
             consent_discussed = ask.ask_y_n(
                 'Has the consent form been discussed with the patient/family? '
             )
             consent = ask.ask_y_n('Did patient give consent?',
                                   yes_ans='consent_given',
                                   no_ans='consent_not_given')
             data = [str(consent_discussed), consent]
             check_review = sql.review_input(file_number, col_list, data)
         sql.update_multiple_key(conn=self.conn,
                                 cursor=self.cursor,
                                 table=self.table_name,
                                 columns=col_list,
                                 key_name='file_number',
                                 key_value=file_number,
                                 data=data)
     return str(consent_discussed), consent
Esempio n. 8
0
 def add_radio(self):
     rep = gf.get_number(4)
     for i in range(rep):
         pk = uuid.uuid4().hex
         sql.add_pk_fk_to_table(self.conn,
                                self.cursor,
                                self.table,
                                col_name='pk',
                                pk=pk)
         col_list = names_radio(self.table)
         # report = Mammography(self.conn, self.cursor, self.file_number, self.user_name)
         data = self.report()
         for col, dat in zip(col_list, data):
             print(col, dat)
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table,
                                 col_list,
                                 key_name='pk',
                                 key_value=pk,
                                 data=data)
Esempio n. 9
0
 def edit_data(self):
     print(self.print_statements[0])
     col_list = names(self.module_list[0])
     enter = sql.review_data_key(self.conn, self.cursor, self.table_name, key_name='fk', key_value=self.fk,
                                 columns=col_list, col_name='surgery_block_id', col_value=self.surgery_block_id)
     if enter:
         data = self.surgery_block_information_0()
         sql.update_multiple(self.conn, self.cursor, self.table_name, col_list, self.file_number, data)
     print(self.print_statements[1])
     col_list = names(self.module_list[1])
     enter = sql.review_data_key(self.conn, self.cursor, self.table_name, key_name='fk', key_value=self.fk,
                                 columns=col_list, col_name='surgery_block_id', col_value=self.surgery_block_id)
     if enter:
         data, block_desc_df = self.surgery_block_information_1
         sql.update_multiple_key(self.conn, self.cursor, self.table_name, col_list, key_name='fk', key_value=self.fk,
                                 data=data)
         block_desc_df.to_sql("block_data", self.conn, index=False, if_exists="append")
     print(self.print_statements[2])
     col_list = names(self.module_list[2])
     enter = sql.review_data_key(self.conn, self.cursor, self.table_name, key_name='fk', key_value=self.fk,
                                 columns=col_list, col_name='surgery_block_id', col_value=self.surgery_block_id)
     if enter:
         data = self.surgery_block_information_2()
         sql.update_multiple_key(self.conn, self.cursor, self.table_name, col_list, key_name='fk', key_value=self.fk,
                                 data=data)
     print(self.print_statements[3])
     col_list = names(self.module_list[3])
     enter = sql.review_data_key(self.conn, self.cursor, self.table_name, key_name='fk', key_value=self.fk,
                                 columns=col_list, col_name='surgery_block_id', col_value=self.surgery_block_id)
     if enter:
         data = self.surgery_block_information_3()
         sql.update_multiple_key(self.conn, self.cursor, self.table_name, col_list, key_name='fk', key_value=self.fk,
                                 data=data)
Esempio n. 10
0
 def add_radio(self, table):
     pk = uuid.uuid4().hex
     sql.add_pk_fk_to_table(self.conn,
                            self.cursor,
                            table,
                            col_name='pk',
                            pk=pk)
     print(table)
     enter = ask.ask_y_n("Enter " + table)
     col_list = names(table)
     if enter:
         data = self.table_fx().get(table)
         try:
             sql.update_multiple_key(self.conn,
                                     self.cursor,
                                     table,
                                     col_list,
                                     key_name='pk',
                                     key_value=pk,
                                     data=data)
         except TypeError:
             print(data)
Esempio n. 11
0
 def edit_data_pk(self, pk, value_row_to_edit):
     print(self.print_statements[0])
     col_list = names(self.module_list[0])
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 key_name='pk',
                                 key_value=pk,
                                 columns=col_list,
                                 col_name='pet_scan_date',
                                 col_value=value_row_to_edit)
     if enter:
         data = self.pet_report_identifier()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 col_list,
                                 key_name='pk',
                                 key_value=pk,
                                 data=data)
     print(self.print_statements[1])
     col_list = names(self.module_list[1])
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 key_name='pk',
                                 key_value=pk,
                                 columns=col_list,
                                 col_name='pet_scan_date',
                                 col_value=value_row_to_edit)
     if enter:
         data = self.pet_report_findings()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 col_list,
                                 key_name='pk',
                                 key_value=pk,
                                 data=data)
     print(self.print_statements[2])
     col_list = names(self.module_list[2])
     enter = sql.review_data_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 key_name='pk',
                                 key_value=pk,
                                 columns=col_list,
                                 col_name='pet_scan_date',
                                 col_value=value_row_to_edit)
     if enter:
         data = self.pet_breast_cancer()
         sql.update_multiple_key(self.conn,
                                 self.cursor,
                                 self.table_name,
                                 col_list,
                                 key_name='pk',
                                 key_value=pk,
                                 data=data)
Esempio n. 12
0
    def edit_block_id(self):
        file_number = 'test'
        check_file = False
        while not check_file:
            print('add_update_patient')
            file_number = input("Enter File Number: ")
            print("File Number: " + file_number)
            check_file = ask.ask_y_n("Is this file number correct")
        action = ask.ask_list('What values are to be updated?', [
            'patient_name', 'mr_number', 'date_of_birth', 'date_first_visit',
            'block_sr_number', 'block_location', 'block_type', 'block_id',
            'current_block_location', 'blocks_received_at_pccm',
            'number_of_blocks', 'block_series', 'consent'
        ])
        columns_action = [action] + ['update_by', 'last_update']
        update_user = [self.user_name, sql.last_update()]
        if action == 'consent':
            data = list(self.get_consent(file_number)) + update_user
            print(data)
            sql.update_multiple_key(self.conn,
                                    self.cursor,
                                    self.table_name,
                                    columns=[
                                        'consent_discussed', 'consent',
                                        'update_by', 'last_update'
                                    ],
                                    key_name='file_number',
                                    key_value=file_number,
                                    data=data)
        elif action in {
                'patient_name', 'block_sr_number', 'block_location',
                'blocks_received_at_pccm', 'mr_number', 'date_of_birth',
                'date_first_visit'
        }:
            data_old = sql.get_value_no_error(col_name=action,
                                              table=self.table_name,
                                              pk=file_number,
                                              pk_name='file_number',
                                              cursor=self.cursor)
            print(action + ' is currently set as: ' + data_old)
            change = ask.ask_y_n('Do you want to change this?')
            if change:
                data_new = ['NA'] + update_user
                check = False
                while not check:
                    if action in {
                            'blocks_recieved_at_pccm', 'date_of_birth',
                            'date_first_visit'
                    }:
                        data = ask.check_date('Please enter ' + action + ': ')
                    elif action == 'block_location':
                        data = block_location_format()
                    else:
                        data = input('Please input ' + action)
                    if action in BlockList.unique_values:
                        check = sql.check_value_not_exist(
                            self.cursor, action, data, self.table_name)
                    else:
                        check = True
                    data_new = [data] + update_user
                sql.update_multiple_key(self.conn,
                                        self.cursor,
                                        self.table_name,
                                        columns=columns_action,
                                        key_name='file_number',
                                        key_value=file_number,
                                        data=data_new)
        elif action in {
                'current_block_location', 'number_of_blocks', 'block_series',
                'block_type', 'block_id'
        }:
            check = False
            block_list = sql.extract_select_column_key(self.conn,
                                                       self.columns,
                                                       self.table_name,
                                                       col_select='block_id',
                                                       key_name='file_number',
                                                       key_value=file_number)

            block_id = ask.ask_list(
                action + ' information is to be entered for: ', block_list)
            pk = sql.extract_select_column_key(self.conn,
                                               self.columns_db,
                                               self.table_name,
                                               col_select='pk',
                                               key_name='block_id',
                                               key_value=block_id)
            # function returns a set so need to convert to str.
            pk = list(pk)[0]
            data = action
            while not check:
                print('BlockList.edit_values[action]: ',
                      BlockList.edit_values[action])
                data = ask.ask_list(action + ' of ' + block_id,
                                    BlockList.edit_values[action])
                if action in BlockList.unique_values:
                    check = sql.check_value_not_exist(self.cursor, action,
                                                      data, self.table_name)
                else:
                    check = True
            if data is set:
                data = list(data)
            data_new = [data] + update_user
            print(data_new, pk)
            sql.update_multiple_key(self.conn,
                                    self.cursor,
                                    self.table_name,
                                    columns=columns_action,
                                    key_name='pk',
                                    key_value=str(pk),
                                    data=data_new)
Esempio n. 13
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)