Exemple #1
0
        public void Patient_SearchByName_ReturnsAllMatches()
        {
            Patient patient1 = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            patient1.Save();
            Patient patient2 = new Patient("Johnathan", "john123", "123", new DateTime(1996, 04, 25));

            patient2.Save();
            Patient patient3 = new Patient("john", "john123", "123", new DateTime(1996, 04, 25));

            patient3.Save();
            Patient patient4 = new Patient("JOHNNY", "john123", "123", new DateTime(1996, 04, 25));

            patient4.Save();
            Patient patient5 = new Patient("Samuel", "john123", "123", new DateTime(1996, 04, 25));

            patient5.Save();

            List <Patient> testList    = Patient.SearchByName("john");
            List <Patient> controlList = new List <Patient> {
                patient1, patient2, patient3, patient4
            };

            Assert.Equal(controlList, testList);
        }
Exemple #2
0
        public void Patient_Find_FindsPatientInDB()
        {
            Patient controlPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            controlPatient.Save();

            Patient testPatient = Patient.Find(controlPatient.Id);

            Assert.Equal(controlPatient, testPatient);
        }
Exemple #3
0
        public void Test_Find_FindsPatientInDatabase()
        {
            Patient testPatient = new Patient("Minh", "June 30 1993", 5);

            testPatient.Save();

            Patient foundPatient = Patient.Find(testPatient.GetId());

            Assert.Equal(testPatient, foundPatient);
        }
Exemple #4
0
        public void Patient_Save_SaveToDatabase()
        {
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();

            Patient testPatient = Patient.GetAll()[0];

            Assert.Equal(newPatient, testPatient);
        }
Exemple #5
0
        public void Patient_Update_UpdatePatientInfo()
        {
            Patient patient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            patient.Save();

            patient.Update("Tom", "tom123", "123");

            Patient controlPatient = new Patient("Tom", "tom123", "123", new DateTime(1996, 04, 25), patient.Id);

            Assert.Equal(controlPatient, patient);
        }
        public void Appointment_Equals_AppointmentEqualsAppointment()
        {
            Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();
            Appointment controlAppointment = new Appointment(new DateTime(2017, 05, 21), newDoctor.Id, newPatient.Id, "Yearly physical");
            Appointment testAppointment    = new Appointment(new DateTime(2017, 05, 21), newDoctor.Id, newPatient.Id, "Yearly physical");

            Assert.Equal(controlAppointment, testAppointment);
        }
Exemple #7
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            Patient testPatient = new Patient("John", "April 1 1954", 5);

            //Act
            testPatient.Save();
            Patient savedPatient = Patient.GetAll()[0];

            int result = savedPatient.GetId();
            int testId = testPatient.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
Exemple #8
0
        public void  Test_Save_SavesToDatabase()
        {
            //Arrange
            Patient testPatient = new Patient("John", "April 1 1945", 5);

            //Act
            testPatient.Save();
            List <Patient> result   = Patient.GetAll();
            List <Patient> testList = new List <Patient> {
                testPatient
            };

            //Assert
            Assert.Equal(testList, result);
        }
Exemple #9
0
        public void Patient_Login_ReturnsTrue()
        {
            Patient patient1 = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            patient1.Save();
            Patient patient2 = new Patient("Tom", "tom123", "12323", new DateTime(1996, 04, 25));

            patient2.Save();

            List <Patient> testList    = Patient.Login("john123", "123");
            List <Patient> controlList = new List <Patient> {
                patient1
            };

            Assert.Equal(controlList, testList);
        }
        public void Appointment_GetPatientName_ReturnsNameOfPatient()
        {
            Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();
            Appointment newAppointment = new Appointment(new DateTime(2017, 05, 21), newDoctor.Id, newPatient.Id, "Yearly physical");

            newAppointment.Save();

            string patient = newAppointment.GetPatientName();

            Assert.Equal("John", patient);
        }
        public void Appointment_Save_SaveToDatabase()
        {
            Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();
            Appointment newAppointment = new Appointment(new DateTime(2017, 05, 21), newDoctor.Id, newPatient.Id, "Yearly physical");

            newAppointment.Save();

            Appointment testAppointment = Appointment.GetAll()[0];

            Assert.Equal(newAppointment, testAppointment);
        }
Exemple #12
0
        public void Patient_CreateAppointment_CreatesAppointmentObjectForPatient()
        {
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();
            Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();
            newPatient.CreateAppointment(new DateTime(2017, 06, 16, 15, 30, 00), newDoctor, "Yearly physical");

            List <Appointment> testList    = newPatient.GetAppointments();
            List <Appointment> controlList = new List <Appointment> {
                new Appointment(new DateTime(2017, 06, 16, 15, 30, 00), newDoctor.Id, newPatient.Id, "Yearly physical", newPatient.GetAppointments()[0].Id)
            };

            Assert.Equal(controlList, testList);
        }
Exemple #13
0
        public void Patient_AddDoctor_AssignsDoctorToPatient()
        {
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();
            Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();

            newPatient.AddDoctor(newDoctor);
            List <Doctor> testList    = newPatient.GetDoctors();
            List <Doctor> controlList = new List <Doctor> {
                newDoctor
            };

            Assert.Equal(controlList, testList);
        }
        public void Doctor_AddPatient_AssignsPatientToDoctor()
        {
            Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();

            newDoctor.AddPatient(newPatient);
            List <Patient> testList    = newDoctor.GetPatients();
            List <Patient> controlList = new List <Patient> {
                newPatient
            };

            Assert.Equal(controlList, testList);
        }
Exemple #15
0
        public void Patient_Delete_DeletesSinglePatient()
        {
            Patient patient1 = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            patient1.Save();
            Patient patient2 = new Patient("Samuel", "john123", "123", new DateTime(1996, 04, 25));

            patient2.Save();

            patient1.DeleteSinglePatient();

            List <Patient> testList    = Patient.GetAll();
            List <Patient> controlList = new List <Patient> {
                patient2
            };

            Assert.Equal(controlList, testList);
        }
Exemple #16
0
        public void Patient_DeleteAppointment_DeletesAllOfPatientAppointments()
        {
            Doctor doctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            doctor.Save();
            Patient patient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            patient.Save();

            Appointment controlAppointment1 = new Appointment(new DateTime(2017, 06, 25), doctor.Id, patient.Id, "Yearly physical");
            Appointment controlAppointment2 = new Appointment(new DateTime(2017, 05, 21), doctor.Id, patient.Id, "Yearly physical");

            patient.DeleteAppointments();
            List <Appointment> testList    = patient.GetAppointments();
            List <Appointment> controlList = new List <Appointment> {
            };

            Assert.Equal(testList, controlList);
        }
Exemple #17
0
        public void Patient_GetMissedAppointments_ReturnsAllMissedAppointments()
        {
            DateTime now       = new DateTime(2017, 06, 22);
            Doctor   newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();
            newPatient.CreateAppointment(new DateTime(2017, 05, 21), newDoctor, "Yearly physical");
            newPatient.CreateAppointment(new DateTime(2017, 05, 26), newDoctor, "Heart check");
            newPatient.CreateAppointment(new DateTime(2017, 06, 25), newDoctor, "Vaccination");
            List <Appointment> testList    = newPatient.GetMissedAppointments(now);
            List <Appointment> controlList = new List <Appointment>
            {
                new Appointment(new DateTime(2017, 05, 21), newDoctor.Id, newPatient.Id, "Yearly physical", newPatient.GetAppointments()[0].Id),
                new Appointment(new DateTime(2017, 05, 26), newDoctor.Id, newPatient.Id, "Heart check", newPatient.GetAppointments()[1].Id)
            };

            Assert.Equal(controlList, testList);
        }
Exemple #18
0
        public void Patient_DeleteDoctorRelationship_DeletesRelationship()
        {
            Patient patient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            patient.Save();
            Doctor doctor1 = new Doctor("Tom", "tom567", "567", "Cardiology");

            doctor1.Save();
            Doctor doctor2 = new Doctor("John", "john567", "567", "Pediatrics");

            doctor2.Save();

            patient.AddDoctor(doctor1);
            patient.AddDoctor(doctor2);
            patient.DeleteDoctorRelationship(doctor1);

            List <Doctor> testList    = patient.GetDoctors();
            List <Doctor> controlList = new List <Doctor> {
                doctor2
            };

            Assert.Equal(controlList, testList);
        }
        public void Doctor_DeletePatientRelationship_DeletesRelationship()
        {
            Doctor doctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            doctor.Save();
            Patient patient1 = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            patient1.Save();
            Patient patient2 = new Patient("Tom", "john123", "123", new DateTime(1996, 04, 25));

            patient2.Save();

            doctor.AddPatient(patient1);
            doctor.AddPatient(patient2);
            doctor.DeletePatientRelationship(patient1);

            List <Patient> testList    = doctor.GetPatients();
            List <Patient> controlList = new List <Patient> {
                patient2
            };

            Assert.Equal(controlList, testList);
        }
Exemple #20
0
        public void Patient_DeleteAppointment_DeletesSingleAppointment()
        {
            Doctor newDoctor = new Doctor("Tom", "tom567", "567", "Cardiology");

            newDoctor.Save();
            Patient newPatient = new Patient("John", "john123", "123", new DateTime(1996, 04, 25));

            newPatient.Save();
            Appointment appointment1 = new Appointment(new DateTime(2017, 05, 21), newDoctor.Id, newPatient.Id, "Yearly physical");

            appointment1.Save();
            Appointment appointment2 = new Appointment(new DateTime(2017, 06, 21), newDoctor.Id, newPatient.Id, "Yearly physical");

            appointment2.Save();

            newPatient.DeleteSingleAppointment(appointment1);

            List <Appointment> testList    = newPatient.GetAppointments();
            List <Appointment> controlList = new List <Appointment> {
                appointment2
            };

            Assert.Equal(controlList, testList);
        }
Exemple #21
0
 public HomeModule()
 {
     Get["/"] = _ => {
         return(View["index.cshtml"]);
     };
     Get["/doctors"] = _ => {
         return(View["doctor_login.cshtml"]);
     };
     Post["/doctors/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Doctor newDoctor = new Doctor(Request.Form["name"], Request.Form["username"], Request.Form["password"], Request.Form["specialty"]);
         newDoctor.Save();
         model.Add("newDoctor", newDoctor);
         return(View["doctor_login.cshtml", model]);
     };
     Get["/doctors/login"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         List <Doctor> loggedIn            = Doctor.Login(Request.Query["login-username"], Request.Query["login-password"]);
         if (loggedIn.Count == 0)
         {
             model.Add("login-status", false);
             return(View["doctor_login.cshtml", model]);
         }
         else
         {
             model.Add("doctor", loggedIn[0]);
             model.Add("appointments", loggedIn[0].GetAppointments());
             model.Add("patients", loggedIn[0].GetPatients());
             // model.Add("patients-delete", false);
             return(View["doctor.cshtml", model]);
         }
     };
     Get["/patients"] = _ => {
         return(View["patient_login.cshtml"]);
     };
     Post["/patients/new"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Patient newPatient = new Patient(Request.Form["name"], Request.Form["username"], Request.Form["password"], Request.Form["date"]);
         newPatient.Save();
         model.Add("newPatient", newPatient);
         return(View["patient_login.cshtml", model]);
     };
     Get["/patients/login"] = _ => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         List <Patient> loggedIn           = Patient.Login(Request.Query["login-username"], Request.Query["login-password"]);
         if (loggedIn.Count == 0)
         {
             model.Add("login-status", false);
             return(View["patient_login.cshtml", model]);
         }
         else
         {
             model.Add("patient", loggedIn[0]);
             model.Add("appointments", loggedIn[0].GetAppointments());
             model.Add("patient-doctors", loggedIn[0].GetDoctors());
             return(View["patient.cshtml", model]);
         }
     };
     Get["/patients/{id}/appointments/new"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         List <Doctor> allDoctors          = Doctor.GetAll();
         model.Add("patient-id", parameters.id);
         model.Add("patient-doctors", Patient.Find(parameters.id).GetDoctors());
         return(View["appointment_form.cshtml", model]);
     };
     Post["/patients/{id}/appointments/added"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Patient selectedPatient           = Patient.Find(parameters.id);
         selectedPatient.CreateAppointment(Request.Form["date"], Doctor.Find(Request.Form["doctor"]), Request.Form["description"]);
         model.Add("patient", selectedPatient);
         model.Add("appointments", selectedPatient.GetAppointments());
         model.Add("patient-doctors", selectedPatient.GetDoctors());
         return(View["patient.cshtml", model]);
     };
     Get["/patients/{id}/doctors/choose"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         List <Doctor> allDoctors          = Doctor.GetAll();
         model.Add("patient-id", parameters.id);
         model.Add("patient-doctors", Patient.Find(parameters.id).GetDoctors());
         model.Add("all-doctors", allDoctors);
         return(View["choose_doctor_form.cshtml", model]);
     };
     Post["/patients/{id}/doctors/added"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Patient selectedPatient           = Patient.Find(parameters.id);
         selectedPatient.AddDoctor(Doctor.Find(Request.Form["selected-doctor"]));
         model.Add("patient", selectedPatient);
         model.Add("appointments", selectedPatient.GetAppointments());
         model.Add("patient-doctors", selectedPatient.GetDoctors());
         return(View["patient.cshtml", model]);
     };
     Get["/doctors/{id}/patients/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Doctor selectedDoctor             = Doctor.Find(parameters.id);
         model.Add("doctor", selectedDoctor);
         model.Add("appointments", selectedDoctor.GetAppointments());
         model.Add("patients", selectedDoctor.GetPatients());
         model.Add("patients-delete", true);
         return(View["doctor.cshtml", model]);
     };
     Delete["/doctors/{id}/patients/delete"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Doctor selectedDoctor             = Doctor.Find(parameters.id);
         string patients = Request.Form["patient"];
         if (patients != null)
         {
             string[] values = patients.Split(',');
             foreach (string patientId in values)
             {
                 selectedDoctor.DeletePatientRelationship(Patient.Find(int.Parse(patientId)));
             }
         }
         model.Add("doctor", selectedDoctor);
         model.Add("appointments", selectedDoctor.GetAppointments());
         model.Add("patients", selectedDoctor.GetPatients());
         return(View["doctor.cshtml", model]);
     };
     Get["/patients/{id}/update"] = parameters => {
         Patient selectedPatient = Patient.Find(parameters.id);
         return(View["patient_update_form.cshtml", selectedPatient]);
     };
     Patch["/patients/{id}/update"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Patient selectedPatient           = Patient.Find(parameters.id);
         selectedPatient.Update(Request.Form["name"], Request.Form["username"], Request.Form["password"]);
         model.Add("patient", selectedPatient);
         model.Add("appointments", selectedPatient.GetAppointments());
         model.Add("patient-doctors", selectedPatient.GetDoctors());
         return(View["patient.cshtml", model]);
     };
     Get["/patients/{id}/search/doctors"] = parameters => {
         Dictionary <string, object> model = new Dictionary <string, object> {
         };
         Patient       selectedPatient     = Patient.Find(parameters.id);
         string        nameQuery           = Request.Query["name-search"];
         string        specialtyQuery      = Request.Query["specialty-search"];
         List <Doctor> results             = new List <Doctor> {
         };
         if (nameQuery != "" && specialtyQuery != "")
         {
             results = Doctor.CombineSearch(nameQuery, specialtyQuery);
         }
         else if (nameQuery != "")
         {
             results = Doctor.SearchByName(nameQuery);
         }
         else
         {
             results = Doctor.SearchBySpecialty(specialtyQuery);
         }
         model.Add("patient-id", parameters.id);
         model.Add("patient-doctors", Patient.Find(parameters.id).GetDoctors());
         model.Add("all-doctors", Doctor.GetAll());
         model.Add("show-results", true);
         model.Add("results", results);
         return(View["choose_doctor_form.cshtml", model]);
     };
 }