Ejemplo n.º 1
0
        async void PatientProblemDetail_Loaded(object sender, RoutedEventArgs e)
        {
            bool NoData = true;

           // PageNavigationParams pnp = new PageNavigationParams();
           // ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
           // ApplicationDataCompositeValue compositeValue = localSettings.Values["PatientProblemDetailPage"] as ApplicationDataCompositeValue;
            //pnp.ProblemDescription = compositeValue["strProblemDescription"] as string;
           // pnp.ProblemID = compositeValue["strProblemID"] as string;
           // pnp.PatientID = compositeValue["strPatientID"] as string;

            ViewModel.ProblemDescription = Nike.Core.Data_Services.PageNavigationService.ChartItem.Name;

            try
            {
                int i = 0;
                //  UserObject use = new UserObject();
                List<VitalData> listPulse = new List<VitalData>();
                List<VitalData> listBMI = new List<VitalData>();
                bool bHasResultData = false;
                bool bHasVitalsData = false;
                bool bHasMedsData = false;

                ChartControl ccVital = new ChartControl();
                ChartControl ccResult = new ChartControl();
                ChartControl ccMeds = new ChartControl();

                string sjson = await ViewModel.PatientDataService.GetProblemActivity(ViewModel.UnityDataService.UnityAppUser, PageNavigationService.PatientItem.ID, PageNavigationService.ChartItem.ID);
                JArray obj = JArray.Parse(sjson);
                foreach (JObject jo in obj)
                {
                    string sPrevResult = "";
                    string sPrevOrder = "";
                    //info4 is results
                    JToken activity = jo.SelectToken("getproblemactivityinfo", false);
                    if (activity != null)
                    {
                        if (activity.Count() == 0)
                            continue;

                        List<ResultData> listResults = new List<ResultData>();
                        foreach (JToken joRow in activity)
                        {
                            string sResultName = joRow["ResultName"].ToString().Trim();
                            string sResultValue = joRow["ResultValue"].ToString().Trim();
                            string sResultUnits = joRow["ResultUnits"].ToString().Trim();
                            string sResultDate = joRow["ResultDate"].ToString().Trim();
                            string sOrderName = joRow["OrderName"].ToString().Trim();
                            string sResultDisplayValue = joRow["DisplayResultValue"].ToString().Trim();

                            decimal dResultValue = 0;
                            if (sPrevOrder != sOrderName)
                            {
                                i = 0;
                            }
                            if (i == 0)
                            {
                                sPrevOrder = sOrderName;
                                ccResult.SetOrderList(sOrderName);
                            }

                            if (!string.IsNullOrEmpty(sResultValue))
                            {
                                if (decimal.TryParse(sResultValue, out dResultValue))
                                {
                                    string sDisplayDate = DateTime.Parse(sResultDate).ToString("MM/dd/yy");
                                    DateTime dt = DateTime.Parse(sResultDate);

                                    ResultData rd = new ResultData(dResultValue, dt, sResultName, sResultUnits, sOrderName, sResultDisplayValue);
                                    listResults.Add(rd);
                                }
                            }

                            i++;
                        }
                        if (listResults.Count() > 0)
                        {
                            bHasResultData = true;
                            ccResult.OrdersAndResults = listResults;
                        }
                    }

                    JToken activity1 = jo.SelectToken("getproblemactivityinfo1", false);
                    if (activity1 != null)
                    {
                        if (activity1.Count() == 0)
                            continue;
                        List<VitalData> listChart = new List<VitalData>();
                        i = 0;
                        foreach (JToken joRow in activity1)
                        {

                            string sVitalName = joRow["vital"].ToString().Trim();
                            string sVitalValue = joRow["vitval"].ToString().Trim();
                            string sVitalUnits = joRow["units"].ToString().Trim();
                            string sVitalDate = joRow["vitaldate"].ToString().Trim();
                            string sDisplay = joRow["disp"].ToString().Trim();

                            decimal dVitalValue = 0;

                            if (i == 0)
                            {
                                sPrevResult = sVitalName;

                            }
                            if (sVitalName != sPrevResult && listChart.Count > 0)
                            {
                                sPrevResult = sVitalName;

                                ccVital.VitalsAddSeries(listChart);
                                if (listChart.Count() > 1)
                                {
                                    bHasVitalsData = true;
                                }
                                listChart.Clear();
                            }
                            if (!string.IsNullOrEmpty(sVitalName))
                            {
                                if (decimal.TryParse(sVitalValue, out dVitalValue))
                                {
                                    string sDisplayDate = DateTime.Parse(sVitalDate).ToString("MM/dd/yy");
                                    DateTime dt = DateTime.Parse(sDisplayDate);
                                    VitalData rd = new VitalData(dVitalValue, dt, sVitalName, sDisplay);
                                    listChart.Add(rd);

                                }
                            }

                            i++;
                        }
                        if (listChart.Count() > 0)
                        {
                            ccVital.VitalsAddSeries(listChart);
                        }
                    }
                    //info2 is meds


                    JToken activity2 = jo.SelectToken("getproblemactivityinfo2", false);
                    if (activity2 != null)
                    {
                        if (activity2.Count() == 0)
                            continue;
                        List<MedData> listMed = new List<MedData>();
                        i = 0;
                        foreach (JToken joRow in activity2)
                        {

                            string sMedName = joRow["drugname"].ToString().Trim();
                            string sMedStrength = joRow["drugstrength"].ToString().Trim();
                            string sStartDate = joRow["startdate"].ToString().Trim();
                            string sEndDate = joRow["enddate"].ToString().Trim();
                            string sDays = joRow["days"].ToString().Trim();

                            decimal dStrength = 0;

                            decimal.TryParse(sMedStrength, out dStrength);

                            MedData md = new MedData(sMedName, sMedStrength, sStartDate, sEndDate, int.Parse(sDays));
                            listMed.Add(md);
                            bHasMedsData = true;


                            i++;
                        }
                        ccMeds.MedsAddSeries(listMed);
                    }
                }
                if (bHasMedsData)
                {
                    Grid.SetRow(ccResult, 0);
                    GraphBody.Children.Add(ccMeds);
                    NoData = false;
                }
                if (bHasResultData)
                {

                    Grid.SetRow(ccResult, 1);

                    //GraphBody.Children.Add(ccResult);
                    ccResult.ControlReady = true;
                    NoData = false;
                }
                if (bHasVitalsData)
                {
                    Grid.SetRow(ccVital, 2);
                    ccVital.SetTitle("Vitals");
                    GraphBody.Children.Add(ccVital);
                    NoData = false;
                }

                if (NoData)
                {
                    TextBox tb = new TextBox();
                    tb.Text = "No data for this patient.";
                    tb.FontSize = 24;
                    GraphBody.Children.Add(tb);

                }
                
            }
            catch (Exception ex)
            {
                ErrorHandler eh = new ErrorHandler(ex, "PatientProblemDetail.xaml onnavigatedto");
                eh.ShowErrorDialog();
            }
        }
Ejemplo n.º 2
0
        public void VitalsAddSeries(List<VitalData> listdata)
        {
            SolidColorBrush scb = new SolidColorBrush();
            scb.Color = Windows.UI.Colors.DimGray;
            this.chart.Background = scb;

            this.chart.VerticalAxis.ShowLabels = false;
            this.chart.HorizontalAxis.Margin = new Thickness(10, 5, 5, 10);

            CategoricalSeries series = Activator.CreateInstance(typeof(LineSeries)) as CategoricalSeries;
            series.CategoryBinding = new PropertyNameDataPointBinding("Category");
            series.ValueBinding = new PropertyNameDataPointBinding("Value");


            ChartSeriesLabelDefinition csld = new ChartSeriesLabelDefinition();


            csld.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Right;
            csld.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            csld.Template = CreateScatterDataLabelTemplate();

            series.LabelDefinitions.Add(csld);

            string sName = listdata[0].Name;

        
            VitalData[] rdArray = null;
            rdArray = new VitalData[listdata.Count()];

            listdata.CopyTo(rdArray);

            for (int b = 0; b < rdArray.Length; b++)
            {
                CategoricalDataPoint cdp = new CategoricalDataPoint();

                cdp.Category = rdArray[b].Category;
                cdp.Value = (double)rdArray[b].Value;

                cdp.Label = rdArray[b].Display;

                series.DataPoints.Add(cdp);

            }
            series.Name = sName;
           
            this.chart.Series.Add(series);
            ChartLegend leg = new ChartLegend();
            leg.ChartControl = this.chart;
            leg.BrushColor = chart.Palette.GetBrush(chart.Series.Count - 1, PaletteVisualPart.Stroke);
            leg.Text = sName;
            leg.SeriesName = series.Name;
            leg.StackPanelParent = this.legend;
            leg.ChartTitleParent = this.stackTitle;

            this.legend.Children.Add(leg);
        
       
        }