예제 #1
0
 private void DeleteProfessional(Professional professional, int id)
 {
     _doc = new DocumentManager(_db);
     List<Follower> follow = _db.SelectRequest.SelectFollowForPro(id);
     foreach (var f in follow)
     {
         _doc.DeleteFollowerFile(professional.ProfessionalId, f.Patient.PatientId);
     }
     _db.SuppressionRequest.ProfessionnalSuppression(professional);
 }
예제 #2
0
        public void CreatePatientAndPro()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                DocumentManager dm = new DocumentManager(context);
                User[] users = GetUsers();
                Professional pro = context.AddRequest.AddProfessional(users[0], "Medecin");
                Professional pro1 = context.AddRequest.AddProfessional(users[1], "Infirmier");
                Professional pro2 = context.AddRequest.AddProfessional(users[2], "Medecin");
                Professional pro3 = context.AddRequest.AddProfessional(users[3], "Medecin");
                Patient patient = context.AddRequest.AddPatient(users[4]);
                dm.CreateEmptyFile(patient.PatientId.ToString());
                Patient patient1 = context.AddRequest.AddPatient(users[5]);
                dm.CreateEmptyFile(patient1.PatientId.ToString());


                context.AddRequest.AddFollow(patient.PatientId, pro1.ProfessionalId);
                dm.CreateEmptyFile(patient.PatientId + "$" + pro1.ProfessionalId);

                context.AddRequest.AddFollow(patient.PatientId, pro2.ProfessionalId);
                dm.CreateEmptyFile(patient.PatientId + "$" + pro2.ProfessionalId);

                context.AddRequest.AddFollow(patient.PatientId, pro3.ProfessionalId);
                dm.CreateEmptyFile(patient.PatientId + "$" + pro3.ProfessionalId);

                Patient p = context.SelectRequest.SelectPatient(patient.PatientId);
                Console.WriteLine("Nom : {0}   Prénom : {1}", p.User.LastName, p.User.FirstName);
                Assert.AreEqual(p.PatientId, patient.PatientId);
                Patient p1 = context.SelectRequest.SelectPatient(patient1.PatientId);
                Console.WriteLine("Nom : {0}   Prénom : {1} ", p1.User.LastName, p1.User.FirstName);
                Assert.AreEqual(p1.PatientId, patient1.PatientId);

                Professional Pro = context.SelectRequest.SelectProfessional(pro.ProfessionalId);
                Console.WriteLine("Nom : {0}   Prénom : {1}", Pro.User.LastName, Pro.User.FirstName);
                Assert.AreEqual(Pro.ProfessionalId, pro.ProfessionalId);
                Professional Pro1 = context.SelectRequest.SelectProfessional(pro1.ProfessionalId);
                Console.WriteLine("Nom : {0}   Prénom : {1}", Pro1.User.LastName, Pro1.User.FirstName);
                Assert.AreEqual(Pro1.ProfessionalId, pro1.ProfessionalId);
                Professional Pro2 = context.SelectRequest.SelectProfessional(pro2.ProfessionalId);
                Console.WriteLine("Nom : {0}   Prénom : {1}", Pro2.User.LastName, Pro2.User.FirstName);
                Assert.AreEqual(Pro2.ProfessionalId, pro2.ProfessionalId);
                Professional Pro3 = context.SelectRequest.SelectProfessional(pro3.ProfessionalId);
                Console.WriteLine("Nom : {0}   Prénom : {1}", Pro3.User.LastName, Pro3.User.FirstName);
                Assert.AreEqual(Pro3.ProfessionalId, pro3.ProfessionalId);
            }
        }
예제 #3
0
        public void CreateMessage()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                DocumentManager dm = new DocumentManager(context);
                List<Professional> receivers = new List<Professional>();
                foreach (var f in context.SelectRequest.SelectFollowForPatient(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId))
                {
                    receivers.Add(f.Professionnal);
                }
                dm.CreateMessage(receivers, context.SelectRequest.SelectUser("ClementR", "ClementR"), "Coucou", "J'ai un pb", context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF"));
                DocumentSerializable document = dm.SeeDocument(context.SelectRequest.SelectProfessional(context.SelectRequest.SelectProfessional("ClementR", "ClementR").ProfessionalId), context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF"));
                Assert.AreEqual(document.Messages.Count, 2);

                dm.DeleteDoc(document.Messages.First(), context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId+"$"+ context.SelectRequest.SelectProfessional("ClementR", "ClementR").ProfessionalId);
                DocumentSerializable documents1 = dm.SeeDocument(context.SelectRequest.SelectProfessional(context.SelectRequest.SelectProfessional("ClementR", "ClementR").ProfessionalId), context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF"));
                Assert.AreEqual(documents1.Messages.Count, 0);
            }
        }
예제 #4
0
        public Data getUser(string pseudo, string password)
        {
            int id = _db.SelectRequest.SelectUser(pseudo, password).UserId;
            DocumentManager _doc = new DocumentManager(_db);
            DocumentSerializable doc;
            Dictionary<Patient, Professional[]> follower = _db.SelectRequest.SelectAllFollow(id);
            User user = _db.SelectRequest.SelectUser(id);
            Professional test = _db.SelectRequest.SelectProfessional(id);
            if (test == null)
            {
                doc = _doc.SeeDocument(id);
            }
            else
            {

                doc = new DocumentSerializable(new List<Message>(), new List<Prescription>());

                //follower.Select(p => follower.Keys).

                foreach (var patient in follower)
                {

                    foreach (var message in _doc.SeeDocument(id, patient.Key.PatientId).Messages)
                    {
                        doc.Messages.Add(message);
                    }
                    foreach (var prescription in _doc.SeeDocument(id, patient.Key.PatientId).Prescriptions)
                    {
                        doc.Prescriptions.Add(prescription);
                    }
                }
            }

            Data swag = new Data(doc, follower, user);
            return swag;
        }
예제 #5
0
        public void PostPrescription()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                DocumentManager dm = new DocumentManager(context);
                List<Professional> listPro = new List<Professional>();
                listPro.Add(context.SelectRequest.SelectProfessional("ClementR", "ClementR"));
                listPro.Add(context.SelectRequest.SelectProfessional("SimonF", "SimonF"));
                User Sender = context.SelectRequest.SelectUser("OlivierS", "OlivierS");
                string Title = "My Title2";
                Patient P = context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF");
                string DocPath = P.PatientId + "$" + Sender.UserId;
                ImageManager img = new ImageManager();
                Image i = img.LoadImage(Sender.Photo);
                Prescription p = new Prescription(Title, Sender.Photo, Sender, listPro, P);

                _documentService.putPrescription(p);

                DocumentSerializable document = dm.SeeDocument(context.SelectRequest.SelectProfessional("ClementR", "ClementR"), context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF"));

                foreach (var prescription in document.Prescriptions)
                {
                    if (prescription.Title == "MyTitle2")
                    {
                        _documentService.postPrescripton(context.SelectRequest.SelectPatient("GuillaumF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("AntoineR", "AntoineR").ProfessionalId, prescription.Date);

                        Assert.That(prescription.Receivers.Count == 3);

                        foreach (var pro in prescription.Receivers)
                        {
                            _documentService.deletePrescription(prescription, prescription.DocPath);
                        }

                        Assert.That(prescription.Receivers.Count == 2);

                    }
                }
            }
        }
예제 #6
0
        public void PutDocPrescription()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                DocumentManager dm = new DocumentManager(context);
                List<Professional> listPro = new List<Professional>();
                listPro.Add(context.SelectRequest.SelectProfessional("ClementR", "ClementR"));
                listPro.Add(context.SelectRequest.SelectProfessional("SimonF", "SimonF"));
                User Sender = context.SelectRequest.SelectUser("OlivierS", "OlivierS");
                string Title = "My Title";
                Patient P = context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF");
                string DocPath = P.PatientId + "$" + Sender.UserId;
                Prescription p = new Prescription(Title, Sender.Photo, Sender, listPro, P);

                _documentService.putPrescription(p);
                DocumentSerializable document = dm.SeeDocument(context.SelectRequest.SelectProfessional("OlivierS", "OlivierS"), context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF"));
                Assert.AreEqual(document.Prescriptions.Count, 3);
            }
        }
예제 #7
0
        public void PostMessage()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                DocumentManager dm = new DocumentManager(context);
                List<Professional> listPro = new List<Professional>();
                listPro.Add(context.SelectRequest.SelectProfessional("ClementR", "ClementR"));
                listPro.Add(context.SelectRequest.SelectProfessional("SimonF", "SimonF"));
                User Sender = context.SelectRequest.SelectUser("AntoineR", "AntoineR");
                string Title = "My Title2";
                string Contents = "My Contents";
                Patient P = context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF");

                _documentService.putMessage(listPro, Sender, Title, Contents, P);


                DocumentSerializable document = dm.SeeDocument(context.SelectRequest.SelectProfessional("ClementR", "ClementR"), context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF"));

                foreach (var message in document.Messages)
                {
                    if (message.Title == "MyTitle2")
                    {
                        _documentService.postMessage(context.SelectRequest.SelectPatient("GuillaumF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("AntoineR", "AntoineR").ProfessionalId, message.Date);

                        Assert.That(message.Receivers.Count == 3);

                        foreach (var pro in message.Receivers)
                        {
                            _documentService.deleteMessage(pro.ProfessionalId, message.Patient.PatientId, message.Date);
                        }

                        Assert.That(message.Receivers.Count == 2);

                    }
                }
            }

        }
예제 #8
0
        public void PutDocMessage()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                DocumentManager dm = new DocumentManager(context);
                List<Professional> listPro = new List<Professional>();
                listPro.Add(context.SelectRequest.SelectProfessional("ClementR", "ClementR"));
                listPro.Add(context.SelectRequest.SelectProfessional("SimonF", "SimonF"));
                User Sender = context.SelectRequest.SelectUser("AntoineR", "AntoineR");
                string Title = "My Title";
                string Contents = "My Contents";
                Patient P = context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF");

                _documentService.putMessage(listPro, Sender, Title, Contents, P);

                DocumentSerializable document = dm.SeeDocument(context.SelectRequest.SelectProfessional("ClementR", "ClementR"), context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF"));
                Assert.AreEqual(document.Messages.Count, 1);


            }
        }
예제 #9
0
        public void PutAndDeleteProfessional()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                _doc = new DocumentManager(context);
                User userTest = new User()
                {
                    FirstName = "TEST",
                    LastName = "TEST",
                    Birthdate = DateTime.Now,
                    Adress = "72 avenue maurice thorez",
                    City = "Ivry-sur-Seine",
                    Postcode = 12345,
                    PhoneNumber = 0606066606,
                    Pseudo = "test",
                    Password = "******",
                    Photo = "yolo"
                };

                ProfessionalCreation newPro = new ProfessionalCreation(userTest, "testeur");
                _professionalService.putProfessional(newPro);
                Assert.IsNotNull(context.SelectRequest.SelectProfessional("test", "mdp"));

                _professionalService.DeleteProfessionalCheck(context.SelectRequest.SelectProfessional("test", "mdp").ProfessionalId);
                Assert.IsNull(context.SelectRequest.SelectProfessional("test", "mdp"));
            }
        }
예제 #10
0
        public void PutFollower()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                _doc = new DocumentManager(context);
                FollowerCreation myNewFollow = new FollowerCreation(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId,
                    context.SelectRequest.SelectProfessional("AntoineR", "AntoineR").ProfessionalId);
                _followerService.PutFollower(myNewFollow);

                Dictionary<Patient, Professional[]> allFollow = _followerService.getDocument(context.SelectRequest.SelectProfessional("ClementR", "ClementR").ProfessionalId);
                foreach (var pair in allFollow)
                {
                    Assert.AreEqual(pair.Value[0].ProfessionalId, context.SelectRequest.SelectProfessional("AntoineR", "AntoineR").ProfessionalId);
                }

                _doc.DeleteFollowerFile(context.SelectRequest.SelectProfessional("AntoineR", "AntoineR").ProfessionalId, context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId);
                context.SuppressionRequest.FollowerSuppression(context.SelectRequest.SelectOneFollow(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("AntoineR", "AntoineR").ProfessionalId));
                Assert.IsNull(context.SelectRequest.SelectOneFollow(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("AntoineR", "AntoineR").ProfessionalId));
            }
        }
예제 #11
0
        public void DeleteFollow()
        {
            using (ArchiViteContext context = new ArchiViteContext())
            {
                FollowerService _followerService = new FollowerService();
                DocumentManager dm = new DocumentManager(context);
                dm.DeleteFollowerFile(context.SelectRequest.SelectProfessional("SimonF", "SimonF").ProfessionalId, context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId);
                context.SuppressionRequest.FollowerSuppression(context.SelectRequest.SelectOneFollow(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("SimonF", "SimonF").ProfessionalId));
                Assert.IsNull(context.SelectRequest.SelectOneFollow(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId, context.SelectRequest.SelectProfessional("SimonF", "SimonF").ProfessionalId));

                FollowerCreation myNewFollow = new FollowerCreation(context.SelectRequest.SelectPatient("GuillaumeF", "GuillaumeF").PatientId,
                    context.SelectRequest.SelectProfessional("SimonF", "Simonf").ProfessionalId);
                _followerService.PutFollower(myNewFollow);
            }
        }
예제 #12
0
 public void DeleteData()
 {
     using (ArchiViteContext context = new ArchiViteContext())
     {
         DocumentManager _doc = new DocumentManager(context);
         var selectQuery1 = context.Follower.ToList();
         foreach (var follow in selectQuery1)
         {
             _doc.DeleteFollowerFile(follow.ProfessionnalId, follow.PatientId);
             context.SuppressionRequest.FollowerSuppression(follow);
             context.SaveChanges();
         }
         var selectQuery2 = context.Patient.ToList();
         foreach (var patient in selectQuery2)
         {
             _doc.DeletePatientFile(patient.PatientId);
             context.Patient.Remove(patient);
             context.SaveChanges();
         }
         var selectQuery3 = context.Professional.ToList();
         foreach (var pro in selectQuery3)
         {
             context.Professional.Remove(pro);
             context.SaveChanges();
         }
         var selectQuery4 = context.User.ToList();
         foreach (var user in selectQuery4)
         {
             context.User.Remove(user);
             context.SaveChanges();
         }
         Assert.IsFalse(context.Follower.Any());
         Assert.IsFalse(context.Patient.Any());
         Assert.IsFalse(context.Professional.Any());
         Assert.IsFalse(context.User.Any());
     }
 }