private void FindVisit(List<Visit> list)
        {
            LinearGradientBrush panelgradient = new LinearGradientBrush()
            {
                StartPoint = new Point(0.5, 0),
                EndPoint = new Point(0.5, 1)
            };
            panelgradient.GradientStops.Add(new GradientStop() {Color = Color.FromArgb(255, 255, 255, 255), Offset = 0});
            panelgradient.GradientStops.Add(new GradientStop() {Color = Color.FromArgb(128, 255, 255, 255), Offset = 1});
            DockPanel panelAllVisit = new DockPanel
            {

                Margin = new Thickness(15, 15, 15, 15),
                Visibility = Visibility.Hidden,
                Background = panelgradient
            };

            Label labelstartvisit = new Label
            {
                Content = "Записи",
                Foreground = Brushes.MediumBlue,
                FontWeight = FontWeights.Bold
            };
            DockPanel.SetDock(labelstartvisit, Dock.Top);
            panelAllVisit.Children.Add(labelstartvisit);
            DockPanel.SetDock(panelAllVisit, Dock.Top);
            PatientsPanel.Children.Add(panelAllVisit);
            foreach (Visit visit in list)
            {
                panelAllVisit.Visibility = Visibility.Visible;
                if (visit.IdWorker == "0" && visit.Snp == "0")
                {
                    WpfMessageBox.Show("Відсутнє підключення до сервера. \n Зверніться до адміністратора!");
                    Close();
                }
                DockPanel panelvisit1 = new DockPanel
                {
                    Background = Brushes.LightSkyBlue,
                    Margin = new Thickness(15, 15, 15, 15),
                };

                DockPanel panelvisit = new DockPanel
                {
                    Background = Brushes.WhiteSmoke,
                    Margin = new Thickness(3, 3, 3, 3),
                };


                Label labelvisit = new Label
                {

                    Content = string.Format(
                        "Причина: {0} \n Скарги: {1} \n Огляд: {2} \n Дата: {3}\n Лікар: {4} ",
                        visit.Reason,
                        visit.Complaints,
                        visit.Inspection,
                        visit.VisitDateOnset,
 visit.Snp),
                    Margin = new Thickness(10, 10, 10, 10),
                };

                DockPanel panelallanalysis = new DockPanel
                {
                    Background = Brushes.LightSkyBlue,
                    Margin = new Thickness(0, 0, 0, 0),
                };
                int intAnalysis = 0;
                foreach (var analysis in Analysis.ListAnalysis)
                {
                    if (analysis.IdVisit == visit.IdVisit)
                    {
                        DockPanel panelanalysis1 = new DockPanel
                        {
                            Background = new SolidColorBrush(Color.FromRgb(244, 244, 40)),
                            Margin = new Thickness(5, 5, 5, 5),
                        };

                        DockPanel panelanalysis = new DockPanel
                        {
                            Background = Brushes.LightSteelBlue,
                            Margin = new Thickness(3, 3, 3, 3),
                        };


                        Label labelanalysis = new Label
                        {

                            Content = string.Format(
                                "Назва: {0} \n Показники: {1} \n Заключення: {2} \n Дата: {3} \n Лікар: {4}",
                                analysis.NameAnalysis,
                                analysis.Indicators,
                                analysis.Result,
                                analysis.AnalysisDateOnset,
                                analysis.Snp),
                            Margin = new Thickness(10, 10, 10, 10),
                        };
                        intAnalysis = intAnalysis + 1;
                        DockPanel.SetDock(panelanalysis1, Dock.Top);
                        DockPanel.SetDock(panelanalysis, Dock.Top);
                        DockPanel.SetDock(labelanalysis, Dock.Top);
                        panelanalysis.Children.Add(labelanalysis);
                        panelanalysis1.Children.Add(panelanalysis);
                        panelallanalysis.Children.Add(panelanalysis1);
                        var analysis1 = analysis;
                        labelanalysis.MouseDoubleClick += (o, args) =>
                        {
                            PatientInfo form = new PatientInfo(analysis1.IdPatient);
                            form.ShowDialog();
                        };
                    }
                }
                if (intAnalysis != 0)
                {
                    LinearGradientBrush gradient = new LinearGradientBrush();
                    gradient.StartPoint = new Point(0, 0);
                    gradient.EndPoint = new Point(1, 1);
                    Button buttonopenanalisis = new Button
                    {
                        Background = gradient,
                        Foreground = Brushes.MediumBlue,
                        FontWeight = FontWeights.Bold,
                        Content = "Переглянути аналізи",
                        Height = 20,
                        Width = 450
                    };
                    gradient.GradientStops.Add(new GradientStop()
                    {
                        Color = Color.FromArgb(255, 249, 249, 200),
                        Offset = 0
                    });
                    gradient.GradientStops.Add(new GradientStop()
                    {
                        Color = Color.FromArgb(255, 251, 228, 0),
                        Offset = 1
                    });

                    DockPanel.SetDock(buttonopenanalisis, Dock.Bottom);
                    panelvisit1.Children.Add(buttonopenanalisis);
                    panelallanalysis.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                    panelallanalysis.Arrange(new Rect(new Point(0, 0), panelallanalysis.DesiredSize));
                    double panelHeight = panelallanalysis.ActualHeight;
                    panelallanalysis.Height = 0;
                    bool isToggle = new bool();
                    buttonopenanalisis.Click += (o, args) =>
                    {
                        DoubleAnimation da = new DoubleAnimation();
                        if (!isToggle)
                        {
                            da.From = 450;
                            da.To = 800;
                            da.Duration = TimeSpan.FromSeconds(1);
                            buttonopenanalisis.BeginAnimation(WidthProperty, da);
                            da.From = 0;
                            da.To = panelHeight;
                            da.Duration = TimeSpan.FromSeconds(1);
                            panelallanalysis.BeginAnimation(HeightProperty, da);
                            isToggle = true;
                            buttonopenanalisis.Content = "Закрити";

                        }
                        else
                        {
                            da.From = 800;
                            da.To = 450;
                            da.Duration = TimeSpan.FromSeconds(1);
                            buttonopenanalisis.BeginAnimation(WidthProperty, da);
                            da.From = panelHeight;
                            da.To = 0;
                            da.Duration = TimeSpan.FromSeconds(1);
                            panelallanalysis.BeginAnimation(HeightProperty, da);
                            isToggle = false;
                            buttonopenanalisis.Content = "Переглянути процедури";
                        }
                    };
                }
                DockPanel.SetDock(panelvisit1, Dock.Top);
                DockPanel.SetDock(panelallanalysis, Dock.Top);
                DockPanel.SetDock(panelvisit, Dock.Top);
                DockPanel.SetDock(labelvisit, Dock.Top);
                panelvisit.Children.Add(labelvisit);
                panelvisit1.Children.Add(panelvisit);
                panelvisit1.Children.Add(panelallanalysis);
                panelAllVisit.Children.Add(panelvisit1);
                var visit1 = visit;
                labelvisit.MouseDoubleClick += (o, args) =>
                {
                    PatientInfo form = new PatientInfo(visit1.IdPatient);
                    form.ShowDialog();
                };
                PatientsPanel.Visibility = Visibility.Visible;
            }
        }
        private void LoadForm()
        {
            string lastDate = "0";
            var result = from acceptance in Acceptance.ListAcceptance
                         orderby acceptance.Date, acceptance.Time
                         select acceptance;
            foreach (Acceptance acceptance in result)
            {
                DateTime acceptanceDate = DateTime.Parse(acceptance.Date);
                if (DateTime.Today > acceptanceDate)
                {
                    continue;
                }
                if (lastDate != acceptance.Date)
                {
                    var labelacceptanceDate = new Label
                    {
                        VerticalAlignment = VerticalAlignment.Top,
                        HorizontalAlignment = HorizontalAlignment.Center,
                        Content = acceptance.Date + "  " + acceptanceDate.ToString("dddd"),
                        FontSize = 12,
                        FontWeight = FontWeights.Bold,
                        Foreground = Brushes.White,
                        Margin = new Thickness(10, 15, 10, 0)
                    };
                    DockPanel.SetDock(FullDock, Dock.Top);
                    DockPanel.SetDock(labelacceptanceDate, Dock.Top);
                    FullDock.Children.Add(labelacceptanceDate);
                    lastDate = acceptance.Date;
                }

                var panelacceptance1 = new DockPanel
                {
                    Background = Brushes.LightSkyBlue,
                    Margin = new Thickness(15, 5, 15, 15),
                };

                var panelacceptance = new DockPanel
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Margin = new Thickness(5, 5, 5, 5),
                    Background = Brushes.White,
                };
                var labelacceptanceComment = new Label
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    Content = acceptance.Comment+"\n"+ acceptance.Time,
                    Margin = new Thickness(10, 5, 10, 10),
                    FontSize = 12
                };
                var acceptance1 = acceptance;
                labelacceptanceComment.MouseDoubleClick += (o, args) =>
                {
                    PatientInfo form = new PatientInfo(acceptance1.PatientIdPatient);
                    form.ShowDialog();
                };
               
                DockPanel.SetDock(labelacceptanceComment, Dock.Top);
                DockPanel.SetDock(panelacceptance, Dock.Top);
                DockPanel.SetDock(FullDock, Dock.Top);
                DockPanel.SetDock(panelacceptance1, Dock.Top);
                panelacceptance.Children.Add(labelacceptanceComment);
                panelacceptance1.Children.Add(panelacceptance);
                FullDock.Children.Add(panelacceptance1);
            }

        }
        private void FindDiagnosis(List<Diagnosis> list)
        {
            LinearGradientBrush panelgradient = new LinearGradientBrush()
            {
                StartPoint = new Point(0.5, 0),
                EndPoint = new Point(0.5, 1)
            };
            panelgradient.GradientStops.Add(new GradientStop() {Color = Color.FromArgb(255, 255, 255, 255), Offset = 0});
            panelgradient.GradientStops.Add(new GradientStop() {Color = Color.FromArgb(198, 250, 225, 4), Offset = 1});
            DockPanel panelAllDiagnosis = new DockPanel
            {
                Background = panelgradient,
                Margin = new Thickness(15, 15, 15, 15),
                Visibility = Visibility.Hidden
            };
            Label labelstartdiagnosis = new Label
            {
                Content = "Діагнози",
                Foreground = Brushes.MediumBlue,
                FontWeight = FontWeights.Bold
            };
            DockPanel.SetDock(panelAllDiagnosis, Dock.Top);
            PatientsPanel.Children.Add(panelAllDiagnosis);
            DockPanel.SetDock(labelstartdiagnosis, Dock.Top);
            panelAllDiagnosis.Children.Add(labelstartdiagnosis);

            foreach (Diagnosis disease in list)
            {
                panelAllDiagnosis.Visibility = Visibility.Visible;
                if (disease.IdWorker == "0" && disease.Snp == "0")
                {
                    WpfMessageBox.Show("Відсутнє підключення до сервера. \n Зверніться до адміністратора!");
                    Close();
                }
                DockPanel paneldiagnosis1 = new DockPanel
                {
                    Background = Brushes.LightSkyBlue,
                    Margin = new Thickness(15, 15, 15, 15),
                };

                DockPanel paneldiagnosis = new DockPanel
                {
                    Background = Brushes.WhiteSmoke,
                    Margin = new Thickness(3, 3, 3, 3),
                };


                Label labeldiagnosis = new Label
                {

                    Content = string.Format(
                        "Назва: {0} \n Діагноз: {1} \n Лікування: {2} \n Дата встановлення захворювання: {3}\n Лікар: {4}",
                        disease.Disease,
                        disease.Disease,
                        disease.Treatment,
                        disease.DateOnset,
                        disease.Snp),
                    Margin = new Thickness(10, 10, 10, 10),
                };

                DockPanel panelallprocedure = new DockPanel
                {
                    Background = Brushes.LightSkyBlue,
                    Margin = new Thickness(0, 0, 0, 0),
                };
                int intProcedure = 0;
                foreach (var procedure in Procedure.ListProcedure)
                {
                    if (procedure.IdDiagnosis == disease.IdDiagnosis)
                    {
                        DockPanel panelprocedure1 = new DockPanel
                        {
                            Background = new SolidColorBrush(Color.FromRgb(244, 244, 40)),
                            Margin = new Thickness(5, 5, 5, 5),
                        };

                        DockPanel panelprocedure = new DockPanel
                        {
                            Background = Brushes.LightSteelBlue,
                            Margin = new Thickness(3, 3, 3, 3),
                        };


                        Label labelprocedure = new Label
                        {

                            Content = string.Format(
                                "Процедура: {0} \n Результат: {1} \n Дата: {2} \n Лікар: {3}",
                                procedure.NameProcedure,
                                procedure.Result,
                                procedure.DateOnset,
                                procedure.Snp),
                            Margin = new Thickness(10, 10, 10, 10),
                        };
                        intProcedure = intProcedure + 1;
                        DockPanel.SetDock(panelprocedure1, Dock.Top);
                        DockPanel.SetDock(panelprocedure, Dock.Top);
                        DockPanel.SetDock(labelprocedure, Dock.Top);
                        panelprocedure.Children.Add(labelprocedure);
                        panelprocedure1.Children.Add(panelprocedure);
                        panelallprocedure.Children.Add(panelprocedure1);
                        var procedure1 = procedure;
                        labelprocedure.MouseDoubleClick += (o, args) =>
                        {
                            PatientInfo form = new PatientInfo(procedure1.IdPatient);
                            form.ShowDialog();
                        };
                    }
                }
                if (intProcedure != 0)
                {
                    LinearGradientBrush gradient = new LinearGradientBrush();
                    gradient.StartPoint = new Point(0, 0);
                    gradient.EndPoint = new Point(1, 1);
                    Button buttonopenprocedure = new Button
                    {
                        Background = gradient,
                        Foreground = Brushes.MediumBlue,
                        FontWeight = FontWeights.Bold,
                        Content = "Переглянути процедури",
                        Height = 20,
                        Width = 450
                    };
                    gradient.GradientStops.Add(new GradientStop()
                    {
                        Color = Color.FromArgb(255, 249, 249, 200),
                        Offset = 0
                    });
                    gradient.GradientStops.Add(new GradientStop()
                    {
                        Color = Color.FromArgb(255, 251, 228, 0),
                        Offset = 1
                    });

                    DockPanel.SetDock(buttonopenprocedure, Dock.Bottom);
                    paneldiagnosis1.Children.Add(buttonopenprocedure);
                    panelallprocedure.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                    panelallprocedure.Arrange(new Rect(new Point(0, 0), panelallprocedure.DesiredSize));
                    double panelHeight = panelallprocedure.ActualHeight;
                    panelallprocedure.Height = 0;
                    bool isToggle = new bool();
                    buttonopenprocedure.Click += (o, args) =>
                    {
                        DoubleAnimation da = new DoubleAnimation();
                        if (!isToggle)
                        {
                            da.From = 450;
                            da.To = 800;
                            da.Duration = TimeSpan.FromSeconds(1);
                            buttonopenprocedure.BeginAnimation(WidthProperty, da);
                            da.From = 0;
                            da.To = panelHeight;
                            da.Duration = TimeSpan.FromSeconds(1);
                            panelallprocedure.BeginAnimation(HeightProperty, da);
                            isToggle = true;
                            buttonopenprocedure.Content = "Закрити";

                        }
                        else
                        {
                            da.From = 800;
                            da.To = 450;
                            da.Duration = TimeSpan.FromSeconds(1);
                            buttonopenprocedure.BeginAnimation(WidthProperty, da);
                            da.From = panelHeight;
                            da.To = 0;
                            da.Duration = TimeSpan.FromSeconds(1);
                            panelallprocedure.BeginAnimation(HeightProperty, da);
                            isToggle = false;
                            buttonopenprocedure.Content = "Переглянути процедури";
                        }
                    };
                }
                DockPanel.SetDock(paneldiagnosis1, Dock.Top);
                DockPanel.SetDock(panelallprocedure, Dock.Top);
                DockPanel.SetDock(paneldiagnosis, Dock.Top);
                DockPanel.SetDock(labeldiagnosis, Dock.Top);
                paneldiagnosis.Children.Add(labeldiagnosis);
                paneldiagnosis1.Children.Add(paneldiagnosis);
                paneldiagnosis1.Children.Add(panelallprocedure);
                panelAllDiagnosis.Children.Add(paneldiagnosis1);
                var disease1 = disease;
                labeldiagnosis.MouseDoubleClick += (o, args) =>
                {
                    PatientInfo form = new PatientInfo(disease1.IdPatient);
                    form.ShowDialog();
                };
                PatientsPanel.Visibility = Visibility.Visible;
            }
        }