public void Initialize(ReadingsMode readingMode,
                               GetPreviousVisitTiming_EOMReading_Result previousEOMReading)
        {
            lstEOMSign_OD.SelectedIndex = -1;
            lstEOMSign_OS.SelectedIndex = -1;
            FullScreenMode = FullScreenMode.NotFullScreen;
            txtReccommednations_OD.EnterMoveNextControl = false;

            ReadingsMode = readingMode;
            switch (readingMode)
            {
            case ReadingsMode.ViewingActiveAllReadings:
                lytGroup_AllReadings.Visibility     = LayoutVisibility.Always;
                lytGroup_AllReadings.Expanded       = true;
                lytGroup_ReadingParent.Visibility   = lyt_Cancel.Visibility =
                    lyt_Add.Visibility              = emptySpaceItem36.Visibility =
                        emptySpaceItem15.Visibility = LayoutVisibility.Never;
                emptySpaceItem2.Visibility          = lytNewReadings.Visibility = LayoutVisibility.Always;
                btnAllReadings_Click(null, null);
                tabSigns.PageVisible = true;
                tabMore.PageVisible  = true;
                break;

            case ReadingsMode.ViewingPreviousReadings:
                Selected_VisitTiming_EOMReading_Result = previousEOMReading;
                btnNewReading.Text         = "Active Reading";
                btnAllReadings.Text        = "Previous Readings";
                emptySpaceItem2.Visibility = lytNewReadings.Visibility = LayoutVisibility.Never;
                ReadyForNewOrEditing(false);
                SetControlsValues();
                lyt_Cancel.Visibility = lyt_Add.Visibility = emptySpaceItem36.Visibility = LayoutVisibility.Never;
                tabSigns.PageVisible  = false;
                tabMore.PageVisible   = false;
                break;
            }

            if (PEMRBusinessLogic.ActivePEMRObject != null)
            {
                List <GetPreviousVisitTiming_EOMReading_Result> list =
                    PEMRBusinessLogic.GetPrevious_VisitTiming_EOMReading_Result(
                        PEMRBusinessLogic.ActivePEMRObject.Active_Patient.ID, dtSearchFrom.EditValue,
                        dtSearchTo.EditValue);
                if (list != null)
                {
                    list = list.OrderByDescending(item => item.TakenDateTime).ToList();
                }
                grdControl.DataSource = list;
                grdControl.RefreshDataSource();
                SetToolTip(list);
            }

            if (PEMRBusinessLogic.ActivePEMRObject == null ||
                PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign == null ||
                PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign.Count == 0 ||
                PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_EOMSign == null ||
                PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_EOMSign.Count == 0)
            {
                return;
            }

            txtReccommednations_OD.EditValue = PEMRBusinessLogic.ActivePEMRObject
                                               .List_VisitTiming_MainEOMSign[0].GeneralDescription_OD;
            txtReccommednations_OS.EditValue = PEMRBusinessLogic.ActivePEMRObject
                                               .List_VisitTiming_MainEOMSign[0].GeneralDescription_OS;

            AddedEOMSign_OD = null;
            AddedEOMSign_OS = null;
            foreach (VisitTiming_EOMSign visitTimingAnterior in PEMRBusinessLogic.ActivePEMRObject
                     .List_VisitTiming_EOMSign.FindAll(item =>
                                                       !Convert.ToInt32(item.PEMRElementStatus).Equals(Convert.ToInt32(PEMRElementStatus.Removed))))
            {
                SegmentSign_cu segmentSign = SegmentSign_cu.ItemsList.Find(item =>
                                                                           Convert.ToInt32(item.ID).Equals(Convert.ToInt32(visitTimingAnterior.SegmentSign_CU_ID)));
                if (segmentSign != null)
                {
                    DB_EyeType_p eyeTpe = (DB_EyeType_p)visitTimingAnterior.Eye_P_ID;
                    switch (eyeTpe)
                    {
                    case DB_EyeType_p.OD:
                        if (AddedEOMSign_OD == null)
                        {
                            AddedEOMSign_OD = new List <SegmentSign_cu>();
                        }
                        AddedEOMSign_OD.Add(segmentSign);
                        break;

                    case DB_EyeType_p.OS:
                        if (AddedEOMSign_OS == null)
                        {
                            AddedEOMSign_OS = new List <SegmentSign_cu>();
                        }
                        AddedEOMSign_OS.Add(segmentSign);
                        break;
                    }
                }
            }

            ClearControls(false);
            CommonViewsActions.FillListBoxControl(lstAddedEOMSign_OD, AddedEOMSign_OD);
            CommonViewsActions.FillListBoxControl(lstAddedEOMSign_OS, AddedEOMSign_OS);
            lstAddedEOMSign_OD.Refresh();
            lstAddedEOMSign_OS.Refresh();
            SetCount_OD();
            SetCount_OS();

            PEMRBusinessLogic.PEMR_EOMSign = this;
        }
        private void btnAddList_OD_Click(object sender, EventArgs e)
        {
            if (TempEOMSignListToBeAdded_OD == null || TempEOMSignListToBeAdded_OD.Count == 0)
            {
                XtraMessageBox.Show(
                    "You should select at least one Anterior Segment Sign to be added." + "\r\n" +
                    "You can select one or more Anterior Segment Sign to add", "Note", MessageBoxButtons.OK,
                    MessageBoxIcon.Hand);
                return;
            }

            if (AddedEOMSign_OD == null)
            {
                AddedEOMSign_OD = new List <SegmentSign_cu>();
            }
            if (TempEOMSignListToBeAdded_OD != null && TempEOMSignListToBeAdded_OD.Count > 0)
            {
                foreach (SegmentSign_cu segmentSign in TempEOMSignListToBeAdded_OD)
                {
                    if (!AddedEOMSign_OD.Exists(item =>
                                                Convert.ToInt32(item.ID).Equals(Convert.ToInt32(segmentSign.ID))))
                    {
                        AddedEOMSign_OD.Add(segmentSign);
                        if (PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign == null)
                        {
                            PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign =
                                new List <VisitTiming_MainEOMSign>();
                            _mainEOMSign = PEMRBusinessLogic.CreateNew_VisitTiming_MainEOMSign(
                                FurtherDetails_OD, FurtherDetails_OS,
                                ApplicationStaticConfiguration.PEMRSavingMode);
                            PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign.Add(
                                _mainEOMSign);
                        }

                        if (PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign[0] != null)
                        {
                            if (!string.IsNullOrEmpty(txtReccommednations_OD.Text) ||
                                !string.IsNullOrWhiteSpace(txtReccommednations_OD.Text))
                            {
                                PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign[0].GeneralDescription_OD
                                    = txtReccommednations_OD.Text;
                            }
                            else
                            {
                                PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign[0]
                                .GeneralDescription_OD = null;
                            }
                        }

                        if (PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_EOMSign == null)
                        {
                            PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_EOMSign =
                                new List <VisitTiming_EOMSign>();
                        }
                        _visitTimingEOM = PEMRBusinessLogic.CreateNew_VisitTiming_EOMSign(
                            PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_MainEOMSign[0], segmentSign,
                            DB_EyeType_p.OD, ApplicationStaticConfiguration.ActiveLoginUser.Person_CU_ID,
                            DB_PEMRSavingMode.SaveImmediately);
                        if (_visitTimingEOM != null)
                        {
                            PEMRBusinessLogic.ActivePEMRObject.List_VisitTiming_EOMSign.Add(
                                _visitTimingEOM);
                        }
                    }
                }
            }

            TempEOMSignListToBeAdded_OD = null;
            CommonViewsActions.FillListBoxControl(lstAddedEOMSign_OD, AddedEOMSign_OD);
            lstAddedEOMSign_OD.Refresh();
            SetCount_OD();
            SetCount_OS();
            lstEOMSign_OD.SelectedIndex = -1;
        }