private static void SetImage(ItemPatient patient, bool isOk)
        {
            if (patient.CheckStateImage != null)
            {
                if (!isOk)
                {
                    patient.CheckStateImage.Source = ControlsFactory.GetImage(ControlsFactory.ImageType.NotificationRegistry);
                }

                patient.CheckStateImage.Visibility = Visibility.Visible;
            }
        }
Пример #2
0
        public PageCheckInCompleted(ItemPatient patient, bool returnBack, bool isAlreadyChecked = false)
        {
            InitializeComponent();
            Console.WriteLine(@"http://CONSTRUCT_PageCheckInCompleted");

            Logging.ToLog("PageCheckInCompleted - Отображение страницы с отметкой о посещении");

            DataContext           = BindingValues.Instance;
            this.patient          = patient;
            this.returnBack       = returnBack;
            this.isAlreadyChecked = isAlreadyChecked;
            Loaded += PageCheckInCompleted_Loaded;
            string title = Properties.Resources.title_notification;

            BindingValues.Instance.SetUpMainWindow(title, true, false);
        }
        private void GetPatientAppointments(ref ItemPatient patient)
        {
            Logging.ToLog("DataHandle - получение списка назнчений для пациента. PCODE: " + patient.PCode + ", ФИО: " + patient.Name);

            Dictionary <string, object> parameters = new Dictionary <string, object> {
                { "@pCode", patient.PCode }
            };

            if (isThisAMoscowFilial && IsCentralDbAvailable())
            {
                Logging.ToLog("DataHandle - Синхронизация данных с ЦБД");
                try {
                    fbClient.ExecuteUpdateQuery(sqlSynchronizeMoscowClientInfo, parameters);
                } catch (Exception e) {
                    Logging.ToLog(e.Message + Environment.StackTrace + e.StackTrace);
                }
            }

            try {
                using (DataTable dataTable = fbClient.GetDataTable(sqlGetAppointments, parameters))
                    foreach (DataRow row in dataTable.Rows)
                    {
                        ParsePatientAppointmentRow(row, ref patient);
                    }
            } catch (Exception e) {
                Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace);
                MainWindow.Instance.ShowErrorScreen(e, true);
                return;
            }


            List <ItemAppointment> appointmentSorted = patient.AppointmentsAvailable.OrderBy(x => x.DateTimeScheduleBegin).ToList();

            patient.AppointmentsAvailable.Clear();
            patient.AppointmentsAvailable.AddRange(appointmentSorted);

            if (patient.StopCodesCurrent.Count == 0 &&
                patient.AppointmentsAvailable.Count + patient.AppointmentsVisited.Count > 0)
            {
                patient.CheckPrinterAndCreateWorksheet();
            }
        }
        public void LoadPatients(string prefix, string number)
        {
            Logging.ToLog("DataHandle - получения списка пациентов по введенному номеру: " + prefix + number);

            PatientsCurrent.Clear();

            Dictionary <string, object> parameters = new Dictionary <string, object> {
                { "@prefix", prefix },
                { "@number", number }
            };

            try {
                using (DataTable dataTable = fbClient.GetDataTable(sqlGetPatients, parameters)) {
                    foreach (DataRow row in dataTable.Rows)
                    {
                        try {
                            ItemPatient itemPatient = new ItemPatient()
                            {
                                PhoneNumber = prefix + number,
                                PCode       = row["PCODE"].ToString(),
                                Name        = row["CNAME"].ToString(),
                                Birthday    = DateTime.Parse(row["BDATE"].ToString())
                            };

                            GetPatientAppointments(ref itemPatient);

                            PatientsCurrent.Add(itemPatient);
                        } catch (Exception e) {
                            Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace);
                        }
                    }
                }
            } catch (Exception e) {
                Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace);
                MainWindow.Instance.ShowErrorScreen(e, true);
                return;
            }

            Logging.ToLog("DataHandle - полученный список пациентов: " +
                          string.Join(Environment.NewLine, PatientsCurrent));
        }
        private void CheckPatientStateAndShowAppointments(ItemPatient patient)
        {
            PageNotification.NotificationType?notificationType = null;
            selectedPatient = patient;

            if (patient.StopCodesCurrent.Contains(ItemPatient.StopCode.FirstTime))
            {
                notificationType = PageNotification.NotificationType.FirstVisit;
            }
            //else if (patient.StopCodesCurrent.Contains(ItemPatient.StopCodes.NotAvailableNow))
            //	notificationType = PageNotification.NotificationType.NoAppointmentsForNow;
            else if (patient.StopCodesCurrent.Contains(ItemPatient.StopCode.Cash))
            {
                notificationType = PageNotification.NotificationType.Cash;
            }
            else if (patient.StopCodesCurrent.Count > 0)
            {
                notificationType = PageNotification.NotificationType.VisitRegistryToCheckIn;
            }

            if (notificationType.HasValue)
            {
                NavigationService.Navigate(new PageNotification(notificationType.Value, returnBack: returnBack));
                SetImage(patient, false);
                return;
            }

            bool isOk = true;

            if (patient.AppointmentsNotAvailable.Count >= 0 &&
                patient.AppointmentsAvailable.Count == 0 &&
                patient.AppointmentsVisited.Count == 0)
            {
                PageNotification pageAppointmentsNotFound =
                    new PageNotification(PageNotification.NotificationType.NoAppointmentsForNow, returnBack: returnBack);
                NavigationService.Navigate(pageAppointmentsNotFound);
                isOk = false;
            }
            else if (
                patient.AppointmentsVisited.Count >= 0 &&
                patient.AppointmentsAvailable.Count == 0)
            {
                //do you want to see already checked appointments?
                BindingValues.Instance.SetUpMainWindow(patient.Name + ",", false, false);
                GridVisitedAppointmentsQuestion.Visibility = Visibility.Visible;

                if (patients.Count == 1)
                {
                    GridSinglePatient.Visibility = Visibility.Hidden;
                }
                else
                {
                    GridMultiplePatients.Visibility = Visibility.Hidden;
                }
            }
            else
            {
                PageShowAppointments pageAppointmentsShow = new PageShowAppointments(patient, returnBack);
                NavigationService.Navigate(pageAppointmentsShow);
            }

            SetImage(patient, isOk);
        }
        private void ButtonPatient_Click(object sender, RoutedEventArgs e)
        {
            ItemPatient itemPatient = (sender as Button).Tag as ItemPatient;

            CheckPatientStateAndShowAppointments(itemPatient);
        }
        public Excel.Worksheet CreateWorksheetAppointments(ItemPatient patient, out Excel.Workbook wb)
        {
            Logging.ToLog("ExcelInterop - Печать назначений для пациента: " + patient.Name + ", pcode: " + patient.PCode);
            wb = null;

            if (xlApp == null)
            {
                Logging.ToLog("ExcelInterop - Не запущен Excel, пропуск");
                return(null);
            }

            Excel.Worksheet ws = OpenTemplate(out wb, patient.Name + "_" + patient.PhoneNumber);
            if (ws == null)
            {
                return(null);
            }

            Logging.ToLog("ExcelInterop - Запись информации о назначениях");
            string[] nameSplitted = patient.Name.Split(' ');
            string   name         = nameSplitted[0];
            string   family       = patient.Name.Replace(name + " ", "");

            SetValue(ws, ROW_CLINIC_ADDRESS, clinic_address);
            SetValue(ws, ROW_CLINIC_PHONE_NUMBER, clinic_phone_number);
            SetValue(ws, ROW_NAME, name);
            SetValue(ws, ROW_FAMILY, family + ",");
            SetValue(ws, ROW_DATE_TIME, DateTime.Now.ToShortDateString() + ", " + DateTime.Now.ToShortTimeString());

            int currentRow = ROW_START;


            foreach (ItemAppointment item in patient.AppointmentsToShow)
            {
                SetValue(ws, currentRow, item.DateTimeScheduleBegin + ", кабинет " + item.RNum);
                currentRow++;
                SetValue(ws, currentRow, item.DName);
                currentRow++;
                SetValue(ws, currentRow, item.DepName);

                PasteFormat(ws, ROW_START, currentRow - 2, ROW_START + 2, currentRow);
                PasteDelimiter(ws, ref currentRow);
            }

            string timeMessage = Properties.Resources.print_message_final_ok;
            int    timeLeft    = patient.AppointmentsToShow.First().GetMinutesLeftToBegin();

            if (timeLeft >= 10)
            {
                timeMessage = Properties.Resources.print_message_time_left + timeLeft +
                              " " + NumbersEndingHelper.GetDeclension(timeLeft);
            }

            SetValue(ws, currentRow, timeMessage);
            PasteFormat(ws, ROW_STYLE, currentRow);
            PasteDelimiter(ws, ref currentRow);

            string notificationMessage = Properties.Resources.print_message_information_loyalty;

            if (patient.InfoCodesCurrent.Contains(ItemPatient.InfoCode.InformAboutLK))
            {
                Random rnd = new Random();
                if (rnd.Next(0, 100) < 50)
                {
                    notificationMessage = Properties.Resources.print_message_information_private_office;
                }
            }

            SetValue(ws, currentRow, notificationMessage);
            PasteFormat(ws, ROW_STYLE, currentRow);

            return(ws);
        }
        private void ParsePatientAppointmentRow(DataRow row, ref ItemPatient patient)
        {
            try {
                string group = row["GROUPS"].ToString().TrimStart(' ').TrimEnd(' ');
                string info  = row["INFO"].ToString().TrimStart(' ').TrimEnd(' ');

                if (info.Equals("0"))
                {
                    return;
                }

                string[] infoData = info.Split('@');
                if (infoData.Length == 0)
                {
                    return;
                }

                switch (group)
                {
                case "_STOP_CODE":
                    foreach (string code in infoData)
                    {
                        switch (code)
                        {
                        case "cash":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Cash);
                            break;

                        case "firsttime":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.FirstTime);
                            break;

                        case "lock":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Lock);
                            break;

                        case "late":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Late);
                            break;

                        //case "not_available_now":
                        //	patient.StopCodesCurrent.Add(ItemPatient.StopCodes.NotAvailableNow);
                        //	break;
                        case "depout":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.DepOut);
                            break;

                        case "debt":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Debt);
                            break;

                        case "sogl":
                            if (isThisASpbFilial)
                            {
                                patient.StopCodesCurrent.Add(ItemPatient.StopCode.Agreement);
                            }
                            break;

                        case "akt":
                            patient.StopCodesCurrent.Add(ItemPatient.StopCode.Akt);
                            break;

                        case "":
                            break;

                        default:
                            Logging.ToLog("DataHandle - Не удается распознать StopCode: " + code);
                            break;
                        }
                    }
                    break;

                case "_INFO_CODE":
                    foreach (string code in infoData)
                    {
                        switch (code)
                        {
                        case "inform_about_lk":
                            patient.InfoCodesCurrent.Add(ItemPatient.InfoCode.InformAboutLK);
                            break;

                        case "":
                            break;

                        default:
                            Logging.ToLog("DataHandle - Не удается распознать InfoCode: " + code);
                            break;
                        }
                    }
                    break;

                default:
                    if (infoData.Length != 7)
                    {
                        Logging.ToLog("DataHandle - Количество элементов в строке не равно 6: " + info);
                        break;
                    }

                    ItemAppointment itemAppointment = new ItemAppointment()
                    {
                        DateTimeScheduleBegin = infoData[0],
                        DateTimeScheduleEnd   = infoData[1],
                        DepShortName          = infoData[2],
                        DepName = ControlsFactory.FirstCharToUpper(infoData[3]),
                        DName   = infoData[4],
                        RNum    = infoData[5].Replace('№', ' '),
                        SchedID = infoData[6]
                    };

                    switch (group)
                    {
                    case "visited":
                        patient.AppointmentsVisited.Add(itemAppointment);
                        itemAppointment.AlreadyChecked = true;
                        break;

                    case "available":
                        patient.AppointmentsAvailable.Add(itemAppointment);
                        break;

                    case "not_available":
                        patient.AppointmentsNotAvailable.Add(itemAppointment);
                        break;

                    default:
                        break;
                    }

                    break;
                }
            } catch (Exception e) {
                Logging.ToLog(e.Message + Environment.NewLine + e.StackTrace);
            }
        }
Пример #9
0
        public PageShowAppointments(ItemPatient patient, bool returnBack)
        {
            InitializeComponent();
            Console.WriteLine(@"http://CONSTRUCT_PageShowAppointments");

            Logging.ToLog("PageShowAppointments - отображение страницы со списком назначений");

            this.returnBack = returnBack;
            this.patient    = patient ?? throw new ArgumentNullException(nameof(patient));
            schedIds        = patient.AppointmentsAvailable.Select(x => x.SchedID).ToList();

            string title = Properties.Resources.title_appointments.Replace("*", patient.Name);;

            if (patient.AppointmentsAvailable.Count == 0)
            {
                ButtonCheckIn.Visibility = Visibility.Hidden;

                if (patient.IsPrinterReady)
                {
                    ButtonPrint.Visibility = Visibility.Visible;
                    ButtonClose.Visibility = Visibility.Visible;
                }
                else
                {
                    ButtonCloseFull.Visibility = Visibility.Visible;
                }
            }

            BindingValues.Instance.SetUpMainWindow(title, true, false);

            int    row         = 0;
            double fontSize    = BindingValues.Instance.FontSizeMain;
            double fontSizeSub = BindingValues.Instance.FontSizeMain * 0.8;
            Brush  brushGray   = Brushes.LightGray;

            foreach (ItemAppointment item in patient.AppointmentsToShow)
            {
                TextBlock textBlockRoom = ControlsFactory.CreateTextBlock("Каб. " + item.RNum);
                textBlockRoom.FontSize          = fontSize;
                textBlockRoom.FontFamily        = BindingValues.Instance.FontFamilyMain;
                textBlockRoom.FontWeight        = FontWeights.Light;
                textBlockRoom.Margin            = new Thickness(10, 10, 20, 10);
                textBlockRoom.VerticalAlignment = VerticalAlignment.Top;
                Grid.SetRow(textBlockRoom, row);
                Grid.SetColumn(textBlockRoom, 0);
                GridAppointments.Children.Add(textBlockRoom);

                Border borderRoom = new Border {
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width      = 4,
                    Background = new SolidColorBrush(Color.FromRgb(171, 208, 71)),
                    Margin     = new Thickness(0, 5, 0, 5)
                };
                Grid.SetRow(borderRoom, row);
                Grid.SetColumn(borderRoom, 0);
                GridAppointments.Children.Add(borderRoom);

                StackPanel stackPanelTime = new StackPanel {
                    Orientation       = Orientation.Vertical,
                    Margin            = new Thickness(20, 10, 20, 10),
                    VerticalAlignment = VerticalAlignment.Center
                };
                Grid.SetRow(stackPanelTime, row);
                Grid.SetColumn(stackPanelTime, 1);
                GridAppointments.Children.Add(stackPanelTime);

                TextBlock textBlockTimeStart = ControlsFactory.CreateTextBlock(
                    "с " + ControlsFactory.ClearTimeString(item.DateTimeScheduleBegin),
                    horizontalAlignment: HorizontalAlignment.Right);
                textBlockTimeStart.FontSize   = fontSize;
                textBlockTimeStart.FontFamily = BindingValues.Instance.FontFamilyMain;
                textBlockTimeStart.FontWeight = FontWeights.Light;
                stackPanelTime.Children.Add(textBlockTimeStart);

                TextBlock textBlockTimeEnd = ControlsFactory.CreateTextBlock(
                    "до " + ControlsFactory.ClearTimeString(item.DateTimeScheduleEnd),
                    horizontalAlignment: HorizontalAlignment.Right);
                textBlockTimeEnd.FontSize   = fontSizeSub;
                textBlockTimeEnd.FontFamily = BindingValues.Instance.FontFamilyMain;
                textBlockTimeEnd.FontWeight = FontWeights.Light;
                textBlockTimeEnd.Foreground = brushGray;
                stackPanelTime.Children.Add(textBlockTimeEnd);

                Border borderTime = new Border {
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width      = 4,
                    Background = new SolidColorBrush(Color.FromRgb(171, 208, 71)),
                    Margin     = new Thickness(0, 5, 0, 5)
                };
                Grid.SetRow(borderTime, row);
                Grid.SetColumn(borderTime, 1);
                GridAppointments.Children.Add(borderTime);

                StackPanel stackPanelDoc = new StackPanel {
                    Orientation       = Orientation.Vertical,
                    Margin            = new Thickness(20, 10, 20, 10),
                    VerticalAlignment = VerticalAlignment.Center
                };
                Grid.SetRow(stackPanelDoc, row);
                Grid.SetColumn(stackPanelDoc, 2);
                GridAppointments.Children.Add(stackPanelDoc);

                TextBlock textBlockDoc = ControlsFactory.CreateTextBlock(item.DName);
                textBlockDoc.FontSize     = fontSize;
                textBlockDoc.FontWeight   = FontWeights.Light;
                textBlockDoc.FontFamily   = BindingValues.Instance.FontFamilyMain;
                textBlockDoc.TextTrimming = TextTrimming.CharacterEllipsis;
                stackPanelDoc.Children.Add(textBlockDoc);

                string deptString = item.DepName;
                if (deptString.Length > 45)
                {
                    deptString = deptString.Substring(0, 42) + "...";
                }

                TextBlock textBlockDept = ControlsFactory.CreateTextBlock(deptString);
                textBlockDept.FontSize     = fontSizeSub;
                textBlockDept.FontWeight   = FontWeights.Light;
                textBlockDept.FontFamily   = BindingValues.Instance.FontFamilyMain;
                textBlockDept.Foreground   = brushGray;
                textBlockDept.TextTrimming = TextTrimming.CharacterEllipsis;
                stackPanelDoc.Children.Add(textBlockDept);

                int    timeLeft       = item.GetMinutesLeftToBegin();
                string timeLeftString = string.Empty;
                Brush  brushTimeLeft  = brushGray;

                if (timeLeft >= -5 && timeLeft <= 5)
                {
                    timeLeftString = "Сейчас";

                    brushTimeLeft = new SolidColorBrush(Color.FromRgb(229, 92, 68));
                }
                else if (timeLeft > 5)
                {
                    timeLeftString = "Через " + timeLeft + " " +
                                     NumbersEndingHelper.GetDeclension(timeLeft);
                }

                Border borderDoc = new Border {
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width      = 4,
                    Background = new SolidColorBrush(Color.FromRgb(171, 208, 71)),
                    Margin     = new Thickness(0, 5, 0, 5)
                };
                Grid.SetRow(borderDoc, row);
                Grid.SetColumn(borderDoc, 2);
                GridAppointments.Children.Add(borderDoc);

                if (!string.IsNullOrEmpty(timeLeftString))
                {
                    TextBlock textBlockTimeLeft = ControlsFactory.CreateTextBlock(timeLeftString);
                    textBlockTimeLeft.FontSize            = fontSizeSub;
                    textBlockTimeLeft.FontWeight          = FontWeights.Light;
                    textBlockTimeLeft.FontFamily          = BindingValues.Instance.FontFamilyMain;
                    textBlockTimeLeft.Foreground          = brushTimeLeft;
                    textBlockTimeLeft.HorizontalAlignment = HorizontalAlignment.Right;
                    textBlockTimeLeft.VerticalAlignment   = VerticalAlignment.Bottom;
                    textBlockTimeLeft.Margin = new Thickness(20, 10, 10, 10);
                    Grid.SetRow(textBlockTimeLeft, row);
                    Grid.SetColumn(textBlockTimeLeft, 3);
                    GridAppointments.Children.Add(textBlockTimeLeft);
                }

                if (item.AlreadyChecked)
                {
                    StackPanel stackPanelChecked = new StackPanel()
                    {
                        Orientation         = Orientation.Horizontal,
                        Margin              = new Thickness(20, 17, 10, 10),
                        HorizontalAlignment = HorizontalAlignment.Right,
                        VerticalAlignment   = VerticalAlignment.Top
                    };

                    Image image = new Image()
                    {
                        Source            = ControlsFactory.GetImage(ControlsFactory.ImageType.NotificationOk),
                        MaxHeight         = 32,
                        MaxWidth          = 32,
                        VerticalAlignment = VerticalAlignment.Center
                    };
                    RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.HighQuality);
                    stackPanelChecked.Children.Add(image);

                    TextBlock textBlockChecked = new TextBlock()
                    {
                        Text              = "Отмечено ранее",
                        FontSize          = fontSizeSub,
                        FontWeight        = FontWeights.Light,
                        FontFamily        = BindingValues.Instance.FontFamilyMain,
                        Foreground        = brushGray,
                        Margin            = new Thickness(10, 0, 0, 0),
                        VerticalAlignment = VerticalAlignment.Center
                    };
                    stackPanelChecked.Children.Add(textBlockChecked);

                    Grid.SetRow(stackPanelChecked, row);
                    Grid.SetColumn(stackPanelChecked, 3);
                    GridAppointments.Children.Add(stackPanelChecked);
                }

                if (row > 0)
                {
                    GridAppointments.RowDefinitions.Add(new RowDefinition());

                    Border border = ControlsFactory.CreateBorder(row);
                    GridAppointments.Children.Add(border);
                }

                row++;

                if (patient.AppointmentsAvailable.Count == 0 &&
                    row == 4)
                {
                    break;
                }

                if (row == 6)
                {
                    break;
                }
            }

            DataContext       = BindingValues.Instance;
            IsVisibleChanged += (s, e) => {
                if ((bool)e.NewValue)
                {
                    if (isFirstLoad)
                    {
                        isFirstLoad = false;
                        return;
                    }

                    if (returnBack)
                    {
                        try {
                            NavigationService.GoBack();
                            NavigationService.RemoveBackEntry();
                        } catch (Exception exc) {
                            Logging.ToLog(exc.Message + Environment.NewLine + exc.StackTrace);
                        }
                    }
                }
            };
        }