def report(self): data_list = ask.default_data_list(self.col_list_all) check = False while not check: reason_report = ask.ask_option( "What is the purpose of this report" "?", MultiTest.test_reason_imaging) report_date = ask.check_date("Date of examination of ABVS: ") abvs_acc = input("Accession number of ABVS: ") abvs_lesion = ask.ask_option("Location of lesion", MultiTest.breast_cancer) if abvs_lesion in {MultiTest.breast_cancer}: abvs_lesion_data = radio_tables.lesion_location(abvs_lesion) else: abvs_lesion_data = "NA" abvs_size = ask.ask_option("Size of lesion", ["<2 cm", "2-5 cm", ">5 cm", "Other"]) abvs_dist = ask.ask_option("Distance from Skin (cm)", ["<0.5 cm", ">0.5 cm", "Other"]) abvs_pect = input("Distance from Pectoralis Major (cm): ") abvs_diagnosis = ask.ask_option("ABVS Diagnosis", Radio.diagnosis) data_list = [ self.file_number, reason_report, report_date, abvs_acc, abvs_lesion, abvs_lesion_data, abvs_size, abvs_dist, abvs_pect, abvs_diagnosis ] check = sql.review_input(self.file_number, self.col_list_all[:-2], data_list) data_list = data_list + [self.user_name, sql.last_update()] return data_list
def mammo_mass(self, mass_id): print(self.table, mass_id) check = False data_list = ask.default_data_list(self.col_list) while not check: mass_location = self.mammo_breast if self.mammo_breast == "bilateral": mass_location = ask.ask_option("Location of mass " + str(mass_id), RadioTables.breast) mass_quadrant = ask.ask_list('Quadrant location of lesion', Radio.lesion_quadrant) mammo_mass_shape = ask.ask_option("Shape of mass", RadioTables.mass_shape) mammo_mass_margin = ask.ask_option("Margins of mass", RadioTables.mass_margin) mass_nipple = input("Distance from nipple (cm): ") mass_dimension, mass_size_unit, mass_longest_dimension = self.lesion_size() modality = self.table data_list = [self.file_number, mass_location, mass_name, mass_quadrant, mammo_mass_shape, mammo_mass_margin, mass_nipple, mass_dimension, mass_longest_dimension, mass_size_unit, modality] check = sql.review_input(self.file_number, columns=self.col_list, data=data_list) data_list = data_list + [self.user_name, sql.last_update()] return data_list
def node_excision (file_number): check = False while not check: surgery_guide, frozen, gross_tumour, skin, nodes, number_lymph, level_lymph, sentinel_method, sentinel_blue, \ sentinel_hot, sentinel_blue_hot, sentinel_non_blue_hot, sentinel_palpable = (" ",)*13 guide_add = True guide = [] while guide_add: surgery_guide = ask_option("Excision guided by", ["Palpation", "USG guided", "Wire placement guided", 'Gamma camera guided', 'Clipped node']) guide.append(surgery_guide) guide_add = ask_y_n("Add another method to guide?") surgery_guide = "; ".join(guide) frozen_samples = ask_option_y_n("Any samples sent for histopathology (frozen)?") if frozen_samples == 'Yes': frozen_samples = [] sn_frozen = ask_y_n("Sentinel Node sent for histopathology (frozen)?", yes_ans="Sentinel Node") if sn_frozen == 'Sentinel Node': frozen_samples.append(sn_frozen) specimen_frozen = ask_y_n_na("Specimen sent for histopathology (frozen)?") if specimen_frozen == 'Yes': nipple_frozen = ask_y_n_na("Under Nipple Surface sent for histopathology (frozen)?", yes_ans='Under Nipple Surface') if nipple_frozen == 'Under Nipple Surface': frozen_samples.append(nipple_frozen) other_frozen = ask_y_n_na("Any other specimen sent for histopathology (frozen)?") if other_frozen == 'Yes': other_frozen = input("Type of tissue sent for histopathology (frozen): ") frozen_samples.append(other_frozen) frozen = "; ".join(frozen_samples) else: frozen = "NA" gross_tumour = input ("Size of tumour on cross section (cm): ") skin = ask_option_y_n("Skin involved", yes_ans="Skin involved", no_ans="Skin not involved") nodes = ask_option("Nodes excised", ["Sentinel Node", "Sentinel and Axillary Nodes", "Axillary Nodes only", "Other"]) number_lymph = input("Number of lymph nodes excised (if available): ") level_lymph = ask_option("Level of lymph node excised", ["I", "II", "III", "Data not available", "Other"]) if nodes == 'Axillary Nodes only': sentinel_method, sentinel_blue, sentinel_hot, sentinel_blue_hot, sentinel_non_blue_hot, sentinel_palpable = \ ('No Sentinel Node excised', )*6 else: sentinel_method = ask_option("Method of labelling Sentinel Node", ["Isotope", "Blue Dye", "Isotope + Blue Dye", "Not done", "Other"]) sentinel_blue = ask_option_y_n("Blue Node", yes_ans="Blue Node", no_ans="No Blue Node") sentinel_hot = ask_option_y_n("Hot Node", yes_ans="Hot Node", no_ans="No Hot Node") sentinel_blue_hot = ask_option_y_n("Blue Hot Node", yes_ans="Blue Hot Node", no_ans="No Blue Hot Node") sentinel_non_blue_hot = ask_option_y_n("Non Blue, Hot Node", yes_ans= "Non Blue, Hot Node", no_ans="No Non Blue, Hot Node") sentinel_palpable = ask_option_y_n("Palpable Node", yes_ans="Palpable Node", no_ans="No Palpable Node") data_list = [surgery_guide, frozen, gross_tumour, skin, nodes, number_lymph, level_lymph, sentinel_method, sentinel_blue, sentinel_hot, sentinel_blue_hot, sentinel_non_blue_hot, sentinel_palpable] col_list = names("node_excision") check = add_update_sql.review_input(file_number, col_list, data_list) return data_list
def bio_info(self): module_name = "bio_info" new_data = ['NA'] * 16 check = False while not check: mr_number = input('MR number :') name = input('Name :') aadhaar_card = input("Aadhaar card number (if available): ") date_first = check_date("Date of first visit: ") permanent_address = input('Permanent Address :') current_address_check = ask_option( 'Current Address', ["Same as Permanent", "Different"]) if current_address_check == "Different": current_address = input("Current Address: ") else: current_address = permanent_address phone = input('Phone :') email_id = input('Email_ID :') gender = ask_option('Gender', ["Female", "Male", "Other"]) age_yrs = input('Age at first visit (yrs) :') age_diag = input('Age at diagnosis (yrs): ') date_of_birth = check_date('Date of Birth (dd/mm/yyyy):') place_birth = input('Place of Birth :') height = ask_option("Height unit", ["cm", "feet/inches", "Height not available"]) height_cm, height_feet, height_inch, weight, bmi = ['NA'] * 5 if height == "Height not available": height_cm = "NA" weight_kg = input('Weight (kg) (if available else enter NA) :') bmi = "NA" else: if height == "cm": height_cm = input('Height (cm) :') else: height_feet = float(input("Height (feet)")) height_inch = float(input("Height (inches)")) height_inch = height_inch + 12 * height_feet height_cm = height_inch * 2.54 weight_kg = input('Weight (kg) (if available else enter NA) :') try: weight = float(weight_kg) height = float(height_cm) / 100 bmi = str(round(weight / (height * height))) except ValueError: bmi = 'NA' columns_list = pccm_names.names_info(module_name) new_data = [ mr_number, name, aadhaar_card, date_first, permanent_address, current_address, phone, email_id, gender, age_yrs, age_diag, date_of_birth, place_birth, height_cm, weight_kg, bmi ] check = review_input(self.file_number, columns_list, new_data) return new_data
def tox_table(file_number, drug_cyc, tox_all): tox_index = 0 check_tox = False while not check_tox: tox = ask.ask_y_n( "Were there any toxic effects in administration of " + drug_cyc) if tox: add_tox = True while add_tox: check = False while not check: tox_present = ask.ask_option("Toxic effects of type", chemo.toxicity()) tox_grade = ask.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.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.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 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.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 patient_status(): status = ask.ask_option("Status at last follow up", [ "Survivor", "Deceased", "Lost to follow-up", 'Case of Non Malignant Breast Disease', "Other" ]) if status == "Survivor": type_survivor = ask.ask_list("the Survivor is ", FollowUpStatus.survivor_status) status = status + ": " + type_survivor if status == "Deceased": type_death = ask.ask_option("Cause of death", FollowUpStatus.deceased_status) status = status + ": " + type_death return status
def review_data_key(conn, cursor, table, key_name, key_value, columns, col_name, col_value): if 'file_number' in columns: # remove 1st position from column names (assumes it is file_number) col_list = columns[1:] else: col_list = columns sql_statement = 'SELECT ' + ", ".join(col_list) + ' FROM ' + table + " WHERE " + key_name + "= '" + key_value + "'" data = cursor.execute(sql_statement) data_list = data.fetchall() if not data_list: print("This " + col_name + ' ' + col_value + ' has not been entered in ' + table) enter = ask.ask_y_n("Do you want to enter now") if enter: add_pk_fk_to_table(conn, cursor, table, col_name=key_name, pk=key_value) print('added new row for this ' + key_name) return enter else: data_list = list(data_list[0]) col_number = len(col_list) if data_list == [None]*len(data_list): print("This section of the database has not been entered") enter = ask.ask_y_n("Do you want to enter now") return enter elif None in set(data_list): print("Some entries are missing from the database: ") for index in range(0, col_number): print(col_list[index] + " : " + str(data_list[index])) enter = ask.ask_option("Do you want to proceed?", ["Edit all", "Add new data only"]) if enter == "Edit all": return True else: enter = edit_few(conn, cursor, table, col_list, key_value, data_list) return enter else: print("Entries present in database are as follows : ") for index in range(0, col_number): print(col_list[index] + " : " + str(data_list[index])) enter = ask.ask_option("Do you want to", ["Edit all", "Edit some entries", "Edit None"]) if enter == "Edit some entries": for index in range(0, col_number): print(col_list[index] + " : " + str(data_list[index])) edit = ask.ask_y_n("Edit") if edit: data = input("Data for " + col_list[index] + ": ") update_single_pk(conn, cursor, table, col_list[index], pk_value=key_name, pk=key_value, var=data) return False elif enter == "Edit all": return True else: return False
def edit_table(df, pk_col, df_col): import helper_function.ask_y_n_statement as ask rows = (df.shape)[0] for row in range(0,rows): print(df.iloc[row].to_string()+'\n') to_correct = ask.ask_y_n("Are entries correct?") if not to_correct: to_correct = ask.ask_y_n("Re-enter entire table?") if to_correct: return to_correct, df else: change_row = True while change_row: pk_list = list(df[pk_col]) print(pk_list) pk = input("Enter " + pk_col + " to change: ") index = pk_list.index(id) to_do = True while to_do: print(df.loc[index, :]) col_change = ask.ask_option("Name of column to change", df_col) old_val = df.loc[index, col_change] print(old_val + '\n') new_val = input("Enter correct value for " + col_change + ' for ' + pk + ": ") df.loc[index, col_change] = new_val print(df.iloc[index].to_string() + '\n') to_do = ask.ask_y_n("Make more changes to " + pk_col + ' ' + pk + '?') print_df(df) change_row = ask.ask_y_n("Change another row?") to_correct = False return to_correct, df
def family_cancer_table(conn, cursor, file_number): add_family = True type_cancer_list, relation_degree_list, type_relation_list, age_detect_list = [], [], [], [] all_data = [] while add_family: type_of_cancer = input("Type of Cancer: ") type_cancer_list.append(type_of_cancer) relation_to_patient = ask_option("Relation to patient", PatientInfo.family) relation_degree_list.append(relation_to_patient) type_relation = input("Specific Relationship:") type_relation_list.append(type_relation) age_at_detection_yrs = input('Age at detection (yrs) :') age_detect_list.append(age_at_detection_yrs) family_history = file_number, type_of_cancer, relation_to_patient, type_relation, age_at_detection_yrs family_history_list = "; ".join([ type_of_cancer, relation_to_patient, type_relation, age_at_detection_yrs ]) all_data.append(family_history_list) columns = 'file_number, type_cancer, relation_to_patient, type_relation, age_at_detection_yrs' table = "family_cancer_history" sql.insert(conn, cursor, table, columns, family_history) add_family = ask_y_n("Add more family cancer history? ") all_data_flat = "|".join(all_data) return (all_data_flat)
def check_path_report_entry(conn, cursor, file_number, table_to_check, pk, block_id, number_of_blocks, user_name): from reports.biopsy_report import BiopsyData from reports.surgery_block import SurgeryBlockData table_data = BiopsyData(conn, cursor, file_number, pk, block_id, number_of_blocks, user_name) col_name = 'pk' if 'surgery' in table_to_check: table_data = SurgeryBlockData(conn, cursor, file_number, pk, block_id, number_of_blocks, user_name) col_filter = 'fk' pk_fk_present = sql.check_pk_fk_exist(cursor, col_name, pk, table_to_check) if not pk_fk_present: sql.add_pk_fk_to_table(conn, cursor, table_to_check, col_name, pk) print("This block_id -'" + block_id + "' for " + file_number + " does not exist in table " + table_to_check + ". Enter new record") table_data.add_data() else: todo = ask.ask_option( file_number + " already exists in table " + table_to_check + ".", ["Edit record", "Edit None"]) if todo == "Edit record": table_data.edit_data() return
def mri_mass(self, mass_id): check = False data_list = ask.default_data_list(self.col_list) while not check: if self.mammo_breast == "bilateral": mass_location = ask.ask_option("Location of mass " + str( mass_id), RadioTables.breast) else: mass_location = self.mammo_breast check_t1_t2 = ask.ask_y_n('Are both T1 and T2 image analysis' 'available for this mass?') type_of_imaging = ['T1', 'T2'] if not check_t1_t2: type_of_imaging = ask.ask_list('Observation of this mass is a' 'result of which type of' 'imaging? ', RadioTables.mri_image_type) data_list = self.mri_mass_detail(type_of_imaging, mass_id) if type_of_imaging in {'T1', 'T2'}: data_list = [('{0}_{1}'.format(type_of_imaging, data)) for data in data_list] mass_name = "Lesion " + str(mass_id) data_list = [self.file_number, mass_location, mass_name]+data_list check = sql.review_input(self.file_number, columns=self.col_list, data=data_list) data_list = [data_list] + [self.user_name, sql.last_update()] data_list = data_list + [self.user_name, sql.last_update()] return data_list
def metastasis(file_number, user_name): check = False while not check: met_has = ask.ask_y_n( "Has the patient been examined for metastatic disease?") if not met_has: met_has = "Not examined for metastatic disease" else: met_has = "Examined for metastatic disease" date_last = ask.check_date("Date of last follow-up: ") recur = ask.ask_y_n("Has the patient experienced a recurrence?") if recur: time_recur = input("Time to disease recurrence: ") nature_recur = ask.ask_option("Nature of recurrence", ["Distant", "Local", "Other"]) if nature_recur == "Distant": distant_site = input("Site of distant recurrence: ") else: distant_site = "NA" else: time_recur, nature_recur, distant_site = ("NA", ) * 3 status = patient_status() data_list = [ met_has, date_last, time_recur, nature_recur, distant_site, status, user_name, last_update() ] col_list = names.names_longterm("metastasis") check = review_input(file_number, col_list, data_list) return data_list
def lesion_location(lesion, option=MultiTest.breast_cancer): lesion_data = {} category = ["Location on right_breast", "Location on left_breast", 'Other Location'] if lesion in {"right_breast", "bilateral"}: lesion_rb = ask.ask_option(category[0], ) lesion_rb_data = "RB-" + lesion_rb lesion_data.append(lesion_rb_data) if lesion in {"right_breast", "bilateral"}: lesion_lb = ask.ask_option(category[1], option) lesion_lb_data = "LB-" + lesion_lb lesion_data.append(lesion_lb_data) if lesion not in {MultiTest.breast_cancer}: lesion_other = str.lower(str.replace(lesion, ' ', '_')) lesion_data.append(lesion_other) lesion_data = "|".join(lesion_data) return lesion_data
def view_multiple(conn, table, col_list, file_number): import pandas as pd from helper_function.ask_y_n_statement import ask_option sql_statement = ('SELECT '+ ", ".join(col_list) +' FROM '+ table + " WHERE file_number = '" +file_number+"'") df = pd.read_sql(sql_statement, conn) print_df(df) enter = ask_option("Do you want to add or edit data", ["Add data", 'Edit data', 'Do not add or edit']) return enter
def usg_mass(self, mass_id): print(self.table, mass_id) check = False data_list = ask.default_data_list(self.col_list) while not check: mass_location = self.mammo_breast if self.mammo_breast == "bilateral": mass_location = ask.ask_option("Location of mass " + str(mass_id), RadioTables.breast) location_clock = ask.check_number_input("What is the clock" "position of mass " + str(mass_id) + "?", 'Please enter only numbers' ' additional paramters ' 'can be entered ' 'next') location_add = input('Additional parameters for clock position') location_clock = location_clock + location_add + " o'clock" mass_quadrant = 'data_not_available' quad = ask.ask_y_n('Is the quadrant location given?') if quad: mass_quadrant = ask.ask_list('what is the quadrant location', Radio.lesion_quadrant) mass_shape = ask.ask_list("Shape of mass " + str(mass_id), RadioTables.mass_shape) mass_name = "lesion_" + str(mass_id) mass_dimension, mass_size_unit, mass_longest_dimension = self.lesion_size() mass_margin = ask.ask_option("Margin of mass " + str(mass_id), RadioTables.mass_margin_usg) mass_echo = ask.ask_option("Echo pattern of mass " + str(mass_id), RadioTables.mass_echo) mass_id = "Mass " + str(mass_id) modality = self.table data_list = [self.file_number, mass_name, mass_location, location_clock, mass_quadrant, mass_shape, mass_margin, mass_echo, mass_dimension, mass_longest_dimension, mass_size_unit, modality] check = sql.review_input(self.file_number, columns=self.col_list, data=data_list) data_list = data_list + [self.user_name, sql.last_update()] return data_list
def nipple_cytology(file_number): module_name = "nipple_cytology" check = False while not check: cyto = ask.ask_option("Nipple Cytology", ["Done", "Not Done"]) if cyto == "Not Done": cyto_date, cyto_number, cyto_report = ("NA", ) * 3 else: cyto_date = input("Date of nipple cytology: ") cyto_number = input("Nipple Cytology number: ") cyto_report = ask.ask_option( "Nipple Cytology report and interpretation", ["Normal", "Suspicious", "Diagnostic for " "Cancer", "Other"]) data_list = [cyto, cyto_date, cyto_number, cyto_report] columns_list = pccm_names.name_clinical(module_name) check = add_update_sql.review_input(file_number, columns_list, data_list) return (tuple(data_list))
def ffpe_csv(): folder_name, file_name, database_folder_name, database_name = ( 'D:/repos/pccm_db/main/DB', "FFPE_new_blocks.csv", 'D:/repos/pccm_db/main/DB', 'PCCM_BreastCancerDB_FFPE_dk_2018-11-20.db') check_folder = None while check_folder != 'All are correct': print('\nFolder location of FFPE new blocks data is set as: \n' + folder_name + '\n') print('File name of FFPE new blocks data is set as: \n' + file_name + '\n') print('Database file folder is set as \n' + database_folder_name + '\n') print('Database file name is set as \n' + database_name + '\n') check_folder = ask_option("Do you want to change any options?", [ 'FFPE File Folder', 'FFPE File Name', 'Database Folder', 'Database Name', 'All are correct' ]) if check_folder == 'FFPE File Folder': print('Folder location of FFPE new blocks data is set as \n' + folder_name + '\n') folder_name = input( "Please enter folder location of FFPE new blocks data: ") elif check_folder == 'FFPE File Name': print('File name of FFPE new blocks data is set as: \n' + file_name + '\n') file_name = input( "Please input correct File name of FFPE new blocks data (with .csv extension): " ) elif check_folder == 'Database Folder': print('Database file folder is set as: \n' + database_folder_name + '\n') database_folder_name = input( "Please input correct database file destination: ") elif check_folder == 'Database Name': print('Database file name is set as: \n' + database_name + '\n') database_name = input( "Please input correct database file name (with .db extension): " ) conn_path = os.path.join(database_folder_name, database_name) conn = sqlite3.connect(conn_path) cursor = conn.cursor() ffpe_data = FFPECSVData(conn, cursor, folder_name, file_name) ffpe_df = ffpe_data.read_file() n_rows = ffpe_df.shape[1] print(str(n_rows) + ' block entries read from file uploaded') ffpe_str = ffpe_df.astype(dtype='str') ffpe_data.write_file(ffpe_str) print( str(n_rows) + ' block entries added to ' + database_name + ' database') output_file_name = 'Uploaded_Database_' + file_name + str( date.today()) + '.xlsx' file_information = database_folder_name, database_name, folder_name, output_file_name print_file = OutputData(file_information) print_file.output_data()
def birads(): check = False while not check: birad_list = [i for i in Radio.birads] mammo_birads = ask.ask_option("BI-RADS Category", birad_list) mammo_birads_det = Radio.birads.get(mammo_birads) birad = mammo_birads + ": " + mammo_birads_det print(birad) check = ask.ask_y_n("Is this correct?") data_list = birad return data_list
def surgery_block_information_0(self): module_name = self.module_list[0] check = False data_list = ['NA']*17 surgery_block_data_type = 'primary' while not check: data_type = ask.ask_y_n("Is surgery type: '" + surgery_block_data_type + "'") if not data_type: surgery_block_data_type = ask.ask_option("Type of surgery", ['revision', 'recurrence']) block_list_table = BlockInformation(self.conn, self.cursor, self.file_number) block_data = ['block_sr_number', 'block_location', 'current_block_location', 'block_series'] block_sr_number, block_location, current_block_location, surgery_block_series = \ block_list_table.get_block_information(self.surgery_block_id, block_data) surgery_block_source = ask.ask_option("Pathology Lab (source of block)", PathReports.path_labs) breast_cancer_yes_no = ask.ask_y_n('Is this a case of breast cancer (Unilateral OR Bilateral)', yes_ans="breast_cancer_yes", no_ans="breast_cancer_no") pathology_report_available_yes_no = ask.ask_y_n('Is the pathology report available', yes_ans="yes", no_ans="no") nat = ask.ask_y_n('Has Neo-Adjuvant therapy been administered to the patient (NACT or NAHT)?') if nat: nact = ask.ask_list('What type of therapy has been givent to the patient?', ['NACT', 'NAHT', 'NACT_and_NAHT']) neoadjuvant_therapy = nact.lower() + '_yes' surgery_block_primary_tissue = 'treated_tissue' else: neoadjuvant_therapy = 'nact_no' surgery_block_primary_tissue = 'primary_tissue' date_of_surgery = ask.check_date("Date of Surgery: ") surgeon_s = ask.ask_option("Name of the Surgeon/s", PathReports.surgeon) surgery_hospital_id = input("Hospital ID: ") surgery_lesion_site = ask.ask_list("Lesion on", ["right_breast", "left_breast", "bilateral"]) surgery_type = self.bilateral_treatment(surgery_lesion_site, 'Type of surgery', PathReports.surgery_type) data_list = [self.file_number, surgery_block_data_type, block_sr_number, block_location, current_block_location, self.surgery_block_id, self.surgery_number_of_blocks, surgery_block_series, breast_cancer_yes_no, pathology_report_available_yes_no, neoadjuvant_therapy, str(surgery_block_primary_tissue).lower(), surgery_block_source, date_of_surgery, surgeon_s, surgery_hospital_id, surgery_lesion_site, surgery_type] columns_list = names(module_name) check = sql.review_input(self.file_number, columns_list, data_list) return data_list
def pet_report_identifier(self): module_name = self.module_list[0] check = False report_identifier = ['NA'] * 12 while not check: pet_scan_date = ask.check_date('Please enter PET report date: ') pet_scan_number = input( 'Please enter PET scan number as given on the report: ') pet_scan_source = input( 'Please enter the facility at which PET scan was done: ') pet_scan_reg_number = input( "Please enter PET report registration number: ") pet_scan_history = input( 'Please input patient history as given on report: ') pet_carcinoma_status = ask.ask_option( 'Please enter breast cancer status', MultiTest.carcinoma_status) pet_cancer_location = ask.ask_list( 'What is the location of the cancer', MultiTest.breast_cancer) pet_recurrence = ask.ask_y_n( 'Does the patient have a previously detected recurrence/mets?') if pet_recurrence: pet_recurrence_known = input( 'Please describe the recurrence/metastasis: ') else: pet_recurrence_known = 'no_known_recurrence_or_metastasis' pet_procedure_body_region = ask.ask_list( "Region of body monitored by PET scan", PetReport.body_region) pet_procedure_fdg_dose_mci = ask.check_number_input( "Please enter dose of 18F-FDG used in mCi. ", "(Please enter only dose. If given in other units " "enter under additional notes.): ") pet_procedure_bsl = input( "Please enter basal sugar level with units as given: ") pet_scanner_name = ask.ask_list('Please enter name of scanner', PetReport.machine_name) pet_procedure_additional_notes = input( 'Please enter additional notes, if any for PET scan and patient ' 'conditions: ') report_identifier = [ self.file_number, pet_scan_date, pet_scan_number, pet_scan_source, pet_scan_reg_number, pet_scan_history, pet_carcinoma_status, pet_cancer_location, pet_recurrence_known, pet_procedure_body_region, pet_procedure_fdg_dose_mci, pet_procedure_bsl, pet_scanner_name, pet_procedure_additional_notes ] columns_list = names(module_name) check = sql.review_input(self.file_number, columns_list, report_identifier) return report_identifier
def abvs(file_number): module_name = "abvs" check = False while not check: abvs = ask.ask_y_n("Automated Breast Volume Scanner (ABVS) done?") if abvs: abvs = "Automated Breast Volume Scanner done" abvs_date = input("Date of examination of ABVS: ") abvs_acc = input("Accession number of ABVS: ") abvs_lesion = ask.ask_option( "Location of lesion", ["Right Breast", "Left Breast", "Both", "Not present"]) if abvs_lesion in {"Right Breast", "Left Breast", "Both"}: abvs_lesion_data = radio_tables_old.lesion_location( abvs_lesion) else: abvs_lesion_data = "NA" abvs_size = ask.ask_option("Size of lesion", ["<2 cm", "2-5 cm", ">5 cm", "Other"]) abvs_dist = ask.ask_option("Distance from Skin (cm)", ["<0.5 cm", ">0.5 cm", "Other"]) abvs_pect = input("Distance from Pectoralis Major (cm): ") abvs_diagnosis = ask.ask_option( "ABVS Diagnosis", ["Normal", "Benign", "Suspicious", "Diagnostic for Cancer"]) else: abvs = "Automated Breast Volume Scanner done" abvs_date, abvs_acc, abvs_lesion, abvs_lesion_data, abvs_size, abvs_dist, abvs_pect, \ abvs_diagnosis = ("NA",) * 8 data_list = [ abvs, abvs_date, abvs_acc, abvs_lesion, abvs_lesion_data, abvs_size, abvs_dist, abvs_pect, abvs_diagnosis ] columns_list = names(module_name) check = add_update_sql.review_input(file_number, columns_list, data_list) return (tuple(data_list))
def mri_mass_detail(self, image_type, mass_id): print(self.table, mass_id) data_list = ask.default_data_list(self.col_list) check = False while not check: non_mass = ask.ask_y_n('Is the enhancement non-mass?') enhancement_type = 'mass' if non_mass: enhancement_type = 'non_mass' location_clock = input("What is the clock position of mass " + str(mass_id) + "? (Enter NA if clock" "position not available)") if location_clock != 'NA': location_clock = location_clock + " o'clock" mass_quadrant = ask.ask_option('Quadrant location of mass', Radio.lesion_quadrant) mass_shape = ask.ask_option("Shape of mass " + str(mass_id), RadioTables.mass_shape) mass_margin = ask.ask_option("Margin of mass " + str(mass_id), RadioTables.mass_margin_mri) mass_dimension, mass_size_unit, mass_longest_dimension = self.lesion_size() mass_echo = ask.ask_option("Internal enhancement characteristics" " " + str(mass_id), RadioTables.mass_iec) mass_id = "Mass " + str(mass_id) modality = self.table data_list = [mass_id, image_type, enhancement_type, location_clock, mass_quadrant, mass_shape, mass_margin, mass_echo, mass_dimension, str(mass_longest_dimension), mass_size_unit, modality] col_list = self.col_list[3:] check = sql.review_input(self.file_number, columns=col_list, data=data_list) data_list = data_list + [self.user_name, sql.last_update()] return data_list
def review_data(self): sql = ('SELECT ' + ", ".join(self.columns) + ' FROM ' + self.table + " WHERE file_number = '" + self.file_number + "'") data = self.cursor.execute(sql) data_list = data.fetchall() data_list = list(data_list[0]) col_number = len(self.columns) if data_list == [None]*len(data_list): print("This section of the database has not been entered") enter = ask.ask_y_n("Do you want to enter now") return enter if None in set(data_list): print("Some entries are missing from the database: ") for index in range(0, col_number): print(self.columns[index] + " : " + str(self.data[index])) enter = ask.ask_option("Do you want to proceed?", ["Edit all", "Add new data only"]) if enter == "Edit all": return True else: edit_few(self.conn, self.cursor, self.table, self.columns, self.file_number, self.data) else: print("Entries present in database are as follows : ") for index in range(0, col_number): print(self.columns[index] + " : " + str(self.data[index])) enter = ask.ask_option("Do you want to", ["Edit all", "Edit some entries", "Edit None"]) if enter == "Edit some entries": for index in range(0, col_number): print(self.columns[index] + " : " + str(self.data[index])) edit = ask.ask_y_n("Edit") if edit: data = input("Data for " + self.columns[index] + ": ") update_single(self.conn, self.cursor, self.table, self.columns, self.file_number, data) return False elif enter == "Edit all": return True else: return False
def bilateral_treatment(surgery_lesion_site, data_type_statement, data_type_options): if data_type_options != 'input': if surgery_lesion_site.lower == "bilateral": print("Right Breast") data_type = ask.ask_option(data_type_statement, data_type_options) data_type_rb = "rb_" + data_type print("Left Breast") data_type = ask.ask_option(data_type_statement, data_type_options) data_type_lb = "lb_" + data_type data = data_type_rb + "; " + data_type_lb else: data = ask.ask_option(data_type_statement, data_type_options) else: if surgery_lesion_site.lower == "bilateral": print("Right Breast") data_type = input(data_type_statement) data_type_rb = "rb_" + data_type print("Left Breast") data_type = input(data_type_statement) data_type_lb = "lb_" + data_type data = data_type_rb + "; " + data_type_lb else: data = input(data_type_statement) return data
def det_by(file_number): module_name = "det_by" check = False while not check: category = "Current Breast Cancer Detected by" options = ["Self", "Physician", "Screening Camp", "Other"] determined_by = ask_option(category, options) if determined_by == "Screening Camp": sc_id = input("Screening Camp ID: ") determined_by = "Screening Camp ID " + sc_id det_date = input("Date of current breast cancer detection: ") columns_list = pccm_names.names_info(module_name) data_list = [determined_by, det_date] check = review_input(file_number, columns_list, data_list) return (tuple(data_list))
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 hormone_therapy_chemo(): hormone_therapy = ask.ask_y_n_na("Was hormone therapy given?") if hormone_therapy == 'Yes': hormone_therapy = "Hormone therapy given" therapy_type = ask.ask_option("Hormone therapy type", ["Sequential", "Concurrent"]) therapy_duration = input("What was the duration of therapy? ") therapy_side = ask.ask_y_n_na("Were any side effects observed ?") if therapy_side == 'Yes': therapy_side = input( "Please give details of side effects observed: ") elif hormone_therapy == 'No': hormone_therapy = "No hormone therapy given" therapy_type, therapy_duration, therapy_side = (hormone_therapy, ) * 3 else: therapy_type, therapy_duration, therapy_side = (hormone_therapy, ) * 3 return hormone_therapy, therapy_type, therapy_duration, therapy_side
def output_data(self): cursor = self.conn.cursor() tables_to_print = [] summary_df = pd.DataFrame(columns=["table_name", "number_entries"]) output_name = self.output_name if self.research: output_name = 'Research_' + self.output_name output_path = os.path.join(self.output_folder, output_name) for table in print_db_tables(): check = table_check(cursor, table) if check: tables_to_print.append(table) if not tables_to_print: print( "Selected Database has no tables. Please re-start and edit database file" ) return else: writer = pd.ExcelWriter(output_path, engine='xlsxwriter') print('This database contains the following tables:') i = 1 for table in tables_to_print: print(str(i) + ". " + table) i = i + 1 to_print = ask_option( "Do you want to print all tables or only select tables?", ["All tables", "Select tables"]) if to_print == "All tables": index = 0 for table in tables_to_print: self.print_table(writer, table) number = self.print_table(writer, table) summary_df.loc[index] = [table, number] index = index + 1 elif to_print == "Select tables": for table in tables_to_print: to_print = ask_y_n("Do you want to print " + table) if to_print: self.print_table(writer, table) number = self.print_table(writer, table) summary_df.loc[table] = [table, number] self.print_summary(summary_df) print("Data file " + output_name + " has been created at " + self.output_folder + '\n') writer.save()
def check_file(conn, cursor, table, file_number, user_name, folders): sql_statement = "SELECT rowid FROM " + table + " WHERE file_number = ?" cursor.execute(sql_statement, (file_number, )) data = cursor.fetchall() if len(data) == 0: if table != "Follow_up_Data": cursor.execute("INSERT INTO " + table + "(file_number) VALUES ('" + file_number + "')") print(file_number + " does not exist in table " + table + ". Enter new record") add_new.add_new(conn, cursor, file_number, table, user_name,folders) else: todo = ask.ask_option(file_number + " already exists in table " + table + ".", ["Edit record", "Add new record for same file number", "Edit None"]) if todo == "Edit record": edit_record.edit_record(conn, cursor, file_number, table, user_name, folders) elif todo == "Add new record for same file number": print("Add additional record module TBD") ask_table = ask.ask_y_n("Add another table?") return ask_table
def feed_duration(conn, cursor, file_number, children_number): table = "breast_feeding" child_list, feeding_duration_list, feeding_details_list = [], [], [] child_number = int(children_number) for index in range(0, child_number): kid = str(index + 1) kid_add = "Child " + kid child_list.append(kid_add) feeding_duration = input("Breast feeding duration for " + kid_add + " (months) ?") feeding_duration_list.append(feeding_duration) feeding_details = ask_option("Breast feeding for child " + kid, PatientInfo.breast_feeding) feeding_details_list.append(feeding_details) columns = 'file_number, child_number, feeding_duration, breast_usage_feeding' data = file_number, kid, feeding_duration, feeding_details sql.insert(conn, cursor, table, columns, data) data_list = [child_list, feeding_duration_list, feeding_details_list] data_return = join_lists(data_list, "; ") return (data_return)