コード例 #1
0
        public static void WorkAllDevices()
        {
            Random rnd = new Random();

            do
            {
                Thread.Sleep(180000);

                EntityModelContainer container = new EntityModelContainer();

                foreach (Device device in container.DeviceSet)
                {
                    int choice = rnd.Next(0, 50);

                    if (choice != 49)
                    {
                        MeasuredData newData = CreateMeasure(device, device.Patient);
                        AddMeasuredData(newData, device.Patient, device);
                    }
                    else
                    {
                        DeviceMessage message = CreateDeviceMessage(device);
                        AddDeviceMessage(message);
                    }
                }
            } while (true);
        }
コード例 #2
0
        private void AdministratorForm_Load(object sender, EventArgs e)
        {
            AdminName.Text = user.FullName;

            _container = new EntityModelContainer();

            MessageList.DataSource = (from patientMessage in user.Message.AsParallel()
                                      select new
            {
                Дата = patientMessage.Date.ToLongDateString(),
                Сообщение = patientMessage.Title,
                Статус = patientMessage.GetChecked(),
                Код = patientMessage.Id
            }).Union(from deviceMessage in user.DeviceMessage.AsParallel()
                     select new
            {
                Дата      = deviceMessage.Date.ToLongDateString(),
                Сообщение = deviceMessage.Title,
                Статус    = deviceMessage.GetChecked(),
                Код       = deviceMessage.Id
            }).ToList();

            MessageList.Update();

            MessageList.Columns[0].Width   = 117;
            MessageList.Columns[1].Width   = 170;
            MessageList.Columns[2].Width   = 100;
            MessageList.Columns[3].Visible = false;
        }
コード例 #3
0
        public static void AddHealthStatus(string info, DateTime creatingTime, Patient owner)
        {
            HealthStatus status = new HealthStatus();

            status.Status       = string.Empty;
            status.CreatingTime = creatingTime;                         // задание времени создания

            //  status.Number = GetHealthStatusCode();

            // задание связи
            EntityModelContainer container = new EntityModelContainer();

            owner          = container.PatientSet.Find(owner.UserCode);
            status.Patient = owner;

            container.HealthStatusSet.Add(status);                      // добавление в базу данных
            container.SaveChanges();

            status = container.HealthStatusSet.Find(status.Number);

            status.Status = info;

            // задание связи с пациентом
            owner.HealthStatus.Add(status);
            int code = owner.UserCode;

            status.OwnerCode = code;

            container.SaveChanges();
        }
コード例 #4
0
        private void ReadMessageForm_Load(object sender, EventArgs e)
        {
            _container = new EntityModelContainer();

            if (isDocMessage)
            {
                MessageTitle.Text = docMessage.Title;
                Doctor mesSender = (from doc in _container.DoctorSet.AsParallel()
                                    where doc.UserCode == docMessage.SenderCode
                                    select doc).ToList()[0];

                MessageSender.Text = mesSender.FullName;
                MessageDate.Text   = docMessage.Date.ToString();

                MessageText.Text = docMessage.Text;

                if (needSignUp)
                {
                    SignUpPatient.Visible = true;
                    this.Size             = new Size(358, 342);
                }
                else
                {
                    SignUpPatient.Visible = false;
                    this.Size             = new Size(358, 307);
                }
            }
        }
コード例 #5
0
        static string GetLogin(string fullName)
        {
            string login = string.Empty;

            string[] nameParts = fullName.Split();

            string surname = nameParts[0];

            login = ConverToEng(surname);

            EntityModelContainer container = new EntityModelContainer();

            int existCount = 0;
            int addCode    = -1;

            login = "******" + login;
            string newLogin = login;

            do
            {
                addCode++;
                if (addCode != 0)
                {
                    newLogin = login + "_" + addCode;
                }

                existCount = (from p in container.PatientSet where p.Login == newLogin select p).Count();
            } while (existCount != 0);

            return(newLogin);
        }
コード例 #6
0
        public static void GiveLoginPassword(string message, out string login, out string password, out bool exist)
        {
            login    = string.Empty;
            password = string.Empty;
            exist    = false;

            string messagePattern =
                @"Зарегистрирован\sновый\sпациент\s([\w,\s]*)\sс\sкодом\s([\d]*)\.\sТребуется\sпредоставление\sдоступа\.";

            string[] info = Regex.Split(message, messagePattern);

            EntityModelContainer container = new EntityModelContainer();
            Patient patient = container.PatientSet.Find(int.Parse(info[2]));

            if (patient.Login != "none")
            {
                exist = true;
            }
            else
            {
                login    = GetLogin(info[1]);
                password = GetPassword(info[1]);

                patient.Login    = login;
                patient.Password = password;
                container.SaveChanges();
            }
        }
コード例 #7
0
        private void PatientForm_Load(object sender, EventArgs e)
        {
            PatientName.Text = user.FullName;

            _container = new EntityModelContainer();

            // собираем результаты всех обследований за все время

            MedicalResults.DataSource = (from measuredData in _container.MeasuredDataSet.AsParallel()
                                         where measuredData.OwnerCode == user.UserCode
                                         orderby measuredData.CreatingTime
                                         select new { Дата = measuredData.CreatingTime, Значение = measuredData.Value, Тип = "Измерение", Код = measuredData.Number }).Union(
                from healthStatus in _container.HealthStatusSet.AsParallel()
                where healthStatus.OwnerCode == user.UserCode
                select new { Дата = healthStatus.CreatingTime, Значение = healthStatus.Status, Тип = "Статус", Код = (long)healthStatus.Number }).ToList();

            MedicalResults.Update();

            BeginPeriod.MaxDate = DateTime.Now;
            EndPeriod.MaxDate   = DateTime.Now;

            MedicalResults.Columns[0].Width   = 100;
            MedicalResults.Columns[1].Width   = 205;
            MedicalResults.Columns[2].Visible = false;
            MedicalResults.Columns[3].Visible = false;
        }
コード例 #8
0
        void RefreshMedicalResults()
        {
            _container = new EntityModelContainer();

            _healthStatuses = _container.HealthStatusSet;

            user = _container.PatientSet.Find(user.UserCode);

            if (ShowHealthState.Checked && ShowMeasuredData.Checked)
            {
                GetAllResults();
            }
            else
            {
                if (ShowHealthState.Checked)
                {
                    GetOnlyHealthStatus();
                }
                else
                {
                    GetOnlyMeasured();
                }
            }

            MedicalResults.Update();
            MedicalResults.Columns[0].Width   = 100;
            MedicalResults.Columns[1].Width   = 205;
            MedicalResults.Columns[2].Visible = false;
            MedicalResults.Columns[3].Visible = false;
        }
コード例 #9
0
        private void DoctorForm_Load(object sender, EventArgs e)
        {
            DoctorName.Text = user.FullName;
            _container      = new EntityModelContainer();

            RefreshPatients();
            PatientsList.Update();
        }
コード例 #10
0
        public static void AddPatient(Patient newPatient, Doctor doctor)
        {
            EntityModelContainer container = new EntityModelContainer();

            container.PatientSet.Add(newPatient);
            container.SaveChanges();

            AddDoctorPatientConnection(doctor, newPatient);
        }
コード例 #11
0
        public static void ChangeHealthStatus(HealthStatus status, string newValue)
        {
            EntityModelContainer container = new EntityModelContainer();

            status        = container.HealthStatusSet.Find(status.Number);
            status.Status = newValue;               // меняем значение

            container.Entry(status).State = EntityState.Modified;
            container.SaveChanges();                // сохранение изменений
        }
コード例 #12
0
        private void NewPatient_Load(object sender, EventArgs e)
        {
            //    dateBirthValidated = false;
            weightValidated = false;
            heightValidated = false;
            hasName         = false;
            hasMale         = false;

            _container = new EntityModelContainer();
        }
コード例 #13
0
        void CodeSearch()
        {
            EntityModelContainer container = new EntityModelContainer();

            bool found = false;

            Patient pat = container.PatientSet.Find(int.Parse(SearchCode.Text));

            if (pat != null)
            {
                found = true;

                if (SearchByName.Checked)
                {
                    if (pat.FullName.IndexOf(SearchName.Text) == -1)
                    {
                        found = false;
                    }
                }

                if (SearchByDate.Checked)
                {
                    if (SearchBirthDate.Value != pat.BirthDate)
                    {
                        found = false;
                    }
                }

                if (user.Patient.Contains(pat, new PatientComparer()))
                {
                    found = false;
                }
            }

            if (found)
            {
                List <Patient> list = new List <Patient>();
                list.Add(pat);

                SearchResults.DataSource = (from p in list select new
                {
                    Код = p.UserCode,
                    ФИО = p.FullName,
                    Дата_рождения = p.BirthDate
                }).ToList();

                SearchResults.Update();
            }
            else
            {
                MessageBox.Show(
                    "Пациент с указанными данными не найден. Возможно, данный пациент уже находится в Вашем списке пациентов.",
                    "Пациент не найден", MessageBoxButtons.OK);
            }
        }
コード例 #14
0
        public static void DeleteHealthStatus(HealthStatus status)
        {
            EntityModelContainer container = new EntityModelContainer();

            Patient owner = container.PatientSet.Find(status.OwnerCode);

            owner.HealthStatus.Remove(status);          // удаление связей
            container.HealthStatusSet.Remove(status);   // удаление сущности

            container.SaveChanges();
        }
コード例 #15
0
        public static void AddDoctorPatientConnection(Doctor doctor, Patient patient)
        {
            EntityModelContainer container = new EntityModelContainer();

            patient = container.PatientSet.Find(patient.UserCode);
            doctor  = container.DoctorSet.Find(doctor.UserCode);

            doctor.Patient.Add(patient);
            patient.Doctor.Add(doctor);

            container.SaveChanges();
        }
コード例 #16
0
        private void LogInButton_Click(object sender, EventArgs e)
        {
            string login    = Login.Text;
            string password = Password.Text;

            User.UserType type;
            User          searchResult;

            EntityModelContainer container = new EntityModelContainer();

            bool correct = InformationSystem.CheckLoginPassword(login, password, out type, out searchResult);

            if (!correct)
            {
                MessageBox.Show("Неверное имя пользователя или пароль");
            }
            else
            {
                if (type == User.UserType.administrator)
                {
                    AdministratorForm adminForm = new AdministratorForm();
                    Administrator     result    = searchResult as Administrator;

                    adminForm.user = container.AdministratorSet.Find(result.UserCode);;
                    adminForm.ShowDialog();
                }
                else
                {
                    if (type == User.UserType.doctor)
                    {
                        DoctorForm doctorForm = new DoctorForm();
                        Doctor     result     = searchResult as Doctor;

                        doctorForm.user = container.DoctorSet.Find(result.UserCode);

                        doctorForm.ShowDialog();
                    }
                    else
                    {
                        PatientForm patientForm = new PatientForm();
                        Patient     result      = searchResult as Patient;

                        patientForm.user = container.PatientSet.Find(result.UserCode);
                        patientForm.ShowDialog();
                    }
                }
            }
        }
コード例 #17
0
        public static void AddDevice(Device newDevice, Patient owner)
        {
            EntityModelContainer container = new EntityModelContainer();

            container.DeviceSet.Add(newDevice);
            //     container.SaveChanges();

            // создание связей между сущностями
            owner     = container.PatientSet.Find(owner.UserCode);
            newDevice = container.DeviceSet.Find(newDevice.DeviceCode);

            owner.Device.Add(newDevice);
            newDevice.Patient = owner;

            container.SaveChanges();
        }
コード例 #18
0
        public static void AddMeasuredData(MeasuredData data, Patient owner, Device device)
        {
            EntityModelContainer container = new EntityModelContainer();

            container.MeasuredDataSet.Add(data);
            //   container.SaveChanges();

            owner  = container.PatientSet.Find(owner.UserCode);
            data   = container.MeasuredDataSet.Find(data.Number);
            device = container.DeviceSet.Find(device.DeviceCode);

            owner.MeasuredData.Add(data);
            data.Patient = owner;

            container.SaveChanges();
        }
コード例 #19
0
        private void AddPatient_Click(object sender, EventArgs e)
        {
            EntityModelContainer container = new EntityModelContainer();

            int row = SearchResults.SelectedCells[0].RowIndex;

            Patient selectedPat =
                container.PatientSet.Find(int.Parse(SearchResults.Rows[row].Cells[0].Value.ToString()));

            AddDeviceForm newDeviceType = new AddDeviceForm();

            if (newDeviceType.ShowDialog() == DialogResult.OK)
            {
                DeviceFunction type  = newDeviceType.function;
                bool           exist = false;

                foreach (Device d in selectedPat.Device)
                {
                    if (d.Function == type)
                    {
                        exist = true;
                    }
                }

                if (exist)
                {
                    if (MessageBox.Show(
                            "Данный тип прибора уже закреплен за пациентом. Добавить пациента в список пациентов?", "",
                            MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        InformationSystem.AddDoctorPatientConnection(user, selectedPat);
                        this.Close();
                    }
                }
                else
                {
                    Device newDevice = InformationSystem.CreateDevice(selectedPat, type);
                    InformationSystem.AddDevice(newDevice, selectedPat);

                    InformationSystem.AddDoctorPatientConnection(user, selectedPat);
                    this.Close();
                }
            }

            container.SaveChanges();
        }
コード例 #20
0
        static void AddDeviceMessage(DeviceMessage message)
        {
            EntityModelContainer container = new EntityModelContainer();

            container.DeviceMessageSet.Add(message);

            DeviceMessage m = container.DeviceMessageSet.Find(message.Id);

            m.Administrator = container.AdministratorSet.Find(m.RecipientCode);
            m.Device        = container.DeviceSet.Find(m.SenderCode);

            Administrator recipient = container.AdministratorSet.Find(m.RecipientCode);

            recipient.DeviceMessage.Add(m);

            container.SaveChanges();
        }
コード例 #21
0
        void RefreshPatients()
        {
            _container = new EntityModelContainer();

            Doctor refreshUser = _container.DoctorSet.Find(user.UserCode);

            user = refreshUser;

            if (AllPatientsSearch.Checked)
            {
                PatientsList.DataSource = (from patient in user.Patient.AsParallel()
                                           select new
                {
                    Код = patient.UserCode,
                    ФИО = patient.FullName,
                    Дата_рождения = patient.BirthDate.ToShortDateString()
                }).ToList();
            }
            else
            {
                if (NameSearch.Checked)
                {
                    PatientsList.DataSource = (from patient in user.Patient.AsParallel()
                                               where patient.FullName.IndexOf(PatientNameSearch.Text) != -1
                                               select new
                    {
                        Код = patient.UserCode,
                        ФИО = patient.FullName,
                        Дата_рождения = patient.BirthDate.ToShortDateString()
                    }).ToList();
                }
                else
                {
                    PatientsList.DataSource = (from patient in user.Patient.AsParallel()
                                               where patient.UserCode == int.Parse(PatientCodeSearch.Text)
                                               select new
                    {
                        Код = patient.UserCode,
                        ФИО = patient.FullName,
                        Дата_рождения = patient.BirthDate.ToShortDateString()
                    }).ToList();
                }
            }

            PatientsList.Update();
        }
コード例 #22
0
        private void SignUp_Click(object sender, EventArgs e)
        {
            string   name      = NewName.Text;
            DateTime birthDate = NewDateBirth.Value;
            Male     male      = NewMale.Checked ? Male.Male : Male.Female;
            byte     height    = byte.Parse(NewHeight.Text);
            byte     weight    = byte.Parse(NewWeight.Text);

            _container = new EntityModelContainer();
            Patient newPatient = InformationSystem.CreatePatient(name, birthDate, male, height, weight, user);

            InformationSystem.AddPatient(newPatient, user);

            DeviceFunction deviceType = 0;

            switch (NewDeviceType.SelectedIndex)
            {
            case 0:
                deviceType = DeviceFunction.Glucometer;
                break;

            case 1:
                deviceType = DeviceFunction.HeartRateMonitor;
                break;

            case 2:
                deviceType = DeviceFunction.BloodPressureMonitor;
                break;
            }

            Device newDevice = InformationSystem.CreateDevice(newPatient, deviceType);

            InformationSystem.AddDevice(newDevice, newPatient);

            DoctorMessage informMessage = InformationSystem.CreatePatientMessage(user, newPatient, AllowAccess.Checked);

            InformationSystem.AddDoctorMessage(informMessage);

            MessageBox.Show("Пациент успешно зарегистрирован");

            this.Close();
        }
コード例 #23
0
        void RefreshData()
        {
            _container = new EntityModelContainer();

            if (ShowHealthState.Checked && ShowMeasuredData.Checked)
            {
                AllData();
            }
            else
            {
                if (ShowHealthState.Checked)
                {
                    AllHealthStatus();
                }
                else
                {
                    AllMeasuredData();
                }
            }
        }
コード例 #24
0
        void OnlyDateSearch()
        {
            EntityModelContainer container = new EntityModelContainer();

            SearchResults.DataSource = (from pat in container.PatientSet.AsParallel()
                                        where pat.BirthDate == SearchBirthDate.Value && !user.Patient.Contains(pat, new PatientComparer())
                                        orderby pat.UserCode
                                        select new
            {
                Код = pat.UserCode,
                ФИО = pat.FullName,
                Дата_рождения = pat.BirthDate
            }).ToList();

            SearchResults.Update();
            if (SearchResults.RowCount == 0)
            {
                MessageBox.Show(
                    "Пациент с указанными данными не найден. Возможно, данный пациент уже находится в Вашем списке пациентов.",
                    "Пациент не найден", MessageBoxButtons.OK);
            }
        }
コード例 #25
0
        private void PatientDataForm_Load(object sender, EventArgs e)
        {
            PatientName.Text      = Patient.FullName;
            PatientBirthDate.Text = Patient.BirthDate.ToShortDateString();

            if (Patient.Male == Male.Female)
            {
                PatientMale.Text = "Женский";
            }
            else
            {
                PatientMale.Text = "Мужской";
            }

            PatientHeight.Text = Patient.Height.ToString() + " см";
            PatientWeight.Text = Patient.Weight.ToString() + " кг";

            _container = new EntityModelContainer();

            PatientResults.DataSource = (from measuredData in _container.MeasuredDataSet
                                         where measuredData.OwnerCode == Patient.UserCode
                                         orderby measuredData.CreatingTime
                                         select new { Дата = measuredData.CreatingTime.ToString(), езультат = measuredData.Value, Тип = "Измерение" }).Union(
                from healthStatus in _container.HealthStatusSet
                where healthStatus.OwnerCode == Patient.UserCode
                select new { Дата = healthStatus.CreatingTime.ToString(), езультат = healthStatus.Status, Тип = "Статус" }).ToList();

            PatientResults.Update();

            PatientResults.Columns[0].Width   = 100;
            PatientResults.Columns[1].Width   = 245;
            PatientResults.Columns[2].Visible = false;

            excelThread =
                new Thread(ExcelWorker.WriteResults);

            EndPeriod.MaxDate = DateTime.Now;
        }
コード例 #26
0
        static void GetPreviousSugarLevel(Device device, out double level)
        {
            level = 0;

            EntityModelContainer container = new EntityModelContainer();
            Patient owner = container.PatientSet.Find(device.OwnerCode);

            List <MeasuredData> list = (from data in owner.MeasuredData
                                        where data.DeviceCode == device.DeviceCode
                                        select data)
                                       .ToList();

            if (list.Count != 0)
            {
                MeasuredData last = list.Max();

                string measurePattern = @"([\d|,]+) ммоль/л.";

                string[] value = Regex.Split(last.Value, measurePattern);

                level = double.Parse(value[1]);
            }
        }
コード例 #27
0
        static void GetPreviousPulse(Device device, out int rate)
        {
            rate = 0;

            EntityModelContainer container = new EntityModelContainer();
            Patient owner = container.PatientSet.Find(device.OwnerCode);

            List <MeasuredData> list = (from data in owner.MeasuredData
                                        where data.DeviceCode == device.DeviceCode
                                        select data)
                                       .ToList();

            if (list.Count != 0)
            {
                MeasuredData last = list.Max();

                string measurePattern = @"([\d]+) уд/мин.";

                string[] value = Regex.Split(last.Value, measurePattern);

                rate = int.Parse(value[1]);
            }
        }
コード例 #28
0
        static void GetPreviousPressure(Device device, out int high, out int low)
        {
            high = 0;
            low  = 0;

            EntityModelContainer container = new EntityModelContainer();
            Patient owner = container.PatientSet.Find(device.OwnerCode);

            List <MeasuredData> list = (from data in owner.MeasuredData
                                        where data.DeviceCode == device.DeviceCode
                                        select data)
                                       .ToList();

            if (list.Count != 0)
            {
                MeasuredData last = list.Max();

                string measurePattern = @"([\d]+)\s/\s([\d]+)";

                string[] values = Regex.Split(last.Value, measurePattern);
                high = int.Parse(values[1]);
                low  = int.Parse(values[2]);
            }
        }
コード例 #29
0
        private void AddHealthStatus_Click(object sender, EventArgs e)
        {
            bool[] symptoms = new bool[14];

            if (Ailment.Checked)     // недомогание
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Недомогание")] = true;
            }

            if (Dizziness.Checked)     // головокружение
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Головокружение")] = true;
            }

            if (HighBloodPressure.Checked)     // повышенное давление
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Повышенное артериальное давление")] = true;
            }

            if (LowBloodPressure.Checked)     // пониженное давление
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Пониженное артериальное давление")] = true;
            }

            if (Fever.Checked)     // жар
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Жар")] = true;
            }

            if (Headache.Checked)     // головная боль
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Головная боль")] = true;
            }

            if (Insomnia.Checked)     // бессонница
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Бессонница")] = true;
            }

            if (Nausea.Checked)     // тошнота
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Тошнота")] = true;
            }

            if (Fatigue.Checked)     // усталость
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Усталость")] = true;
            }

            if (DryMouth.Checked)     // сухость во рту
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Сухость во рту")] = true;
            }

            if (IncreasedWeigh.Checked)     // прибавление веса
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Прибавление веса")] = true;
            }

            if (DecreasedWeigh.Checked)     // потеря веса
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Потеря веса")] = true;
            }

            if (Weakness.Checked)     // слабость
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Слабость")] = true;
            }

            if (Thirst.Checked)     // жажда
            {
                symptoms[Array.IndexOf(HealthStatus.SymptomsNames, "Жажда")] = true;
            }

            string generatedStatus = HealthStatus.GetHealthStatus(symptoms);

            if (newStatus)
            {
                InformationSystem.AddHealthStatus(generatedStatus, DateTime.Now, user);
            }
            else
            {
                EntityModelContainer container = new EntityModelContainer();

                status = container.HealthStatusSet.Find(status.Number);
                InformationSystem.ChangeHealthStatus(status, generatedStatus);
            }

            this.Close();
        }
コード例 #30
0
        void RefreshMessages()
        {
            _container = new EntityModelContainer();
            user       = _container.AdministratorSet.Find(user.UserCode);

            if (NewPatientsMessage.Checked && DeviceMessages.Checked)
            {
                if (AllMessages.Checked)
                {
                    MessageList.DataSource = (from patientMessage in user.Message.AsParallel()
                                              select new
                    {
                        Дата = patientMessage.Date.ToString(),
                        Сообщение = patientMessage.Title,
                        Статус = patientMessage.GetChecked(),
                        Код = patientMessage.Id
                    }).Union(from deviceMessage in user.DeviceMessage.AsParallel()
                             select new
                    {
                        Дата      = deviceMessage.Date.ToString(),
                        Сообщение = deviceMessage.Title,
                        Статус    = deviceMessage.GetChecked(),
                        Код       = deviceMessage.Id
                    }).ToList();

                    MessageList.Update();
                }
                else
                {
                    MessageList.DataSource = (from patientMessage in user.Message.AsParallel()
                                              where patientMessage.Checked == false
                                              select new
                    {
                        Дата = patientMessage.Date.ToString(),
                        Сообщение = patientMessage.Title,
                        Статус = patientMessage.GetChecked(),
                        Код = patientMessage.Id
                    }).Union(from deviceMessage in user.DeviceMessage.AsParallel()
                             where deviceMessage.Checked == false
                             select new
                    {
                        Дата      = deviceMessage.Date.ToString(),
                        Сообщение = deviceMessage.Title,
                        Статус    = deviceMessage.GetChecked(),
                        Код       = deviceMessage.Id
                    }).ToList();

                    MessageList.Update();
                }
            }
            else
            {
                if (NewPatientsMessage.Checked)
                {
                    if (AllMessages.Checked)
                    {
                        MessageList.DataSource = (from patientMessage in user.Message.AsParallel()
                                                  select new
                        {
                            Дата = patientMessage.Date.ToString(),
                            Сообщение = patientMessage.Title,
                            Статус = patientMessage.GetChecked(),
                            Код = patientMessage.Id
                        }).ToList();
                    }
                    else
                    {
                        MessageList.DataSource = (from patientMessage in user.Message.AsParallel()
                                                  where patientMessage.Checked == false
                                                  select new
                        {
                            Дата = patientMessage.Date.ToString(),
                            Сообщение = patientMessage.Title,
                            Статус = patientMessage.GetChecked(),
                            Код = patientMessage.Id
                        }).ToList();
                    }
                }
                else
                {
                    if (DeviceMessages.Checked)
                    {
                        if (AllMessages.Checked)
                        {
                            MessageList.DataSource = (from deviceMessage in user.DeviceMessage.AsParallel()
                                                      select new
                            {
                                Дата = deviceMessage.Date.ToString(),
                                Сообщение = deviceMessage.Title,
                                Статус = deviceMessage.GetChecked(),
                                Код = deviceMessage.Id
                            }).ToList();
                        }
                        else
                        {
                            MessageList.DataSource = (from deviceMessage in user.DeviceMessage.AsParallel()
                                                      where deviceMessage.Checked == false
                                                      select new
                            {
                                Дата = deviceMessage.Date.ToString(),
                                Сообщение = deviceMessage.Title,
                                Статус = deviceMessage.GetChecked(),
                                Код = deviceMessage.Id
                            }).ToList();
                        }
                    }
                    else
                    {
                        MessageList.DataSource = null;
                    }
                }
            }

            MessageList.Update();
        }