Example #1
0
        private void FillGrid()
        {
            if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" ||
                textDateFrom.errorProvider1.GetError(textDateFrom) != "")
            {
                //MsgBox.Show(this,"Please fix errors first.");
                return;
            }
            DateTime dateMax = new DateTime(2100, 1, 1);

            if (textDateTo.Text != "")
            {
                dateMax = PIn.Date(textDateTo.Text);
            }
            table = LabCases.Refresh(PIn.Date(textDateFrom.Text), dateMax, checkShowAll.Checked, checkShowUnattached.Checked);
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col;

            col = new GridColumn(Lan.g("TableLabCases", "Appt Date Time"), 120);
            col.SortingStrategy = GridSortingStrategy.DateParse;
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabCases", "Procedures"), 200);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabCases", "Patient"), 120);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabCases", "Status"), 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabCases", "Lab"), 75);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabCases", "Lab Phone"), 100);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g("TableLabCases", "Instructions"), 100);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow     row;
            List <long> operatoryNums = new List <long>();

            if (PrefC.HasClinicsEnabled)
            {
                if (comboClinic.SelectedIndex == 0 && !Security.CurUser.ClinicIsRestricted)               //"All"
                {
                    operatoryNums = null;
                }
                else if (comboClinic.SelectedIndex == 0)               //"All" that the user has access to.
                {
                    foreach (Clinic clinic in _listClinics)
                    {
                        operatoryNums.AddRange(Operatories.GetOpsForClinic(clinic.ClinicNum).Select(x => x.OperatoryNum));
                    }
                }
                else
                {
                    operatoryNums.AddRange(Operatories.GetOpsForClinic(_listClinics[comboClinic.SelectedIndex - 1].ClinicNum).Select(x => x.OperatoryNum));
                }
            }
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (PrefC.HasClinicsEnabled &&             //no filtering for non clinics.
                    operatoryNums != null &&                   //we don't have "All" selected for an unrestricted user.
                    table.Rows[i]["AptNum"].ToString() != "0" &&                   //show unattached for any clinic
                    !operatoryNums.Contains(PIn.Long(table.Rows[i]["OpNum"].ToString()))) //Attached appointment is scheduled in an Op for the clinic
                {
                    continue;                                                             //appointment scheduled in an operatory for another clinic.
                }
                row = new GridRow();
                row.Cells.Add(table.Rows[i]["aptDateTime"].ToString());
                row.Cells.Add(table.Rows[i]["ProcDescript"].ToString());
                row.Cells.Add(table.Rows[i]["patient"].ToString());
                row.Cells.Add(table.Rows[i]["status"].ToString());
                row.Cells.Add(table.Rows[i]["lab"].ToString());
                row.Cells.Add(table.Rows[i]["phone"].ToString());
                row.Cells.Add(table.Rows[i]["Instructions"].ToString());
                row.Tag = table.Rows[i];
                gridMain.ListGridRows.Add(row);
            }
            gridMain.AllowSortingByColumn = true;
            gridMain.EndUpdate();
        }
Example #2
0
        private void DoSearch()
        {
            Cursor = Cursors.WaitCursor;
            DateTime startDate = dateSearchFrom.Value.Date.AddDays(-1);          //Text on boxes is To/From. This will effecitvely make it the 'afterDate'.
            DateTime endDate   = dateSearchTo.Value.Date.AddDays(1);

            _listOpenings.Clear();
            #region validation
            if (startDate.Year < 1880 || endDate.Year < 1880)
            {
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Invalid date selection.");
                return;
            }
            TimeSpan beforeTime = new TimeSpan(0);
            if (textBefore.Text != "")
            {
                try {
                    beforeTime = GetBeforeAfterTime(textBefore.Text, radioBeforePM.Checked);
                }
                catch {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "Invalid 'Starting before' time.");
                    return;
                }
            }
            TimeSpan afterTime = new TimeSpan(0);
            if (textAfter.Text != "")
            {
                try {
                    afterTime = GetBeforeAfterTime(textAfter.Text, radioAfterPM.Checked);
                }
                catch {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "Invalid 'Starting after' time.");
                    return;
                }
            }
            if (comboBoxMultiProv.SelectedTags <Provider>().Contains(null) && comboBlockout.GetSelectedDefNum() == 0)
            {
                Cursor = Cursors.Default;
                MsgBox.Show(this, "Please pick a provider or a blockout type.");
                return;
            }
            #endregion
            //get lists of info to do the search
            List <long> listOpNums     = new List <long>();
            List <long> listClinicNums = new List <long>();
            List <long> listProvNums   = new List <long>();
            long        blockoutType   = 0;
            if (comboBlockout.GetSelectedDefNum() != 0)
            {
                blockoutType = comboBlockout.GetSelectedDefNum();
                listProvNums.Add(0);                //providers don't matter for blockouts
            }
            if (!comboBoxMultiProv.SelectedTags <Provider>().Contains(null))
            {
                foreach (ODBoxItem <Provider> provBoxItem in comboBoxMultiProv.ListSelectedItems)
                {
                    listProvNums.Add(provBoxItem.Tag.ProvNum);
                }
            }
            if (PrefC.HasClinicsEnabled)
            {
                if (comboBoxClinic.SelectedClinicNum != 0)
                {
                    listClinicNums.Add(comboBoxClinic.SelectedClinicNum);
                    listOpNums = Operatories.GetOpsForClinic(comboBoxClinic.SelectedClinicNum).Select(x => x.OperatoryNum).ToList();
                }
                else                  //HQ //and unassigned (which is clinic num 0)
                {
                    long apptViewNum = comboApptView.GetSelected <ApptView>().ApptViewNum;
                    //get the disctinct clinic nums for the operatories in the current appointment view
                    List <long>      listOpsForView  = ApptViewItems.GetOpsForView(apptViewNum);
                    List <Operatory> listOperatories = Operatories.GetOperatories(listOpsForView, true);
                    listClinicNums = listOperatories.Select(x => x.ClinicNum).Distinct().ToList();
                    listOpNums     = listOperatories.Select(x => x.OperatoryNum).ToList();
                }
            }
            else              //no clinics
            {
                listOpNums = Operatories.GetDeepCopy(true).Select(x => x.OperatoryNum).ToList();
            }
            if (blockoutType != 0 && listProvNums.Max() > 0)
            {
                _listOpenings.AddRange(ApptSearch.GetSearchResultsForBlockoutAndProvider(listProvNums, _appt.AptNum, startDate, endDate, listOpNums, listClinicNums
                                                                                         , beforeTime, afterTime, blockoutType, 15));
            }
            else
            {
                _listOpenings = ApptSearch.GetSearchResults(_appt.AptNum, startDate, endDate, listProvNums, listOpNums, listClinicNums
                                                            , beforeTime, afterTime, blockoutType, resultCount: 15);
            }
            Cursor = Cursors.Default;
            FillGrid();
        }