def drug_table_enter(file_number, drug_table): drug_add = True drug_index = 0 while drug_add: check_drug= False while not check_drug: drug = ask_y_n_statement.ask_option("Drug used for therapy", chemo.drug_list()) try: dose = input("Dose of " + drug +" (actual dose ammount without unit, numbers only): ") dose_x = float(dose) except: print ('ERROR: enter numbers only') dose = input("Dose of " + drug +" (actual dose ammount without unit, numbers only): ") dose_unit = input("Dose unit: ") cyc_freq_week = input("Cycle Frequency (frequency per week, so three weekly is 3 and weekly is 1): ") try: number_cycle = input("Number of cycles actually given: ") dose_x = int(number_cycle) except: print('ERROR: enter numbers only') number_cycle = input("Number of cycles actually given: ") try: drug_dose = float(dose) * int(number_cycle) except: drug_dose = 'PLEASE RE-ENTER DATA, DOSE AND NUMBER OF CYCLES MUST BE DIGITS ONLY' data_drug = [file_number, number_cycle, drug, str(drug_dose), dose_unit, cyc_freq_week] drug_table.loc[drug_index] = data_drug check_drug, drug_table = review_df_row(drug_table) drug_index = drug_index + 1 drug_add = ask_y_n_statement.ask_y_n("Add another drug") return drug_table
def tox_table(file_number, drug_cyc, tox_all): tox_index = 0 check_tox = False while not check_tox: tox = ask_y_n_statement.ask_y_n( "Were there any toxic effects in administration of " + drug_cyc) if tox: add_tox = True while add_tox: tox_present = ask_y_n_statement.ask_option( "Toxic effects of type", chemo.toxicity()) tox_grade = ask_y_n_statement.ask_option( ("the grade of " + tox_present + "? "), ["Mild", "Moderate", "Severe", "Other"]) treatment = input("Treatment given for " + tox_grade + " " + tox_present + " (include all details): ") resp_treatment = ask_y_n_statement.ask_option( ("Response to treatment given for " + tox_grade + " " + tox_present), ["Partial", "Complete", "No Effect", "Other"]) cyc_tox = input("Cycle at which toxicity occurred: ") change_tox = ask_y_n_statement.ask_option( "Changes to treatment", [ "No change", "Therapy changed due to toxicity", "Therapy stopped due to toxicity", "Therapy changed due to other reasons", "Therapy stopped due to other reasons" ]) if change_tox == "Therapy changed due to toxicity" or change_tox == "Therapy changed due to other "\ "reasons": change = input("Please describe changes to Therapy: ") change_tox = change_tox + ": " + change check = False while not check: data = [ file_number, drug_cyc, tox_present, tox_grade, treatment, resp_treatment, cyc_tox, change_tox ] tox_all.loc[tox_index] = data check = review_df_row(tox_all) tox_index = tox_index + 1 add_tox = ask_y_n_statement.ask_y_n( 'Add another toxicity type?') else: tox_present, tox_grade, treatment, resp_treatment, cyc_tox, change_tox = ( "No Toxicity", ) * 6 data = [ file_number, drug_cyc, tox_present, tox_grade, treatment, resp_treatment, cyc_tox, change_tox ] tox_all.loc[tox_index] = data check_tox = review_df(tox_all) return tox_all
def drug_table_enter(file_number, drug_table): drug_add = True drug_index = 0 while drug_add: check_drug = False while not check_drug: drugs_administered = ask.ask_option("Drug used for therapy", chemo.drug_list()) dose_check = ask.ask_y_n('Is the drug dose available?') if dose_check: dose = ask.check_number_input( "Dose of " + drugs_administered + ':', 'Please input dose amount' 'without unit') if dose == 'NA': dose_unit = 'NA' else: dose_unit = input("Dose unit: ") else: dose, dose_unit = [ 'NA', ] * 2 cycle_check = ask.ask_y_n('Is the drug cycle available?') if cycle_check: cycle_frequency_per_week = ask.check_number_input( "Cycle Frequency: ", 'Please enter frequency per ' 'week, so three weekly is 3 and ' 'weekly is 1') number_cycle = ask.check_number_input( "Number of cycles actually given: ", 'Please enter numbers only') else: cycle_frequency_per_week, number_cycle = [ 'NA', ] * 2 drug_dose = 'NA' if number_cycle != 'NA' and dose != 'NA': drug_dose = float(dose) * int(number_cycle) data_drug = [ file_number, drugs_administered, number_cycle, cycle_frequency_per_week, str(drug_dose), dose_unit ] drug_table.loc[drug_index] = data_drug check_drug, drug_table = review_df_row(drug_table) drug_index = drug_index + 1 drug_add = ask.ask_y_n("Add another drug") return drug_table
def update_block_id(self, file_number, block_type): block_df = self.block_data pk = uuid.uuid4().hex data_list = self.columns check = False while not check: patient_name = sql.get_value_no_error(col_name='patient_name', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) mr_number = sql.get_value_no_error(col_name='mr_number', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) date_of_birth = sql.get_value_no_error(col_name='date_of_birth', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) date_first_visit = sql.get_value_no_error( col_name='date_first_visit', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) block_sr_number = sql.get_value_no_error( col_name='block_sr_number', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) block_location = sql.get_value_no_error(col_name='block_location', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) blocks_received_at_pccm = sql.get_value_no_error( col_name='blocks_received_at_pccm', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) consent_discussed = sql.get_value_no_error( col_name='consent_discussed', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) consent = sql.get_value_no_error(col_name='consent', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) block_id = self.check_block_value_in_db( input_statement='Please enter block id: ', value_name='block_id', integer=False) if blocks_received_at_pccm == 'NA': number_of_blocks, block_series, current_block_location = [ 'NA', ] * 3 else: number_of_blocks = ask.check_number_input( 'Please enter number of blocks recieved at PCCM: ', 'Number of blocks has to be a whole number or NA') block_series = input( "Series of blocks recieved (Please enter series in the form A-B and separate " "series by '|' e.g, A-B|E): ") current_block_location = ask.ask_list( 'Current location of block', BlockList.edit_values['current_block_location']) data_list = [ pk, file_number, 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, str(consent_discussed), consent, self.user_name, sql.last_update() ] # print(data_list, self.columns_db) block_df.loc[pk] = data_list check, block_df = sql.review_df_row(block_df) return data_list[1:], pk
def add_block_id(self, file_number): block_df = self.block_data pk = uuid.uuid4().hex data_list = self.columns check = False while not check: check_name = False while not check_name: patient_name = input('Please enter patient name: '), print('Patient name: ' + str(patient_name)) check_name = ask.ask_y_n('Is name correct') mr_number = self.check_block_value_in_db( input_statement='Please enter MR number: ', value_name='mr_number', integer=True) date_of_birth = self.get_value_and_check_value( col_name='date_of_birth', file_number=file_number, input_statement='Please input patient date of birth ' '(format: dd.mm.yyyy): ', integer=False) date_first_visit = ask.check_date( 'Please enter date of first visit: ') block_sr_number = self.check_block_value_in_db( input_statement='Please enter block serial number: ', value_name='block_sr_number', integer=True) block_pccm = ask.ask_y_n( 'Have these blocks been recieved at PCCM?') block_location, blocks_received_at_pccm = [ 'NA', ] * 2 if block_pccm: block_location_check = False while not block_location_check: block_location = block_location_format() block_location_check = sql.check_value_not_exist( self.cursor, value_name='block_location', value=block_location, table=self.table_name) blocks_received_at_pccm = ask.check_date_or_today( 'Please enter date blocks recieved at PCCM (or ' 'today): ') consent_discussed, consent = self.get_consent(file_number) block_id = self.check_block_value_in_db( input_statement='Please enter block id: ', value_name='block_id', integer=False) block_type = ask.ask_list('Block type', ['biopsy', 'surgery']) if blocks_received_at_pccm == 'NA': number_of_blocks, block_series, current_block_location = [ 'NA', ] * 3 else: number_of_blocks = ask.check_number_input( 'Please enter number of blocks recieved at PCCM: ', 'Number of blocks has to be a whole number or NA') block_series = input( "Series of blocks recieved (Please enter series in the form A-B and separate " "series by '|' e.g, A-B|E): ") current_block_location = ask.ask_list( 'Current location of block', BlockList.edit_values['current_block_location']) data_list = [ pk, file_number, 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, str(consent_discussed), consent, self.user_name, sql.last_update() ] block_df.loc[pk] = data_list check, block_df = sql.review_df_row(block_df) return data_list[1:], pk
def update_patient(self, file_number, block_id): block_df = self.block_data check = False while not check: print('update_patient') pk = uuid.uuid4().hex patient_name = self.get_value_and_check_value( col_name='patient_name', file_number=file_number, input_statement='Please enter patient name: ', integer=False) block_sr_number = self.get_value_and_check_value( col_name='block_sr_number', file_number=file_number, input_statement='Please enter block serial number: ', integer=True) if block_sr_number != 'block_not_available': block_location_check = sql.get_value_no_error( 'block_location', self.table_name, file_number, 'file_number', self.cursor) block_location = block_location_check print('block_location: ' + str(block_location)) block_location_check = ask.ask_y_n('Is this correct?') while not block_location_check: block_location = block_location_format() block_location_check = self.check_block_value_not_exist( value_name='block_location', value=block_location, table=self.table_name) blocks_received_at_pccm = sql.check_db_value( col_name='blocks_received_at_pccm', table=self.table_name, file_number=file_number, cursor=self.cursor, error_statement='Please enter date blocks recieved at PCCM' ' (dd.mm.yyyy): ') block_type = ask.ask_list('Block type', ['biopsy', 'surgery']) if block_id == 'block_id': block_id = self.check_block_value_in_db( input_statement='Please enter block id: ', value_name='block_id', integer=False) number_of_blocks = ask.check_number_input( 'Please enter number of blocks recieved at PCCM: ', 'Number of blocks has to be a whole number or NA') block_series = input( "Series of blocks recieved (Please separate series by ';'): " ) current_block_location = ask.ask_list( 'Current location of block', names.block_list('location')) consent_discussed, consent = self.get_consent(file_number) else: block_type = ask.ask_list('Block type', ['biopsy', 'surgery']) if block_id == 'block_id': block_id = self.check_block_value_in_db( input_statement='Please enter block id: ', value_name='block_id', integer=False) block_location, blocks_received_at_pccm, number_of_blocks, block_series, current_block_location, \ consent_discussed, consent = (block_sr_number, )*7 data_list = [ pk, file_number, patient_name, block_sr_number, block_location, block_type, block_id, current_block_location, blocks_received_at_pccm, number_of_blocks, block_series, consent_discussed, consent, self.user_name, sql.last_update() ] block_df.loc[pk] = data_list check, block_df = sql.review_df_row(block_df) print("error check in update_patient") sql.print_df(block_df) return block_df
def add_update_patient(self): block_df = self.block_data 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") check = False while not check: if sql.check_file_number_exist(self.cursor, file_number, self.table_name): print('add_update_patient_not_checck') pk = uuid.uuid4().hex patient_name = self.get_value_and_check_value( col_name='patient_name', file_number=file_number, input_statement='Please enter patient name: ', integer=False) block_sr_number = self.get_value_and_check_value( col_name='block_sr_number', file_number=file_number, input_statement='Please enter block serial number: ', integer=True) # block_location = 'block_location' block_location_check = sql.get_value_no_error( col_name='block_location', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) if not block_location_check: print( 'Block location already exists for another file_number' ) while not block_location_check: block_location = block_location_format() block_location_check = sql.check_value_not_exist( self.cursor, value_name='block_location', value=block_location, table=self.table_name) else: block_location = block_location_check blocks_received_at_pccm = sql.get_value_no_error( col_name='blocks_received_at_pccm', table=self.table_name, pk=file_number, pk_name='file_number', cursor=self.cursor) if not blocks_received_at_pccm: blocks_received_at_pccm = ask.check_date_or_today( 'Please enter date blocks recieved at PCCM (or ' 'today): ') consent_discussed, consent = self.get_consent(file_number) else: pk = uuid.uuid4().hex patient_name = input('Please enter patient name: ') block_sr_number = self.check_block_value_in_db( input_statement='Please enter block serial number: ', value_name='block_sr_number', integer=True) block_pccm = ask.ask_y_n( 'Have these blocks been recieved at PCCM?') block_location, blocks_received_at_pccm = [ 'NA', ] * 2 if block_pccm: block_location_check = False while not block_location_check: block_location = block_location_format() block_location_check = sql.check_value_not_exist( self.cursor, value_name='block_location', value=block_location, table=self.table_name) blocks_received_at_pccm = ask.check_date_or_today( 'Please enter date blocks recieved at PCCM (or ' 'today): ') consent_discussed, consent = self.get_consent(file_number) block_type = ask.ask_list('Block type', ['biopsy', 'surgery']) block_id = self.check_block_value_in_db( input_statement='Please enter block id: ', value_name='block_id', integer=False) number_of_blocks = ask.check_number_input( 'Please enter number of blocks recieved at PCCM: ', 'Number of blocks has to be a whole number or NA') block_series = input( "Series of blocks recieved (Please separate series by ';'): ") current_block_location = ask.ask_list('Current location of block', names.block_list('location')) data_list = [ pk, file_number, patient_name, block_sr_number, block_location, block_type, block_id, current_block_location, blocks_received_at_pccm, number_of_blocks, block_series, str(consent_discussed), consent, self.user_name, sql.last_update() ] # error check print("error check in loop 1") sql.print_df(block_df) block_df.loc[pk] = data_list print("error check in loop 2") sql.print_df(block_df) check, block_df = sql.review_df_row(block_df) # error check print("error check out of loop_to_db") sql.print_df(block_df) return block_df
def multiple_mass(table, mammo_breast="Right Breast"): import modules.ask_y_n_statement as ask_y_n_statement import sql.add_update_sql as add_update_sql import modules.pccm_names as pccm_names import pandas as pd number_mass = input("Number of masses detected: ") try: mass_number = int(number_mass) except: mass_number = 1 col_list = pccm_names.names_radio_df(table) mass_df = pd.DataFrame(columns=col_list) for index in range(0, mass_number): mass_id = index + 1 if table == "Mammography_Mass": check = False while not check: if mammo_breast == "Bilateral": mass_location = ask_y_n_statement.ask_option( "Location of mass " + str(mass_id), ["Right Breast", "Left Breast"]) else: mass_location = mammo_breast location_quad = lesion_location(mass_location) mammo_mass_shape = ask_y_n_statement.ask_option( "Shape of mass", ["Oval", "Round", "Irregular", "Other"]) mammo_mass_margin = ask_y_n_statement.ask_option( "Margins of mass", [ "Circumscribed", "Obscured", "Microlobulated", "Indistinct", "Spiculated", "Other" ]) mass_nipple = input("Distance from nipple (cm): ") mass_size = input("Mass dimensions (without unit): ") mass_size_unit = input("Mass dimensions unit") mass_id = "Mass " + str(index + 1) data_list = [ mass_id, location_quad, mammo_mass_shape, mammo_mass_margin, mass_nipple, mass_size, mass_size_unit ] mass_df.loc[index] = data_list check, mass_df = add_update_sql.review_df_row(mass_df) data_list = [] for index in col_list: data_mass = "; ".join(list(mass_df.loc[:, index])) data_list.append([data_mass]) data_df = ask_y_n_statement.join_lists(data_list, "; ") mass_id_, location_quad, mammo_mass_shape, mammo_mass_margin, mass_nipple, \ mass_size, mass_size_unit = data_df data_return = number_mass, location_quad, mammo_mass_shape, mammo_mass_margin, mass_nipple, mass_size, mass_size_unit elif table == "SonnoMammography_Mass": check = False while not check: if mammo_breast == "Bilateral": mass_location = ask_y_n_statement.ask_option( "Location of mass " + str(mass_id), ["Right Breast", "Left Breast"]) else: mass_location = mammo_breast location_clock = input("What is the clock position of mass " + str(mass_id) + "?") location_clock = location_clock + " o'clock" mass_shape = ask_y_n_statement.ask_option( "Shape of mass " + str(mass_id), ["Oval", "Round", "Irregular", "Other"]) mass_size = input("Mass dimensions (without unit: ") mass_size_unit = input("Mass dimensions unit") mass_margin = ask_y_n_statement.ask_option( "Margin of mass " + str(mass_id), [ "Circumscribed", "Indistinct", "Angular", "Microlobulated" ]) mass_echo = ask_y_n_statement.ask_option( "Echo pattern of mass " + str(mass_id), [ "Anechoic", "Hyperechoic", "Complex cystic " "and solid", "Hypoechoic", "Isoechoic", "Heterogeneous", "Other" ]) mass_id = "Mass " + str(index + 1) data_list = [ mass_id, mass_location, location_clock, mass_shape, mass_margin, mass_echo, mass_size, mass_size_unit ] mass_df.loc[index] = data_list check, mass_df = add_update_sql.review_df_row(mass_df) data_list = [] for index in col_list: data_mass = "; ".join(list(mass_df.loc[:, index])) data_list.append([data_mass]) data_df = ask_y_n_statement.join_lists(data_list, "; ") mass_id_, mass_location, location_clock, mass_shape, mass_margin, mass_echo, mass_size, mass_size_unit = data_df if mammo_breast != 'Bilateral': mass_location = mammo_breast data_return = number_mass, mass_location, location_clock, mass_shape, mass_margin, mass_echo, mass_size, mass_size_unit elif table == "MRI_Mass": check = False while not check: if mammo_breast == "Bilateral": mass_location = ask_y_n_statement.ask_option( "Location of mass " + str(mass_id), ["Right Breast", "Left Breast"]) else: mass_location = mammo_breast mri_mass_shape = ask_y_n_statement.ask_option( "Shape of mass", ["Oval", "Round", "Irregular", "Other"]) mri_mass_margin = ask_y_n_statement.ask_option( "Margins of mass", ["Circumscribed", "Irregular", "Spiculated"]) mri_mass_internal = ask_y_n_statement.ask_option( "Internal enhancement characteristics", [ "Homogeneous", "Heterogeneous", "Rim enhancement", "Dark internal septations" ]) mass_id = "Mass " + str(index + 1) data_list = [ str(mass_id), mass_location, mri_mass_shape, mri_mass_margin, mri_mass_internal ] mass_df.loc[index] = data_list check, mass_df = add_update_sql.review_df_row(mass_df) data_list = [] for index in col_list: data_mass = "; ".join(list(mass_df.loc[:, index])) data_list.append([data_mass]) data_df = ask_y_n_statement.join_lists(data_list, "; ") mass_id_, mass_location, mri_mass_shape, mri_mass_margin, mri_mass_internal = data_df if mammo_breast != 'Bilateral': mass_location = mammo_breast data_return = number_mass, mass_location, mri_mass_shape, mri_mass_margin, mri_mass_internal else: data_return = "Table does not exist" return data_return
def follow_up(self): follow = True follow_index = 0 col_list = ["file_number"] + names() follow_up_data = pd.DataFrame(columns=col_list) while follow: check = False while not check: time_follow = ask.ask_option("Follow-up Period", [ "3 months", "6 months", "9 months", "1 year", "1 year, 3 months", "1 year, 6 months", "1 year, 9 months", "2 years", "2 years, 6 months", "3 years", "3 years, 6 months", "4 years", "4 years, 6 months", "5 years", "6 years", "7 years", "8 years", "9 years", "10 years", "Other" ]) follow_status = patient_status() follow_mammo, follow_mammo_date, follow_usg, follow_usg_date = ( "NA", ) * 4 is_mammo = ask.ask_y_n('Is follow up mammogramm present?') if is_mammo: follow_mammo_date = ask.check_date( 'Date of follow-up Mammograph? ') follow_mammo = input( "Results of Mammography (Please enter in the format (Observation(mass/calc/lesion " "etc)/Location/BIRADs)): ") is_usg = ask.ask_y_n( 'Is follow up USG abdomen/Pelvis present?') if is_usg: follow_usg_date = ask.check_date( 'Date of follow-up USG abdomen/Pelvis? ') follow_usg = input( "Results of USG abdomen/Pelvis (Please enter in the format (Observation" "(mass/calc/lesion etc)/Location/BIRADs)): ") other_type_date, other_type, other_result = ("NA", ) * 3 follow_other = ask.ask_y_n( "Are there other reports in follow-up?") if follow_other: other_type_date_list = [] other_type_list = [] other_result_list = [] while follow_other: other_type_date = ask.check_date( 'Date of other test: ') other_type = input("Type of other report: ") other_result = input("Result of " + other_type + ": ") other_type_date_list.append(other_type_date) other_type_list.append(other_type) other_result_list.append(other_result) follow_other = ask.ask_y_n("Add more reports?") all_data = [ other_type_date_list, other_type_list, other_result_list ] all_data = ask.join_lists(all_data, "; ") other_type_date, other_type, other_result = all_data follow_up_treatment = ask.ask_y_n( 'Was any oncological treatment given after follow up?') if not follow_up_treatment: follow_up_treatment, follow_up_treatment_result = [ 'no_treatment_given', ] * 2 else: follow_up_treatment = input( 'What follow up treatment was given?') follow_up_treatment_result = input( 'What was the result of follow-up treatment ' + follow_up_treatment + '?') data_list = [ self.file_number, time_follow, follow_status, follow_mammo_date, follow_mammo, follow_usg_date, follow_usg, other_type, other_type_date, other_result, follow_up_treatment, follow_up_treatment_result, self.user_name, sql.last_update() ] follow_up_data.loc[follow_index] = data_list check, follow_up_data = sql.review_df_row(follow_up_data) follow_index = follow_index + 1 follow_up_period = list(follow_up_data.loc[:, "follow_up_period"]) print("\n Follow up periods added: " + "; ".join(follow_up_period) + '\n') follow = ask.ask_y_n("Add another follow-up period?") return follow_up_data