public void Page_Load(object sender, EventArgs e)
        {
            wsEMR = (EmrSvc)Session[SessionVariables.Service];

            var patient = wsEMR.select(Request.QueryString["localPid"]);

            author.Text = Session[SessionVariables.Name].ToString();
            Patient.Text = patient.patientName;

            //var ID = Request.QueryString["localpid"];
            //var PatientSID = Request.QueryString["PatientSID"];
            //System.Timers.Timer aTimer = new System.Timers.Timer();
            //aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            //aTimer.Interval = 35000;
            //aTimer.Enabled = true;
            //aTimer.Start();

            //if (aTimer.Interval < 30000)
            //{
            //    MessageBox.Show("This session is ending in two minutes. Be sure to submit your note to CPRS, or you will be redirected to the login screen");
            //}

            //if (aTimer.Interval < 0001)
            //{
            //    aTimer.Stop();
            //    aTimer.Enabled = false;
            //    MessageBox.Show("This session has ended. You will now be redirected to the CPRS Login Page");
            //    Session.Abandon();
            //    wsEMR.disconnect();
            //    Session.Contents.RemoveAll();
            //    Response.Redirect("CPRSLogin.aspx?localpid=" + ID + "&PatientSID=" + PatientSID);
            //}
        }
        protected void BiopsyResults_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
              {
              wsEMR = (EmrSvc)Session[SessionVariables.Service];
            if (!IsPostBack)
            {
                var patient = wsEMR.select(Request.QueryString["localPid"]);
                author.Text = Session[SessionVariables.Name].ToString();
                Patient.Text = patient.patientName;
            }

            else if (IsPostBack)
            {

                var patient = wsEMR.select(Request.QueryString["localPid"]);
                int pt = Convert.ToInt32(Request.QueryString["PatientSID"]);

                //author.Text = Session[SessionVariables.Name].ToString();
                //Patient.Text = patient.patientName;

                var context = new CohortDBContext();
                //Database.SetInitializer<CohortDBContext>(null);
                //var pid = context.PatientCohorts.Where(p => p.PatientSSN == patient.ssn).SingleOrDefault();
                var genotype = (from pc in context.PatientCohorts
                                where pc.PatientSID == pt
                                select pc.Genotype).First();

                //var lab = pid.PatientLabs.OrderByDescending(Lab => Lab.LabChemSpecimenDateTime).Where(Lab => Lab.HepCAntibody != null)
                //    .Select(Lab => Lab.HepCAntibody).First();
                //var lab = pid.PatientLabs.OrderByDescending(Lab => Lab.LabChemSpecimenDateTime).First();
                string br = drpBiopsyResults.Text;
                string week = drpWeek.Text;
                string drug = drpDrug.Text;
                string therapy = drpTherapy.Text;
                string duration = drpDuration.Text;
                string physical = drpPhysical.Text;
                string mental = drpMental.Text;
                string doses = drpDoses.Text;
                string biopsyDone = drpLiverBiopsy.Text;
                //string biopsyDone = hide.Value.ToString();
                string physExam = null;
                string GeneralcbAlert = null;

                string strPhysical = "";
                foreach(ListItem Item in PhysicalSymptoms.Items)
                {
                    if(Item.Selected)
                    {
                        if (strPhysical.StartsWith("Physical Symptoms: "))
                        {
                            strPhysical = strPhysical + ", " + Item.Value;
                        }
                        else strPhysical = "Physical Symptoms: " + Item.Value;
                    }

                }

                txtboxNote.Text = patient.name.ToString() + " is currently on week " + week +
                    " of a planned total duration of therapy of " + duration + " weeks for treatment of cHCV genotype " + genotype + " with \n" + drug +
                    ". " + biopsyDone + br + " \nPatient " + physical + " physical adverse drug effects " +
                    " \nPatient " + mental + " mental health adverse drug effects " +
                    " \nSince last visit, adherence to therapy has been " + therapy +
                    " as patient reports a total of " + doses + " missed doses.\n"
                    + physExam + GeneralcbAlert + strPhysical ;
            }
            }
            catch(NullReferenceException ex)
             {
                 ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('" + ex.Message + "')", true);
             }
        }