Ejemplo n.º 1
0
        void GraphPSAs(int patientId, DateTime dxDate)
        {
            DataView labtests = ActiveSurveillanceDa.GetPSAs(patientId);


            float?   dxPSA     = null;
            DateTime?dxPSADate = null;

            bool enableGraph = false;
            SortedList <DateTime, List <float> > postDxDatapoints = new SortedList <DateTime, List <float> >();

            foreach (DataRowView row in labtests)
            {
                // are the date and result valid?
                string   ds = row["LabDate"].ToString();
                DateTime psaDate;

                if (!DateTime.TryParse(ds, out psaDate))
                {
                    continue;
                }

                string rs = row["LabResult"].ToString();
                if (!string.IsNullOrEmpty(rs))
                {
                    rs = rs.Replace("<", "");
                }

                float psa;
                if (!float.TryParse(rs, out psa))
                {
                    continue;
                }

                // update the current psa
                CurrentPSA = rs;

                // update dx psa if <= dx date
                if (psaDate <= dxDate)
                {
                    PreDiagnosisPSA = rs;
                    dxPSA           = psa;
                    dxPSADate       = psaDate;
                }
                else if (postDxDatapoints.ContainsKey(psaDate))
                {
                    postDxDatapoints[psaDate].Add(psa);
                }
                else
                {
                    List <float> f = new List <float>();
                    f.Add(psa);
                    postDxDatapoints[psaDate] = f;
                }
            }

            // graph last pre dx and subsequent psas (bool)
            DataTable table    = InitPSAChartTable();
            DateTime  baseDate = DateTime.MinValue;

            if (dxPSADate.HasValue)
            {
                baseDate    = dxPSADate.Value;
                enableGraph = true;
            }
            else if (postDxDatapoints.Count > 0)
            {
                baseDate    = postDxDatapoints.First().Key;
                enableGraph = true;
            }

            if (enableGraph)
            {
                if (dxPSADate.HasValue)
                {
                    AddPSADataPoint(table, 0, dxPSA.Value);
                }

                foreach (var dp in postDxDatapoints)
                {
                    AddPSADataPoint(table, (dp.Key - baseDate).Days / DAYS_PER_MONTH, dp.Value.Average());
                }

                PSAChart.Series["Actual"].Points.DataBind(table.DefaultView, "Months", "ngml", "Tooltip=ngml, Label=ngml");


                // add series for biopsies
                SortedList <DateTime, SortedList <float, string> > postDxBiopsyDatapoints = new SortedList <DateTime, SortedList <float, string> >();
                DataView  biopsies         = ActiveSurveillanceDa.GetBiopsies(patientId);
                DataTable biopsyChartTable = InitBiopsyChartTable();

                foreach (DataRowView row in biopsies)
                {
                    int      gg1, gg2, posCores, numCores;
                    string   biopsyToolTip = String.Empty;
                    DateTime biopsyDate;
                    string   ds = row[Procedure.ProcDate].ToString();

                    // only continue if date is valid
                    if (!DateTime.TryParse(ds, out biopsyDate))
                    {
                        continue;
                    }
                    else
                    {
                        biopsyToolTip = String.Concat(biopsyToolTip, biopsyDate.ToShortDateString());
                    }

                    if (!String.IsNullOrEmpty(row[Procedure.ProcName].ToString()))
                    {
                        biopsyToolTip = String.Concat(biopsyToolTip, " ", row[Procedure.ProcName].ToString());
                    }

                    if (int.TryParse(row[BiopsyProstatePathology.PathGG1].ToString(), out gg1))
                    {
                        biopsyToolTip = String.Concat(biopsyToolTip, " ", gg1.ToString());
                    }

                    if (int.TryParse(row[BiopsyProstatePathology.PathGG2].ToString(), out gg2))
                    {
                        biopsyToolTip = String.Concat(biopsyToolTip, "+", gg2.ToString());
                    }

                    if (int.TryParse(row[BiopsyProstatePathology.PathPosCores].ToString(), out posCores))
                    {
                        biopsyToolTip = String.Concat(biopsyToolTip, " Pos. Cores: ", posCores.ToString());
                    }

                    if (int.TryParse(row[BiopsyProstatePathology.PathNumCores].ToString(), out numCores))
                    {
                        biopsyToolTip = String.Concat(biopsyToolTip, "/", numCores.ToString());
                    }


                    if (postDxBiopsyDatapoints.ContainsKey(biopsyDate))
                    {
                        postDxBiopsyDatapoints[biopsyDate].Add(1, biopsyToolTip);
                    }
                    else
                    {
                        SortedList <float, string> f = new SortedList <float, string>();
                        f.Add(1, biopsyToolTip);
                        postDxBiopsyDatapoints[biopsyDate] = f;
                    }
                }

                if (postDxBiopsyDatapoints.Count > 0)
                {
                    foreach (var dp in postDxBiopsyDatapoints)
                    {
                        SortedList <float, string> sortedDbValue = dp.Value;
                        AddBiopsyDataPoint(biopsyChartTable, (dp.Key - baseDate).Days / DAYS_PER_MONTH, sortedDbValue.Keys.Average(), sortedDbValue.Values[0]);
                    }

                    PSAChart.Series["Biopsies"].Points.DataBind(biopsyChartTable.DefaultView, "Months", "ngml", "Tooltip=BiopsyToolTip");
                }
            }
            else
            {
                // no graph to see!
            }
        }
Ejemplo n.º 2
0
        DateTime?ProcessBiopsyData(int patientId)
        {
            DataView diagnosticBiopsy = ActiveSurveillanceDa.GetDiagnositicBiopsy(patientId);

            if (diagnosticBiopsy.Count == 0)
            {
                return(null);
            }

            DataView biopsies  = ActiveSurveillanceDa.GetBiopsies(patientId);
            DataView clinStage = ActiveSurveillanceDa.GetCurrentClinicalStage(patientId);

            DataRowView dx     = diagnosticBiopsy[0];
            DateTime    dxDate = (DateTime)dx["ProcDate"];
            DateTime    now    = DateTime.Now;

            PatientAge           = (int)dx["PtAge"];
            MonthsSinceDiagnosis = (int)Math.Round((now - dxDate).Days / DAYS_PER_MONTH, 0);

            DataRowView current = biopsies[biopsies.Count - 1];

            LastBiopsyDate = (DateTime)current["ProcDate"];

            int gg1, gg2, posCores, numCores;

            if (int.TryParse(current["PathGG1"].ToString(), out gg1))
            {
                BiopsyPrimaryGleason = gg1;
            }

            if (int.TryParse(current["PathGG2"].ToString(), out gg2))
            {
                BiopsySecondaryGleason = gg2;
            }

            if (int.TryParse(current["PathPosCores"].ToString(), out posCores))
            {
                PositiveCores = posCores;
            }

            if (int.TryParse(current["PathNumCores"].ToString(), out numCores))
            {
                TotalCores = numCores;
            }

            if (clinStage.Count > 0)
            {
                ClinTStage = clinStage[0]["ClinStageT"].ToString();
            }

            List <string> biopsyDates = new List <string>();

            for (int i = 0; i < biopsies.Count - 1; i++)
            {
                biopsyDates.Add(((DateTime)biopsies[i]["ProcDate"]).ToString("MMMM d, yyyy"));
            }

            PreviousBiopsiesRepeater.DataSource = biopsyDates;
            PreviousBiopsiesRepeater.DataBind();

            return(dxDate);
        }