Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            context.Response.ContentEncoding = Encoding.UTF8;

            // The Request QueryString here is protected against XSS attacks by Request Validation
            QuerySettings settings = CCHSerializer.DeserializeSettings<QuerySettings>(context.Request.QueryString);
            if (settings.Latitude == null) { settings.Latitude = context.GetLatitude<String>(); }
            if (settings.Longitude == null) { settings.Longitude = context.GetLongitude<String>(); }
            if (String.IsNullOrWhiteSpace(settings.CurrentSort)) settings.CurrentSort = ThisSession.DefaultSort;
            if (String.IsNullOrWhiteSpace(settings.Distance)) settings.Distance = "20";
            if (settings.ToRow == 0) { settings.ToRow = 49; }

            ResultsBack rb = new ResultsBack();
            if (context.GetChosenDrugs<DataTable>() == null || context.GetChosenDrugs<DataTable>().CheckForRows())
            {
                using (GetDrugPricingResults gdpr = new GetDrugPricingResults())
                {
                    gdpr.Distance = settings.Distance.To<Int32>();
                    gdpr.Latitude = settings.Latitude;
                    gdpr.Longitude = settings.Longitude;
                    gdpr.FromIndex = settings.FromRow;
                    gdpr.ToIndex = settings.ToRow;
                    gdpr.OrderByField = settings.CurrentDirection;
                    //gdpr.MemberRXID = ThisSession.SubscriberRXID;
                    gdpr.CCHID = context.GetCCHID<Int32>();
                    gdpr.UserID = context.GetUserLogginID<String>(); // System.Web.Security.Membership.GetUser(ThisSession.PatientEmail).ProviderUserKey.ToString();
                    if (context.GetChosenDrugs<DataTable>() == null)
                    {
                        gdpr.DrugID = context.GetDrugID<String>();// ThisSession.DrugID;
                        gdpr.GPI = context.GetDrugGPI<String>();// ThisSession.DrugGPI;
                        gdpr.Quantity = context.GetDrugQuantity<String>();// ThisSession.DrugQuantity;
                        if (!String.IsNullOrWhiteSpace(context.GetPastCareID<String>()))
                            gdpr.PastCareID = context.GetPastCareID<String>();
                    }
                    else
                    {
                        gdpr.DrugID = context.GetDrugID<String>(0);// ThisSession.ChosenDrugs.Rows[0]["DrugID"].ToString();
                        gdpr.GPI = context.GetDrugGPI<String>(0);// ThisSession.ChosenDrugs.Rows[0]["GPI"].ToString();
                        gdpr.Quantity = context.GetDrugQuantity<String>(0);// ThisSession.ChosenDrugs.Rows[0]["Quantity"].ToString();
                        gdpr.PastCareID = context.GetPastCareID<String>(0);// ThisSession.ChosenDrugs.Rows[0]["PastCareID"].ToString();
                    }
                    gdpr.SessionID = context.GetSessionID<String>();
                    gdpr.Domain = context.GetDomain<String>();
                    gdpr.GetData();

                    if (gdpr.RawResults.TableName != "EmptyTable")
                    {
                        foreach (DataRow dr in gdpr.RawResults.Rows)
                        {
                            ResultData rd = CCHSerializer.DeserializeDataRow<ResultData>(dr);
                            rd.Price = String.Format("{0:C2}", Convert.ToDouble(rd.Price));
                            rd.YourCost = String.Format("{0:C2}", Convert.ToDouble(rd.YourCost));
                            rd.Distance = String.Format("{0:#0.0 mi}", Convert.ToDouble(rd.Distance));
                            rb.AddResult(rd);
                        }
                    }
                }
            }
            else
            {
                using (GetDrugMultiPricingResults gdmpr = new GetDrugMultiPricingResults())
                {
                    using (DataView dv = new DataView(ThisSession.ChosenDrugs))
                        gdmpr.DrugList = dv.ToTable("DrugInput", false, new String[] { "DrugID", "GPI", "Quantity", "PastCareID" });
                    gdmpr.Latitude = settings.Latitude;
                    gdmpr.Longitude = settings.Longitude;
                    gdmpr.GetData();
                    if (gdmpr.RawResults.TableName != "EmptyTable")
                    {
                        foreach (DataRow dr in gdmpr.RawResults.Rows)
                        {
                            ResultData rd = CCHSerializer.DeserializeDataRow<ResultData>(dr);
                            rd.Price = String.Format("{0:C2}", Convert.ToDouble(rd.Price));
                            rd.YourCost = String.Format("{0:C2}", Convert.ToDouble(rd.YourCost));
                            rd.Distance = String.Format("{0:#0.0 mi}", Convert.ToDouble(rd.Distance));
                            rb.AddResult(rd);
                        }
                    }
                }
            }

            JavaScriptSerializer jss = new JavaScriptSerializer();
            String jsonBack = jss.Serialize(rb);

            context.Response.Write(jsonBack);
        }
Beispiel #2
0
        private void SetupGrid(String Lat, String Lng)
        {
            String currentPharmacyName = String.Empty;

            if (ChosenDrugsTable == null || ChosenDrugsTable.Rows.Count == 1)
            {
                using (GetDrugPricingResults gdpr = new GetDrugPricingResults())
                {
                    gdpr.Latitude = Lat;
                    gdpr.Longitude = Lng;
                    if (this.ChosenDrugsTable == null)
                    {
                        gdpr.DrugID = ThisSession.DrugID;
                        gdpr.GPI = ThisSession.DrugGPI;
                        gdpr.Quantity = ThisSession.DrugQuantity;
                        if (ThisSession.PastCareID != "")
                            gdpr.PastCareID = ThisSession.PastCareID;
                    }
                    else
                    {
                        gdpr.DrugID = this.ChosenDrugsTable.Rows[0]["DrugID"].ToString();
                        gdpr.GPI = this.ChosenDrugsTable.Rows[0]["GPI"].ToString();
                        gdpr.Quantity = this.ChosenDrugsTable.Rows[0]["Quantity"].ToString();
                        gdpr.PastCareID = this.ChosenDrugsTable.Rows[0]["PastCareID"].ToString();
                    }
                    //gdpr.MemberRXID = ThisSession.SubscriberRXID;
                    gdpr.CCHID = ThisSession.CCHID;
                    gdpr.UserID = Membership.GetUser().ProviderUserKey.ToString();
                    gdpr.GetData();

                    //If there were details returned from the database
                    if (gdpr.RawResults.TableName != "EmptyTable")
                    {
                        //Bind the details to the repeater
                        //rptResults.DataSource = gdpr.RawResults;
                        //rptResults.DataBind();

                        if (gdpr.CurrentPharmacyTable.Rows.Count > 0)
                        {
                            if (ThisSession.CurrentPharmacyID == String.Empty)
                                ThisSession.CurrentPharmacyID = gdpr.CurrentPharmacyTable.Rows[0]["PharmacyID"].ToString();
                            if (ThisSession.CurrentPharmacyLocationID == String.Empty)
                                ThisSession.CurrentPharmacyLocationID = gdpr.CurrentPharmacyTable.Rows[0]["PharmacyLocationID"].ToString();
                            if (ThisSession.CurrentPharmacyPrice == String.Empty)
                                ThisSession.CurrentPharmacyPrice = gdpr.CurrentPharmacyTable.Rows[0]["Price"].ToString();

                            currentPharmacyName = gdpr.CurrentPharmacyTable.Rows[0]["PharmacyName"].ToString();
                        }
                    }
                    //If there were results return for Past Care
                    if (gdpr.PastCare.TableName != "EmptyTable" && gdpr.PastCare.Rows.Count > 0)
                    {
                        //Set the visibility of the alert bars based off of having any pertinent past care data

                        abCurrentPrice.Visible = gdpr.HasPastCare;
                        abCouldSave.Visible = gdpr.HasPastCare;
                        //Additional PastCare work
                        if (gdpr.HasPastCare)
                        {
                            //Update the alert bar savings total with the data from the database
                            abCurrentPrice.SaveTotal = String.Format("${0:f2}", gdpr.CurrentPrice);
                            abCurrentPrice.PharmacyName = currentPharmacyName;

                            //lbNew.Text = "New Past Care";
                            //lbNew.PostBackUrl = "search.aspx#tabpast";
                        }
                    }
                    //If there were results returned for Pricing
                    if (gdpr.Pricingtable.TableName != "EmptyTable" && gdpr.Pricingtable.Rows.Count > 0)
                    {
                        //Assign the difference to the total savings property to drive the visibility of certain controls
                        abCouldSave.TotalSavings = Math.Round((gdpr.CurrentPrice - gdpr.BestPrice), 2);
                        //Set the savings total to the difference (even if 0)
                        //  lam, 20130401, MSF-260, remove .ToString() at the end so that the decimal point displays correctly
                        //abCouldSave.SaveTotal = String.Format("${0:f2}", Math.Round((gdpr.CurrentPrice - gdpr.BestPrice), 2).ToString());
                        abCouldSave.SaveTotal = String.Format("${0:f2}", Math.Round((gdpr.CurrentPrice - gdpr.BestPrice), 2));
                        abCouldSave.PharmacyName = currentPharmacyName;
                    }
                    //If we received a drug display name back from the database
                    if (gdpr.DisplayName != String.Empty)
                    {
                        lblSingleDrugName.Text = gdpr.DisplayName;
                        ltlSingleDrugDose.Text = (gdpr.DisplayStrength.Trim() == String.Empty ? String.Empty : String.Format("&nbsp; &nbsp; &nbsp; Searched Dose:<b>{0}</b>", gdpr.DisplayStrength));
                        //lblSingleDrugDose.Text = gdpr.DisplayStrength;
                        ThisSession.DrugStrength = gdpr.DisplayStrength;
                    }
                }
            }
            else
            {
                using (GetDrugMultiPricingResults gdmpr = new GetDrugMultiPricingResults())
                {
                    using (DataView dv = new DataView(this.ChosenDrugsTable))
                        gdmpr.DrugList = dv.ToTable("DrugInput", false, new String[] { "DrugID", "GPI", "Quantity", "PastCareID" });

                    gdmpr.Latitude = Lat;
                    gdmpr.Longitude = Lng;
                    gdmpr.GetData();

                    if (gdmpr.RawResults.TableName != "EmptyTable")
                    {
                        //Bind the details to the repeater
                        //rptResults.DataSource = gdpr.RawResults;
                        //rptResults.DataBind();

                        if (gdmpr.CurrentPharmacyTable.TableName != "EmptyTable" && gdmpr.CurrentPharmacyTable.Rows.Count > 0)
                        {
                            if (ThisSession.CurrentPharmacyID == String.Empty)
                                ThisSession.CurrentPharmacyID = gdmpr.CurrentPharmacyTable.Rows[0]["PharmacyID"].ToString();
                            if (ThisSession.CurrentPharmacyLocationID == String.Empty)
                                ThisSession.CurrentPharmacyLocationID = gdmpr.CurrentPharmacyTable.Rows[0]["PharmacyLocationID"].ToString();
                            if (ThisSession.CurrentPharmacyPrice == String.Empty)
                                ThisSession.CurrentPharmacyPrice = gdmpr.CurrentPharmacyTable.Rows[0]["Price"].ToString();

                            currentPharmacyName = gdmpr.CurrentPharmacyTable.Rows[0]["PharmacyName"].ToString();
                        }
                    }
                    //If there were results return for Past Care
                    if (gdmpr.PastCare.TableName != "EmptyTable" && gdmpr.PastCare.Rows.Count > 0)
                    {
                        //Set the visibility of the alert bars based off of having any pertinent past care data

                        abCurrentPrice.Visible = gdmpr.HasPastCare;
                        abCouldSave.Visible = gdmpr.HasPastCare;
                        //Additional PastCare work
                        if (gdmpr.HasPastCare)
                        {
                            //Update the alert bar savings total with the data from the database
                            abCurrentPrice.SaveTotal = String.Format("${0:f2}", gdmpr.CurrentPrice);
                            abCurrentPrice.PharmacyName = currentPharmacyName;
                        }
                    }
                    abCurrentPrice.Visible = (currentPharmacyName.Trim() != String.Empty);
                    //If there were results returned for Pricing
                    if (gdmpr.PricingTable.TableName != "EmptyTable" && gdmpr.PricingTable.Rows.Count > 0)
                    {
                        //Assign the difference to the total savings property to drive the visibility of certain controls
                        abCouldSave.TotalSavings = Math.Round((gdmpr.CurrentPrice - gdmpr.BestPrice), 2);
                        //Set the savings total to the difference (even if 0)
                        abCouldSave.SaveTotal = String.Format("${0:f2}",
                            Math.Round((gdmpr.CurrentPrice - gdmpr.BestPrice), 2).ToString());
                        abCouldSave.PharmacyName = currentPharmacyName;
                    }
                    abCouldSave.Visible = (currentPharmacyName.Trim() != String.Empty);
                }
            }

            //List<SqlParameter> prms = new List<SqlParameter>();
            //DataView dv = new DataView(this.ChosenDrugsTable);
            //DataSet results = null;

            //prmLat.Value = Convert.ToDouble(Lat);
            //prms.Add(prmLat);
            //prmLng.Value = Convert.ToDouble(Lng);
            //prms.Add(prmLng);

            //if (this.SingleDrugResults)
            //{
            //    if (this.ChosenDrugsTable == null)
            //    {
            //        prmDrugID.Value = ThisSession.DrugID;
            //        prms.Add(prmDrugID);
            //        prmGPI.Value = ThisSession.DrugGPI;
            //        prms.Add(prmGPI);
            //        prmQuantity.Value = Convert.ToDouble(ThisSession.DrugQuantity);
            //        prms.Add(prmQuantity);
            //        if (ThisSession.PastCareID != "")
            //        {
            //            prmPastCareID.Value = Convert.ToInt32(ThisSession.PastCareID);
            //            prms.Add(prmPastCareID);
            //        }
            //    }
            //    else
            //    {
            //        prmDrugID.Value = dv[0].Row["DrugID"];
            //        prms.Add(prmDrugID);
            //        prmGPI.Value = dv[0].Row["GPI"];
            //        prms.Add(prmGPI);
            //        prmQuantity.Value = Convert.ToDouble(dv[0].Row["Quantity"]);
            //        prms.Add(prmQuantity);
            //        prmPastCareID.Value = Convert.ToInt32(dv[0].Row["PastCareID"]);
            //        prms.Add(prmPastCareID);
            //    }

            //    results = QueryPharmaciesFor(PharmacyProcs.GetDrugPricingResults, prms, ThisSession.CnxString);
            //}
            //else
            //{
            //    string[] contentcols = { "DrugID", "GPI", "Quantity", "PastCareID" };
            //    prmDrugList.Value = dv.ToTable("DrugInput", false, contentcols);
            //    prms.Add(prmDrugList);

            //    results = QueryPharmaciesFor(PharmacyProcs.GetDrugMultiPricingResults, prms, ThisSession.CnxString);
            //}

            ////If there is details table returned from the database
            //if (results.Tables.Count > 0)
            //{
            //    DataView fullView = new DataView(results.Tables[0]);
            //    //Bind the details to the repeater
            //    rptResults.DataSource = fullView; //results.Tables[0];
            //    rptResults.DataBind();

            //    List<String> neededCols = new List<string>();
            //    neededCols.Add("PharmacyName");
            //    neededCols.Add("PharmacyID");
            //    neededCols.Add("PharmacyLocationID");
            //    neededCols.Add((this.SingleDrugResults ? "Price" : "TotalCost"));
            //    fullView.RowFilter = "CurrentPharmText <> ''";
            //    String pharmName = "";
            //    DataTable tblPharm = fullView.ToTable("CurrentPharm", true, neededCols.ToArray<String>());
            //    if (tblPharm.Rows.Count > 0)
            //    {
            //        if(ThisSession.CurrentPharmacyID == string.Empty)
            //            ThisSession.CurrentPharmacyID = tblPharm.Rows[0]["PharmacyID"].ToString();
            //        if(ThisSession.CurrentPharmacyLocationID == string.Empty)
            //            ThisSession.CurrentPharmacyLocationID = tblPharm.Rows[0]["PharmacyLocationID"].ToString();
            //        if (ThisSession.CurrentPharmacyPrice == string.Empty)
            //            ThisSession.CurrentPharmacyPrice = tblPharm.Rows[0][(this.SingleDrugResults ? "Price" : "TotalCost")].ToString();

            //        pharmName = tblPharm.Rows[0]["PharmacyName"].ToString();
            //    }

            //    //If there is a second table with past care info
            //    if (results.Tables.Count > 1)
            //    {
            //        DataTable visibilityTable = results.Tables[1];
            //        //If there are any rows in the past care table
            //        if (visibilityTable.Rows.Count > 0)
            //        {
            //            //Get the Yes or No text from the first column
            //            String pharmShow = visibilityTable.Rows[0]["ShowCurrentPharmacy"].ToString();
            //            Boolean hasPast = (pharmShow.ToLower() == "yes" && (visibilityTable.Rows[0]["CurrentPrice"].ToString() != ""));

            //            //Bind the visiblity of the two alert bars to whether or not there is any past care data
            //            abCurrentPrice.Visible = hasPast;
            //            abCouldSave.Visible = hasPast;

            //            //Additional past care work
            //            if (hasPast)
            //            {
            //                //Store the current price for use with the next table ("Best Price")
            //                Double currentPrice = Double.Parse(visibilityTable.Rows[0]["CurrentPrice"].ToString());
            //                //Get the name of the current pharmacy
            //                //String currentPharm = pharmName;//visibilityTable.Rows[0]["PharmName"].ToString();
            //                //Update the alert bar savings total with the data from the database
            //                abCurrentPrice.SaveTotal = String.Format("${0:f2}",currentPrice);
            //                abCurrentPrice.PharmacyName = pharmName;

            //                //If there is a third table returned
            //                if (results.Tables.Count > 2)
            //                {
            //                    DataTable priceTable = results.Tables[2];
            //                    //If that table has any rows
            //                    if (priceTable.Rows.Count > 0)
            //                    {
            //                        //Capture the best price total
            //                        Double bestPrice = Double.Parse(priceTable.Rows[0]["BestPrice"].ToString());
            //                        //Compare it to the current price to find savings
            //                        Double savings = currentPrice - bestPrice;
            //                        //Assign the difference to the total savings property do drive the visibilty of certain controls
            //                        abCouldSave.TotalSavings = Math.Round(savings, 2);
            //                        //Set the savings total to the difference (even if 0)
            //                        abCouldSave.SaveTotal = String.Format("${0:f2}", Math.Round(savings, 2).ToString());
            //                        abCouldSave.PharmacyName = pharmName;

            //                        ////If the savings are more than Zero, make visible the text "You could be saving...."
            //                        //((Label)abCouldSave.FindControl("lblCouldSave")).Visible = (savings != 0.0);
            //                        ////If the savings are equal to Zero, make visible the text "You are saving the most!"
            //                        //((Label)abCouldSave.FindControl("lblMaxSave")).Visible = (savings == 0.0);
            //                    }
            //                }
            //            }
            //        }

            //    }
            //}
        }
Beispiel #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType     = "application/json";
            context.Response.ContentEncoding = Encoding.UTF8;

            // The Request QueryString here is protected against XSS attacks by Request Validation
            QuerySettings settings = CCHSerializer.DeserializeSettings <QuerySettings>(context.Request.QueryString);

            if (settings.Latitude == null)
            {
                settings.Latitude = context.GetLatitude <String>();
            }
            if (settings.Longitude == null)
            {
                settings.Longitude = context.GetLongitude <String>();
            }
            if (String.IsNullOrWhiteSpace(settings.CurrentSort))
            {
                settings.CurrentSort = ThisSession.DefaultSort;
            }
            if (String.IsNullOrWhiteSpace(settings.Distance))
            {
                settings.Distance = "20";
            }
            if (settings.ToRow == 0)
            {
                settings.ToRow = 49;
            }

            ResultsBack rb = new ResultsBack();

            if (context.GetChosenDrugs <DataTable>() == null || context.GetChosenDrugs <DataTable>().CheckForRows())
            {
                using (GetDrugPricingResults gdpr = new GetDrugPricingResults())
                {
                    gdpr.Distance     = settings.Distance.To <Int32>();
                    gdpr.Latitude     = settings.Latitude;
                    gdpr.Longitude    = settings.Longitude;
                    gdpr.FromIndex    = settings.FromRow;
                    gdpr.ToIndex      = settings.ToRow;
                    gdpr.OrderByField = settings.CurrentDirection;
                    //gdpr.MemberRXID = ThisSession.SubscriberRXID;
                    gdpr.CCHID  = context.GetCCHID <Int32>();
                    gdpr.UserID = context.GetUserLogginID <String>(); // System.Web.Security.Membership.GetUser(ThisSession.PatientEmail).ProviderUserKey.ToString();
                    if (context.GetChosenDrugs <DataTable>() == null)
                    {
                        gdpr.DrugID   = context.GetDrugID <String>();       // ThisSession.DrugID;
                        gdpr.GPI      = context.GetDrugGPI <String>();      // ThisSession.DrugGPI;
                        gdpr.Quantity = context.GetDrugQuantity <String>(); // ThisSession.DrugQuantity;
                        if (!String.IsNullOrWhiteSpace(context.GetPastCareID <String>()))
                        {
                            gdpr.PastCareID = context.GetPastCareID <String>();
                        }
                    }
                    else
                    {
                        gdpr.DrugID     = context.GetDrugID <String>(0);       // ThisSession.ChosenDrugs.Rows[0]["DrugID"].ToString();
                        gdpr.GPI        = context.GetDrugGPI <String>(0);      // ThisSession.ChosenDrugs.Rows[0]["GPI"].ToString();
                        gdpr.Quantity   = context.GetDrugQuantity <String>(0); // ThisSession.ChosenDrugs.Rows[0]["Quantity"].ToString();
                        gdpr.PastCareID = context.GetPastCareID <String>(0);   // ThisSession.ChosenDrugs.Rows[0]["PastCareID"].ToString();
                    }
                    gdpr.SessionID = context.GetSessionID <String>();
                    gdpr.Domain    = context.GetDomain <String>();
                    gdpr.GetData();

                    if (gdpr.RawResults.TableName != "EmptyTable")
                    {
                        foreach (DataRow dr in gdpr.RawResults.Rows)
                        {
                            ResultData rd = CCHSerializer.DeserializeDataRow <ResultData>(dr);
                            rd.Price    = String.Format("{0:C2}", Convert.ToDouble(rd.Price));
                            rd.YourCost = String.Format("{0:C2}", Convert.ToDouble(rd.YourCost));
                            rd.Distance = String.Format("{0:#0.0 mi}", Convert.ToDouble(rd.Distance));
                            rb.AddResult(rd);
                        }
                    }
                }
            }
            else
            {
                using (GetDrugMultiPricingResults gdmpr = new GetDrugMultiPricingResults())
                {
                    using (DataView dv = new DataView(ThisSession.ChosenDrugs))
                        gdmpr.DrugList = dv.ToTable("DrugInput", false, new String[] { "DrugID", "GPI", "Quantity", "PastCareID" });
                    gdmpr.Latitude  = settings.Latitude;
                    gdmpr.Longitude = settings.Longitude;
                    gdmpr.GetData();
                    if (gdmpr.RawResults.TableName != "EmptyTable")
                    {
                        foreach (DataRow dr in gdmpr.RawResults.Rows)
                        {
                            ResultData rd = CCHSerializer.DeserializeDataRow <ResultData>(dr);
                            rd.Price    = String.Format("{0:C2}", Convert.ToDouble(rd.Price));
                            rd.YourCost = String.Format("{0:C2}", Convert.ToDouble(rd.YourCost));
                            rd.Distance = String.Format("{0:#0.0 mi}", Convert.ToDouble(rd.Distance));
                            rb.AddResult(rd);
                        }
                    }
                }
            }

            JavaScriptSerializer jss = new JavaScriptSerializer();
            String jsonBack          = jss.Serialize(rb);

            context.Response.Write(jsonBack);
        }
Beispiel #4
0
        private void SetupGrid(String Lat, String Lng)
        {
            String currentPharmacyName = String.Empty;

            if (ChosenDrugsTable == null || ChosenDrugsTable.Rows.Count == 1)
            {
                using (GetDrugPricingResults gdpr = new GetDrugPricingResults())
                {
                    gdpr.Latitude  = Lat;
                    gdpr.Longitude = Lng;
                    if (this.ChosenDrugsTable == null)
                    {
                        gdpr.DrugID   = ThisSession.DrugID;
                        gdpr.GPI      = ThisSession.DrugGPI;
                        gdpr.Quantity = ThisSession.DrugQuantity;
                        if (ThisSession.PastCareID != "")
                        {
                            gdpr.PastCareID = ThisSession.PastCareID;
                        }
                    }
                    else
                    {
                        gdpr.DrugID     = this.ChosenDrugsTable.Rows[0]["DrugID"].ToString();
                        gdpr.GPI        = this.ChosenDrugsTable.Rows[0]["GPI"].ToString();
                        gdpr.Quantity   = this.ChosenDrugsTable.Rows[0]["Quantity"].ToString();
                        gdpr.PastCareID = this.ChosenDrugsTable.Rows[0]["PastCareID"].ToString();
                    }
                    //gdpr.MemberRXID = ThisSession.SubscriberRXID;
                    gdpr.CCHID  = ThisSession.CCHID;
                    gdpr.UserID = Membership.GetUser().ProviderUserKey.ToString();
                    gdpr.GetData();

                    //If there were details returned from the database
                    if (gdpr.RawResults.TableName != "EmptyTable")
                    {
                        //Bind the details to the repeater
                        //rptResults.DataSource = gdpr.RawResults;
                        //rptResults.DataBind();

                        if (gdpr.CurrentPharmacyTable.Rows.Count > 0)
                        {
                            if (ThisSession.CurrentPharmacyID == String.Empty)
                            {
                                ThisSession.CurrentPharmacyID = gdpr.CurrentPharmacyTable.Rows[0]["PharmacyID"].ToString();
                            }
                            if (ThisSession.CurrentPharmacyLocationID == String.Empty)
                            {
                                ThisSession.CurrentPharmacyLocationID = gdpr.CurrentPharmacyTable.Rows[0]["PharmacyLocationID"].ToString();
                            }
                            if (ThisSession.CurrentPharmacyPrice == String.Empty)
                            {
                                ThisSession.CurrentPharmacyPrice = gdpr.CurrentPharmacyTable.Rows[0]["Price"].ToString();
                            }

                            currentPharmacyName = gdpr.CurrentPharmacyTable.Rows[0]["PharmacyName"].ToString();
                        }
                    }
                    //If there were results return for Past Care
                    if (gdpr.PastCare.TableName != "EmptyTable" && gdpr.PastCare.Rows.Count > 0)
                    {
                        //Set the visibility of the alert bars based off of having any pertinent past care data

                        abCurrentPrice.Visible = gdpr.HasPastCare;
                        abCouldSave.Visible    = gdpr.HasPastCare;
                        //Additional PastCare work
                        if (gdpr.HasPastCare)
                        {
                            //Update the alert bar savings total with the data from the database
                            abCurrentPrice.SaveTotal    = String.Format("${0:f2}", gdpr.CurrentPrice);
                            abCurrentPrice.PharmacyName = currentPharmacyName;

                            //lbNew.Text = "New Past Care";
                            //lbNew.PostBackUrl = "search.aspx#tabpast";
                        }
                    }
                    //If there were results returned for Pricing
                    if (gdpr.Pricingtable.TableName != "EmptyTable" && gdpr.Pricingtable.Rows.Count > 0)
                    {
                        //Assign the difference to the total savings property to drive the visibility of certain controls
                        abCouldSave.TotalSavings = Math.Round((gdpr.CurrentPrice - gdpr.BestPrice), 2);
                        //Set the savings total to the difference (even if 0)
                        //  lam, 20130401, MSF-260, remove .ToString() at the end so that the decimal point displays correctly
                        //abCouldSave.SaveTotal = String.Format("${0:f2}", Math.Round((gdpr.CurrentPrice - gdpr.BestPrice), 2).ToString());
                        abCouldSave.SaveTotal    = String.Format("${0:f2}", Math.Round((gdpr.CurrentPrice - gdpr.BestPrice), 2));
                        abCouldSave.PharmacyName = currentPharmacyName;
                    }
                    //If we received a drug display name back from the database
                    if (gdpr.DisplayName != String.Empty)
                    {
                        lblSingleDrugName.Text = gdpr.DisplayName;
                        ltlSingleDrugDose.Text = (gdpr.DisplayStrength.Trim() == String.Empty ? String.Empty : String.Format("&nbsp; &nbsp; &nbsp; Searched Dose:<b>{0}</b>", gdpr.DisplayStrength));
                        //lblSingleDrugDose.Text = gdpr.DisplayStrength;
                        ThisSession.DrugStrength = gdpr.DisplayStrength;
                    }
                }
            }
            else
            {
                using (GetDrugMultiPricingResults gdmpr = new GetDrugMultiPricingResults())
                {
                    using (DataView dv = new DataView(this.ChosenDrugsTable))
                        gdmpr.DrugList = dv.ToTable("DrugInput", false, new String[] { "DrugID", "GPI", "Quantity", "PastCareID" });

                    gdmpr.Latitude  = Lat;
                    gdmpr.Longitude = Lng;
                    gdmpr.GetData();

                    if (gdmpr.RawResults.TableName != "EmptyTable")
                    {
                        //Bind the details to the repeater
                        //rptResults.DataSource = gdpr.RawResults;
                        //rptResults.DataBind();

                        if (gdmpr.CurrentPharmacyTable.TableName != "EmptyTable" && gdmpr.CurrentPharmacyTable.Rows.Count > 0)
                        {
                            if (ThisSession.CurrentPharmacyID == String.Empty)
                            {
                                ThisSession.CurrentPharmacyID = gdmpr.CurrentPharmacyTable.Rows[0]["PharmacyID"].ToString();
                            }
                            if (ThisSession.CurrentPharmacyLocationID == String.Empty)
                            {
                                ThisSession.CurrentPharmacyLocationID = gdmpr.CurrentPharmacyTable.Rows[0]["PharmacyLocationID"].ToString();
                            }
                            if (ThisSession.CurrentPharmacyPrice == String.Empty)
                            {
                                ThisSession.CurrentPharmacyPrice = gdmpr.CurrentPharmacyTable.Rows[0]["Price"].ToString();
                            }

                            currentPharmacyName = gdmpr.CurrentPharmacyTable.Rows[0]["PharmacyName"].ToString();
                        }
                    }
                    //If there were results return for Past Care
                    if (gdmpr.PastCare.TableName != "EmptyTable" && gdmpr.PastCare.Rows.Count > 0)
                    {
                        //Set the visibility of the alert bars based off of having any pertinent past care data

                        abCurrentPrice.Visible = gdmpr.HasPastCare;
                        abCouldSave.Visible    = gdmpr.HasPastCare;
                        //Additional PastCare work
                        if (gdmpr.HasPastCare)
                        {
                            //Update the alert bar savings total with the data from the database
                            abCurrentPrice.SaveTotal    = String.Format("${0:f2}", gdmpr.CurrentPrice);
                            abCurrentPrice.PharmacyName = currentPharmacyName;
                        }
                    }
                    abCurrentPrice.Visible = (currentPharmacyName.Trim() != String.Empty);
                    //If there were results returned for Pricing
                    if (gdmpr.PricingTable.TableName != "EmptyTable" && gdmpr.PricingTable.Rows.Count > 0)
                    {
                        //Assign the difference to the total savings property to drive the visibility of certain controls
                        abCouldSave.TotalSavings = Math.Round((gdmpr.CurrentPrice - gdmpr.BestPrice), 2);
                        //Set the savings total to the difference (even if 0)
                        abCouldSave.SaveTotal = String.Format("${0:f2}",
                                                              Math.Round((gdmpr.CurrentPrice - gdmpr.BestPrice), 2).ToString());
                        abCouldSave.PharmacyName = currentPharmacyName;
                    }
                    abCouldSave.Visible = (currentPharmacyName.Trim() != String.Empty);
                }
            }


            //List<SqlParameter> prms = new List<SqlParameter>();
            //DataView dv = new DataView(this.ChosenDrugsTable);
            //DataSet results = null;

            //prmLat.Value = Convert.ToDouble(Lat);
            //prms.Add(prmLat);
            //prmLng.Value = Convert.ToDouble(Lng);
            //prms.Add(prmLng);

            //if (this.SingleDrugResults)
            //{
            //    if (this.ChosenDrugsTable == null)
            //    {
            //        prmDrugID.Value = ThisSession.DrugID;
            //        prms.Add(prmDrugID);
            //        prmGPI.Value = ThisSession.DrugGPI;
            //        prms.Add(prmGPI);
            //        prmQuantity.Value = Convert.ToDouble(ThisSession.DrugQuantity);
            //        prms.Add(prmQuantity);
            //        if (ThisSession.PastCareID != "")
            //        {
            //            prmPastCareID.Value = Convert.ToInt32(ThisSession.PastCareID);
            //            prms.Add(prmPastCareID);
            //        }
            //    }
            //    else
            //    {
            //        prmDrugID.Value = dv[0].Row["DrugID"];
            //        prms.Add(prmDrugID);
            //        prmGPI.Value = dv[0].Row["GPI"];
            //        prms.Add(prmGPI);
            //        prmQuantity.Value = Convert.ToDouble(dv[0].Row["Quantity"]);
            //        prms.Add(prmQuantity);
            //        prmPastCareID.Value = Convert.ToInt32(dv[0].Row["PastCareID"]);
            //        prms.Add(prmPastCareID);
            //    }

            //    results = QueryPharmaciesFor(PharmacyProcs.GetDrugPricingResults, prms, ThisSession.CnxString);
            //}
            //else
            //{
            //    string[] contentcols = { "DrugID", "GPI", "Quantity", "PastCareID" };
            //    prmDrugList.Value = dv.ToTable("DrugInput", false, contentcols);
            //    prms.Add(prmDrugList);

            //    results = QueryPharmaciesFor(PharmacyProcs.GetDrugMultiPricingResults, prms, ThisSession.CnxString);
            //}

            ////If there is details table returned from the database
            //if (results.Tables.Count > 0)
            //{
            //    DataView fullView = new DataView(results.Tables[0]);
            //    //Bind the details to the repeater
            //    rptResults.DataSource = fullView; //results.Tables[0];
            //    rptResults.DataBind();

            //    List<String> neededCols = new List<string>();
            //    neededCols.Add("PharmacyName");
            //    neededCols.Add("PharmacyID");
            //    neededCols.Add("PharmacyLocationID");
            //    neededCols.Add((this.SingleDrugResults ? "Price" : "TotalCost"));
            //    fullView.RowFilter = "CurrentPharmText <> ''";
            //    String pharmName = "";
            //    DataTable tblPharm = fullView.ToTable("CurrentPharm", true, neededCols.ToArray<String>());
            //    if (tblPharm.Rows.Count > 0)
            //    {
            //        if(ThisSession.CurrentPharmacyID == string.Empty)
            //            ThisSession.CurrentPharmacyID = tblPharm.Rows[0]["PharmacyID"].ToString();
            //        if(ThisSession.CurrentPharmacyLocationID == string.Empty)
            //            ThisSession.CurrentPharmacyLocationID = tblPharm.Rows[0]["PharmacyLocationID"].ToString();
            //        if (ThisSession.CurrentPharmacyPrice == string.Empty)
            //            ThisSession.CurrentPharmacyPrice = tblPharm.Rows[0][(this.SingleDrugResults ? "Price" : "TotalCost")].ToString();

            //        pharmName = tblPharm.Rows[0]["PharmacyName"].ToString();
            //    }

            //    //If there is a second table with past care info
            //    if (results.Tables.Count > 1)
            //    {
            //        DataTable visibilityTable = results.Tables[1];
            //        //If there are any rows in the past care table
            //        if (visibilityTable.Rows.Count > 0)
            //        {
            //            //Get the Yes or No text from the first column
            //            String pharmShow = visibilityTable.Rows[0]["ShowCurrentPharmacy"].ToString();
            //            Boolean hasPast = (pharmShow.ToLower() == "yes" && (visibilityTable.Rows[0]["CurrentPrice"].ToString() != ""));

            //            //Bind the visiblity of the two alert bars to whether or not there is any past care data
            //            abCurrentPrice.Visible = hasPast;
            //            abCouldSave.Visible = hasPast;

            //            //Additional past care work
            //            if (hasPast)
            //            {
            //                //Store the current price for use with the next table ("Best Price")
            //                Double currentPrice = Double.Parse(visibilityTable.Rows[0]["CurrentPrice"].ToString());
            //                //Get the name of the current pharmacy
            //                //String currentPharm = pharmName;//visibilityTable.Rows[0]["PharmName"].ToString();
            //                //Update the alert bar savings total with the data from the database
            //                abCurrentPrice.SaveTotal = String.Format("${0:f2}",currentPrice);
            //                abCurrentPrice.PharmacyName = pharmName;

            //                //If there is a third table returned
            //                if (results.Tables.Count > 2)
            //                {
            //                    DataTable priceTable = results.Tables[2];
            //                    //If that table has any rows
            //                    if (priceTable.Rows.Count > 0)
            //                    {
            //                        //Capture the best price total
            //                        Double bestPrice = Double.Parse(priceTable.Rows[0]["BestPrice"].ToString());
            //                        //Compare it to the current price to find savings
            //                        Double savings = currentPrice - bestPrice;
            //                        //Assign the difference to the total savings property do drive the visibilty of certain controls
            //                        abCouldSave.TotalSavings = Math.Round(savings, 2);
            //                        //Set the savings total to the difference (even if 0)
            //                        abCouldSave.SaveTotal = String.Format("${0:f2}", Math.Round(savings, 2).ToString());
            //                        abCouldSave.PharmacyName = pharmName;

            //                        ////If the savings are more than Zero, make visible the text "You could be saving...."
            //                        //((Label)abCouldSave.FindControl("lblCouldSave")).Visible = (savings != 0.0);
            //                        ////If the savings are equal to Zero, make visible the text "You are saving the most!"
            //                        //((Label)abCouldSave.FindControl("lblMaxSave")).Visible = (savings == 0.0);
            //                    }
            //                }
            //            }
            //        }

            //    }
            //}
        }