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 other_test(file_number, user_name): data_list = [ 'data_to_be_entered', ] * 14 + [user_name, sql.last_update()] module_name = "other_test" data = clinical_tests() data_list = data + [user_name, sql.last_update()] return data_list
def other_test(self): data_list = [ 'data_to_be_entered', ] * 14 + [self.user_name, last_update()] module_name = "other_test" check = False while not check: print( 'In this module please enter data for tests done at the time of diagnosis before the start of ' 'treatment') data = clinical_tests() data_list = data + [self.user_name, last_update()] col_list = pccm_names.names_info(module_name) check = review_input(self.file_number, col_list, data_list) return data_list
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 surgery_block_information_3(self): module_name = self.module_list[3] review_surgery_date, review_surgery_source, review_surgery_diagnosis, review_surgery_diagnosis_comment, \ review_surgery_block_id, review_surgery_er, review_surgery_er_percent, review_surgery_pr, review_surgery_pr_percent, \ review_surgery_her2, review_surgery_her2_grade, review_surgery_fish, review_surgery_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 surgery block?') if review: review_surgery_date = ask.check_date('Date of review (if multiple dates?): ') review_surgery_source = input( 'Name of Review Laboratory (Enter multiple if required Lab_test): ') review_surgery_diagnosis = input('Enter diagnosis of review: ') review_surgery_diagnosis_comment = input('Additional comments for review diagnosis: ') review_surgery_block_id = self.surgery_block_id block_id = ask.ask_y_n('Has the block been relabelled in the review?') if block_id: old_block_id = input('Please enter old block id: ') new_block_id = input('Please enter new block id: ') review_surgery_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_surgery_er, review_surgery_er_percent, review_surgery_pr, review_surgery_pr_percent, \ review_surgery_her2, review_surgery_her2_grade, review_surgery_fish, review_surgery_ki67 = \ BlockDescription.ihc_report('review_surgery') data_list = [review_surgery_date, review_surgery_source, review_surgery_diagnosis, review_surgery_diagnosis_comment, review_surgery_block_id, review_surgery_er, review_surgery_er_percent, review_surgery_pr, review_surgery_pr_percent, review_surgery_her2, review_surgery_her2_grade, review_surgery_fish, review_surgery_ki67] col_list = names(module_name) check = sql.review_input(self.file_number, col_list[:-2], data_list) data = data_list + [self.user_name, sql.last_update()] return data
def mammo_mass(self, mass_id): data_list = ask.default_data_list(self.col_list) mass_location = self.mammo_breast if self.mammo_breast == "bilateral": mass_location = gf.get_choice(RadioTables.breast) mass_quadrant = gf.get_choice(Radio.lesion_quadrant) mammo_mass_shape = gf.get_choice(RadioTables.mass_shape) mammo_mass_margin = gf.get_choice(RadioTables.mass_margin) mass_nipple = gf.get_number(10) size_input = gf.get_choice(['3d', '2d']) x = gf.get_number_lt(1, 10) y = gf.get_number_lt(1, 10) z = gf.get_number_lt(1, 10) if size_input == '3d': mass_dimension = [str(x) + ' x ' + str(y) + ' x ' + str(z)] mass_longest_dimension = max([x, y, z]) elif size_input == '2d': mass_dimension = [str(x) + ' x ' + str(y)] mass_longest_dimension = max([x, y]) mass_size_unit = gf.get_choice(RadioTables.mass_units) mass_name = "lesion_" + str(mass_id) 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 ] 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 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 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)
def pet_breast_cancer(self): module_name = self.module_list[2] breast_report = [ 'NA', ] * 7 check = False while not check: pet_breast = ask.ask_y_n( 'Does this report describe a breast cancer?') if pet_breast: print('\nPlease describe primary breast lesion\n') pet_breast_lesion_size = input( 'Dimensions of breast lesion/s: ') pet_breast_lesion_size_unit = ask.ask_list( 'Unit of breast lesion size', ['mm', 'cm']) pet_breast_lesion_suv = ask.check_number_input( 'Please enter SUV max of breast lesion: ', 'Please enter only SUV not description') pet_breast_lesion_location = input( 'Please enter description of lesion location: ') pet_breast_lesion_type = input( 'Please input description of lesion: ') pet_breast_lesion_comments = input( 'Please input any additional notes for breast lesion: ') pet_breast_nodes = ask.ask_y_n( 'Does the report describe breast related nodes?') if pet_breast_nodes: pet_breast_nodes_description = input( 'Please enter nodes description as given: ') else: pet_breast_nodes_description = 'nodes_not_described' pet_breast_skin = ask.ask_y_n( 'Does the PET report describe any skin changes?') if pet_breast_skin: pet_breast_lesion_skin = input( 'Please enter description of skin changes: ') else: pet_breast_lesion_skin = 'skin_changes_not_described' else: pet_breast_lesion_size, pet_breast_lesion_size_unit, pet_breast_lesion_suv, pet_breast_lesion_location,\ pet_breast_lesion_type, pet_breast_lesion_comments, pet_breast_nodes_description, \ pet_breast_lesion_skin = ['no_breast_cancer', ] * 8 breast_report = [ pet_breast_lesion_size, pet_breast_lesion_size_unit, pet_breast_lesion_suv, pet_breast_lesion_location, pet_breast_lesion_type, pet_breast_lesion_comments, pet_breast_nodes_description, pet_breast_lesion_skin ] columns_list = names(module_name) check = sql.review_input(self.file_number, columns_list[:-2], breast_report) data_list = breast_report + [self.user_name, sql.last_update()] return data_list
def block_description_df(self, block_id_list, block_desc_df): for block in block_id_list: print("For Block ID " + self.block_id + ', Block reference: ' + block) block_type = ask.ask_list("Block type", self.block_type_list) block_desc = input("Block Description for block " + block + ": ") block_desc_df.loc[block] = [ self.pk, self.file_number, self.block_id, block, block_type, block_desc, self.user_name, sql.last_update() ] return block_desc_df
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 edit_table(df, pk_col, df_col, update_by): import sql.add_update_sql as sql rows = (df.shape)[0] for row in range(0, rows): print(df.iloc[row].to_string() + '\n') to_correct = ask_y_n("Are entries correct?") if not to_correct: print('To delete a single entry select No here and proceed') to_correct = 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(pk) to_do = True while to_do: print(df.loc[index, :]) print( "\nTo delete a single entry select 'file_number' column here and change file number by \n", "appending (_delete) eg., 123/13 file becomes 123/13_delete\n" ) col_change = 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 df.ix[index, 'update_by'] = update_by df.ix[index, 'last_update'] = sql.last_update() print(df.iloc[index].to_string() + '\n') to_do = ask_y_n("Make more changes to " + pk_col + ' ' + pk + '?') sql.print_df(df) change_row = ask_y_n("Change another row?") to_correct = False return to_correct, df
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 surgery_block_information_2(self): module_name = self.module_list[2] data_list = ['NA', ] * 18 check = False while not check: ihc_report = BlockDescription.ihc_report(ihc_type='Tumour_surgery_block') surgery_er, surgery_er_percent, surgery_pr, surgery_pr_percent, surgery_her2, surgery_her2_grade, \ surgery_fish, surgery_ki67 = ihc_report surgery_subtype = breast_cancer_subtype('surgery', surgery_er, surgery_pr, surgery_her2, surgery_her2_grade, surgery_fish) node_details = self.node_details() sentinel_node_number_removed, sentinel_node_number_positive, axillary_node_number_removed, \ axillary_node_number_positive, apical_node_number_removed, apical_node_number_positive = node_details surgery_perinodal_spread = ask.ask_list('Perinodal Spread', ask.create_yes_no_options ('Perinodal Spread', not_cancer='requires_follow_up')) pathological_pt = input('Pathological T Status (Enter T0/T1/T2 etc as given in report): ') pathological_pn = input('Pathological N Status (Enter N0/N1/N2 etc as given in report): ') metastasis = ask.ask_y_n('Did the patient have metastasis at diagnosis?') nat = sql.get_value(col_name='neoadjuvant_therapy', table=self.table_name, pk=self.fk, cursor=self.cursor, pk_name='fk', error_statement='what is the nact status?') if nat != 'nact_no': prefix = 'yp' else: prefix = 'p' pathological_stage, clinical_stage = BlockDescription.stage(pathological_pt, pathological_pn, metastasis, prefix) data_list = [surgery_er, surgery_er_percent, surgery_pr, surgery_pr_percent, surgery_her2, surgery_her2_grade, surgery_fish, surgery_ki67, surgery_subtype, sentinel_node_number_removed, sentinel_node_number_positive, axillary_node_number_removed, axillary_node_number_positive, apical_node_number_removed, apical_node_number_positive, surgery_perinodal_spread, pathological_pt, pathological_pn, str(metastasis).lower(), pathological_stage, clinical_stage, self.user_name, sql.last_update()] columns_list = names(module_name) check = sql.review_input(self.file_number, columns_list[:-2], data_list[:-2]) return data_list
def report(self): data_list = ask.default_data_list(self.col_list_all[1:]) check_mammo = gf.get_choice(MultiTest.test_reason) reason_report = check_mammo mammo = gf.get_bool() if mammo: tomo = gf.get_bool() if tomo: tomography_y_n = "Yes" else: tomography_y_n = "No" report_date = gf.gen_date('2019-03-13') mammo_place = gf.get_choice(["PCCM", "Outside"]) if mammo_place == "Outside": mammography_place = names.get_full_name() else: mammography_place = mammo_place mammography_indication = gf.get_choice(Radiology.mammo_indication) mammography_breast = gf.get_choice(MultiTest.breast_cancer) mammo_mass = gf.get_bool() mass_all = [] mass_data = ['no_mass_detected'] mass_all.append(mass_data) mammography_massnumber = "No mass detected" mammography_masslocation = "No mass detected" mammography_massshape = "No mass detected" mammography_massmargin = "No mass detected" mammography_massnipple_cm = "No mass detected" mammography_masssize = "No mass detected" mammography_masssize_unit = "No mass detected" mass_longest_dimension = 'na' if mammo_mass: mass_breast = gf.get_choice(MultiTest.breast_cancer) mass = radio_tables.MassCalcification(self.table, mass_breast, self.file_number, self.user_name) mammography_massnumber, mass_dat = mass.multiple_mass() [ mammography_masslocation, mass_name, mass_quadrant, mammography_massshape, mammography_massmargin, mammography_massnipple_cm, mammography_masssize, mass_longest_dimension, mammography_masssize_unit, modality ] = mass_dat[1:] mammography_calcificationnumber = "No Calcification detected" mammography_calcificationlocation = "No Calcification detected" mammography_calcificationtype = "No Calcification detected" mammography_calcification_comments = "No Calcification detected" calc = gf.get_bool() if calc: mammography_calcification = radio_tables.cal_table( self.file_number, mammography_breast) (mammography_calcificationnumber, mammography_calcificationlocation, mammography_calcificationtype, mammography_calcification_comments ) = mammography_calcification mammography_skin_involvement = gf.get_choice( Radiology.skin_involvement) mammography_node_description = 'nodes_not_described' mammography_node_size = 'nodes_not_described' mammography_node_size_unit = 'nodes_not_described' node_description = gf.get_bool() if node_description: mammography_node_description = gf.get_choice( Radiology.node_description) mammography_node_size = gf.get_number_lt(3, 10) mammography_node_size_unit = 'cm' mammo_birad = gf.get_bool() if mammo_birad: mammography_birad = radio_tables.birads() else: mammography_birad = "BI-RAD not assigned in report" mammography_impression = gf.get_choice(Radiology.impression) data_list = [ reason_report, report_date, mammography_place, mammography_indication, mammography_breast, mammography_massnumber, mammography_masslocation, mammography_massshape, mammography_massmargin, mammography_massnipple_cm, mammography_masssize[0], mammography_masssize_unit, mammography_calcificationnumber, mammography_calcificationlocation, mammography_calcificationtype, mammography_calcification_comments, mammography_skin_involvement, mammography_node_description, mammography_node_size, mammography_node_size_unit, mammography_birad, mammography_impression, tomography_y_n ] data_list = [str(dat) for dat in data_list] data_list = [self.file_number] + data_list + [ self.user_name, sql.last_update() ] return data_list
def mri_breast(conn, cursor, file_number, user_name): module_name = "mri_breast" check = False while not check: mri_breast = ask_y_n_statement.ask_y_n("Has MRI-Breast been done?") if mri_breast: mri_breast = "MRI-Breast done" mri_breast_date = input("Date of examination of MRI: ") mri_breast_acc = input( "Accession number of MRI (Include location): ") fgt_mri = ask_y_n_statement.ask_option( "Ammount of Fibroglandular Tissue", [ "a. Almost entirely fat", "b. Scattered fibroglandular tissue", "c. Heterogeneous fibroglandular tissue", "d. Extreme fibroglandular tissue", "Other" ]) bpe_level_mri = ask_y_n_statement.ask_option( "Background parenchymal enhancement Level", ["Minimal", "Mild", "Moderate", "Marked", "Other"]) bpe_symm_mri = ask_y_n_statement.ask_option( "Background parenchymal enhancement Symmetry", ["Symmetric", "Asymmetric", "Other"]) focus_mri = input("Details of Focus: ") mass_mri = ask_y_n_statement.ask_y_n("Are masses detected?") if mass_mri: mass_mri = "Mass Detected" table = "mri_multiple_mass" mri_mass_number, mass_location, mass_quad, mass_shape, mass_margin, mass_internal = \ radio_tables_old.multiple_mass(table, conn, cursor, file_number) else: mass_mri = "No Mass Detected" mri_mass_number, mass_location, mass_quad, mass_shape, mass_margin, mass_internal = ( "NA", ) * 6 asso_feat = [ "Nipple Retraction", "Nipple Invasion", "Skin Retraction", "Skin Thickening", "Axillary adenopathy", "Pectoralis muscle invasion", "Chest wall invasion", "Architectural Distortion" ] asso_feat_data = [] for index in (asso_feat): print("Associated feature: " + index) print("Detailed description can be added by choosing 'Other'") var = ask_y_n_statement.ask_option(index, [ "Right Breast", "Left Breast", "Both", "Not Present", "Other" ]) asso_feat_data.append(var) asso_feat_9 = ask_y_n_statement.ask_option( "Associated Feature: Skin Invasion", ["Direct invasion", "Inflammatory cancer", "Other"]) asso_feat_1, asso_feat_2, asso_feat_3, asso_feat_4, asso_feat_5, asso_feat_6, asso_feat_7, \ asso_feat_8 = asso_feat_data fat_lesions = ask_y_n_statement.ask_option( "Fat Containing Lesions", [ "Lymph nodes: Normal", "Lymph nodes: Abnormal", "Fat necrosis", "Hamartoma", "Postoperative seroma", "hematoma with fat" ]) mri_breast_kinetics_initial = ask_y_n_statement.ask_option( "Kinetic curve assessment Signal intensity " "(SI)/time curve description (Initial Phase)", ["Slow", "Medium", "Fast", "Other"]) mri_breast_kinetics_delayed = ask_y_n_statement.ask_option( "Kinetic curve assessment Signal intensity " "(SI)/time curve description (Delayed Phase)", ["Persistent", "Plateau", "Washout", "Other"]) mri_breast_non_enhance = ask_y_n_statement.ask_option( "Non-enhancing findings", [ "Ductal precontrast high signal on T1W", "Cyst", "Postoperative collections (hematoma/seroma)", "Post-therapy skin thickening and trabecular " "thickening", "Signal void from foreign bodies, " "clips, etc.", "Other" ]) mri_breast_implant = input("Implant related findings: ") mri_breast_lesion = ask_y_n_statement.ask_option( "Location of lesion", ["Right Breast", "Left Breast", "Both", "Not present"]) if mri_breast_lesion in {"Right Breast", "Left Breast", "Both"}: mri_breast_lesion_location = radio_tables_old.lesion_location( mri_breast_lesion) mri_breast_lesion_depth = input("Lesion depth: ") else: mri_breast_lesion_location, mri_breast_lesion_depth = ( "NA", ) * 2 mri_breast_size = ask_y_n_statement.ask_option( "Size of lesion", ["<2 cm", "2-5 cm", ">5 cm", "Other"]) mri_breast_dist = ask_y_n_statement.ask_option( "Distance from Skin (cm)", ["<0.5 cm", ">0.5 cm", "Other"]) mri_breast_pect = input("Distance from Pectoralis Major (cm): ") mri_breast_birad = ask_y_n_statement.ask_y_n( "Does the report include a BI-RAD assessment/Diagnosis?") if mri_breast_birad: mri_breast_birad, mri_breast_birad_diag = radio_tables_old.birads( ) else: mri_breast_birad, mri_breast_birad_diag = ("NA", ) * 2 else: mri_breast = "MRI-Breast not done" mri_breast_date, mri_breast_acc, fgt_mri, bpe_level_mri, bpe_symm_mri, focus_mri, mass_mri, mri_mass_number, \ mass_location, mass_quad, mass_shape, mass_margin, mass_internal, asso_feat_1, asso_feat_2, asso_feat_3, \ asso_feat_4, asso_feat_5, asso_feat_6, asso_feat_7, asso_feat_8, asso_feat_9, fat_lesions, \ mri_breast_lesion, mri_breast_lesion_location, mri_breast_lesion_depth, mri_breast_kinetics_initial, \ mri_breast_kinetics_delayed, mri_breast_non_enhance, mri_breast_implant, mri_breast_size, mri_breast_dist, \ mri_breast_pect, mri_breast_birad, mri_breast_birad_diag = ("NA",) * 35 data_list = [ mri_breast, mri_breast_date, mri_breast_acc, fgt_mri, bpe_level_mri, bpe_symm_mri, focus_mri, mass_mri, mri_mass_number, mass_location, mass_quad, mass_shape, mass_margin, mass_internal, asso_feat_1, asso_feat_2, asso_feat_3, asso_feat_4, asso_feat_5, asso_feat_6, asso_feat_7, asso_feat_8, asso_feat_9, fat_lesions, mri_breast_kinetics_initial, mri_breast_kinetics_delayed, mri_breast_non_enhance, mri_breast_implant, mri_breast_lesion, mri_breast_lesion_location, mri_breast_lesion_depth, mri_breast_size, mri_breast_dist, mri_breast_pect, mri_breast_birad, mri_breast_birad_diag, user_name, add_update_sql.last_update() ] columns_list = names(module_name) check = add_update_sql.review_input(file_number, columns_list, data_list) return (tuple(data_list))
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
def post_surgery(file_number, user_name): check = False while not check: check_drain = ask_y_n('Was drain inserted post surgery?') drain, total_drain = ('No drain used', )*2 if check_drain: drain = input("Drain removal date: ") total_drain = input("Total drain days: ") post_comp = ask_y_n("Did post-surgery complications occur?") if post_comp: df_complications_col = ["Day", "Complication", "Treatment"] df_complications = pd.DataFrame(columns = df_complications_col) day_add = True index = 0 while day_add: comp =surgery_tables.surg_complications("post_surgery_comp") day = "Day "+input("Days post surgery: ") treatment_list = [] complication = [] for i in comp: data = ask_y_n("On "+str(day)+ " did post surgery complication "+i+" occur?") if data: complication.append(i) treatment = ask_option("What treatment was done for "+str(i), surgery_tables.surg_complications("surgical_treatment")) if treatment == 'Non surgical treatment': treatment = input ("What type of non surgical treatment was used?") else: treatment = "Surgical treatment - "+ treatment treatment_list.append(treatment) complication= "; ".join(complication) treatment_list = "; ".join(treatment_list) data = [day, complication, treatment_list] df_complications.loc[index] = data index = index + 1 day_add = ask_y_n("Add another day for post surgery complications? ") all_data = [] for index in df_complications_col: data = "; ".join(list(df_complications.loc[:, index])) all_data.append(data) days, complications, treatments = all_data else: days, complications, treatments = ("No post surgical complications", )*3 chemo = ask_option_y_n("Is chemotherapy planned?", "Chemotherapy planned", "No Chemotherapy") radio = ask_option_y_n("Is radiotherapy planned?", "RadiotherapyOptions planned", "No RadiotherapyOptions") other = ask_option_y_n("Are there any other post-surgery plans") if other == 'Yes': other = input("Please specify other post-surgery plans: ") elif other == 'No': other = "No other post surgery plans" recur = ask_option_y_n("Did recurrence occur post surgery?") if recur == 'Yes': recurs = [] days_recurs = [] late_add = True recur = surgery_tables.surg_complications("recurrence_sites") while late_add: day = "Day " + input("Days post surgery: ") for i in recur: data = ask_y_n("On " + str(day) + " did " + i + " recurrence occur?") if data: recurs.append(i) if recurs == []: recurs = "No recurrence post surgery" days_recurs.append(day) late_add = ask_y_n("Add another day for post surgery recurrence? ") all_data = [days_recurs, recurs] days_recurs, recurs = join_lists(all_data, "; ") elif recur == 'No': days_recurs, recurs = ("No recurrence post surgery",) * 2 else: days_recurs, recurs = (recur,) * 2 opd = input("Please input OPD notes (if any): ") data_list = [chemo, radio, other,drain, total_drain, days, complications, treatments, days_recurs, recurs, opd, user_name, add_update_sql.last_update()] col_list = names("post_surgery") check = add_update_sql.review_input(file_number, col_list, data_list) return data_list
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 chemotherapy(file_number, user_name): col_drug = names("chemo_drug_table") drug_table = pd.DataFrame(columns=col_drug) col_tox = names('chemo_tox_table') toxicity = pd.DataFrame(columns=col_tox) data_list = [ 'data_to_be_entered', ] * 27 + [user_name, sql.last_update()] check = False while not check: chemo = ask.ask_y_n_na( "Has adjuvant chemotherapy been done for the patient?") if chemo == 'Yes': place_chemo = ask.ask_y_n_na( "Has Adjuvant Chemotherapy been done at PCCM?", "At PCCM", "Outside", "Not Certain, requires follow-up") details_chemo = ask.ask_y_n( "Are Adjuvant Chemotherapy details available?", "Details Available", "Follow-up required") chemo = "act_given" if details_chemo == "Follow-up required": plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, tox_type, tox_grade, \ tox_treat, tox_response, tox_cycle, change_tox,chemo_response_by, chemo_response, chemo_size, \ chemo_size_date, trast_chemo, trast_regime, trast_courses,date_complete, reason_incomplete, \ hormone_therapy, therapy_type, therapy_duration, therapy_side, ovary_status, patient_wt, drug_freq\ = (details_chemo,)*28 elif details_chemo == "Details Available": plan_chemo = input( "What is the plan of Adjuvant Chemotherapy (for eg., " "4 cycles AC followed by 12 cycles Paclitaxel):") date_start_chemo = ask.check_date( "Date of starting Adjuvant Chemotherapy: ") patient_wt = ask.check_number_input( "Weight of patient at start of therapy (in kgs): ", 'Weight must ' 'be a number') check_wt = ask.ask_y_n( "Is weight at any other time point mentioned in report?") while check_wt: other_wt = input("Time point at which weight mentioned: ") other_wt = other_wt + " " + input("Weight of patient at " + other_wt + ": ") patient_wt = patient_wt + "; " + other_wt check_wt = ask.ask_y_n( "Is weight at any other time point mentioned in report " "(with date, if given)?") drug_table = drug_table_enter(file_number, drug_table) data_drug = col_drug[1:] data_drug_list = [] for index in data_drug: data_drug = "; ".join(list(drug_table.loc[:, index])) data_drug_list.append(data_drug) drug_cyc, cyc_number, drug_freq, drug_doses, drug_units = data_drug_list toxicity = tox_table(file_number, drug_cyc, toxicity) columns = col_tox tox_details = [] for column in columns: tox_detail = toxicity.loc[:, column].drop_duplicates() tox_details.append(list(tox_detail)) tox_details = ask.join_lists(tox_details, "; ") file_number_tox, drug_tox, tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox \ = tox_details trast_chemo = ask.ask_y_n("Trastuzumab used?") if trast_chemo: trast_regime = ask.ask_option("Trastuzumab use was", ["Sequential", "Concurrent"]) trast_chemo = "Trastuzumab used" trast_courses = ask.check_number_input( "Number of courses of trastuzumab/herceptin taken: ", 'Enter number only') else: trast_chemo, trast_regime, trast_courses, therapy_side = ( "Trastuzumab not used", ) * 4 date_complete = ask.check_date( "Date of completion of Adjuvant Chemotherapy: ") complete_chemo = ask.ask_y_n( "Was Adjuvant Chemotherapy completed as per schedule?") if complete_chemo: reason_incomplete = "Adjuvant Chemotherapy completed as per schedule" else: reason_incomplete = ask.ask_option( "Reason for discontinuation", [ "Toxicity", "Reluctance of patient", "Progression on chemotherapy", "Advised by treating doctor", "Death due to toxicity", "Death due to progressive disease", "Preferred treatment at another centre", "Death due to unrelated cause", "Patient was unable to afford treatment" ]) reason_incomplete = "Adjuvant Chemotherapy incomplete: " + reason_incomplete menopause = ask.ask_option("Menopausal Status", [ "Pre-menopausal", "Peri-menopausal", "Post-Menopausal", "Other" ]) if menopause in {"Pre-menopausal", "Peri-menopausal"}: ovary_status = ask.ask_option( "Status of ovarian function after Chemotherapy", [ "Menses ongoing", "Amenorrhoea on Chemo", "Amenorrhoea post Chemotherapy" ]) else: ovary_status = menopause #hormone_therapy, therapy_type, therapy_duration, therapy_side = hormone_therapy_chemo() hormone_therapy, therapy_type, therapy_duration, therapy_side = ( 'NA', ) * 4 else: plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, drug_freq,tox_type, \ tox_grade, tox_treat, tox_response, tox_cycle, change_tox,chemo_response_by, chemo_response, \ chemo_size, chemo_size_date, trast_chemo, trast_regime, trast_courses, hormone_therapy, therapy_type, \ therapy_duration, therapy_side, date_complete, reason_incomplete,ovary_status, patient_wt \ = (details_chemo,)*28 elif chemo == 'No': place_chemo, plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, \ drug_freq,tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox, chemo_response_by, \ chemo_response, chemo_size, chemo_size_date, trast_chemo, trast_regime, trast_courses, hormone_therapy, \ therapy_type, therapy_duration, therapy_side, date_complete, reason_incomplete, details_chemo, chemo, \ ovary_status, patient_wt = ("Adjuvant Chemotherapy not given",)*31 else: place_chemo, plan_chemo, date_start_chemo, cyc_number, drug_cyc, drug_doses, drug_units, drug_freq, \ tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox, chemo_response_by, chemo_response, \ chemo_size, chemo_size_date, trast_chemo, trast_regime, trast_courses, hormone_therapy, therapy_type, \ therapy_duration,ovary_status, therapy_side, date_complete, reason_incomplete, details_chemo, patient_wt \ = (chemo,)*30 data_list = [ chemo, place_chemo, details_chemo, plan_chemo, date_start_chemo, patient_wt, drug_cyc, cyc_number, drug_freq, drug_doses, drug_units, tox_type, tox_grade, tox_treat, tox_response, tox_cycle, change_tox, reason_incomplete, date_complete, trast_chemo, trast_regime, trast_courses, ovary_status, hormone_therapy, therapy_type, therapy_duration, therapy_side, user_name, sql.last_update() ] col_list = names("adjuvant_chemotherapy") check = sql.review_input(file_number, col_list, data_list) return data_list, drug_table, toxicity
def report(self): data_list = ask.default_data_list(self.col_list_all) check_mammo = ask.ask_option("What is the purpose of this report?", MultiTest.test_reason_imaging) reason_report = check_mammo check = False while not check: mammo = ask.ask_y_n("Are mammography results available for this " "patient?") if mammo: tomo = ask.ask_y_n("Have 3D Tomography images also been " "acquired?") if tomo: tomography_y_n = "Yes" print("Please include 3d-Tomo observations in Mammography " "results") else: tomography_y_n = "No" report_date = ask.check_date("Date of mammography: ") mammo_place = ask.ask_y_n("Was exam peformed at PCCM?", yes_ans="PCCM", no_ans="Outside") if mammo_place == "Outside": mammography_place = input("Please input Radiologist name " "and place (Name; Place): ") else: mammography_place = mammo_place mammography_indication = input("Indication for mammography: ") mammography_breast = ask.ask_option("Details described for", MultiTest.breast_cancer) # masscalc = radio_tables.MassCalcification(self.table, # mass_breast, # self.file_number, # self.user_name) mammo_mass = ask.ask_y_n("Is there any mass/lesion detected? ") mass_all = [] mass_data = ['no_mass_detected'] mass_all.append(mass_data) [ mammography_massnumber, mammography_masslocation, mammography_massshape, mammography_massmargin, mammography_massnipple_cm, mammography_masssize, mammography_masssize_unit ] = ("No mass detected", ) * 7 if mammo_mass: mass_breast = ask.ask_option( 'What is the location of the' ' lesions?', MultiTest.breast_cancer) masscalc = radio_tables.MassCalcification( self.table, mass_breast, self.file_number, self.user_name) # mass_data = mass.multiple_mass() mass_data = masscalc.multiple_mass() mammography_massnumber, mammography_masslocation, mammography_massshape, mammography_massmargin, mammography_massnipple_cm, mammography_masssize, mammography_masssize_unit = mass_data[:-2] mammography_calcificationnumber, mammography_calcificationlocation, mammography_calcificationtype, mammography_calcification_comments = ("No Calcification" " detected", ) * 4 calc = ask.ask_y_n("Is Calcification present?") if calc: mammography_calcificationnumber, mammography_calcificationlocation, mammography_calcificationtype, mammography_calcification_comments = radio_tables.cal_table( self.file_number, mammography_breast) mammography_skin_involvement = input("Please input description" " of skin involvement if " "present: ") mammography_node_description, mammography_node_size, mammography_node_size_unit = ('nodes_not_described', ) * 3 node_description = ask.ask_y_n('Does the report include ' 'description of nodes?') if node_description: mammography_node_description = input('Please enter ' 'description of nodes' ': )') mammography_node_size, longest_dimension = ask.check_size_input() mammography_node_size_unit = 'NA' if mammography_node_size != 'NA': mammography_node_size_unit = ask.ask_list( 'Unit of node size: ', MultiTest.size_unit) mammo_birad = ask.ask_y_n('Does the report include a BI-RAD' 'assessment/diagnosis?') if mammo_birad: mammography_birad = radio_tables.birads() else: mammography_birad = "BI-RAD not assigned in report" mammography_impression = input('Input Impression(if available' '): "') data_list = [ reason_report, report_date, mammography_place, mammography_indication, mammography_breast, mammography_massnumber, mammography_masslocation, mammography_massshape, mammography_massmargin, mammography_massnipple_cm, mammography_masssize, mammography_masssize_unit, mammography_calcificationnumber, mammography_calcificationlocation, mammography_calcificationtype, mammography_calcification_comments, mammography_skin_involvement, mammography_node_description, mammography_node_size, mammography_node_size_unit, mammography_birad, mammography_impression, tomography_y_n, self.user_name, sql.last_update ] data_list = [self.file_number] + data_list else: data_list = [self.file_number] + data_list 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 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 breast_symptoms(file_number, user_name): module_name = "breast_symptoms" check = False while not check: note = "Pain or tenderness; Lumps, Nipple Discharge - Milky/water discharge on pressing nippple, " \ "Nipple Retraction - nipple reagion goes inside, Dimpling small pits anwywhere on breast, " \ "Discolouration - may occur after surgery, Ulceration (small boils on surface), " \ "Eczema - Reddish spots with without itching" wrapper = textwrap.TextWrapper(width=100) string = wrapper.fill(text=note) print(string) symp_state = ["Pain or tenderness", "Lumps", "Nipple Discharge", "Nipple Retraction", "Dimpling", \ "Discolouration", "Ulceration", "Eczema"] rb_symp_list = [] rb_dur_list = [] lb_symp_list = [] lb_dur_list = [] for index in symp_state: symp = ask_y_n("Is " + index + " present") if symp: RB = ask_y_n(index + " in Right Breast?") if RB: rb_symp = index rb_dur = input("Duration of " + index + ": ") rb_symp_list.append(rb_symp) rb_dur_list.append(rb_dur) LB = ask_y_n(index + " in Left Breast?") if LB: lb_symp = index lb_dur = input("Duration of " + index + ": ") lb_symp_list.append(lb_symp) lb_dur_list.append(lb_dur) rb_symps = "; ".join(rb_symp_list) rb_duration = "; ".join(rb_dur_list) lb_symps = "; ".join(lb_symp_list) lb_duration = "; ".join(lb_dur_list) data_list_symp = [rb_symps, rb_duration, lb_symps, lb_duration] for index in range(0, len(data_list_symp)): if data_list_symp[index] == '': data_list_symp[index] = "NA" rb_symp_list = [] rb_dur_list = [] lb_symp_list = [] lb_dur_list = [] other_symptom = ask_y_n("Other Symptoms?") if other_symptom: check = True while check: type = input("Other Symptoms type? ") RB = ask_y_n(type + " in Right Breast?") if RB: rb_symp = type rb_dur = input("Duration of " + type) rb_symp_list.append(rb_symp) rb_dur_list.append(rb_dur) LB = ask_y_n(type + " in Left Breast?") if LB: lb_symp = type lb_dur = input("Duration of " + type) lb_symp_list.append(lb_symp) lb_dur_list.append(lb_dur) check = ask_y_n("Additional Symptoms?") rb_symps_other = "; ".join(rb_symp_list) rb_duration_other = "; ".join(rb_dur_list) lb_symps_other = "; ".join(lb_symp_list) lb_duration_other = "; ".join(lb_dur_list) data_list_other = [ rb_symps_other, rb_duration_other, lb_symps_other, lb_duration_other ] for index in range(0, len(data_list_other)): if data_list_other[index] == '': data_list_other[index] = "NA" met = [] met_bone = ask_y_n("Is Bone Pain present?") if met_bone: met.append(["Bone Pain"]) met_cough = ask_y_n("Is Cough present") if met_cough: met.append(["Cough"]) met_jaundice = ask_y_n("Is Jaundice present") if met_jaundice: met.append(["Jaundice"]) met_headache = ask_y_n("Is Headache present") if met_headache: met.append(["Headache"]) met_weight = ask_y_n("Has Weight loss occurred") if met_weight: met.append(["WeightLoss"]) met_flat = [item for sublist in met for item in sublist] data_met = "; ".join(met_flat) if met_flat == []: data_met = "No Metastatis Symptoms" columns_list = pccm_names.names_info(module_name) data_list = data_list_symp + data_list_other + [ data_met, user_name, last_update() ] check = review_input(file_number, columns_list, data_list) return (tuple(data_list))
def clinical_exam_initial(file_number, user_name): module_name = "clinical_exam_initial" check = False while not check: # con_stat = ask.ask_y_n("Has consent been taken from patient?", "Consent Taken", "No Consent") # if con_stat == "Consent Taken": # con_form = ask.ask_y_n("Is consent form with signature present in file ?", # "Consent form with signature present in folder", # "Completed consent form not present in folder") # else: # con_form = "NA" prov_diag = input("Provisional Diagnosis: ") options = ["Definite", "Vague", "Diffuse", "Nil", "Other"] lump_palp = ask.ask_option("Palpable lump in the breast?", options) lump_location = ask.ask_option( "Location of lump", ["Right Breast", "Left Breast", "Both", "Not present"]) lump_location_data = [] if lump_location == "Right Breast" or lump_location == "Both": category = "Lump location on Right Breast" options = ["UOQ", "UIQ", "C", "UCQ", "LCQ", "LOQ", "LIQ"] lump_location_rb = ask.ask_option(category, options) lump_location_rb_data = "RB-" + lump_location_rb lump_location_data.append(lump_location_rb_data) if lump_location == "Left Breast" or lump_location == "Both": category = "Lump location on Left Breast" options = ["UOQ", "UIQ", "C", "UCQ", "LCQ", "LOQ", "LIQ"] lump_location_lb = ask.ask_option(category, options) lump_location_lb_data = "LB-" + lump_location_lb lump_location_data.append(lump_location_lb_data) lump_location_data = "; ".join(lump_location_data) if lump_location == "Not present": lump_location_data = "Lump " + lump_location lump_size, lump_number, lump_consistency, lump_fixity = ( "NA", ) * 4 else: lump_size = ask.ask_option("Lump size", ["< 2cm", "2-5 cm", ">5 cm"]) lump_number = ask.ask_option("Number of lumps", ["Single", "Multiple", "Other"]) lump_consistency = ask.ask_option( "Consistency of lumps", ["Soft", "Firm", "Hard", "Cystic", "Mobile", "Other"]) lump_fixity = ask.ask_option("Lump fixity to ", [ "Skin", "Chest wall", "Pectoral major muscle", "No Fixation", "Other" ]) mastitis_location = ask.ask_option( "Location of mastitis", ["Right Breast", "Left Breast", "Both", "Not present"]) mastitis_location_data = [] if mastitis_location == "Right Breast" or mastitis_location == "Both": category = "Mastitis location on Right Breast" options = ["UOQ", "UIQ", "C", "UCQ", "LCQ", "LOQ", "LIQ"] mastitis_location_rb = ask.ask_option(category, options) mastitis_location_rb_data = "RB-" + mastitis_location_rb mastitis_location_data.append(mastitis_location_rb_data) if mastitis_location == "Left Breast" or mastitis_location == "Both": category = "Mastitis location on Left Breast" options = ["UOQ", "UIQ", "C", "UCQ", "LCQ", "LOQ", "LIQ"] mastitis_location_lb = ask.ask_option(category, options) mastitis_location_lb_data = "LB-" + mastitis_location_lb mastitis_location_data.append(mastitis_location_lb_data) mastitis_location_data = "; ".join(mastitis_location_data) if mastitis_location == "Not present": mastitis_location_data = "mastitis " + mastitis_location mastitis_type = "NA" else: mastitis_type = ask.ask_option("Mastitis type", ["Diffuse", "Sectoral", "Other"]) tender = ask.ask_option( "Tenderness in breast ?", ["Right Breast", "Left Breast", "Both", "Not Present", "Other"]) retract = ask.ask_option( "Nipple Retraction ?", ["Right Breast", "Left Breast", "Both", "Not Present", "Other"]) discharge = ask.ask_option( "Nipple Discharge ?", ["Right Breast", "Left Breast", "Both", "Not Present", "Other"]) if discharge == "Not Present": discharge_type = "NA" else: discharge_type = ask.ask_option( "Discharge Type?", ["Serous", "Milky", "Brown", "Bloody", "Other"]) skin_change_location = ask.ask_option( "Skin Changes?", ["Right Breast", "Left Breast", "Both", "Not Present", "Other"]) if skin_change_location == "Not Present": skin_change_type = "NA" else: skin_change = [] change_add = True while change_add: skin_change_type = ask.ask_option("Type of skin change?", [ "Dimpling", "Ulceration", "Discolouration", "Eczema", "Edema", "Redness", "Peau d'orange", "Other" ]) skin_change.append(skin_change_type) change_add = ask.ask_y_n("Enter another type of skin change?") skin_change_type = "; ".join(skin_change) ax_nodes = ask.ask_option( "Palpable axillary nodes", ["Right Breast", "Left Breast", "Both", "Not palpable", "Other"]) if ax_nodes == "Not palpable": ax_nodes_number, ax_nodes_size, ax_nodes_fixity = ("NA", ) * 3 else: ax_nodes_number = input("Number of nodes: ") ax_nodes_size = input("Size of nodes: ") ax_nodes_fixity = ask.ask_y_n("Fixity of axillary nodes", "Yes", "No") supra_nodes = ask.ask_option( "Palpable supraclavicular nodes", ["Right Breast", "Left Breast", "Both", "Not palpable", "Other"]) if supra_nodes == "Not palpable": supra_nodes_number, supra_nodes_size, supra_nodes_fixity = ( "NA", ) * 3 else: supra_nodes_number = input("Number of nodes: ") supra_nodes_size = input("Size of nodes: ") supra_nodes_fixity = ask.ask_y_n("Fixity of supraclavicular nodes", "Yes", "No") contra_breast = ask.ask_option( "Contralateral Breast", ["Normal", "Diffuse Mastitis", "Localised Mastitis", "Other"]) arm_edema = ask.ask_option( "Edema of arm", ["Right", "Left", "Both", "Not Present", "Other"]) arm_circ_right = input("Circumference of right arm (cm): ") arm_volume_right = input("Upper limb volume - right arm (cc): ") arm_elbow_right = input("Distance from the elbow - right arm (cm): ") arm_circ_left = input("Circumference of left arm (cm): ") arm_volume_left = input("Upper limb volume - left arm (cc): ") arm_elbow_left = input("Distance from the elbow - left arm (cml): ") follow_up_advised = input("Follow up tests advised for patient: ") data_list = [ prov_diag, lump_palp, lump_location_data, lump_size, lump_number, lump_consistency, lump_fixity, mastitis_location_data, mastitis_type, tender, retract, discharge, discharge_type, skin_change_location, skin_change_type, ax_nodes, ax_nodes_number, ax_nodes_size, ax_nodes_fixity, supra_nodes, supra_nodes_number, supra_nodes_size, supra_nodes_fixity, contra_breast, arm_edema, arm_circ_right, arm_volume_right, arm_elbow_right, arm_circ_left, arm_volume_left, arm_elbow_left, follow_up_advised, user_name, add_update_sql.last_update() ] 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 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)
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: ") mri_place = ask.ask_y_n("Was exam peformed at PCCM?", yes_ans="PCCM", no_ans="Outside") mri_breast_acc = input("Accession number of MRI: ") mri_breast_described = ask.ask_option("Details described for", MultiTest.breast_cancer) fgt_mri = ask.ask_option("Ammount of Fibroglandular Tissue", [ "a. Almost entirely fat", "b. Scattered fibroglandular tissue", "d. Extreme fibroglandular tissue", "Other" ]) bpe_level_mri = ask.ask_option( "Background parenchymal enhancement Level", ["Minimal", "Mild", "Moderate", "Marked", "Other"]) bpe_symm_mri = ask.ask_option( "Background parenchymal enhancement Symmetry", ["Symmetric", "Asymmetric", "Other"]) focus_mri = input("Details of Focus: ") mass_mri = ask.ask_y_n("Are masses detected?") if mass_mri: mass_mri = "Mass Detected" table = "mri_mass" mri_mass_number, mass_location, mass_shape, mass_margin, mass_internal = \ radio_tables.multiple_mass(table, mri_breast_described) else: mass_mri = "No Mass Detected" mri_mass_number, mass_location, mass_quad, mass_shape, mass_margin, mass_internal = ( "NA", ) * 6 asso_feat = [ "Nipple Retraction", "Nipple Invasion", "Skin Retraction", "Skin Thickening", "Axillary adenopathy", "Pectoralis muscle invasion", "Chest wall invasion", "Architectural Distortion" ] asso_feat_data = [] for index in (asso_feat): print("Associated feature: " + index) print("Detailed description can be added by choosing 'Other'") var = ask.ask_option(index, MultiTest.breast_cancer) asso_feat_data.append(var) asso_feat_9 = ask.ask_option( "Associated Feature: Skin Invasion", ["Direct invasion", "Inflammatory cancer", "Other"]) asso_feat_1, asso_feat_2, asso_feat_3, asso_feat_4, asso_feat_5, asso_feat_6, asso_feat_7, \ asso_feat_8 = asso_feat_data fat_lesions = ask.ask_option("Fat Containing Lesions", [ "Lymph nodes: Normal", "Lymph nodes: Abnormal", "Fat necrosis", "Hamartoma", "Postoperative seroma", "hematoma with fat" ]) mri_breast_kinetics_initial = ask.ask_option( "Kinetic curve assessment Signal intensity " "(SI)/time curve description (Initial Phase)", ["Slow", "Medium", "Fast", "Other"]) mri_breast_kinetics_delayed = ask.ask_option( "Kinetic curve assessment Signal intensity " "(SI)/time curve description (Delayed Phase)", ["Persistent", "Plateau", "Washout", "Other"]) mri_breast_non_enhance = ask.ask_option("Non-enhancing findings", [ "Ductal precontrast high signal on T1W", "Cyst", "Postoperative collections (hematoma/seroma)", "Post-therapy skin thickening and trabecular " "thickening", "Signal void from foreign bodies, " "clips, etc.", "Other" ]) mri_breast_implant = input("Implant related findings: ") mri_breast_lesion = ask.ask_option("Location of lesion", MultiTest.breast_cancer) if mri_breast_lesion in {MultiTest.breast_cancer}: mri_breast_lesion_location = radio_tables.lesion_location( mri_breast_lesion) mri_breast_lesion_depth = input("Lesion depth: ") else: mri_breast_lesion_location, mri_breast_lesion_depth = ( "NA", ) * 2 mri_breast_size = ask.ask_option( "Size of lesion", ["<2 cm", "2-5 cm", ">5 cm", "Other"]) mri_breast_dist = ask.ask_option("Distance from Skin (cm)", ["<0.5 cm", ">0.5 cm", "Other"]) mri_breast_pect = input("Distance from Pectoralis Major (cm): ") mri_breast_birad = ask.ask_y_n( "Does the report include a BI-RAD assessment/Diagnosis?") if mri_breast_birad: mri_breast_birad = radio_tables.birads() else: mri_breast_birad = "No BI-RAD Category given in report" data_list = [ self.file_number, reason_report, report_date, mri_place, mri_breast_acc, mri_breast_described, fgt_mri, bpe_level_mri, bpe_symm_mri, focus_mri, mass_mri, mri_mass_number, mass_location, mass_shape, mass_margin, mass_internal, asso_feat_1, asso_feat_2, asso_feat_3, asso_feat_4, asso_feat_5, asso_feat_6, asso_feat_7, asso_feat_8, asso_feat_9, fat_lesions, mri_breast_kinetics_initial, mri_breast_kinetics_delayed, mri_breast_non_enhance, mri_breast_implant, mri_breast_lesion, mri_breast_lesion_location, mri_breast_lesion_depth, mri_breast_size, mri_breast_dist, mri_breast_pect, mri_breast_birad ] 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 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 nact_test(self): col_drug = names("nact_drug_table") drug_table = pd.DataFrame(columns=col_drug) col_tox = names('nact_tox_table') toxicity = pd.DataFrame(columns=col_tox) nact_status, place_nact, details_nact, plan_nact, date_start_nact, patient_weight_nact, nact_drugs_administered, number_cycles_nact, cycle_weekly_frequency, drugs_totaldose, drugs_unit, toxicity_type, toxicity_grade, toxicity_treatment, toxicity_response, nact_change_due_to_toxicity, tumour_response_check_method, tumour_response_nact, tumour_size, tumour_size_unit, date_tumour_size_checked, nact_response_impression, nact_response_node, nact_completion_status, nact_end_date, trastuzumab_use_nact, trastuzumab_regime_nact, trastuzumab_courses_taken_nact, hormone_therapy_nact, hormone_therapy_type_nact, hormone_therapy_duration, horomone_therapy_side_effects = [ 'NA', ] * 33 data_list = [ 'NA', ] * 30 + [self.user_name, sql.last_update()] check = False while not check: nact_status = ask.ask_y_n_na( "Has neo adjuvant therapy been done for the patient (Please check for chemotherapy and/hormone therapy)?" ) if nact_status == 'Yes': place_nact = ask.ask_y_n_na( "Has neo adjuvant therapy been done at PCCM?", "At PCCM", "Outside", "Not Certain, requires follow-up") details_nact = ask.ask_y_n( "Are neo adjuvant therapy details available?", "Details Available", "Follow-up required") if details_nact == "Follow-up required": plan_nact, date_start_nact, patient_weight_nact, nact_drugs_administered, number_cycles_nact, cycle_weekly_frequency, drugs_totaldose, drugs_unit, toxicity_type, toxicity_grade, toxicity_treatment, toxicity_response, toxicity_at_cycle, nact_change_due_to_toxicity, tumour_response_check_method, tumour_response_nact, tumour_size, tumour_size_unit, date_tumour_size_checked, nact_response_impression, nact_response_node, nact_completion_status, nact_end_date, trastuzumab_use_nact, trastuzumab_regime_nact, trastuzumab_courses_taken_nact, hormone_therapy_nact, hormone_therapy_type_nact, hormone_therapy_duration, dhoromone_therapy_side_effects = ( details_nact, ) * 30 elif details_nact == "Details Available": plan_nact = input( "What is the plan of NACT (for eg., 4 cycles AC followed by 12 cycles Paclitaxel; " "Include hormone therapy plan here):") date_start_nact = ask.check_date( "Date of starting neo-adjuvant therapy: ") patient_weight_nact = input( "Weight of patient at start of therapy (in kgs): ") check_wt = ask.ask_y_n( "Is weight at any other time point mentioned in report " "(with date, if given)?") while check_wt: other_wt = input( "Time point at which weight mentioned: ") other_wt = other_wt + " " + \ input("Weight of patient at " + other_wt + ": ") patient_weight_nact = patient_weight_nact + "; " + other_wt check_wt = ask.ask_y_n( "Is weight at any other time point mentioned in report " "(with date, if given)?") drug_admin = drug_table_enter(file_number, drug_table) data_drug = col_drug[1:] data_drug_list = [] for index in data_drug: data_drug = "; ".join(list(drug_admin.loc[:, index])) data_drug_list.append(data_drug) nact_drugs_administered, number_cycles_nact, cycle_weekly_frequency, drugs_totaldose, drugs_unit\ = data_drug_list toxicity = tox_table(file_number, nact_drugs_administered, toxicity) columns = col_tox tox_details = [] for column in columns: tox_detail = toxicity.loc[:, column].drop_duplicates() tox_details.append(list(tox_detail)) tox_details = ask.join_lists(tox_details, "; ") print(tox_details) file_number, nact_drugs_administered, toxicity_type, toxicity_grade, toxicity_treatment, toxicity_response, \ toxicity_at_cycle, nact_change_due_to_toxicity = tox_details tumour_response_check_method = ask.ask_option( "Response to NACT measured by", ['Mammography', 'SonoMammography']) if tumour_response_check_method not in { 'Mammography', 'SonoMammography' }: tumour_response_nact, tumour_size, tumour_size_unit, date_tumour_size_checked, nact_response_impression, \ nact_response_node, nact_response_impression, nact_response_node = ( tumour_response_check_method,)*8 else: tumour_response_nact = ask.ask_list( "Response of tumour", ["Partial", "Complete", "No Effect", "Other"]) tumour_size = input( "Tumour size (without unit, e.g., 2 x 4 x 5) after treatment: " ) tumour_size_unit = ask.ask_option( "Tumour size unit", ['mm', 'cm']) date_tumour_size_checked = ask.check_date( "Date tumour size checked: ") nact_response_impression = input( 'Please input impression given in report for NACT response: ' ) nact_node = ask.ask_y_n( 'Does the report mention node response? ') nact_response_node = 'nact_node_response_not_mentioned' if nact_node: nact_response_node = input( 'Please input statement on node response to NACT: ' ) trast_nact = ask.ask_y_n("Trastuzumab used?") if trast_nact: trastuzumab_regime_nact = ask.ask_option( "Trastuzumab use was", ["Sequential", "Concurrent"]) trastuzumab_use_nact = "Trastuzumab used" trastuzumab_courses_taken_nact = input( "Number of courses of trastuzumab/herceptin taken: " ) else: trastuzumab_use_nact, trastuzumab_regime_nact, trastuzumab_courses_taken_nact, \ = ("no_neo_adjuvant_trastuzumab", )*3 nact_end_date = ask.check_date( "Date of completion of NACT: ") complete_nact = ask.ask_y_n( "Was NACT completed as per schedule? ") if complete_nact: nact_completion_status = "nact_complete" else: nact_completion_status = ask.ask_option( "Reason for discontinuation", [ "Toxicity", "Reluctance of patient", "Progression on chemotherapy", "Advised by treating doctor", "Death due to toxicity", "Death due to progressive disease", "Preferred treatment at another centre", "Death due to unrelated cause", "Patient was unable to afford treatment" ]) nact_completion_status = "NACT incomplete: " + nact_completion_status hormone_therapy = ask.ask_y_n_na( "Was hormone therapy given?") if hormone_therapy == 'Yes': hormone_therapy_nact = "naht_given" hormone_therapy_type_nact = ask.ask_option( "Hormone therapy type", ["Sequential", "Concurrent"]) hormone_therapy_duration = input( "What was the duration of therapy? ") therapy_side = ask.ask_y_n_na( "Were any side effects observed ?") horomone_therapy_side_effects = 'no_side_effects' if therapy_side == 'Yes': horomone_therapy_side_effects = input( "Please give details of side effects observed: " ) nact_naht = ask.ask_y_n( 'Was chemotherapy given in addition to hormone therapy?' ) if nact_naht: nact_status = 'nact_and_naht_given' else: nact_status = 'naht_given' elif hormone_therapy == 'No': hormone_therapy = "no_naht" nact_status = "nact_given" hormone_therapy_nact, hormone_therapy_type_nact, hormone_therapy_duration, \ horomone_therapy_side_effects = ( hormone_therapy,) * 4 else: hormone_therapy_nact, hormone_therapy_type_nact, hormone_therapy_duration, \ horomone_therapy_side_effects = ( hormone_therapy,) * 4 nact_status = "nact_given" data_list = [ nact_status, place_nact, details_nact, plan_nact, date_start_nact, patient_weight_nact, nact_drugs_administered, number_cycles_nact, cycle_weekly_frequency, drugs_totaldose, drugs_unit, toxicity_type, toxicity_grade, toxicity_treatment, toxicity_response, toxicity_at_cycle, nact_change_due_to_toxicity, tumour_response_check_method, tumour_response_nact, tumour_size, tumour_size_unit, nact_response_impression, nact_response_node, date_tumour_size_checked, nact_completion_status, nact_end_date, trastuzumab_use_nact, trastuzumab_regime_nact, trastuzumab_courses_taken_nact, hormone_therapy_nact, hormone_therapy_type_nact, hormone_therapy_duration, horomone_therapy_side_effects, self.user_name, sql.last_update() ] col_list = names("neo_adjuvant_therapy") check = sql.review_input(file_number, col_list, data_list) return data_list, drug_table, toxicity