public RadioResultPageVM(INavigation _Nav)
        {
            Navigation = _Nav;

            CheckFilterIndex = -1;

            CalendarCommand = new DelegateCommand((s) =>
            {
                CalendarVisibility = true;
            });
            CheckFilterCommand = new DelegateCommand(async(s) =>
            {
                var index = await ShowActionSheet("Filter", CheckReportsFilter.ToList());// await MaterialDialog.Instance.SelectActionAsync(CheckReportsFilter);
                if (index >= 0)
                {
                    RadioResultList.Clear();
                    PageNumber       = 1;
                    CheckFilterIndex = index;
                    var list         = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates);
                    list.ForEach(a => RadioResultList.Add(a));
                    FilterLabelText = SetFilterLabelText(CheckFilterIndex, CalendarSelectedDates);
                }
            });

            SortCommand = new DelegateCommand(async(s) =>
            {
                try
                {
                    var index = await ShowActionSheet("Sort", SortDatesFilter.ToList());// await MaterialDialog.Instance.SelectActionAsync(SortDatesFilter);
                    if (index >= 0)
                    {
                        RadioResultList.Clear();
                        PageNumber  = 1;
                        SortedIndex = index;
                        var list    = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates);
                        list.ForEach(a => RadioResultList.Add(a));
                    }
                }
                catch (Exception ex)
                {
                }
            });

            FilterCommand = new DelegateCommand(async(s) =>
            {
                try
                {
                    RadioResultList.Clear();
                    await Initilize();
                    PageNumber = 1;
                    var list   = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates);
                    list.ForEach(a => RadioResultList.Add(a));
                    CalendarVisibility = false;
                    FilterLabelText    = SetFilterLabelText(CheckFilterIndex, CalendarSelectedDates);
                }
                catch (Exception ex)
                {
                }
            });
        }
        internal async void Search(string text)
        {
            text = text.ToLower();
            RadioResultList.Clear();

            if (String.IsNullOrEmpty(text))
            {
                var loader = await MaterialDialog.Instance.LoadingDialogAsync("Loading ..");
                await Initilize();

                await loader.DismissAsync();
            }
            else
            {
                PageNumber = 1;
                var mainList = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates);
                var list     = mainList.Where(s => s.ASREF.ToLower().Contains(text) || s.ASBRCH.ToLower().Contains(text) || s.ASYEAR.ToLower().Contains(text) ||
                                              s.ASPATT.ToLower().Contains(text) || s.ASPATF.ToLower().Contains(text) || s.ASPATL.ToLower().Contains(text));
                list.ForEach(s => RadioResultList.Add(s));
            };
        }
        public async Task Initilize()
        {
            try
            {
                UserDialogs.Instance.ShowLoading();

                PageNumber       = 1;
                CheckFilterIndex = 2;
                SortedIndex      = 4;
                var result = await ReportsService.GetAllLabReports(Constants.UserProfile.Role, Constants.UserProfile.LabID, "R", CalendarSelectedDates.StartDate, CalendarSelectedDates.EndDate);

                if (result.Success)
                {
                    foreach (var reportsModel in result.data)
                    {
                        //ReportViewedModel viewedModel = new ReportViewedModel
                        //{
                        //    ReportBrch = reportsModel.ASBRCH,
                        //    ReportRef = reportsModel.ASREF,
                        //    ReportYear = reportsModel.ASYEAR
                        //};

                        //var data = Settings.RadiologyReportViewed;
                        //if (data.Any(x => x.ReportBrch == reportsModel.ASBRCH &&
                        //                  x.ReportRef == reportsModel.ASREF &&
                        //                  x.ReportYear == reportsModel.ASYEAR))
                        //{
                        //    reportsModel.IsViewed = true;
                        //}

                        bool   isChecked = false;
                        string checkedOn = String.Empty;

                        switch (Constants.UserProfile.Role)
                        {
                        case "patient":
                            isChecked             = !String.IsNullOrEmpty(reportsModel.ASPCHKBY);
                            checkedOn             = reportsModel.ASPCHKDTE;
                            reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASPVIEWED);
                            break;

                        case "doctor":
                            isChecked             = !String.IsNullOrEmpty(reportsModel.ASDCHKBY);
                            checkedOn             = reportsModel.ASDCHKDTE;
                            reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASDVIEWED);
                            break;

                        case "agent":
                            isChecked             = !String.IsNullOrEmpty(reportsModel.ASACHKBY);
                            checkedOn             = reportsModel.ASACHKDTE;
                            reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASAVIEWED);
                            break;

                        case "guarantor":
                            isChecked             = !String.IsNullOrEmpty(reportsModel.ASGCHKBY);
                            checkedOn             = reportsModel.ASGCHKDTE;
                            reportsModel.IsViewed = !String.IsNullOrEmpty(reportsModel.ASGVIEWED);
                            break;
                        }
                        reportsModel.CheckedSource = isChecked ? "check.png" : "checkbox.png";
                        reportsModel.CheckDate     = isChecked ? checkedOn : String.Empty;
                    }

                    RadioResultListComplete = new ObservableCollection <ReportsModel>(result.data);
                    var newList = SortAndFilter(CheckFilterIndex, SortedIndex, PageNumber, CalendarSelectedDates);
                    newList.ForEach(s => RadioResultList.Add(s));
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }