Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Doctor import Doctor
- class Admin:
- def __init__(self, username, password, address = ''):
- self.__username = username
- self.__password = password
- self.__address = address
- def view(self,a_list):
- for index, item in enumerate(a_list):
- print(f'{index+1:3}|{item}')
- def login(self):
- print("-----Login-----")
- username = input('Enter the username: ')
- password = input('Enter the password: ')
- return self.__username in username and self.__password == password
- def find_index(self,index,doctors):
- if index in range(0,len(doctors)):
- return True
- else:
- return False
- def get_doctor_details(self):
- first_name = input('Enter the first name: ')
- surname = input('Enter the surname: ')
- speciality = input('Enter the speciality: ')
- return first_name, surname, speciality
- def doctor_management(self, doctors):
- print("\n-----Doctor Management-----")
- print('Choose the operation:')
- print(' 1 - Register')
- print(' 2 - View')
- print(' 3 - Update')
- print(' 4 - Delete')
- op = input('Input: ')
- if op == '1':
- print("-----Register-----")
- print('Enter the doctor\'s details:')
- first_name, surname, speciality = self.get_doctor_details()
- name_exists = False
- for doctor in doctors:
- if first_name.lower() == doctor.get_first_name().lower() and surname.lower() == doctor.get_surname().lower():
- print('Name already exists.')
- name_exists=True
- if(name_exists==False):
- doctors.append(Doctor(first_name, surname, speciality))
- print('Doctor registered.')
- elif op == '2':
- if doctors:
- print("\n-----List of Doctors-----")
- print('ID | Full name | Speciality')
- self.view(doctors)
- else:
- print('There are no doctors in the system to view.')
- elif op == '3':
- if doctors:
- while True:
- print("\n-----Update Doctor`s Details-----")
- print('ID | Full name | Speciality')
- self.view(doctors)
- try:
- index = int(input('Enter the ID of the doctor: ')) - 1
- doctor_index=self.find_index(index,doctors)
- if doctor_index!=False:
- break
- else:
- print("Doctor not found")
- except ValueError:
- print('The ID entered is incorrect')
- print('Choose the field to be updated:')
- print(' 1 First name')
- print(' 2 Surname')
- print(' 3 Speciality')
- op = int(input('Input: '))
- doctor = doctors[index]
- if op==1:
- fn=input('Enter the new first name: ')
- doctor.set_first_name(fn)
- if op==2:
- sn=input('Enter the new surname: ')
- doctor.set_surname(sn)
- if op==3:
- sp=input('Enter the new speciality: ')
- doctor.set_speciality(sp)
- else:
- print('There are no doctors in the system to update.')
- elif op == '4':
- if doctors:
- print("\n-----Delete Doctor-----")
- print('ID | Full Name | Speciality')
- self.view(doctors)
- doctor_index = input('Enter the ID of the doctor to be deleted: ')
- try:
- doctors.pop(int(doctor_index) -1)
- print('Doctor deleted')
- except:
- print("The id entered was not found")
- return doctors
- print('The id entered is incorrect')
- else:
- print('There are no doctors to delete.')
- def view_patient(self, patients):
- print("\n-----View Patients-----")
- print('ID | Full Name | Doctor`s Full Name | Age | Mobile | Postcode | Symptom ')
- self.view(patients)
- def discharge(self, patients, discharge_patients):
- print("\n-----Discharge Patient-----")
- print('ID | Full Name | Doctor`s Full Name | Age | Mobile | Postcode | Symptom ')
- self.view(patients)
- while True:
- try:
- patient_index=int(input('Please enter the patient ID: ')) - 1
- patient_valid=self.find_index(patient_index,patients)
- if patient_valid!=False:
- return patient_index
- break
- else:
- print("ID not found")
- except ValueError:
- print("entered id is invalid.")
- def dischargeview(self, discharged_patients):
- print("\n-----Discharged Patients-----")
- print('ID | Full Name | Doctor`s Full Name | Age | Mobile | Postcode | Symptom ')
- self.view(discharged_patients)
- def assign_doctor_to_patient(self, patients, doctors):
- print("\n-----Assign Patients-----")
- print('ID | Full Name | Doctor`s Full Name | Age | Mobile | Postcode | Symptom ')
- self.view(patients)
- patient_index = input('Please enter the patient ID: ')
- try:
- patient_index = int(patient_index) -1
- if patient_index not in range(len(patients)):
- print('The id entered was not found.')
- return
- except ValueError:
- print('The id entered is incorrect')
- return
- print("-----Doctors Select-----")
- print('Select the doctor that fits these symptoms:')
- print('--------------------------------------------------')
- print('ID | Full Name | Speciality ')
- self.view(doctors)
- doctor_index = input('Please enter the doctor ID: ')
- try:
- doctor_index = int(doctor_index) -1
- if self.find_index(doctor_index,doctors)!=False:
- patients[patient_index].link(doctors[doctor_index].full_name())
- doctors[doctor_index].add_patient(doctors[doctor_index])
- print('The patient is now assign to the doctor.')
- else:
- print('The id entered was not found.')
- except ValueError:
- print('The id entered is incorrect')
- def group_family(self,patients):
- print("\n-----Patients Family-----")
- print(' Full Name | Doctor`s Full Name | Age | Mobile | Postcode | Symptom ')
- family = ("Smith")
- print(*[p for p in patients if p.get_surname() == family], sep='\n')
- def management_report(self,doctors,patients):
- print("\n-----Management Reports-----")
- print('Choose the operation:')
- print(' 1 - Amount of doctors')
- print(' 2 - Patients per Doctors')
- op = input('Input: ')
- if op =='1':
- print("Amount of doctors: {0}".format(len(doctors)))
- elif op =='2':
- print("{0} has {1} patients".format(doctors,len(patients)))
- def update_details(self):
- print('Choose the field to be updated:')
- print(' 1 Username')
- print(' 2 Password')
- print(' 3 Address')
- print(' 4 Admin Details')
- op = int(input('Input: '))
- while True:
- if op == 1:
- username = input('Enter the new username: ')
- if username == input('Enter the new Username again: '):
- self.__username = username
- print("User has been updated to {0}".format(username))
- break
- else:
- print("Username does not match, try again")
- elif op == 2:
- password = input('Enter the new password: ')
- if password == input('Enter the new password again: '):
- self.__password = password
- print("Password has been changed.")
- break
- else:
- print("Password does not match")
- elif op == 3:
- address = input('Enter the new address: ')
- if address == input('Enter the new address again: '):
- self.__address = address
- print("Address has been changed to {0}.".format(address))
- break
- elif op == 4:
- print('Admin Details\nUsername: {0}\nPassword: {1} \nAddress: {2}'.format(self.__username, self.__password, self.__address))
- break
- else:
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement