示例#1
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);
            }
        }
示例#2
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;
        }
示例#3
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);

                    }
                }
            }
        }
示例#4
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);
            }
        }
示例#5
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);

                    }
                }
            }

        }
示例#6
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);


            }
        }