예제 #1
0
        private void FillGrid()
        {
            table = EhrPatListElements.GetListOrderBy2014Retro(elementList);
            int      colWidth = 0;
            Graphics g        = CreateGraphics();

            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn("PatNum", 60, HorizontalAlignment.Center);
            col.SortingStrategy = GridSortingStrategy.AmountParse;
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Full Name", 200);
            col.SortingStrategy = GridSortingStrategy.StringCompare;
            gridMain.Columns.Add(col);
            for (int i = 0; i < elementList.Count; i++)
            {
                if (orderByColumn == -1 && elementList[i].OrderBy)
                {
                    //There can be 0 to 1 elements that have OrderBy set to true.
                    //we will use this to determine how to use the ASC/DESC buttons.
                    //some elements add one column, others add two, this selects the column that is to be added next.
                    orderByColumn = gridMain.Columns.Count;
                }
                switch (elementList[i].Restriction)
                {
                case EhrRestrictionType.Birthdate:
                    col = new ODGridColumn("Birthdate", 80, HorizontalAlignment.Center);
                    col.SortingStrategy = GridSortingStrategy.DateParse;
                    gridMain.Columns.Add(col);
                    break;

                case EhrRestrictionType.Gender:
                    col = new ODGridColumn("Gender", 80, HorizontalAlignment.Center);
                    gridMain.Columns.Add(col);
                    break;

                case EhrRestrictionType.LabResult:
                    colWidth            = System.Convert.ToInt32(g.MeasureString("Lab Value: " + elementList[i].CompareString, this.Font).Width);
                    col.SortingStrategy = GridSortingStrategy.AmountParse;
                    colWidth            = colWidth + (colWidth / 10);           //Add 10%
                    col = new ODGridColumn("Lab Value: " + elementList[i].CompareString, colWidth, HorizontalAlignment.Center);
                    gridMain.Columns.Add(col);
                    break;

                case EhrRestrictionType.Medication:
                    col = new ODGridColumn("Medication", 90, HorizontalAlignment.Center);
                    col.SortingStrategy = GridSortingStrategy.StringCompare;
                    gridMain.Columns.Add(col);
                    break;

                case EhrRestrictionType.Problem:
                    col = new ODGridColumn("Disease", 160, HorizontalAlignment.Center);
                    col.SortingStrategy = GridSortingStrategy.StringCompare;
                    gridMain.Columns.Add(col);
                    break;

                default:
                    //should not happen.
                    break;
                }
            }
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(table.Rows[i]["PatNum"].ToString());
                row.Cells.Add(table.Rows[i]["LName"].ToString() + ", " + table.Rows[i]["FName"].ToString());
                //Add 3 to j to compensate for PatNum, LName and FName.
                for (int j = 0; j < elementList.Count; j++)           //sometimes one element might pull two columns, Lab Results for instance.//<elementList.Count;j++) {
                {
                    switch (elementList[j].Restriction)
                    {
                    case EhrRestrictionType.Medication:
                    case EhrRestrictionType.Problem:
                        row.Cells.Add(table.Rows[i][j + 3].ToString());
                        break;

                    case EhrRestrictionType.Birthdate:
                        row.Cells.Add(table.Rows[i][j + 3].ToString().Replace(" 12:00:00 AM", ""));
                        break;

                    case EhrRestrictionType.LabResult:
                        row.Cells.Add(table.Rows[i][j + 3].ToString());                              //obsVal
                        break;

                    case EhrRestrictionType.Gender:
                        switch (table.Rows[i][j + 3].ToString())
                        {
                        case "0":                                        //Male
                            row.Cells.Add("Male");
                            break;

                        case "1":                                        //Female
                            row.Cells.Add("Female");
                            break;

                        case "2":                                        //Unknown
                        default:
                            row.Cells.Add("Unknown");
                            break;
                        }
                        break;
                    }
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            g.Dispose();
        }