Exemplo n.º 1
0
 ///<summary>Just checks if the primary keys for this device and the passed in device matches</summary>
 public bool Matches(SheetDevice device)
 {
     if (IsKiosk && device.IsKiosk)
     {
         return(this._computerKiosk.TerminalActiveNum == device._computerKiosk.TerminalActiveNum);
     }
     else if (!IsKiosk && !device.IsKiosk)
     {
         return(this._mobileDevice.MobileAppDeviceNum == device._mobileDevice.MobileAppDeviceNum);
     }
     return(false);                //one is kiosk and the other isn't
 }
Exemplo n.º 2
0
        private void butPatForms_Click(object sender, EventArgs e)
        {
            if (gridMain.GetSelectedIndex() < 0)
            {
                return;
            }
            FormPatientForms formPF = new FormPatientForms();
            SheetDevice      device = (SheetDevice)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;

            formPF.PatNum = device.PatNum == 0?FormOpenDental.CurPatNum:device.PatNum;
            formPF.ShowDialog();
            FillPat();
        }
Exemplo n.º 3
0
        private void FillPat()
        {
            bool isRowSelected = gridMain.GetSelectedIndex() > -1;

            groupBoxPatient.Enabled = isRowSelected;
            listSheets.Visible      = isRowSelected;
            butPatForms.Visible     = isRowSelected;
            if (!isRowSelected)
            {
                groupBoxPatient.Text = "Select a Device First";
                labelPatient.Text    = "";
                labelSheets.Text     = "";
                return;
            }
            SheetDevice device = (SheetDevice)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;

            listSheets.Items.Clear();
            if (device.PatNum == 0)
            {
                groupBoxPatient.Text = "Patient to Load to Device";
                labelSheets.Text     = "Forms to Load to Device";
                if (FormOpenDental.CurPatNum == 0)
                {
                    labelPatient.Text   = "None Selected";
                    butPatForms.Enabled = false;
                }
                else
                {
                    labelPatient.Text   = Patients.GetLim(FormOpenDental.CurPatNum).GetNameLF();
                    butPatForms.Enabled = true;
                    Sheets.GetForTerminal(FormOpenDental.CurPatNum).ForEach(x => listSheets.Items.Add(new ODBoxItem <Sheet>(x.Description, tag: x)));
                }
            }
            else
            {
                groupBoxPatient.Text = "Patient on Device";
                labelSheets.Text     = "Forms on Device";
                labelPatient.Text    = device.PatName;
                butPatForms.Enabled  = !device.IsKiosk;
                Sheets.GetForTerminal(device.PatNum).ForEach(x => listSheets.Items.Add(new ODBoxItem <Sheet>(x.Description, x)));
            }
        }
Exemplo n.º 4
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();
        }