protected void Page_Load(object sender, EventArgs e)
        {
            age                  = Convert.ToInt32(HttpContext.Current.Session["Age"]);
            PatientId            = Convert.ToInt32(HttpContext.Current.Session["PatientPK"]);
            PatientMasterVisitId = Convert.ToInt32(Request.QueryString["visitId"] != null ? Request.QueryString["visitId"] : HttpContext.Current.Session["PatientMasterVisitId"]);
            userId               = Convert.ToInt32(Session["AppUserId"]);
            if (Request.QueryString["visitId"] != null)
            {
                Session["ExistingRecordPatientMasterVisitID"] = Request.QueryString["visitId"].ToString();
                PatientEncounterExists = Convert.ToInt32(Request.QueryString["visitId"].ToString());
            }
            else
            {
                Session["ExistingRecordPatientMasterVisitID"] = "0";

                ///////Check if visit is scheduled
                if (PEL.isVisitScheduled(HttpContext.Current.Session["PatientPK"].ToString()) > 0)
                {
                    vsYes.Checked = true;
                }
                else
                {
                    vsNo.Checked = true;
                }
            }

            // Get Gender
            PatientLookup genderId = _patientLookupmanager.GetGenderID(Convert.ToInt32(HttpContext.Current.Session["PatientPK"]));

            if (genderId != null)
            {
                genderID = genderId.Sex;
            }

            LookupItemView genderType = _lookupItemManager.GetPatientGender(genderID);

            gender = genderType.ItemName;

            ILookupManager        mgr      = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC");
            List <LookupItemView> statuses = mgr.GetLookItemByGroup("AppointmentStatus");

            if (statuses != null && statuses.Count > 0)
            {
                status.Items.Add(new ListItem("select", "0"));
                foreach (var k in statuses)
                {
                    status.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
                status.SelectedIndex = 1;
                status.Enabled       = false;
            }


            List <LookupItemView> whoStage = mgr.GetLookItemByGroup("WHOStage");

            if (whoStage != null && whoStage.Count > 0)
            {
                WHOStage.Items.Add(new ListItem("select", ""));
                foreach (var k in whoStage)
                {
                    WHOStage.Items.Add(new ListItem(k.ItemName, k.ItemId.ToString()));
                }
            }

            List <LookupItemView> areas = mgr.GetLookItemByGroup("ServiceArea");

            if (areas != null && areas.Count > 0)
            {
                ServiceArea.Items.Add(new ListItem("select", "0"));
                foreach (var k in areas)
                {
                    ServiceArea.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
            }

            List <LookupItemView> reasons = mgr.GetLookItemByGroup("AppointmentReason");

            if (reasons != null && reasons.Count > 0)
            {
                Reason.Items.Add(new ListItem("select", "0"));
                foreach (var k in reasons)
                {
                    Reason.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
            }

            List <LookupItemView> care = mgr.GetLookItemByGroup("DifferentiatedCare");

            if (care != null && care.Count > 0)
            {
                DifferentiatedCare.Items.Add(new ListItem("select", "0"));
                foreach (var k in care)
                {
                    DifferentiatedCare.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
            }

            if (!IsPostBack)
            {
                LookupLogic lookUp = new LookupLogic();
                //lookUp.populateDDL(tbscreeningstatus, "TBStatus");
                lookUp.populateDDL(nutritionscreeningstatus, "NutritionStatus");
                lookUp.populateDDL(AdverseEventAction, "AdverseEventsActions");
                lookUp.populateDDL(ddlAdverseEventSeverity, "ADRSeverity");
                lookUp.populateDDL(ddlVisitBy, "VisitBy");
                lookUp.populateDDL(ChronicIllnessName, "ChronicIllness");
                lookUp.populateDDL(ddlVaccine, "Vaccinations");
                lookUp.populateDDL(ddlVaccineStage, "VaccinationStages");
                lookUp.populateDDL(ddlExaminationType, "ReviewOfSystems");
                //lookUp.populateDDL(ddlExamination, "PhysicalExamination");
                lookUp.populateCBL(cblGeneralExamination, "GeneralExamination");
                lookUp.populateCBL(cblPHDP, "PHDP");
                lookUp.populateDDL(arvAdherance, "ARVAdherence");
                lookUp.populateDDL(ctxAdherance, "CTXAdherence");
                lookUp.populateDDL(ddlAllergySeverity, "ADRSeverity");
                lookUp.populateDDL(stabilityStatus, "StabilityAssessment");
                lookUp.populateDDL(ddlPartnerStatus, "HivStatus");
                lookUp.populateDDL(ddlPartnerGender, "Gender");
                lookUp.populateDDL(ddlSexualOrientation, "SexualOrientation");

                var ddlHighRiskBehaviour = this.FindControl("ddlHighRiskBehaviour") as System.Web.UI.HtmlControls.HtmlSelect;
                // lookUp.populateDDL(ddlHighRiskBehaviour, "HighRisk");
                //lookUp.populateDDL(WHOStage, "WHOStage");
                //Patient Nutrition assessment notes and screening
                lookUp.populateDDL(ddlOnAntiTBDrugs, "GeneralYesNo");
                lookUp.populateDDL(ddlICFCough, "GeneralYesNo");
                lookUp.populateDDL(ddlICFFever, "GeneralYesNo");
                lookUp.populateDDL(ddlICFWeight, "GeneralYesNo");
                lookUp.populateDDL(ddlICFNightSweats, "GeneralYesNo");
                lookUp.populateDDL(ddlICFRegimen, "TBRegimen");
                lookUp.populateDDL(ddlICFCurrentlyOnIPT, "GeneralYesNo");
                lookUp.populateDDL(ddlICFStartIPT, "GeneralYesNo");
                lookUp.populateDDL(ddlICFTBScreeningOutcome, "TBFindings");

                lookUp.populateDDL(ddlSputumSmear, "SputumSmear");
                lookUp.populateDDL(ddlGeneXpert, "GeneExpert");
                lookUp.populateDDL(ddlChestXray, "ChestXray");
                lookUp.populateDDL(ddlStartAntiTB, "GeneralYesNo");
                lookUp.populateDDL(ddlInvitationofContacts, "GeneralYesNo");
                lookUp.populateDDL(ddlEvaluatedforIPT, "GeneralYesNo");
                getPatientNotesandScreening();
                populatePNS();
                getPNSData();

                //List<LookupItemView> highriskorientation = mgr.GetLookItemByGroup("HighRisk");
                //if (highriskorientation != null && highriskorientation.Count > 0)
                //{
                //    DifferentiatedCare.Items.Add(new ListItem("select", "0"));
                //    foreach (var k in highriskorientation)
                //    {
                //        ddlHighRiskBehaviour.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                //    }
                //}
                //ddlHighRiskBehaviour.Attributes["multiple"] = "multiple";
                var          patientVitals = new PatientVitalsManager();
                PatientVital patientTriage = patientVitals.GetByPatientId(Convert.ToInt32(Session["PatientPK"].ToString()));
                if (patientTriage != null)
                {
                    Weight         = patientTriage.Weight.ToString();
                    txtWeight.Text = Weight;
                    txtHeight.Text = patientTriage.Height.ToString();
                    txtBMI.Text    = patientTriage.BMI.ToString();
                    if (patientTriage.BMIZ != null)
                    {
                        txtBMIZ.Text = patientTriage.BMIZ.ToString();
                    }
                }


                //if (Convert.ToInt32(Session["PatientMasterVisitId"]) > 0)
                loadPatientEncounter();
            }

            Control NeonatalHistoryCtrl = Page.LoadControl("~/CCC/UC/ucNeonatalHistory.ascx");

            NeonatalHistoryPH.Controls.Add(NeonatalHistoryCtrl);

            Control TannerStagingCtrl = Page.LoadControl("~/CCC/UC/ucTannerStaging.ascx");

            TannersStagingPH.Controls.Add(TannerStagingCtrl);

            Control SocialHoistoryCtrl = Page.LoadControl("~/CCC/UC/ucSocialHistory.ascx");

            SocialHistoryPH.Controls.Add(SocialHoistoryCtrl);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            age                  = Convert.ToInt32(HttpContext.Current.Session["Age"]);
            PatientId            = Convert.ToInt32(HttpContext.Current.Session["PatientPK"]);
            PatientMasterVisitId = Convert.ToInt32(Request.QueryString["visitId"] != null ? Request.QueryString["visitId"] : HttpContext.Current.Session["PatientMasterVisitId"]);
            if (Request.QueryString["visitId"] != null)
            {
                Session["ExistingRecordPatientMasterVisitID"] = Request.QueryString["visitId"].ToString();
                PatientEncounterExists = Convert.ToInt32(Request.QueryString["visitId"].ToString());
            }
            else
            {
                Session["ExistingRecordPatientMasterVisitID"] = "0";

                ///////Check if visit is scheduled
                if (PEL.isVisitScheduled(HttpContext.Current.Session["PatientPK"].ToString()) > 0)
                {
                    vsYes.Checked = true;
                }
                else
                {
                    vsNo.Checked = true;
                }
            }

            // Get Gender
            PatientLookup genderId = _patientLookupmanager.GetGenderID(Convert.ToInt32(HttpContext.Current.Session["PatientPK"]));

            if (genderId != null)
            {
                genderID = genderId.Sex;
            }

            LookupItemView genderType = _lookupItemManager.GetPatientGender(genderID);

            gender = genderType.ItemName;

            ILookupManager        mgr      = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC");
            List <LookupItemView> statuses = mgr.GetLookItemByGroup("AppointmentStatus");

            if (statuses != null && statuses.Count > 0)
            {
                status.Items.Add(new ListItem("select", "0"));
                foreach (var k in statuses)
                {
                    status.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
                status.SelectedIndex = 1;
                status.Enabled       = false;
            }


            List <LookupItemView> whoStage = mgr.GetLookItemByGroup("WHOStage");

            if (whoStage != null && whoStage.Count > 0)
            {
                WHOStage.Items.Add(new ListItem("select", ""));
                foreach (var k in whoStage)
                {
                    WHOStage.Items.Add(new ListItem(k.ItemName, k.ItemId.ToString()));
                }
            }

            List <LookupItemView> areas = mgr.GetLookItemByGroup("ServiceArea");

            if (areas != null && areas.Count > 0)
            {
                ServiceArea.Items.Add(new ListItem("select", "0"));
                foreach (var k in areas)
                {
                    ServiceArea.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
            }

            List <LookupItemView> reasons = mgr.GetLookItemByGroup("AppointmentReason");

            if (reasons != null && reasons.Count > 0)
            {
                Reason.Items.Add(new ListItem("select", "0"));
                foreach (var k in reasons)
                {
                    Reason.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
            }

            List <LookupItemView> care = mgr.GetLookItemByGroup("DifferentiatedCare");

            if (care != null && care.Count > 0)
            {
                DifferentiatedCare.Items.Add(new ListItem("select", "0"));
                foreach (var k in care)
                {
                    DifferentiatedCare.Items.Add(new ListItem(k.ItemDisplayName, k.ItemId.ToString()));
                }
            }

            if (!IsPostBack)
            {
                LookupLogic lookUp = new LookupLogic();
                lookUp.populateDDL(tbscreeningstatus, "TBStatus");
                lookUp.populateDDL(nutritionscreeningstatus, "NutritionStatus");
                lookUp.populateDDL(AdverseEventAction, "AdverseEventsActions");
                lookUp.populateDDL(ddlAdverseEventSeverity, "ADRSeverity");
                lookUp.populateDDL(ddlVisitBy, "VisitBy");
                lookUp.populateDDL(ChronicIllnessName, "ChronicIllness");
                lookUp.populateDDL(ddlVaccine, "Vaccinations");
                lookUp.populateDDL(ddlVaccineStage, "VaccinationStages");
                lookUp.populateDDL(ddlExaminationType, "ReviewOfSystems");
                //lookUp.populateDDL(ddlExamination, "PhysicalExamination");
                lookUp.populateCBL(cblGeneralExamination, "GeneralExamination");
                lookUp.populateCBL(cblPHDP, "PHDP");
                lookUp.populateDDL(arvAdherance, "ARVAdherence");
                lookUp.populateDDL(ctxAdherance, "CTXAdherence");
                lookUp.populateDDL(ddlAllergySeverity, "ADRSeverity");
                lookUp.populateDDL(stabilityStatus, "StabilityAssessment");
                //lookUp.populateDDL(WHOStage, "WHOStage");

                var          patientVitals = new PatientVitalsManager();
                PatientVital patientTriage = patientVitals.GetByPatientId(Convert.ToInt32(Session["PatientPK"].ToString()));
                if (patientTriage != null)
                {
                    Weight         = patientTriage.Weight.ToString();
                    txtWeight.Text = Weight;
                    txtHeight.Text = patientTriage.Height.ToString();
                    txtBMI.Text    = patientTriage.BMI.ToString();
                    txtBMIZ.Text   = patientTriage.BMIZ.ToString();
                }


                //if (Convert.ToInt32(Session["PatientMasterVisitId"]) > 0)
                loadPatientEncounter();
            }
        }