using framework_business; using framework_library; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Web.UI; using System.Web.UI.WebControls; using Telerik.Web.UI; public partial class controls_module_medicalSubjectives : UserControl, ISurfaceControlBase { #region methods /// /// ReloadControl /// /// public void ReloadControl(oSurfaceFieldData controlFieldData, bool alternateView = false, bool readOnly = false) { try { SurfaceItemId = controlFieldData.surfaceItemId; if(!alternateView) FillChart(); FillGrid(); } catch (Exception ex) { exception.HandleException("medicalSubjectives:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } private void FillGrid() { try { DtSubjectives = xData.GetSubjectivesAndNotesBySurfaceItemId(SurfaceItemId); ////if no subjectives //{ DataView dv = new DataView(DtSubjectives); if (DtSubjectives.Columns.Count > 1) dv.Sort = "Date DESC"; grdSubjectives.DataSource = dv.ToTable(); grdSubjectives.DataBind(); //} } catch (Exception ex) { exception.HandleException("medicalSubjectives:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } /// /// Save Control Data /// /// public void SaveControlData(ref oSurfaceFieldData _surfaceFieldData) { try { } catch (Exception ex) { exception.HandleException("medicalSubjectives:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } private void FillChart() { try { HtmlChartHolderXS.Visible = true; HtmlChartHolderSM.Visible = true; HtmlChartHolderMD.Visible = true; HtmlChartHolderLG.Visible = true; DtSubjectives = xData.GetSubjectivesBySurfaceItemId(SurfaceItemId); if (DtSubjectives.Rows.Count > 0) { //RadHtmlChart scatterChart = new RadHtmlChart(); //scatterChart.ID = "ScatterChart"; //scatterChart.Legend.Appearance.Position = Telerik.Web.UI.HtmlChart.ChartLegendPosition.Bottom; //scatterChart.CssClass = "scatterChart"; ////scatterChart.Width = "100%"; //scatterChart.PlotArea.XAxis.TitleAppearance.Text = "Complaints"; //scatterChart.PlotArea.XAxis.Type = Telerik.Web.UI.HtmlChart.AxisType.Date; //scatterChart.PlotArea.XAxis.MinorGridLines.Visible = false; //scatterChart.PlotArea.XAxis.MajorGridLines.Visible = false; //scatterChart.PlotArea.XAxis.BaseUnit = Telerik.Web.UI.HtmlChart.DateTimeBaseUnit.Days; //scatterChart.PlotArea.XAxis.LabelsAppearance.DataFormatString = "{0:dd/MM/yy}"; ////scatterChart.PlotArea.XAxis.Step = 1; //scatterChart.PlotArea.YAxis.TitleAppearance.Text = "Score"; //scatterChart.PlotArea.YAxis.MaxValue = 10; //scatterChart.PlotArea.YAxis.Step = 1; //scatterChart.PlotArea.YAxis.MinorGridLines.Visible = false; //scatterChart.ChartTitle.Text = "Subjectives (Pain Score History)"; for (int i = 0; i < DtSubjectives.Columns.Count - 1; i++) { ScatterLineSeries complaintSeries = new ScatterLineSeries(); complaintSeries.Name = DtSubjectives.Columns[i + 1].ColumnName; complaintSeries.LabelsAppearance.Visible = false; complaintSeries.TooltipsAppearance.Visible = false; //complaintSeries.MarkersAppearance.MarkersType = Telerik.Web.UI.HtmlChart.MarkersType.Circle; complaintSeries.LineAppearance.Width = 4; complaintSeries.MarkersAppearance.Size = 12; foreach (DataRow row in DtSubjectives.Rows) { int currentScore = (row[DtSubjectives.Columns[i + 1]] is DBNull) ? 0 : Convert.ToInt32(row[DtSubjectives.Columns[i + 1]]); DateTime dateVal = Convert.ToDateTime(row["date"].ToString()); decimal currentDate = (decimal)dateVal.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds; ScatterSeriesItem scoreItem = new ScatterSeriesItem(currentDate, currentScore); //CVH 2018-07-20 Show 0's on chart //if (currentScore > 0) complaintSeries.SeriesItems.Add(scoreItem); } //ChartColors colors = (ChartColors)Enum.ToObject(typeof(ChartColors), i); //complaintSeries.MarkersAppearance.BorderColor = System.Drawing.Color.FromName(colors.ToString()); //complaintSeries.MarkersAppearance.BackgroundColor = System.Drawing.Color.FromName(colors.ToString()); ScatterChartSM.PlotArea.Series.Add(complaintSeries); ScatterChartMD.PlotArea.Series.Add(complaintSeries); ScatterChartLG.PlotArea.Series.Add(complaintSeries); } HtmlChartHolderXS.Controls.Add(ScatterChartXS); HtmlChartHolderSM.Controls.Add(ScatterChartSM); HtmlChartHolderMD.Controls.Add(ScatterChartMD); HtmlChartHolderLG.Controls.Add(ScatterChartLG); //string script = "function f(){$find(\"" + ScatterChart.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); //; } } catch (Exception ex) { exception.HandleException("medicalSubjectives:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } #endregion #region events /// /// Page Init /// /// /// protected void Page_Init(object sender, EventArgs e) { } /// /// Page Load /// /// /// protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { } } catch (Exception ex) { exception.HandleException("medicalSubjectives:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } #endregion #region properties public DataTable DtSubjectives { get { if (ViewState["dtSubjectives"] == null) return null; else return (DataTable)ViewState["dtSubjectives"]; } set { ViewState["dtSubjectives"] = value; } } public int SurfaceItemId { get { if (ViewState["surfaceItemId"] == null) return 0; else return (int)ViewState["surfaceItemId"]; } set { ViewState["surfaceItemId"] = value; } } #endregion }