def search_customer_duplicate_checker(self): # Check the new customer if it's already in the table, preventing from upload # Connect to the database cnxn, cursor = ConnectingToDatabase.connect_database(self) userin = UserInput() userin.adding_new_patient() self.upload_for_searching( userin.FirstName, userin.LastName, userin.Dob, userin.MotherMaidenName, userin.Phone_number, userin.AppointmentDate, ) # Querying the result in the patient table query_search = "SELECT ID FROM Patient WHERE FirstName=? and LastName=? and DateOfBirth=? and MotherMaidenName=?;" cursor.execute(query_search, self.firstName, self.lastName, self.dateOfBirth, self.motherMaidenName) row = cursor.fetchone() try: id_current_query = row[0] return id_current_query except: return None
def modifying_first_name(self): # Change the first name and update in the table search = SearchingCustomer() customer = search.search_customer() if customer is not None: change_first_name = UserInput() change_name = change_first_name.change_first_name() cnxn, cursor = ConnectingToDatabase.connect_database(self) query_mod_first_name = "UPDATE Patient SET FirstName=? WHERE ID=?;" cursor.execute(query_mod_first_name, change_name, customer) cnxn.commit()
def modifying_dob(self): # Change the date of birth and update in the table search = SearchingCustomer() customer = search.search_customer() if customer is not None: change_date_of_birth = UserInput() change_dob = change_date_of_birth.change_dob() cnxn, cursor = ConnectingToDatabase.connect_database(self) query_mod_dob = "UPDATE Patient SET DateOfBirth=? WHERE ID=?;" cursor.execute(query_mod_dob, change_dob, customer) cnxn.commit()
def modifying_phone_number(self): # Change the phone number and update in the table search = SearchingCustomer() customer = search.search_customer() if customer is not None: change_phone_number = UserInput() change_pnumber = change_phone_number.change_phonenumber() cnxn, cursor = ConnectingToDatabase.connect_database(self) query_mod_phone_number = "UPDATE Patient SET PhoneNumber=? WHERE ID=?;" cursor.execute(query_mod_phone_number, change_pnumber, customer) cnxn.commit()
def modifying_appointment_date(self): # Change appointment date and update in the table search = SearchingCustomer() customer = search.search_customer() if customer is not None: change_appointment_date = UserInput() change_appointmentdate = change_appointment_date.change_appointment_date( ) cnxn, cursor = ConnectingToDatabase.connect_database(self) query_mod_appointment_date = "UPDATE Patient SET AppointmentDate=? WHERE ID=?;" cursor.execute(query_mod_appointment_date, change_appointmentdate, customer) cnxn.commit()
def enumerate_rows(target): '''Present the options and prompts for selecting tables, columns, number of rows to enumerate''' enumerated_rows = [] user_input = UserInput(target=target) table, col = user_input.show_prompts() selected_table = table['selected'] num_rows = table['num_rows'] selected_col = col['selected'] selected_limit = col['limit'] print("\nTable selected: {} {}".format(clr.red(selected_table),clr.yellow("({} rows)".format(num_rows)))) print("Column selected: {}".format(clr.red(selected_col))) print("\nEnumerating rows for {}.{}\n".format(clr.red(selected_table), clr.red(selected_col))) try: curr_rows = target.get_curr_enum_rows(selected_table,selected_col) if selected_limit == len(curr_rows): print(render_rows(curr_rows,selected_col)) else: if len(curr_rows) > 0: enumerated_rows = enumerated_rows + curr_rows rows = target.generate_rows(selected_col, selected_table, selected_limit) for row in rows: enumerated_rows.append(row) print(render_rows(enumerated_rows,selected_col)) if(len(target.get_long_rows_for_table_col(selected_table, selected_col)) > 0): if input("Long rows present, enumerate them? [y/n, default:n]: ") in ['y','']: user_input.select_long_row() enumerate_long_rows(target, user_input.long_row, selected_table, selected_col) return True except KeyboardInterrupt: print("\nRow enumeration aborted, partial enumeration results for {}.{}:\n".format(clr.red(selected_table),clr.red(selected_col))) print(render_rows(enumerated_rows,selected_col)) if input("Continue enumerating rows for other tables? [y/n, default:n]: ") == 'y': enumerate_rows(target) else: return False
def search_customer(self): # Searching customer by first name + last name + mother maiden name + dob return PK ID # Connect to the database cnxn, cursor = ConnectingToDatabase.connect_database(self) # Searching the patient giving back patient not found if there are no records in the table userin = UserInput() userin.change_first_name() userin.change_last_name() userin.change_dob() userin.change_mother_maiden_name() self.upload_for_searching(userin.FirstName, userin.LastName, userin.Dob, userin.MotherMaidenName) # Querying the result in the patient table query_search = "SELECT ID FROM Patient WHERE FirstName=? and LastName=? and DateOfBirth=? and MotherMaidenName=?;" cursor.execute(query_search, self.firstName, self.lastName, self.dateOfBirth, self.motherMaidenName) row = cursor.fetchone() try: id_current_query = row[0] return id_current_query except: return None
def pressButton(self, x, y): print("You have pressed ",x,", ",y) row = self.buttonList[y] button = row[x] button['bg'] = '#8c8c8c' UI = UserInput.UserInput(self, x, y)
def __init__(self, potential_params, config_params, teleop, predictor_type, robot_type, grasp, user_input_type, index_test, DH_params, name_user_test, dynamic_system, gripper_active, escape_active): self._potential_params = potential_params self._config_params = config_params self._vmax = self._config_params[1] self._teleop = teleop self._predictor_type = predictor_type self._robot_type = robot_type self._grasp = grasp self._user_input_type = user_input_type self._index_test = index_test self._DH_params = DH_params self._goal_radius = config_params[3] self._indexEE = len(self._DH_params[0]) self._gripper_active = gripper_active if (self._gripper_active): self._indexGripper = self._indexEE + 1 self._end_system = False self._distance_type = "distance" self._dynamic_system = dynamic_system self._escape_active = escape_active self._LEN_TWIST_VECTOR = 6 self._ZT = 1.20 #Variables for dynamic system: only obstacles can change, not goals if (self._dynamic_system): self._dynamic_first_lecture = True self._dynamic_goal = None self._dynamic_joints = None self._dynamic_obstacles = None self._dynamic_escape_points = None self._joints_target_positions = None self._dynamic_goal_msg = None self._dynamic_sub_objs = None #User Input, PrintFile and kinematics self._userinput = UserInput.UserInput(self._robot_type, self._user_input_type) self._print_file = None if (self._teleop): self._print_file = PrintFile.PrintFile("teleop", self._index_test, name_user_test, self._user_input_type) else: self._print_file = PrintFile.PrintFile(self._predictor_type, self._index_test, name_user_test, self._user_input_type) self._rob_kin = rk.RobotKinematics( self._DH_params[0], self._DH_params[1], self._DH_params[2], self._DH_params[3], self._robot_type, self._gripper_active) #Services self._service_obj = None self._service_move = None self._service_grasp = None self._service_init_pred_node = None self._service_predictor = None self._reset_myo_service = None