Beispiel #1
0
        private void FillGrid()
        {
            try{
                TerminalList = TerminalActives.Refresh();
            }
            catch {           //SocketException if db connection gets lost.
                return;
            }
            int selected = gridMain.GetSelectedIndex();

            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableTerminals", "Computer Name"), 150);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableTerminals", "Status"), 100);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableTerminals", "Patient"), 150);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < TerminalList.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(TerminalList[i].ComputerName);
                row.Cells.Add(Lan.g("TerminalStatusEnum", TerminalList[i].TerminalStatus.ToString()));

                /*switch (TerminalList[i].TerminalStatus){
                 *      case TerminalStatusEnum.Standby:
                 *              row.Cells.Add("");
                 *              break;
                 * }*/
                if (TerminalList[i].PatNum == 0)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(Patients.GetLim(TerminalList[i].PatNum).GetNameLF());
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            gridMain.SetSelected(selected, true);
            if (gridMain.GetSelectedIndex() == -1 && gridMain.Rows.Count > 0)
            {
                gridMain.SetSelected(0, true);
            }
        }
        private void FillGrid()
        {
            long selectedTermNum = -1;

            if (gridMain.GetSelectedIndex() > -1)
            {
                selectedTermNum = (long)gridMain.Rows[gridMain.GetSelectedIndex()].Tag;              //set selectedTermNum before refreshing the _terminalList
            }
            try{
                _terminalList = TerminalActives.Refresh();
            }
            catch (Exception) {           //SocketException if db connection gets lost.
                return;
            }
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableTerminals", "Computer Name"), 110));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableTerminals", "Session Name"), 110));
            gridMain.Columns.Add(new ODGridColumn(Lan.g("TableTerminals", "Patient"), 185));
            gridMain.Rows.Clear();
            ODGridRow row;
            int       selectedIndex = -1;

            foreach (TerminalActive termCur in _terminalList)
            {
                row = new ODGridRow();
                row.Cells.Add(termCur.ComputerName);
                row.Cells.Add(termCur.SessionName);
                row.Cells.Add(termCur.PatNum > 0?Patients.GetLim(termCur.PatNum).GetNameLF():"");
                row.Tag = termCur.TerminalActiveNum;
                gridMain.Rows.Add(row);
                if (termCur.TerminalActiveNum == selectedTermNum)
                {
                    selectedIndex = gridMain.Rows.Count - 1;
                }
            }
            gridMain.EndUpdate();
            gridMain.SetSelected(Math.Max(selectedIndex, 0), true);          //selectedIndex could be -1 if the selected term is not in the list, default to row 0
        }
        private void FillGrid()
        {
            SheetDevice selected = new SheetDevice(new MobileAppDevice());          //just instantiate to something random that won't match any of our actual devices

            if (gridMain.GetSelectedIndex() > -1)
            {
                selected = (SheetDevice)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
            }
            List <SheetDevice> listDevices = new List <SheetDevice>();

            foreach (TerminalActive kiosk in TerminalActives.Refresh())
            {
                listDevices.Add(new SheetDevice(kiosk));
            }
            List <MobileAppDevice> listMobileDevices = new List <MobileAppDevice>();

            if (PrefC.HasClinicsEnabled)
            {
                //Option "All" is selected and at least one clinic is signed up for the eClipboard feature
                if (contrClinicPicker.IsAllSelected && PrefC.GetString(PrefName.EClipboardClinicsSignedUp) != "")
                {
                    listMobileDevices = MobileAppDevices.GetForUser(Security.CurUser).FindAll(x => x.IsAllowed);
                }
                //A specific clinic is selected and that is signed up for the eClipboard feature
                else if (MobileAppDevices.IsClinicSignedUpForEClipboard(contrClinicPicker.SelectedClinicNum))
                {
                    listMobileDevices = MobileAppDevices.GetForUser(Security.CurUser).FindAll(x => x.IsAllowed && x.ClinicNum == contrClinicPicker.SelectedClinicNum);
                }
            }
            //We aren't using clinics and the zero clinic is signed up
            else if (MobileAppDevices.IsClinicSignedUpForEClipboard(0))
            {
                listMobileDevices = MobileAppDevices.GetForUser(Security.CurUser).FindAll(x => x.IsAllowed);
            }
            //Add the clinics we decided on the the d
            foreach (MobileAppDevice device in listMobileDevices)
            {
                listDevices.Add(new SheetDevice(device));
            }
            int selectedIndex = -1;

            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.AddColumn("Device Name", 150);
            gridMain.AddColumn("Session Name", 110);
            gridMain.AddColumn("Patient", 185);
            if (PrefC.HasClinicsEnabled)
            {
                gridMain.AddColumn("Clinic", 150);
            }
            gridMain.ListGridColumns.Add(new GridColumn("Action", 50)
            {
                TextAlign = HorizontalAlignment.Center
            });
            if (_isSetupMode)
            {
                gridMain.ListGridColumns.Add(new GridColumn("Delete", 50)
                {
                    TextAlign = HorizontalAlignment.Center
                });
            }
            gridMain.ListGridRows.Clear();
            foreach (SheetDevice device in listDevices)
            {
                GridRow row = new GridRow();
                row.Tag = device;
                if (device.IsMobileAppDevice)
                {
                    row.Cells.Add(new GridCell(device.Name + "\r\n(" + device.MobileDevice.UniqueID + ")"));
                }
                else
                {
                    row.Cells.Add(new GridCell(device.Name));
                }
                row.Cells.Add(new GridCell(device.SessionName));
                row.Cells.Add(new GridCell(device.PatName));
                if (PrefC.HasClinicsEnabled)
                {
                    row.Cells.Add(new GridCell(device.ClinicDesc));
                }
                #region Load/Clear click handler
                void CellClick(object sender, EventArgs e)
                {
                    FillGrid();
                    if (device.PatNum == 0)                    //we are trying to load the patient
                    {
                        if (FormOpenDental.CurPatNum == 0)
                        {
                            MsgBox.Show(this, "There is currently no patient selected to send to the device. Select a patient in Open Dental " +
                                        "in order to continue.");
                            return;
                        }
                        if (device.IsKiosk)                          //kiosk only
                        {
                            if (listSheets.Items.Count == 0)         //eClipboard will allow to continue to load here in case we just want to take a photo
                            {
                                MsgBox.Show(this, "There are no sheets to send to the computer or device for the current patient.");
                                return;
                            }
                        }
                        else                           //eclipboard only
                        {
                            if (MobileAppDevices.PatientIsAlreadyUsingDevice(FormOpenDental.CurPatNum))
                            {
                                MsgBox.Show(this, "The patient you have selected is already using another device. Select a patient who is not currently " +
                                            "using a device in order to continue.");
                                return;
                            }
                            Appointment apptForToday = Appointments.GetAppointmentsForPat(FormOpenDental.CurPatNum).FirstOrDefault(x => x.AptDateTime.Date == DateTime.Today.Date);
                            if (apptForToday == null)
                            {
                                MsgBox.Show(this, "The patient you have selected does not have an appointment today. Only patients with an " +
                                            "appointment on the same day can be sent to eClipboard.");
                                return;
                            }
                            List <Sheet> listNonMobileSheets = listSheets.AllTags <Sheet>().FindAll(x => !x.HasMobileLayout);
                            if (listNonMobileSheets.Count > 0)
                            {
                                if (!MsgBox.Show(MsgBoxButtons.YesNo, "The following sheets that have been queued for this patient cannot be " +
                                                 $"loaded onto an eClipboard device because they do not have a mobile layout: \r\n" +
                                                 $"{string.Join(", ",listNonMobileSheets.Select(x => x.Description))}. \r\nDo you still wish to continue?"))
                                {
                                    return;
                                }
                            }
                            //They are in setup mode (not normal workflow) and there are no sheets for this patient. They have not run the rules to generate
                            //sheets as the patient has not been marked as arrived. When they push the patient to the device, they will not generate the sheets
                            //from there either. Ask them if they want to generate the sheets in this case.
                            if (_isSetupMode && listSheets.Items.Count == 0 && ClinicPrefs.GetBool(PrefName.EClipboardCreateMissingFormsOnCheckIn, apptForToday.ClinicNum))
                            {
                                bool generateSheets = MsgBox.Show(MsgBoxButtons.YesNo, "This patient has no forms to load. Would you like to generate the " +
                                                                  "forms based on the eClipboard rules?");
                                if (generateSheets)
                                {
                                    //We do not need to update the UI here. It will be updated at the end of this click method.
                                    Sheets.CreateSheetsForCheckIn(apptForToday);
                                }
                            }
                        }
                        device.SetPatNum(FormOpenDental.CurPatNum);
                    }
                    else                       //we are trying to clear the patient
                    {
                        if (!MsgBox.Show(this, true, "A patient is currently using the terminal.  If you continue, they will lose the information that is on their "
                                         + "screen.  Continue anyway?"))
                        {
                            return;
                        }
                        device.SetPatNum(0);
                    }
                    FillGrid();
                }

                #endregion Load/Clear click handler
                GridCell cell = new GridCell(device.PatNum == 0?"Load":"Clear");
                cell.ColorBackG = Color.LightGray;
                cell.ClickEvent = CellClick;
                row.Cells.Add(cell);
                if (_isSetupMode)
                {
                    #region Delete click handler
                    void DeleteClick(object sender, EventArgs e)
                    {
                        FillGrid();
                        if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "A row should not be deleted unless it is showing erroneously and there really is " +
                                         "nothing running on the computer or device shown.  Continue anyway?"))
                        {
                            return;
                        }
                        device.Delete();
                        FillGrid();
                    }

                    #endregion Delete click handler
                    cell            = new GridCell("Delete");
                    cell.ColorBackG = Color.LightGray;
                    cell.ClickEvent = DeleteClick;
                    row.Cells.Add(cell);
                }
                gridMain.ListGridRows.Add(row);
                if (selected != null && device.Matches(selected))
                {
                    selectedIndex = gridMain.ListGridRows.Count - 1;
                }
            }
            gridMain.EndUpdate();
            gridMain.SetSelected(selectedIndex, true);           //selectedIndex could be -1 if the selected term is not in the list, default to row 0
            FillPat();
        }