/////////////////////////////////////////////////////////////////////
    // Code Written By   : John Macharia
    // Written Date      : 26th Jul 2012
    // Description       : Pharmacy Notes Form
    //
    /// /////////////////////////////////////////////////////////////////
    #region "UserFunctions"
    private void Init_Form()
    {
        string       strPatientEnrollmentId = string.Empty;
        IPatientHome PatientManager;

        PatientManager = (IPatientHome)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BPatientHome, BusinessProcess.Clinical");
        System.Data.DataSet theDS = PatientManager.GetPatientDetails(Convert.ToInt32(Session["PatientId"]), Convert.ToInt32(Session["SystemId"]), Convert.ToInt32(Session["TechnicalAreaId"]));
        PatientManager = null;

        #region "Patient Data"
        Session["PatientInformation"] = theDS.Tables[0];
        #endregion



        #region "Fill Details"
        if (theDS.Tables[0].Rows.Count > 0)
        {
            if (Convert.ToInt32(Session["SystemId"]) == 1)
            {
                lblpatientname.Text = theDS.Tables[0].Rows[0]["LastName"].ToString() + ", " + theDS.Tables[0].Rows[0]["FirstName"].ToString();
                lblage.Text         = theDS.Tables[0].Rows[0]["AGEINYEARMONTH"].ToString();
                lblgender.Text      = theDS.Tables[0].Rows[0]["SexNM"].ToString();
                if (theDS.Tables[19].Rows.Count > 0)
                {
                    if (theDS.Tables[19].Rows[0]["ART/PalliativeCare"].ToString() == "Care Ended")
                    {
                        lblptnstatus.Text = "Care Ended";
                    }

                    else if (theDS.Tables[19].Rows[0]["ART/PalliativeCare"].ToString() != "Care Ended")
                    {
                        lblptnstatus.Text = "Active";
                    }

                    DataTable dt = new DataTable();
                    dt = theDS.Tables[42];
                    if (theDS.Tables[42].Rows.Count > 0)
                    {
                        if (dt.Rows[0]["PatientExitReason"].ToString() == "93")
                        {
                            lblptnstatus.Text = "Care Ended";
                        }
                    }
                }
            }
            else
            {
            }
        }
        #endregion

        IDrug PNotes;
        PNotes = (IDrug)ObjectFactory.CreateInstance("BusinessProcess.Pharmacy.BDrug, BusinessProcess.Pharmacy");
        System.Data.DataSet thePN = PNotes.GetPharmacyNotes(Convert.ToInt32(Session["PatientId"]));
        PNotes = null;

        Session["GrdData"]       = thePN.Tables[0];
        Session["SortDirection"] = "Asc";

        grdPharmacyNotes.DataSource = thePN.Tables[0];
        grdPharmacyNotes.DataBind();
    }
        void ReleaseDesignerOutlets()
        {
            if (AStList != null)
            {
                AStList.Dispose();
                AStList = null;
            }

            if (AParList != null)
            {
                AParList.Dispose();
                AParList = null;
            }

            if (ATeaList != null)
            {
                ATeaList.Dispose();
                ATeaList = null;
            }

            if (AAClassForm != null)
            {
                AAClassForm.Dispose();
                AAClassForm = null;
            }

            if (AAClassLetter != null)
            {
                AAClassLetter.Dispose();
                AAClassLetter = null;
            }

            if (AAClassProfile != null)
            {
                AAClassProfile.Dispose();
                AAClassProfile = null;
            }

            if (AAClassYear != null)
            {
                AAClassYear.Dispose();
                AAClassYear = null;
            }

            if (AAddClErr != null)
            {
                AAddClErr.Dispose();
                AAddClErr = null;
            }

            if (AAddGrillErr != null)
            {
                AAddGrillErr.Dispose();
                AAddGrillErr = null;
            }

            if (AAddLessErr != null)
            {
                AAddLessErr.Dispose();
                AAddLessErr = null;
            }

            if (AAddParErr != null)
            {
                AAddParErr.Dispose();
                AAddParErr = null;
            }

            if (AAddProfile != null)
            {
                AAddProfile.Dispose();
                AAddProfile = null;
            }

            if (AAddProfileErr != null)
            {
                AAddProfileErr.Dispose();
                AAddProfileErr = null;
            }

            if (AAddRoomErr != null)
            {
                AAddRoomErr.Dispose();
                AAddRoomErr = null;
            }

            if (AAddStClass != null)
            {
                AAddStClass.Dispose();
                AAddStClass = null;
            }

            if (AAddStErr != null)
            {
                AAddStErr.Dispose();
                AAddStErr = null;
            }

            if (AAddStHome != null)
            {
                AAddStHome.Dispose();
                AAddStHome = null;
            }

            if (AAddStLast != null)
            {
                AAddStLast.Dispose();
                AAddStLast = null;
            }

            if (AAddStMail != null)
            {
                AAddStMail.Dispose();
                AAddStMail = null;
            }

            if (AAddStName != null)
            {
                AAddStName.Dispose();
                AAddStName = null;
            }

            if (AAddStNum != null)
            {
                AAddStNum.Dispose();
                AAddStNum = null;
            }

            if (AAddStPesel != null)
            {
                AAddStPesel.Dispose();
                AAddStPesel = null;
            }

            if (AAddStRegNum != null)
            {
                AAddStRegNum.Dispose();
                AAddStRegNum = null;
            }

            if (AAddSubErr != null)
            {
                AAddSubErr.Dispose();
                AAddSubErr = null;
            }

            if (AAddTeaErr != null)
            {
                AAddTeaErr.Dispose();
                AAddTeaErr = null;
            }

            if (AAddUnitErr != null)
            {
                AAddUnitErr.Dispose();
                AAddUnitErr = null;
            }

            if (AALessClL != null)
            {
                AALessClL.Dispose();
                AALessClL = null;
            }

            if (AALessClY != null)
            {
                AALessClY.Dispose();
                AALessClY = null;
            }

            if (AALessDay != null)
            {
                AALessDay.Dispose();
                AALessDay = null;
            }

            if (AALessRF != null)
            {
                AALessRF.Dispose();
                AALessRF = null;
            }

            if (AALessRR != null)
            {
                AALessRR.Dispose();
                AALessRR = null;
            }

            if (AALessSub != null)
            {
                AALessSub.Dispose();
                AALessSub = null;
            }

            if (AALessUH != null)
            {
                AALessUH.Dispose();
                AALessUH = null;
            }

            if (AALessUM != null)
            {
                AALessUM.Dispose();
                AALessUM = null;
            }

            if (AAParHome != null)
            {
                AAParHome.Dispose();
                AAParHome = null;
            }

            if (AAParLast != null)
            {
                AAParLast.Dispose();
                AAParLast = null;
            }

            if (AAParMail != null)
            {
                AAParMail.Dispose();
                AAParMail = null;
            }

            if (AAParMoney != null)
            {
                AAParMoney.Dispose();
                AAParMoney = null;
            }

            if (AAParNa != null)
            {
                AAParNa.Dispose();
                AAParNa = null;
            }

            if (AAParNum != null)
            {
                AAParNum.Dispose();
                AAParNum = null;
            }

            if (AAParPe != null)
            {
                AAParPe.Dispose();
                AAParPe = null;
            }

            if (AARoomChairs != null)
            {
                AARoomChairs.Dispose();
                AARoomChairs = null;
            }

            if (AARoomFloor != null)
            {
                AARoomFloor.Dispose();
                AARoomFloor = null;
            }

            if (AARoomRoom != null)
            {
                AARoomRoom.Dispose();
                AARoomRoom = null;
            }

            if (AASub != null)
            {
                AASub.Dispose();
                AASub = null;
            }

            if (AATaNa != null)
            {
                AATaNa.Dispose();
                AATaNa = null;
            }

            if (AATeaHome != null)
            {
                AATeaHome.Dispose();
                AATeaHome = null;
            }

            if (AATeaLast != null)
            {
                AATeaLast.Dispose();
                AATeaLast = null;
            }

            if (AATeaMail != null)
            {
                AATeaMail.Dispose();
                AATeaMail = null;
            }

            if (AATeaName != null)
            {
                AATeaName.Dispose();
                AATeaName = null;
            }

            if (AATeaPe != null)
            {
                AATeaPe.Dispose();
                AATeaPe = null;
            }

            if (AATeaPhone != null)
            {
                AATeaPhone.Dispose();
                AATeaPhone = null;
            }

            if (AATeaWork != null)
            {
                AATeaWork.Dispose();
                AATeaWork = null;
            }

            if (AAUnitH != null)
            {
                AAUnitH.Dispose();
                AAUnitH = null;
            }

            if (AAUnitM != null)
            {
                AAUnitM.Dispose();
                AAUnitM = null;
            }

            if (ACClass != null)
            {
                ACClass.Dispose();
                ACClass = null;
            }

            if (ACForm != null)
            {
                ACForm.Dispose();
                ACForm = null;
            }

            if (AchCl != null)
            {
                AchCl.Dispose();
                AchCl = null;
            }

            if (AChClass != null)
            {
                AChClass.Dispose();
                AChClass = null;
            }

            if (AChClErr != null)
            {
                AChClErr.Dispose();
                AChClErr = null;
            }

            if (AChFormEr != null)
            {
                AChFormEr.Dispose();
                AChFormEr = null;
            }

            if (AChFormErr != null)
            {
                AChFormErr.Dispose();
                AChFormErr = null;
            }

            if (AChSt != null)
            {
                AChSt.Dispose();
                AChSt = null;
            }

            if (ADelgrillErr != null)
            {
                ADelgrillErr.Dispose();
                ADelgrillErr = null;
            }

            if (ADelGrillPar != null)
            {
                ADelGrillPar.Dispose();
                ADelGrillPar = null;
            }

            if (ADelGrillSt != null)
            {
                ADelGrillSt.Dispose();
                ADelGrillSt = null;
            }

            if (ADelPar != null)
            {
                ADelPar.Dispose();
                ADelPar = null;
            }

            if (ADelParErr != null)
            {
                ADelParErr.Dispose();
                ADelParErr = null;
            }

            if (ADelSt != null)
            {
                ADelSt.Dispose();
                ADelSt = null;
            }

            if (ADelStErr != null)
            {
                ADelStErr.Dispose();
                ADelStErr = null;
            }

            if (ADelTea != null)
            {
                ADelTea.Dispose();
                ADelTea = null;
            }

            if (ADelteaErr != null)
            {
                ADelteaErr.Dispose();
                ADelteaErr = null;
            }

            if (AGrillParent != null)
            {
                AGrillParent.Dispose();
                AGrillParent = null;
            }

            if (AGrillStudent != null)
            {
                AGrillStudent.Dispose();
                AGrillStudent = null;
            }

            if (PChildList != null)
            {
                PChildList.Dispose();
                PChildList = null;
            }

            if (PeselInput != null)
            {
                PeselInput.Dispose();
                PeselInput = null;
            }

            if (PLegitimize != null)
            {
                PLegitimize.Dispose();
                PLegitimize = null;
            }

            if (PLegitimizeErr != null)
            {
                PLegitimizeErr.Dispose();
                PLegitimizeErr = null;
            }

            if (PMyInfo != null)
            {
                PMyInfo.Dispose();
                PMyInfo = null;
            }

            if (PNotes != null)
            {
                PNotes.Dispose();
                PNotes = null;
            }

            if (PPresance != null)
            {
                PPresance.Dispose();
                PPresance = null;
            }

            if (PWarnings != null)
            {
                PWarnings.Dispose();
                PWarnings = null;
            }

            if (SNotes != null)
            {
                SNotes.Dispose();
                SNotes = null;
            }

            if (SPoints != null)
            {
                SPoints.Dispose();
                SPoints = null;
            }

            if (SPresance != null)
            {
                SPresance.Dispose();
                SPresance = null;
            }

            if (SWarnings != null)
            {
                SWarnings.Dispose();
                SWarnings = null;
            }

            if (SyInfo != null)
            {
                SyInfo.Dispose();
                SyInfo = null;
            }

            if (TAddCatErr != null)
            {
                TAddCatErr.Dispose();
                TAddCatErr = null;
            }

            if (TBest1 != null)
            {
                TBest1.Dispose();
                TBest1 = null;
            }

            if (TCatNam != null)
            {
                TCatNam.Dispose();
                TCatNam = null;
            }

            if (TCatWeight != null)
            {
                TCatWeight.Dispose();
                TCatWeight = null;
            }

            if (TChaPrErr != null)
            {
                TChaPrErr.Dispose();
                TChaPrErr = null;
            }

            if (TCheckPresance != null)
            {
                TCheckPresance.Dispose();
                TCheckPresance = null;
            }

            if (TCheckStudent != null)
            {
                TCheckStudent.Dispose();
                TCheckStudent = null;
            }

            if (TChePrErr != null)
            {
                TChePrErr.Dispose();
                TChePrErr = null;
            }

            if (TClass != null)
            {
                TClass.Dispose();
                TClass = null;
            }

            if (TCNDesc != null)
            {
                TCNDesc.Dispose();
                TCNDesc = null;
            }

            if (TCNSt != null)
            {
                TCNSt.Dispose();
                TCNSt = null;
            }

            if (TCNVal != null)
            {
                TCNVal.Dispose();
                TCNVal = null;
            }

            if (TErrNote != null)
            {
                TErrNote.Dispose();
                TErrNote = null;
            }

            if (TErrNoteChange != null)
            {
                TErrNoteChange.Dispose();
                TErrNoteChange = null;
            }

            if (TErrWar != null)
            {
                TErrWar.Dispose();
                TErrWar = null;
            }

            if (TextOnFirstPage != null)
            {
                TextOnFirstPage.Dispose();
                TextOnFirstPage = null;
            }

            if (TMyInfo != null)
            {
                TMyInfo.Dispose();
                TMyInfo = null;
            }

            if (TNCat != null)
            {
                TNCat.Dispose();
                TNCat = null;
            }

            if (TNDesc != null)
            {
                TNDesc.Dispose();
                TNDesc = null;
            }

            if (TNSt != null)
            {
                TNSt.Dispose();
                TNSt = null;
            }

            if (TNSub != null)
            {
                TNSub.Dispose();
                TNSub = null;
            }

            if (TNVal != null)
            {
                TNVal.Dispose();
                TNVal = null;
            }

            if (TPreSt != null)
            {
                TPreSt.Dispose();
                TPreSt = null;
            }

            if (TPreStat != null)
            {
                TPreStat.Dispose();
                TPreStat = null;
            }

            if (TPreUnit != null)
            {
                TPreUnit.Dispose();
                TPreUnit = null;
            }

            if (TPrUnit != null)
            {
                TPrUnit.Dispose();
                TPrUnit = null;
            }

            if (TWDesc != null)
            {
                TWDesc.Dispose();
                TWDesc = null;
            }

            if (TWPoints != null)
            {
                TWPoints.Dispose();
                TWPoints = null;
            }

            if (TWSt != null)
            {
                TWSt.Dispose();
                TWSt = null;
            }
        }