def main():
    """Quick tests."""
    a1 = Appointment("yo", "saturday", "12:30pm", "1:30pm", [1, 2, 3])
    a3 = Appointment("yo1", "saturday", "1:30am", "12:30pm", [1])
    a4 = Appointment("yo2", "sunday", "2:30am", "12:30pm", [1])
    a5 = Appointment("yo3", "monday", "12:30am", "3:30am", [1])
    a6 = Appointment("yo4", "tuesday", "4:30am", "12:30pm", [1])
    a7 = Appointment("yo5", "wednesday", "5:30am", "12:30pm", [1])
    a8 = Appointment("yo6", "thursday", "6:30am", "12:30pm", [1])
    a9 = Appointment("yo7", "friday", "7:30am", "12:30pm", [1])
    a10 = Appointment("yo8", "monday", "8:30am", "9:30am", [1])
    a11 = Appointment("yo9", "tuesday", "12:30pm", "2:30pm", [1])

    c3 = Calendar(a1, a3, a4, a5, a6, a7, a8, a9, a10, a11)

    serial_calendar = Calendar.serialize(c3)

    import pickle
    import sys
    msg = pickle.dumps(serial_calendar)
    size = sys.getsizeof(msg)

    print "size", size

    uC = Calendar.deserialize(serial_calendar)

    print c3 == uC
    pass
def main():
    """Quick tests."""
    "schedule yaboi (user0,user1,user2,user3) (4:00pm,6:00pm) Friday"
    "schedule xxboi (user1,user3,user4) (1:30am,11:30am) Wednesday"
    "schedule beez (user0,user1,user2,user3) (4:00pm,6:00pm) Saturday"
    "schedule beez2 (user0,user1,user2,user3) (3:00pm,4:00pm) Saturday"
    "schedule zo (user1,user2,user3) (12:30pm,1:30pm) Friday"
    "schedule hamma (user1,user2,user3) (1:00am,1:30am) Friday"
    "cancel yaboi (user0,user1,user2,user3) (4:00pm,6:00pm) Friday"
    "cancel xxboi (user1,user3,user4) (1:30am,11:30am) Wednesday"

    a1 = Appointment("zo", "Friday", "12:30pm", "1:30pm", [1, 2, 8])
    a2 = Appointment("xxboi", "Wednesday", "1:30am", "11:30am", [1, 4, 5])
    a3 = Appointment("lol", "saturday", "11:30am", "12:30pm", [1])
    a4 = Appointment("yeee", "MondAy", "11:30am", "12:30pm", [1])
    a5 = Appointment("lolololol", "Thursday", "11:30am", "12:30pm", [1])

    c = Calendar()
    c1 = Calendar(a1)
    c2 = Calendar(a1, a2)
    c3 = Calendar(a1, a2, a3)
    c4 = Calendar(a1, a2, a3, a4)
    c5 = Calendar(a1, a2, a3, a4, a5)

    set_verbosity(4)

    N = Node(int(sys.argv[1]))
    '''
    N._log[0] = c1
    N._log[1] = c2
    N._log[2] = c3
    N._log[3] = c4
    N._log[4] = c5
    '''
    N._calendar = c

    #try to load a previous state of this Node
    #'''
    try:
        N = Node.load()
    except ValueError:
        pass
    except IOError:
        pass
    #'''

    N.elect_leader(poll_time=6, timeout=3)
    N.paxos()

    print("@> Node Started")
    while True:
        message = raw_input('')
        if message == "quit":
            Node.save(N)
            N.terminate()
            break
        else:
            Node._parse_command(message, N)
    def findTimeSlot(earliest: int, duration: int, participants: List[Participant]):

        #Get intersections of participants
        intersections = getAllIntersections(participants)

        #Iterate free slots and check for beginning time and duration
        for intersection in intersections:
            if (intersection.start <= earliest && intersection.end >= earliest+duration):
                return Appointment(earliest, earliest+duration, "Slot")
            else if(intersection.start > earliest && intersection.start+duration <= intersection.end):
                return(Appointment(start, start+duration, "Slot"))
            else:
                return(null)
def main():
    strt = datetime.datetime(2017, 10, 28, 10, 30, 12)
    end = datetime.datetime(2017, 10, 28, 11, 30, 12)
    a = Appointment(strt, end, 'Appnt1', 'an example of an appointment')
    strt = datetime.datetime(2017, 10, 28, 11, 30, 12)
    end = datetime.datetime(2017, 10, 28, 12, 30, 12)
    b = Appointment(strt, end, 'Appnt2', 'another example of an appointment')
    d = Diary('guru''s')
    print(d)
    d += a
    d += b
    print(d, len(d))
    print(d.next_appointments(1))
Example #5
0
    def negateAppointments(self, start: int, end: int):
        ans = []

        for inx, a in enumerate(self.mergedAppointments):
            if (inx == 0):
                ans.append(Appointment(start, a.start, "Description"))
            else:
                ans.append(
                    Appointment(self.mergedAppointments[inx - 1].end, a.start,
                                "Descripion"))
        ans.append(
            Appointment(self.mergedAppointments[-1].end, end, "Description"))
        self.negatedAppointments = ans
    def __init__(self, *appointments):
        """
        Initialize a Calendar object with any number of Appointment objects.

        Raise TypeError if some provided arg is not of type Appointment.
        Raise ValueError if any two Appointment objects provided are
        conflicting.
        """

        #Enforce positional arguments as only consisting of Appointment objects
        for appt in appointments:
            if not hasattr(appt, "_is_Appointment"):
                raise TypeError(
                    "Positional arguments must Appointment objects")

        #Enforce no two conflicting Appointment objects
        for i, appt1 in enumerate(list(appointments)):
            for j, appt2 in enumerate(list(appointments)):
                if i != j:
                    if Appointment._is_conflicting(appt1, appt2):
                        raise ValueError("Appointments \n" + str(appt1) +
                                         "\n and \n" + str(appt2) +
                                         "\n are conflicting.")

        #remove duplicates and set
        l_appointments = list(appointments)
        self._appointments = []

        #loop through with list instead of set to keep order
        for appointment in l_appointments:
            if appointment not in self._appointments:
                self._appointments.append(appointment)

        self._is_Calendar = True
        def _parse_appointment(argv):
            """Try to parse an Appointment object from given argv."""
            generic_error_msg = "Invalid command; Schedule and cancel " + \
                    "commands must be of form: \n" + \
                    "{schedule,cancel} [Appointment name] " + \
                    "(user1,user2,...usern) (start_time,end_time) [day]"

            if len(argv) != 5:
                raise ValueError(generic_error_msg)

            name, participants, times, day = argv[1:]
            participants = participants[1:-1].split(",")
            try:
                participants = [int(user[4:]) for user in participants]
            except ValueError:
                raise ValueError(
                    "Invalid command; participants must be of form "
                    "(user1,user2,...,usern)")
            try:
                start, end = times[1:-1].split(',')
            except ValueError:
                raise ValueError("Invalid command; times must be of form "
                                 "(start_time,end_time)")

            try:
                return Appointment(name, day, start, end, participants)
            except ValueError as excinfo:
                raise ValueError("Invalid command; " + excinfo.message)
    def __setitem__(self, key, value):
        """
        Implement Calendar[key] = value; needed to ensure no conflicts added.
        """

        if not hasattr(value, "_is_Appointment"):
            raise TypeError("value parameter must be an Appointment object")

        #Ensure valid key while setting
        try:
            self._appointments[key]
        except TypeError:
            raise TypeError("Index must be an int")
        except IndexError:
            raise IndexError("invalid index: " + str(key))

        non_key_appts = []
        for i, appt in enumerate(self._appointments):
            if i != key:
                non_key_appts.append(appt)

        for appt in non_key_appts:
            if Appointment._is_conflicting(value, appt):
                raise ValueError(
                    str(value) + "\n conflicts with \n" + str(appt) +
                    "\n already in Calendar")

        for appt in non_key_appts:
            if value == appt:
                raise ValueError(
                    "Cannot add duplicate Appointment to Calendar")

        self._appointments[key] = value
    def _is_calendar_conflicting(self, other):
        """Determine if self and other are conflicting."""

        if not hasattr(other, "_is_Calendar"):
            raise TypeError("both parameters must be Calendar objects.")

        #if any pair of appointments is conflicting, calendars conflict
        for appt1 in self:
            for appt2 in other:
                if Appointment._is_conflicting(appt1, appt2):
                    return True

        return False
    def deserialize(serial_msg):
        """Return a Calendar object parsed from a serialized string"""
        if not serial_msg:
            return serial_msg

        if type(serial_msg) != str:
            return serial_msg

        appt_list = serial_msg.split("#")
        appt_for_calendar = []
        for appt_str in appt_list:

            first_str = appt_str.split(" on ")
            appt_name = first_str[0].split("Appointment ")[1][1:-1]

            second_str = first_str[1].split(" with ")
            user_list = second_str[1].split(" and ")
            users_final = []

            for part in user_list:
                users = part.split(" ")
                for part in users:
                    if len(part) == 2:
                        users_final.append(int(part[:-1]))
                    else:
                        users_final.append(int(part))

            dates_part_1 = first_str[1].split(" from ")
            times = dates_part_1[1].split(" to ")
            start_time = times[0]
            end_time = times[1].split(" with ")[0]
            appointment_day = dates_part_1[0]

            start_time_hour, start_time_minute = [
                int(comp_time) for comp_time in start_time.split(":")
            ]
            end_time_hour, end_time_minute = [
                int(comp_time) for comp_time in end_time.split(":")
            ]
            start_time_final = datetime.time(start_time_hour,
                                             start_time_minute)
            end_time_final = datetime.time(end_time_hour, end_time_minute)

            appointment = Appointment(appt_name, appointment_day,
                                      start_time_final, end_time_final,
                                      users_final)
            appt_for_calendar.append(appointment)

        return Calendar(*appt_for_calendar)
Example #11
0
    def request_appointment(self, database, medicalWorkerUserName,
                            appointmentDateTimeTuple, reason):
        now = datetime.now()
        appointmentID = now.strftime("%Y%m%d%H%M%S") + self.userName
        result = Appointment(self.userName, medicalWorkerUserName,
                             appointmentDateTimeTuple, reason)

        database["appointment"][appointmentID] = result
        try:
            database["user_confirmed"][
                medicalWorkerUserName].appointment_waiting[
                    appointmentDateTimeTuple].append(appointmentID)
        except KeyError:
            database["user_confirmed"][
                medicalWorkerUserName].appointment_waiting[
                    appointmentDateTimeTuple] = [appointmentID]
    def getIntersections(A: List[Appointment], B: List[Appointment]):
        ans = []
        i = j = 0
        while i < len(A) and j < len(B):
            # Let's check if A[i] intersects B[j].
            # lo - the startpoint of the intersection
            # hi - the endpoint of the intersection
            lo = max(A[i].start, B[j].start)
            hi = min(A[i].end, B[j].end)
            if lo <= hi:
                ans.append(Appointment(lo, hi, "Description"))

            # Remove the interval with the smallest endpoint
            if A[i].end < B[j].end:
                i += 1
            else:
                j += 1
        return ans
    def _is_appointment_conflicting(self, appointment):
        """
        Determine if Appointment object appointment conflicts with any
        Appointment in Calendar object calendar.

        NOTE: if a copy of appointment is in this Calendar, appointment param
        will not conflict with the copy.
        """

        #Type checking first
        if not hasattr(appointment, "_is_Appointment"):
            raise TypeError(
                "appointment parameter must be an Appointment object")

        #if appointment conflicts with anything in this Calendar
        for calendar_appointment in self:
            if Appointment._is_conflicting(calendar_appointment, appointment):
                return True

        return False
Example #14
0
    def __init__(self,root, appointment_id = None):
        AppointmentBase.isopen = True
        
        # Variables
        self.log = logging.getLogger(__name__)
        self.colour = Colours.calendarbase
        self.relief = Relief.calendarbase
        self.root = root
        self.appointment_id = appointment_id
        self.dataappointment = DataAppointment()
        self.datapatient = DataPatient()
        self.datadoctor = DataDoctor()
        
        # Build Window
        tk.Toplevel.__init__(self,root,bg=self.colour['frame'])
        self.title('Appointment')
        self.protocol('WM_DELETE_WINDOW', self.Close)

        # Configure Window
        for i in range(4): self.grid_columnconfigure(i,weight=1)
        
        self.grid_rowconfigure(0,weight=0)
        self.grid_rowconfigure(1,weight=1)
        # Widgets
        self.checkbutton = tk.Button(self, text='Check', bg=self.colour['button'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'])
        self.seepatientbutton = tk.Button(self, text='See Patient', bg=self.colour['button'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'])
        self.typemenu = tk.Menubutton(self, text='Type', bg=self.colour['button'], relief=self.relief['button'])
        self.printbutton = tk.Button(self, text='Print', bg=self.colour['button'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'])
        self.savebutton = tk.Button(self, text='Save', bg=self.colour['savebutton'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'], command=self.SaveAppointment)
        self.appointment = Appointment(self, self.appointment_id)
        
        # Place Widgets
        self.checkbutton.grid(row=0,column=0,sticky=tk.N+tk.E+tk.S+tk.W)
        self.seepatientbutton.grid(row=0,column=1,sticky=tk.N+tk.E+tk.S+tk.W)
        self.typemenu.grid(row=0,column=2,sticky=tk.N+tk.E+tk.S+tk.W)
        self.printbutton.grid(row=0,column=3,sticky=tk.N+tk.E+tk.S+tk.W)
        self.savebutton.grid(row=0,column=4,sticky=tk.N+tk.E+tk.S+tk.W)
        self.appointment.grid(row=1,column=0,columnspan=5, sticky=tk.N+tk.S+tk.E+tk.W)
Example #15
0
     print("That selection was invalid.")
 else:
     if user_input == 1:   #option to input patients into the system
         patient_name = input("Enter patient/'s name: ")
         ID_number = input("Enter patient/'s identity number: ")
         age = input("Enter patient/'s age:" )
         address = input("Enter patient/'s address:")
         Patients_1[ID_number] = patient_name   
     elif user_input == 2:    #option to input doctors into the system
         doctor_name = input("Enter doctor/'s name: ")
         dr_ID_number = input("Enter doctor/'s identity number: ")
         age = input("Enter doctor/'s age:" )
         address = input("Enter doctor/'s address:")            
         Doctors_1[dr_ID_number] = doctor_name   
     elif user_input == 3:     #option to input appointments into the system
         e = Appointment()
         e.patient_identity_no= (input("Enter patient/'s identity number: "))
         e.doctor_identity_no= (input("Enter doctor/'s identity number: "))
         e.timestamp= (str(input('Enter appointment date (yy,mm,dd,hours,minutes,00): ')))
         e.description = (input("Type the discription:"))
         appointment = datetime.datetime(int(e.timestamp[0:4]),int(e.timestamp[5:7]),int(e.timestamp[8:10]),int(e.timestamp[11:13]),int(e.timestamp[14:16]))            
         Appointments_1[appointment] = e
     if user_input == 4:      #option to place a patient for an appointment
         if r == 0:
             for i in Appointments_1:
                 n[i] = []
         r += 1
         patient_ID = input("Enter patient/'s identity number: ")
         app_time = str(input('Enter appointment date (yy,mm,dd,hours,minutes,00): '))
         appointment = datetime.datetime(int(app_time[0:4]),int(app_time[5:7]),int(app_time[8:10]),int(app_time[11:13]),int(app_time[14:16]))              
         if patient_ID in Patients_1:
Example #16
0
 elif option==1:
     patnt=Patient()
     patnt.name=input("Enter the patient name:")
     patnt.age=eval(input("Enter the age of a pateint:"))
     patnt.idnumber=input("Enter the id number of the patient:")
     patnt.adress=input("Enter the address of a patient:")
     patnt.visit=input("Enter the number of visit:")
     patient.append(str(patnt))
 elif option==2:
     doc=Doctor()
     doc.name=input("Enter the doctor's name:")
     doc.address=input("Enter the address of the doctor:")
     doc.Id=input("Enter the Doctor's ID:")
     doctor.append(str(doc))
 elif option==3:
     appoint=Appointment()
     appoint.pid=input("Enter the patient's ID:")
     appoint.did=input("Enter the Doctor's ID:")
     appoint.memo=input("Enter the memo:")
     appoint.day=input("Enter the day of the appointment:")
     appointment.append(str(appoint))
 elif option==4:
     for i in patient:
         print(i)
 elif option==5:
     for i in doctor:
         print(i)
 elif option==6:
     for i in appointment:
         print(i)
 elif option==7:
Example #17
0
 if option == 1:
     patnt = Patient()
     patnt.name = input("Enter the patient name:")  # name iherited from person
     patnt.age = eval(input("Enter the age of a pateint:"))  # age inherited from person
     patnt.idnumber = input("Enter the id number of the patient:")  # the patient is given the id number
     patnt.adress = input("Enter the address of a patient:")
     patnt.visit = input("Enter the number of visit:")
     patient.append(str(patnt))  # The whole patient class is appended into the list
 elif option == 2:
     doc = Doctor()
     doc.name = input("Enter the doctor's name:")  # The doctor is given the name,address and Id number
     doc.address = input("Enter the address of the doctor:")
     doc.Id = input("Enter the Doctor's ID:")
     doctor.append(str(doc))  # The whole doctor class is aasigned into the list
 elif option == 3:
     appoint = Appointment()
     appoint.pid = input(
         "Enter the patient's ID:"
     )  # The appointment is assigned doctor's id, when the appointment is and is also assigne the discription of the appointment
     appoint.did = input("Enter the Doctor's ID:")  # did=Doctor's id
     appoint.memo = input("Enter the memo:")
     appoint.day = input("Enter the day of the appointment:")
     appointment.append(str(appoint))  # The whole appointment class is assigned to the list
 elif option == 4:
     for i in patient:  # Going throught Patient list
         print(i)
 elif option == 5:
     for i in doctor:
         print(i)
 elif option == 6:
     for i in appointment:
Example #18
0
def main():
    patients,doctors,appointments=[],[],[]
    while True:
        print("Welcome to the Clinic. Please select an option:\n")
        option=int(input("1.Add a doctor, patient or create an appointment.\n2.Search and dispay all patients, doctors or appointments.\n3.Search all appointments for a patient or a doctor.\n0.Quit.\n"))
        if option==0:break
        
        elif option==1:                                                                 
            option1=int(input("1.Add a doctor.\n2.Add Patient.\n3.Create appointment.\n"))
            if option1==1:                                                              #Adding a doctor
                d=Doctor()
                d.name=input("Please enter doctor's name.\n")
                d.age=input("Please enter doctor's age.\n")
                d.doctor_id_no=input("Please enter doctor's I.D number.\n")
                d.doctor_address=input("Please enter doctor's address.\n")
                doctors.append(d)
            elif option1==2:                                                            #Adding patient
                p=Patient()
                p.name=input("Please enter patient's name.\n")
                p.age=input("Please enter patient's age.\n")
                p.patient_id_no=input("Please enter patient's I.D number.\n")
                p.patient_address=input("Please enter patient's address.\n")
                patients.append(p)
            elif option1==3:                                                            #creating an appointment
                a=Appointment()
                a.doc_id=input("Please enter doctor's I.D number.\n")
                a.pat_id=input("Please enter patient's I.D number.\n")
                a.time=input("Please enter date and time for the appointment(yyyy/mm/dd hh:mm)\n")
                a.memo()
                appointments.append(a)
        elif option==2:
            option2=int(input("1.Display doctors.\n2.Display patients.\n3.Display appointments.\n"))
            if option2==1:
                for i in doctors:
                    print(i.display())
            elif option2==2:
                for i in patients:
                    print(i.display())
            elif option2==3:
                for i in appointments:
                    print(i.display())
        elif option==3:
            option3=int(input("1.Search for doctor's appointments.\n2.Search for patient's appointments"))
            if option3==1:
                doctor_id=input("Enter doctor's I.D number")
                for i in doctors:
                    if i.doctor_id_no==doctor_id:
                        print(i.name)
                        break
                for j in doctors:
                    for k in appointments:
                        if j.doctor_id_no==k.doc_id:
                            print(k.display())
                
            elif option3==2:
                patient_id=input("Enter patient's I.D number")
                for i in doctors:
                    if i.patient_id_no==patient_id:
                        print(i.name)
                        break
                    for j in patients:
                        for k in appointments:
                            if j.patient_id_no==k.pat_id:
                                print(k.display())  
Example #19
0
def main():    
    input_file=open('Outputs.txt','wb') #opens file to save input
    while True:
        intro() #calls options
        
        option=int(input('>'))
    
        if option== 0: #ceases operation
            data_files=[doctors,patients,appointments,doctor_appointments,patient_appointments]
            dump(data_files, input_file)
            input_file.close()
            break
        
        elif option== 1: #inputs patient's info
            patient=Patient()
            patient.id_input()
            patients[patient.pat_id_number]=patient
            
        elif option== 2: #inputs for doctor's info
            doctor=Doctor()
            doctor.input()
            doctors[doctor.doc_id_number]=doctor
            
        elif option== 3: #inputs appointment info
            Appointment_number+=1
            appointment=Appointment()
            appointment.input()
            appointments[Appointment_number]=appointment
            
        elif option== 4: #searchs for patient
            pat_id_number=input('Enter Patient\'s Id number: ')
            appointment=Appointment()
            appointment.input()
            
            if len(patient.pat_id_number)>0:
                for i in patients:
                    if pat_id_number == i:
                        patient_appointments[pat_id_number]=appointment
                print('Could not find a patient with that Id number.')
        
            else:
                print('Could not find a patient with that student number.')
     
        elif option== 5: #searchs for doctor
            doc_id_number=input('Enter Doctor\'s Id number: ')
            appointment=Appointment()
            appointment.input()
            
            if len(doctor.doc_id_number)>0:
                for i in doctors:
                    if doc_id_number == i:
                        doctor_appointments[doc_id_number]=appointment
                print('Could not find a doctor with that Id number.')
        
            else:
                print('Could not find a doctor with that id number.')
                
        elif option== 6: #searchs for appointment
            Appointment_number=int(input('Enter Appointment number: '))
            appointment=Appointment()
            appointment.input()
            
            if len(appintment_number)>0:
                for i in appointments:
                    if Appointment_number == i:
                        appointments[Appointment_number]=appointment
                print('Could not find an appointment with that appointment number.')
        
            else:
                print('Could not find an appointment with that appointment number.')                       
        
        elif option== 7: #finds doctor
            doc_id_number=input('Enter Doctor\'s Id number: ')
            
            if doc_id_number in doctors:
                print(doctors[doc_id_number])
                
            else:
                print('Could not find a doctor with that id number.')
            
        elif option== 8: #finds patient
            patient_id_number=input('Enter Patient\'s Id number: ')
            
            if len(patient_id_number)>0:
                for ptt in patients:
                    if patient_id_number==ptt:
                        print(patients[patient_id_number])
                print('Could not find a patient with that id number.')
            else:
                print('Could not find a patient with that id number.')
        
        elif option== 9: #displays all appointments
            display_dictionary_values(appointments)
        
        elif option== 10: #displays all doctors
            display_dictionary_values(doctors)
        
        elif option== 11: #displays all patients
            display_dictionary_values(patients)
        
        else: #printed when option is not found
            print('That selection was not recognised.')
Example #20
0
     Doctor_ = Doctor(Doctor_ID,Doctor_Address)
     
     #pickle to file:
     getfilename_ = "doctor.txt"
     getfilename_2 = "doctor_unpickled.txt"
     getstring_ = Person_.__str__()+','+Doctor_.__str__()
     pickle_to_file(getfilename_,getstring_,getfilename_2)
     
 elif selection == 3:
     #Create Appointment Object:
     Patient_ID = input("Enter Patient ID Number : ")
     Doctor_ID = input("Enter Doctor ID Number : ")
     Appointment_time = input("Enter Appointment time dd/mm/yyyy: ")
     Appointment_Memo = input("Enter Appointment Memo : ")
     
     Appointment_ = Appointment(Patient_ID, Doctor_ID, Appointment_time, Appointment_Memo)
     
     #pickle to file:
     getfilename_ = "appointment.txt"
     getfilename_2 = "appointment_unpickled.txt"
     getstring_ = Appointment_.__str__()
     pickle_to_file(getfilename_,getstring_,getfilename_2)
     
 elif selection == 4:
     #def display_list(filename,NameofList):
     getfilename_ = "patient_unpickled.txt"
     display_list(getfilename_,"Patients")
     
 elif selection == 5:
     getfilename_ = "doctor_unpickled.txt"
     display_list(getfilename_,"Doctors") 
Example #21
0
class AppointmentBase(tk.Toplevel):
    # root:
    #     no space needed
    #     variable 'appointment' can be set to None

    isopen = False

    def __init__(self, root, appointment_id=None):
        AppointmentBase.isopen = True

        # Variables
        self.log = logging.getLogger(__name__)
        self.colour = Colours.calendarbase
        self.relief = Relief.calendarbase
        self.root = root
        self.appointment_id = appointment_id
        self.dataappointment = DataAppointment()
        self.datapatient = DataPatient()
        self.datadoctor = DataDoctor()

        # Build Window
        tk.Toplevel.__init__(self, root, bg=self.colour['frame'])
        self.title('Appointment')
        self.protocol('WM_DELETE_WINDOW', self.Close)

        # Configure Window
        for i in range(4):
            self.grid_columnconfigure(i, weight=1)

        self.grid_rowconfigure(0, weight=0)
        self.grid_rowconfigure(1, weight=1)
        # Widgets
        self.checkbutton = tk.Button(
            self,
            text='Check',
            bg=self.colour['button'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'])
        self.seepatientbutton = tk.Button(
            self,
            text='See Patient',
            bg=self.colour['button'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'])
        self.typemenu = tk.Menubutton(self,
                                      text='Type',
                                      bg=self.colour['button'],
                                      relief=self.relief['button'])
        self.printbutton = tk.Button(
            self,
            text='Print',
            bg=self.colour['button'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'])
        self.savebutton = tk.Button(
            self,
            text='Save',
            bg=self.colour['savebutton'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'],
            command=self.SaveAppointment)
        self.appointment = Appointment(self, self.appointment_id)

        # Place Widgets
        self.checkbutton.grid(row=0,
                              column=0,
                              sticky=tk.N + tk.E + tk.S + tk.W)
        self.seepatientbutton.grid(row=0,
                                   column=1,
                                   sticky=tk.N + tk.E + tk.S + tk.W)
        self.typemenu.grid(row=0, column=2, sticky=tk.N + tk.E + tk.S + tk.W)
        self.printbutton.grid(row=0,
                              column=3,
                              sticky=tk.N + tk.E + tk.S + tk.W)
        self.savebutton.grid(row=0, column=4, sticky=tk.N + tk.E + tk.S + tk.W)
        self.appointment.grid(row=1,
                              column=0,
                              columnspan=5,
                              sticky=tk.N + tk.S + tk.E + tk.W)

    # Method to save the current appointment to the database
    def SaveAppointment(self, event=None):
        try:
            appointment = self.dataappointment.View(self.appointment_id)
        except:
            appointment = [{}, {}]

        fields = self.appointment.Get_Fields()
        for key in fields:
            appointment[1][key] = fields[key]

        if 'patient_id' not in appointment[1]:
            try:
                patient = self.datapatient.View(
                    appointment[1]['firstname'].lower() +
                    appointment[1]['lastname'].lower())
                appointment[1]['patient_id'] = patient[0]['_id']
            except:
                print 'failed to get patient id'
        del appointment[1]['firstname']
        del appointment[1]['lastname']

        self.dataappointment.Write(appointment)

        self.Close()

    def Close(self):
        AppointmentBase.isopen = False
        self.root.appointment = None
        self.dataappointment.Close()
        self.appointment.Close()
        self.destroy()
Example #22
0
    def __init__(self, root, appointment_id=None):
        AppointmentBase.isopen = True

        # Variables
        self.log = logging.getLogger(__name__)
        self.colour = Colours.calendarbase
        self.relief = Relief.calendarbase
        self.root = root
        self.appointment_id = appointment_id
        self.dataappointment = DataAppointment()
        self.datapatient = DataPatient()
        self.datadoctor = DataDoctor()

        # Build Window
        tk.Toplevel.__init__(self, root, bg=self.colour['frame'])
        self.title('Appointment')
        self.protocol('WM_DELETE_WINDOW', self.Close)

        # Configure Window
        for i in range(4):
            self.grid_columnconfigure(i, weight=1)

        self.grid_rowconfigure(0, weight=0)
        self.grid_rowconfigure(1, weight=1)
        # Widgets
        self.checkbutton = tk.Button(
            self,
            text='Check',
            bg=self.colour['button'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'])
        self.seepatientbutton = tk.Button(
            self,
            text='See Patient',
            bg=self.colour['button'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'])
        self.typemenu = tk.Menubutton(self,
                                      text='Type',
                                      bg=self.colour['button'],
                                      relief=self.relief['button'])
        self.printbutton = tk.Button(
            self,
            text='Print',
            bg=self.colour['button'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'])
        self.savebutton = tk.Button(
            self,
            text='Save',
            bg=self.colour['savebutton'],
            highlightthickness=0,
            activebackground=self.colour['buttonactive'],
            relief=self.relief['button'],
            command=self.SaveAppointment)
        self.appointment = Appointment(self, self.appointment_id)

        # Place Widgets
        self.checkbutton.grid(row=0,
                              column=0,
                              sticky=tk.N + tk.E + tk.S + tk.W)
        self.seepatientbutton.grid(row=0,
                                   column=1,
                                   sticky=tk.N + tk.E + tk.S + tk.W)
        self.typemenu.grid(row=0, column=2, sticky=tk.N + tk.E + tk.S + tk.W)
        self.printbutton.grid(row=0,
                              column=3,
                              sticky=tk.N + tk.E + tk.S + tk.W)
        self.savebutton.grid(row=0, column=4, sticky=tk.N + tk.E + tk.S + tk.W)
        self.appointment.grid(row=1,
                              column=0,
                              columnspan=5,
                              sticky=tk.N + tk.S + tk.E + tk.W)
Example #23
0
def main():
    """ three lists to store patients, doctors and appointments """
    patients = []    
    doctors = []
    appointments = []
    
    while True:
        print()
        """ options choose from """
        print("*****Clinic******")
        print("1. To add a patient")
        print("2. To add a doctor")
        print("3. To make an appointment")
        print("4. To display all patients")
        print("5. To display all doctors")
        print("6. To display all appointments")
        print("7. To display appointments for a specific individual (doctor or patient)")
        print("0. To quit")
        
        print()
        
        response = input()                                                              # getting an input from the user
        
        if response == "0": break
        elif response == "1":
            patient = Patient()
            patient.name = input("Enter the name of the patient? \n")
            patient.age = input("Enter age of the patient? \n")
            patient.identity = input("The patients ID number? \n")
            patient.address = input("The patients address? \n")
            patient.number_of_visits = input("The patients number of visits? \n")
            
            patients.append(patient)
            
        elif response == "2":                                           
            doctor = Doctor()                                                           # creating an object variable doctor
            """ getting object variables """
            doctor.name = input("Enter the name of the doctor? \n")
            doctor.age = input("Enter age of the doctor? \n")
            doctor.identity = input("The doctors ID number? \n")
            doctor.address = input("The doctors address? \n")  
            
            doctors.append(doctor)                                                      # appending the object doctor to a list doctors  
            
        elif response == "3":
            appointment = Appointment()
            
            appointment.patients_identity = input("Enter patient's ID number? \n")
            appointment.doctors_identity = input("Enter doctor's ID number? \n")
            appointment.timestamp = input("Enter date and time? \n")
            appointment.memo = input("Enter memorundum of the appointment? \n")
            
            appointments.append(appointment)                                            # adding the oject appointment to list appointments
            
        elif response == "4":
            control = 1
            for item in patients:
                print("Patient No.", control)
                item.display()
                control +=1
                print()
                
        elif response == "5":
            control = 1
            for item in doctors:
                print("Doctor No.", control)
                item.display()
                control +=1
                print()       
                
        elif response == "6":
            for item in appointments:
                print(item)
                print()
            
        
        elif response == "7":
            user_id = input("Enter ID number for which you want to check appointments scheduled? \n ")
            print("Scheduled appointment(s) for", user_id, "are as follows: ")
            """ looping through the list appointment and comparing id's"""
            for item in appointments:
                if user_id == item.patients_identity:
                    print(item.timestamp)
                
                elif user_id == item.doctors_identity:
                    print(item)
                    
        else:
            print("The value entered is not in the option manu.")
            print("Please enter value available in the menu")
Example #24
0
 def bookAppointment(self):
     print('Please Enter the following information.')
     print('1. First Name')
     firstName = input()
     print('2. Surname')
     lastName = input()
     print('3. Telephone')
     phone = input()
     print('4. Date of Birth (dd//MM//YYYY) format')
     dateOfBirth = input()
     print('Country of Origin')
     countryOfOrigin = input()
     # creating patient object
     patient = Patient(firstName, lastName, phone, dateOfBirth,
                       countryOfOrigin)
     print('Succesful register!')
     print('**************************************\n')
     print(
         'Now please enter the time you want to make an appointment (hour 8-14)'
     )
     hour = input()
     print('\n')
     # validation of hour goes here
     while (True):
         if hour.isdigit():
             hourInt = int(hour)
             if hourInt >= 8 and hourInt <= 14:
                 break
             else:
                 print('Please enter valid input hour')
                 hour = input()
         else:
             print('Please enter valid input hour')
             hour = input()
     # ...
     schedules = self.findSchedules(hourInt)
     print('Available doctors are: ')
     index = 1
     for schedule in schedules:
         print(
             str(index) + ') ' + schedule.getDoctor().getFriendlyName() +
             ' - ' + str(schedule.getStartHour()) + ' to ' +
             str(schedule.getEndHour()))
         index += 1
     # ...
     print('Choose a appointment 1 - ' + str(index - 1))
     indexRead = input()
     print('\n')
     # validation goes here
     valid = False
     indexReadInt = 0
     while (not valid):
         if indexRead.isdigit():
             indexReadInt = int(indexRead)
             if indexReadInt > 0 and indexReadInt < index:
                 valid = True
             else:
                 print('Enter a index in interval 1 - ' + str(index - 1))
         else:
             print('Enter a index in interval 1 - ' + str(index - 1))
     # creating appointment object
     appointment = Appointment(schedules[indexReadInt], patient)
     self.appointments.append(appointment)
     print('Congrats! You have made a appointment')
     print('**************************************\n')
     return True
Example #25
0
class AppointmentBase(tk.Toplevel):
    # root:
    #     no space needed
    #     variable 'appointment' can be set to None
    
    isopen = False
    
    def __init__(self,root, appointment_id = None):
        AppointmentBase.isopen = True
        
        # Variables
        self.log = logging.getLogger(__name__)
        self.colour = Colours.calendarbase
        self.relief = Relief.calendarbase
        self.root = root
        self.appointment_id = appointment_id
        self.dataappointment = DataAppointment()
        self.datapatient = DataPatient()
        self.datadoctor = DataDoctor()
        
        # Build Window
        tk.Toplevel.__init__(self,root,bg=self.colour['frame'])
        self.title('Appointment')
        self.protocol('WM_DELETE_WINDOW', self.Close)

        # Configure Window
        for i in range(4): self.grid_columnconfigure(i,weight=1)
        
        self.grid_rowconfigure(0,weight=0)
        self.grid_rowconfigure(1,weight=1)
        # Widgets
        self.checkbutton = tk.Button(self, text='Check', bg=self.colour['button'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'])
        self.seepatientbutton = tk.Button(self, text='See Patient', bg=self.colour['button'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'])
        self.typemenu = tk.Menubutton(self, text='Type', bg=self.colour['button'], relief=self.relief['button'])
        self.printbutton = tk.Button(self, text='Print', bg=self.colour['button'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'])
        self.savebutton = tk.Button(self, text='Save', bg=self.colour['savebutton'], highlightthickness=0, activebackground=self.colour['buttonactive'], relief=self.relief['button'], command=self.SaveAppointment)
        self.appointment = Appointment(self, self.appointment_id)
        
        # Place Widgets
        self.checkbutton.grid(row=0,column=0,sticky=tk.N+tk.E+tk.S+tk.W)
        self.seepatientbutton.grid(row=0,column=1,sticky=tk.N+tk.E+tk.S+tk.W)
        self.typemenu.grid(row=0,column=2,sticky=tk.N+tk.E+tk.S+tk.W)
        self.printbutton.grid(row=0,column=3,sticky=tk.N+tk.E+tk.S+tk.W)
        self.savebutton.grid(row=0,column=4,sticky=tk.N+tk.E+tk.S+tk.W)
        self.appointment.grid(row=1,column=0,columnspan=5, sticky=tk.N+tk.S+tk.E+tk.W)

    # Method to save the current appointment to the database
    def SaveAppointment(self, event=None):
        try:
            appointment = self.dataappointment.View(self.appointment_id)
        except:
            appointment = [{},{}]

        fields = self.appointment.Get_Fields()
        for key in fields:
            appointment[1][key] = fields[key]
            
        if 'patient_id' not in appointment[1]:
            try:
                patient = self.datapatient.View(appointment[1]['firstname'].lower()+appointment[1]['lastname'].lower())
                appointment[1]['patient_id'] = patient[0]['_id']
            except:
                print 'failed to get patient id'
        del appointment[1]['firstname']
        del appointment[1]['lastname']

        self.dataappointment.Write(appointment)

        self.Close()
        
    def Close(self):
        AppointmentBase.isopen = False
        self.root.appointment = None
        self.dataappointment.Close()
        self.appointment.Close()
        self.destroy()