Beispiel #1
0
 private void FormOrthoChart_Load(object sender, EventArgs e)
 {
     signatureBoxWrapper.SetAllowDigitalSig(true);
     _listOrthoChartsInitial = OrthoCharts.GetAllForPatient(_patCur.PatNum);
     _listDatesAdded         = new List <DateTime>()
     {
         DateTime.Today
     };
     _listOrthoChartTabs = OrthoChartTabs.GetDeepCopy(true);
     FillTabs();
     _dictOrthoCharts = new SortedDictionary <DateTime, List <OrthoChart> >();
     FillDictionary();
     //A specific tab is desired to be pre-selected.  This has to happen after FillDataTable() because it causes FillGrid() to get called.
     if (_indexInitialTab != tabControl.SelectedIndex)
     {
         tabControl.SelectedIndex = _indexInitialTab;
     }
     else              //Tab index hasn't changed, fill the grid.
     {
         FillGrid();
     }
     FillGridPat();
     if (PrefC.GetBool(PrefName.OrthoCaseInfoInOrthoChart))
     {
         gridOrtho.Visible = true;
         FillOrtho();
     }
 }
Beispiel #2
0
        private void FormOrthoChart_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Save data from grid to table
            for (int i = 0; i < gridMain.Rows.Count; i++)
            {
                table.Rows[i]["Date"] = gridMain.Rows[i].Tag;              //store date
                for (int j = 0; j < listOrthDisplayFields.Count; j++)
                {
                    table.Rows[i][j + 1] = gridMain.Rows[i].Cells[j + 1].Text;
                }
            }
            List <OrthoChart> tempOrthoChartsFromDB    = OrthoCharts.GetAllForPatient(PatCur.PatNum);
            List <OrthoChart> tempOrthoChartsFromTable = new List <OrthoChart>();

            for (int r = 0; r < table.Rows.Count; r++)
            {
                for (int c = 1; c < table.Columns.Count; c++)           //skip col 0
                {
                    OrthoChart tempChart = new OrthoChart();
                    tempChart.DateService = (DateTime)table.Rows[r]["Date"];
                    tempChart.FieldName   = listOrthDisplayFields[c - 1].Description;
                    tempChart.FieldValue  = table.Rows[r][c].ToString();
                    tempChart.PatNum      = PatCur.PatNum;
                    tempOrthoChartsFromTable.Add(tempChart);
                }
            }
            //Check table list vs DB list for inserts, updates, and deletes.
            for (int i = 0; i < tempOrthoChartsFromTable.Count; i++)
            {
                //Either delete an existing record from the DB or ignore this non-entry.
                if (tempOrthoChartsFromTable[i].FieldValue == "")
                {
                    for (int j = 0; j < tempOrthoChartsFromDB.Count; j++)
                    {
                        if (tempOrthoChartsFromDB[j].DateService == tempOrthoChartsFromTable[i].DateService &&
                            tempOrthoChartsFromDB[j].FieldName == tempOrthoChartsFromTable[i].FieldName)
                        {
                            OrthoCharts.Delete(tempOrthoChartsFromDB[j].OrthoChartNum);
                            break;
                        }
                    }
                    continue;                    //i loop
                }
                //Update the Record if it already exists or Insert if it's new.
                for (int j = 0; j <= tempOrthoChartsFromDB.Count; j++)
                {
                    //Insert if you've made it through the whole list.
                    if (j == tempOrthoChartsFromDB.Count)
                    {
                        OrthoCharts.Insert(tempOrthoChartsFromTable[i]);
                        break;
                    }
                    //Update if type and date match
                    if (tempOrthoChartsFromDB[j].DateService == tempOrthoChartsFromTable[i].DateService &&
                        tempOrthoChartsFromDB[j].FieldName == tempOrthoChartsFromTable[i].FieldName)
                    {
                        tempOrthoChartsFromTable[i].OrthoChartNum = tempOrthoChartsFromDB[j].OrthoChartNum;
                        OrthoCharts.Update(tempOrthoChartsFromTable[i]);
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        private void FormOrthoChart_Load(object sender, EventArgs e)
        {
            //define the table----------------------------------------------------------------------------------------------------------
            table = new DataTable("OrthoChartForPatient");
            //define columns----------------------------------------------------------------------------------------------------------
            table.Columns.Add("Date", typeof(DateTime));
            listOrthDisplayFields = DisplayFields.GetForCategory(DisplayFieldCategory.OrthoChart);
            for (int i = 0; i < listOrthDisplayFields.Count; i++)
            {
                table.Columns.Add((i + 1).ToString());              //named by number, but probably refer to by index
            }
            //define rows------------------------------------------------------------------------------------------------------------
            listOrthoCharts = OrthoCharts.GetAllForPatient(PatCur.PatNum);
            List <DateTime> datesShowing          = new List <DateTime>();
            List <string>   listDisplayFieldNames = new List <string>();

            for (int i = 0; i < listOrthDisplayFields.Count; i++)       //fill listDisplayFieldNames to be used in comparison
            {
                listDisplayFieldNames.Add(listOrthDisplayFields[i].Description);
            }
            //start adding dates starting with today's date
            datesShowing.Add(DateTime.Today);
            for (int i = 0; i < listOrthoCharts.Count; i++)
            {
                if (!listDisplayFieldNames.Contains(listOrthoCharts[i].FieldName))                 //skip rows not in display fields
                {
                    continue;
                }
                if (!datesShowing.Contains(listOrthoCharts[i].DateService))                 //add dates not already in date list
                {
                    datesShowing.Add(listOrthoCharts[i].DateService);
                }
            }
            datesShowing.Sort();
            //We now have a list of dates.
            //add all blank cells to each row except for the date.
            DataRow row;

            //create and add row for each date in date showing
            for (int i = 0; i < datesShowing.Count; i++)
            {
                row         = table.NewRow();
                row["Date"] = datesShowing[i];
                for (int j = 0; j < listOrthDisplayFields.Count; j++)
                {
                    row[j + 1] = "";                //j+1 because first row is date field.
                }
                table.Rows.Add(row);
            }
            //We now have a table with all empty strings in cells except dates.
            //Fill with data as necessary.
            for (int i = 0; i < listOrthoCharts.Count; i++)       //loop
            {
                if (!datesShowing.Contains(listOrthoCharts[i].DateService))
                {
                    continue;
                }
                if (!listDisplayFieldNames.Contains(listOrthoCharts[i].FieldName))
                {
                    continue;
                }
                for (int j = 0; j < table.Rows.Count; j++)
                {
                    if (listOrthoCharts[i].DateService == (DateTime)table.Rows[j]["Date"])
                    {
                        table.Rows[j][listDisplayFieldNames.IndexOf(listOrthoCharts[i].FieldName) + 1] = listOrthoCharts[i].FieldValue;
                    }
                }
            }
            FillGrid();
            FillGridPat();
        }