Ejemplo n.º 1
0
        private void butSetupTabs_Click(object sender, EventArgs e)
        {
            FormOrthoChartSetup form = new FormOrthoChartSetup();

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            List <OrthoChartTabFields> listOldTabDisplayFields = _listTabDisplayFields;

            _listTabDisplayFields = new List <OrthoChartTabFields>();
            //The tab order may have changed.  Also new tabs may have been added.  Tabs were not removed, because they can only be hidden not deleted.
            //If orthocharttabs order changed or new tabs were added, then the cache was updated in FormOrthoChartSetup in OK click.
            _listOrthoChartTabs = OrthoChartTabs.GetDeepCopy(true);
            foreach (OrthoChartTab orthoChartTab in _listOrthoChartTabs)
            {
                OrthoChartTabFields orthoChartTabFieldsOld = listOldTabDisplayFields.FirstOrDefault(
                    x => x.OrthoChartTab != null && x.OrthoChartTab.OrthoChartTabNum == orthoChartTab.OrthoChartTabNum);
                OrthoChartTabFields orthoChartTabFields = new OrthoChartTabFields();
                orthoChartTabFields.OrthoChartTab = orthoChartTab;
                if (orthoChartTabFieldsOld == null)               //Either a new tab was added or a hidden tab was un-hidden.
                {
                    orthoChartTabFields.ListDisplayFields = new List <DisplayField>();
                    List <OrthoChartTabLink> listOrthoChartTabLinks = OrthoChartTabLinks.GetWhere(
                        x => x.OrthoChartTabNum == orthoChartTab.OrthoChartTabNum);
                    foreach (OrthoChartTabLink orthoChartTabLink in listOrthoChartTabLinks)
                    {
                        orthoChartTabFields.ListDisplayFields.AddRange(_listAllDisplayFields.FindAll(x => x.DisplayFieldNum == orthoChartTabLink.DisplayFieldNum));
                    }
                }
                else                  //The tab already existed.  Maintain the display field names and order within the tab, especially if the tab order changed.
                {
                    orthoChartTabFields.ListDisplayFields = orthoChartTabFieldsOld.ListDisplayFields;
                }
                _listTabDisplayFields.Add(orthoChartTabFields);
            }
            //Always add the orphaned OrthoChartTabFields back because they can not be affected from the Tab Setup window.
            _listTabDisplayFields.AddRange(listOldTabDisplayFields.FindAll(x => x.OrthoChartTab == null));
            //Refresh the combo box and the grid because there is a chance that the user was viewing a different tab than the first in the list.
            FillComboOrthoChartTabs();
            FillGrids();
        }
Ejemplo n.º 2
0
        private void LoadDisplayFields()
        {
            OrthoChartTabs.RefreshCache();
            OrthoChartTabLinks.RefreshCache();
            DisplayFields.RefreshCache();
            _listAllDisplayFields = DisplayFields.GetAllAvailableList(DisplayFieldCategory.OrthoChart);
            _listTabDisplayFields = new List <OrthoChartTabFields>();
            //Add all fields that are actively associated to a tab to our class wide list of tabs and fields.
            for (int i = 0; i < _listOrthoChartTabs.Count; i++)
            {
                OrthoChartTabFields orthoChartTabFields = new OrthoChartTabFields();
                orthoChartTabFields.OrthoChartTab     = _listOrthoChartTabs[i];
                orthoChartTabFields.ListDisplayFields = new List <DisplayField>();
                List <OrthoChartTabLink> listOrthoChartTabLinks = OrthoChartTabLinks.GetWhere(
                    x => x.OrthoChartTabNum == _listOrthoChartTabs[i].OrthoChartTabNum);
                listOrthoChartTabLinks.OrderBy(x => x.ItemOrder);
                foreach (OrthoChartTabLink orthoChartTabLink in listOrthoChartTabLinks)
                {
                    orthoChartTabFields.ListDisplayFields.AddRange(_listAllDisplayFields.FindAll(x => x.DisplayFieldNum == orthoChartTabLink.DisplayFieldNum));
                }
                _listTabDisplayFields.Add(orthoChartTabFields);
            }
            //Add a dummy OrthoChartTabFields object to the list that represents available fields that are not part of any tab.
            //These "display fields" were previously used at least once. A patient has info for this field, then the office removed the field from all tabs.
            List <DisplayField> listOrphanedFields = _listAllDisplayFields.FindAll(x => x.DisplayFieldNum == 0 ||
                                                                                   !OrthoChartTabLinks.GetExists(y => y.DisplayFieldNum == x.DisplayFieldNum));

            if (listOrphanedFields != null && listOrphanedFields.Count > 0)
            {
                OrthoChartTabFields orphanedFields = new OrthoChartTabFields();
                orphanedFields.OrthoChartTab     = null;          //These are fields not associated to any tab.  Purposefully use null.
                orphanedFields.ListDisplayFields = new List <DisplayField>();
                orphanedFields.ListDisplayFields.AddRange(listOrphanedFields);
                _listTabDisplayFields.Add(orphanedFields);
            }
        }
Ejemplo n.º 3
0
        ///<summary>Clears the current grid and fills from datatable.  Do not call unless you have saved changes to database first.</summary>
        private void FillGrid()
        {
            if (tabControl.SelectedIndex == -1)
            {
                return;                //This happens when the tab pages are cleared (updating the selected index).
            }
            //else if(_indexInitialTab!=0) {
            //	tabControl.SelectedIndex=_indexInitialTab;
            //	_indexInitialTab=0;
            //}
            Cursor = Cursors.WaitCursor;
            //Get all the corresponding fields from the OrthoChartTabLink table that are associated to the currently selected ortho tab.
            OrthoChartTab       orthoChartTab = _listOrthoChartTabs[tabControl.SelectedIndex];
            List <DisplayField> listSelectedTabDisplayFields =
                OrthoChartTabLinks.GetWhere(x => x.OrthoChartTabNum == orthoChartTab.OrthoChartTabNum)           //Determines the number of items that will be returned
                .OrderBy(x => x.ItemOrder)                                                                       //Each tab is ordered based on the ortho tab link entry
                .Select(x => _listOrthDisplayFields.FirstOrDefault(y => y.DisplayFieldNum == x.DisplayFieldNum)) //Project all corresponding display fields in order
                .Where(x => x != null)                                                                           //Can happen when there is an OrthoChartTabLink in the database pointing to an invalid display field.
                .ToList();                                                                                       //Casts the projection to a list of display fields

            _sigColIdx = -1;                                                                                     //Clear out the signature column index cause it will most likely change or disappear (switching tabs)
            int gridMainScrollValue = gridMain.ScrollValue;

            gridMain.BeginUpdate();
            //Set the title of the grid to the title of the currently selected ortho chart tab.  This is so that medical users don't see Ortho Chart.
            gridMain.Title = orthoChartTab.TabName;
            gridMain.Columns.Clear();
            ODGridColumn col;

            //First column will always be the date.  gridMain_CellLeave() depends on this fact.
            col = new ODGridColumn(Lan.g(this, "Date"), 70);
            gridMain.Columns.Add(col);
            foreach (DisplayField field in listSelectedTabDisplayFields)
            {
                string columnHeader = string.IsNullOrEmpty(field.DescriptionOverride) ? field.Description : field.DescriptionOverride;
                if (!string.IsNullOrEmpty(field.PickList))
                {
                    List <string> listComboOptions = field.PickList.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
                    col = new ODGridColumn(columnHeader, field.ColumnWidth, listComboOptions);
                }
                else
                {
                    col = new ODGridColumn(columnHeader, field.ColumnWidth, true);
                    if (field.InternalName == "Signature")
                    {
                        _sigColIdx     = gridMain.Columns.Count;
                        col.TextAlign  = HorizontalAlignment.Center;
                        col.IsEditable = false;
                    }
                }
                col.Tag = field.Description;
                gridMain.Columns.Add(col);
            }
            gridMain.Rows.Clear();
            ODGridRow row;

            foreach (KeyValuePair <DateTime, List <OrthoChart> > kvPair in _dictOrthoCharts)
            {
                row = new ODGridRow();
                DateTime tempDate = kvPair.Key;
                row.Cells.Add(tempDate.ToShortDateString());
                row.Tag = tempDate;
                bool areAllColumnsBlank = true;
                foreach (DisplayField field in listSelectedTabDisplayFields)
                {
                    string cellValue = "";
                    if (field.InternalName != "Signature")
                    {
                        //Find the index of the corresponding column in our table via the column title.
                        OrthoChart chart = kvPair.Value.Find(x => x.FieldName == field.Description);
                        if (chart != null)
                        {
                            cellValue = chart.FieldValue;
                        }
                    }
                    if (!string.IsNullOrEmpty(field.PickList))
                    {
                        List <string> listComboOptions = field.PickList.Split(new string[] { "\r\n" }, StringSplitOptions.None).ToList();
                        int           selectedIndex    = listComboOptions.FindIndex(x => x == cellValue);
                        row.Cells.Add(cellValue, selectedIndex);
                    }
                    else
                    {
                        row.Cells.Add(cellValue);
                    }
                    if (cellValue != "")
                    {
                        areAllColumnsBlank = false;
                    }
                }
                if (!areAllColumnsBlank || _listDatesAdded.Contains(tempDate))
                {
                    gridMain.Rows.Add(row);
                }
                CanEditRow(tempDate);
            }
            gridMain.EndUpdate();
            if (gridMainScrollValue == 0)
            {
                gridMain.ScrollToEnd();
            }
            else
            {
                gridMain.ScrollValue = gridMainScrollValue;
                gridMainScrollValue  = 0;
            }
            //Show the signature control if a signature display field is present on any tab.
            _showSigBox = _listOrthDisplayFields.Any(x => x.InternalName == "Signature");
            signatureBoxWrapper.Visible = _showSigBox;          //Hide the signature box if this tab does not have the signature column present.
            if (_showSigBox)
            {
                for (int i = 0; i < gridMain.Rows.Count; i++)
                {
                    DisplaySignature(i, false);
                }
                signatureBoxWrapper.ClearSignature();
                signatureBoxWrapper.Enabled = false;              //We don't want it to be enabled unless the user has clicked on a row.
                _prevRow = -1;
            }
            Cursor = Cursors.Default;
        }