def create_new_patient(cls, user_id, age, gender, phone): try: Database.add_patient(user_id, age, gender, phone) except DatabaseConnectionError: print('Something went wrong with the server! Please, try again.') sys.exit(1) return cls.find_patient(user_id)
def list_slots(self): doctor_slots = Database.list_doctor_slots(self.id) print('| ID | Date | From | To | Reservation Status |') print('|------|--------|--------|------|--------------------|') for slot in doctor_slots: print('| {:^8} | {:^8} | {:^8} | {:^8} | {:^8} |'.format( slot[0], slot[1], slot[2], slot[3], slot[4]))
def show_reservations(self): reservations = Database.list_reservations(self.id) print('| ID | Slot | Status |') print('|---------|------------------|----------|') for reservation in reservations: print('| {:^7} | {:^16} | {:^8} |'.format(reservation[0], reservation[1], reservation[2]))
def create_new_doctor(cls, user_id, specialty, phone): try: doctor = Database.add_doctor(user_id, specialty, phone) except DatabaseConnectionError: print( 'Oops, something went wrong with the server! Please, try again.' ) sys.exit(1) return cls.find_doctor(user_id)
def view_available_slots(self): doctor_slots = Database.list_available_slots() print( '| ID | Date | From | To | Reservation Status |' ) print( '|--------------|------------|------------|----------|--------------------|' ) for slot in doctor_slots: print('| {:^10} | {:^10} | {:^6} | {:^6} | {:^14} |'.format( slot[0], slot[1], slot[2], slot[3], slot[4]))
def remove_slot(self, slot_id): Database.delete_slot(slot_id)
def add_slot(self, slot_id, date, start_hour, end_hour, reservation_status): Database.add_available_slot(self.id, slot_id, date, start_hour, end_hour, reservation_status)
def find_doctor(cls, user_id): attr = Database.find_doctor(user_id) if attr: return cls(attr[0], attr[1], attr[2], attr[3])
def cancel_reservation(self, slot_id): Database.cancel_reservation(slot_id)
def reserve_slot(self, slot_id): Database.add_reservation(self.id, slot_id)
def find_patient(cls, user_id): attr = Database.find_patient(user_id) if attr: return cls(attr[0], attr[1], attr[2], attr[3], attr[4])
def _get_last_registered_status_patient(cls): return Database.last_reg_patient()[0]
def _get_last_registered_status_doctor(cls): return Database.last_reg_doctor()[ 0] # return last registered doctors user_id
def find(cls, username, password): attr = Database.find_user(username, password) if attr: return cls(attr[0], attr[1], attr[2], attr[3], attr[4])
def create_new_user(cls, username, password, full_name, status): try: current_user = Database.add_user(username, password, full_name, status) except DatabaseConnectionError: print('Something went wrong with the server! Please, try again.')