Advertisement
Guest User

qn 3

a guest
Aug 24th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.54 KB | None | 0 0
  1. def registerPatient(patientList):
  2.     pID = (input("Enter patient's ID: ")).upper()
  3.     d = []
  4.        
  5.        
  6.     for i in range(0,len(patientList)): # check for patient ID
  7.         if (patientList[i][0] == pID):
  8.             print("{} already in queue {}".format(pID,i+1))
  9.             return
  10.            
  11.     else:
  12.         # prompt input for patient name
  13.         name = input("Enter Patient's name: ").upper()
  14.        
  15.         # adding new patient information into the list
  16.         d.append(pID)
  17.         d.append(name)
  18.         patientList.append(d)
  19.         queue = len(patientList)
  20.         print(patientList)
  21.         print(d)
  22.         print("{} is registered with queue number {}".format(pID,(queue)))
  23.            
  24.  
  25. def callnext(patientList):
  26.    
  27.     if not patientList:
  28.             print("No patient in queue")
  29.     else:
  30.         for i in range(0,len(patientList)):
  31.             print("Calling queue number {}".format(i+1))
  32.             print("Serving queue number {}".format(i+1))
  33.  
  34.  
  35.                
  36. import random  
  37. def doesPatientmissqueue():
  38.     return random.choices([True,False,False,False])
  39.        
  40. def listPatient(patientList):
  41.     if not patientList:
  42.         print("There is no patient")
  43.     else:
  44.         print("PatientID:\tName:\tQueue Number:\t Calls Missed:")
  45.         for x in range(0,len(patientList)):
  46.             print("{:9}\t{:6}\t{:13}\t{:14}".format(patientList[x][0],patientList[x][1],(x+1),0))
  47.    
  48.                
  49.    
  50.    
  51. def menu():
  52.     while True:
  53.         print("Menu")
  54.         print("1. Register a Patient")
  55.         print("2. Call Next Patient")
  56.         print("3. List Patients in Queue")
  57.         print("4. Search Patient's Queue Position")
  58.         print("5. Record Patients Seen")
  59.         print("0. Exit")
  60.         otp = int(input("Enter option: "))
  61.         if otp in range(6):
  62.             return otp
  63.         else:
  64.             print("invalid input")
  65.  
  66. def main():
  67.     patientList = []
  68.     queueMiss = []
  69.     queueNumber = 0
  70.     with open ("patient.txt", "a+") as fout:
  71.         while True:
  72.             choice = menu()
  73.             if choice == 0:
  74.                 break
  75.             elif choice == 1:
  76.                 registerPatient(patientList)
  77.             elif choice == 2:
  78.                 callnext(patientList)
  79.             elif choice == 3:
  80.                 listPatient(patientList)
  81.             elif choice == 4:
  82.                 break
  83.             elif choice == 5:
  84.                 break
  85.            
  86.            
  87.                  
  88.                
  89.     print("End program")
  90. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement