public ActionResult GetAppointments()
        {
            if (Convert.ToString(Session["key"]) != "doctor")
            {
                return(RedirectToAction("Login", "Home"));
            }

            int        doctor_id    = (int)Session["UserId"];// 5006;
            Doctor_Api doctorApi    = new Doctor_Api();
            var        appointments = doctorApi.GetDocApntment_Api(doctor_id);

            //var appointments = doctorApi.GetDocApntment_Api(doctor_id);

            appointments.First().filterApps.Add(new SelectListItem {
                Text = "-Select", Value = "0"
            });
            appointments.First().filterApps.Add(new SelectListItem {
                Text = "Today", Value = "1"
            });
            appointments.First().filterApps.Add(new SelectListItem {
                Text = "Tomorrow", Value = "2"
            });
            appointments.First().filterApps.Add(new SelectListItem {
                Text = "All", Value = "3"
            });
            LabIncharge_Api lApi       = new LabIncharge_Api();
            var             allReports = lApi.ViewPatientReports_Api(new ReportModel());

            foreach (var a in appointments)
            {
                if (allReports.Where(r => r.appointment_ID == a.appointment_ID).FirstOrDefault() != null)
                {
                    a.reportAvailable = true;
                }
                else
                {
                    a.reportAvailable = false;
                }
                if (a.appointment_Date > DateTime.Now)
                {
                    a.canCancel = true;
                }
            }


            if (appointments != null)
            {
                return(View("~/Views/Doctor/DoctorViewAppointments.cshtml", appointments.OrderBy(a => a.appointment_Date)));
            }
            return(View("~/Views/Error.cshtml"));
        }
        public ActionResult ViewPatientReports()
        {
            if (Convert.ToString(Session["key"]) != "labIncharge")
            {
                return(RedirectToAction("Login", "Home"));
            }

            ReportModel reportModel = new ReportModel();

            reportModel.labIncharge_ID = (int)Session["UserId"];

            LabIncharge_Api inchargeApi  = new LabIncharge_Api();
            var             reportsModel = inchargeApi.ViewPatientReports_Api(reportModel);

            if (reportsModel != null)
            {
                return(View("~/Views/LabIncharge/LabInchargeViewReports.cshtml", reportsModel));
            }
            // ErrorModel.ErrorMessage = "Unable to fetch Patient Reports Please try again";
            return(View("~/Views/Error.cshtml"));
        }
        public ActionResult GetAppointmentsByFilter(int filterID)
        {
            if (Convert.ToString(Session["key"]) != "doctor")
            {
                return(RedirectToAction("Login", "Home"));
            }


            int        doctor_id    = (int)Session["UserId"];// 5006;
            Doctor_Api doctorApi    = new Doctor_Api();
            var        appointments = doctorApi.GetDocApntment_Api(doctor_id);

            LabIncharge_Api lApi       = new LabIncharge_Api();
            var             allReports = lApi.ViewPatientReports_Api(new ReportModel());

            foreach (var a in appointments)
            {
                if (allReports.Where(r => r.appointment_ID == a.appointment_ID).FirstOrDefault() != null)
                {
                    a.reportAvailable = true;
                }
                else
                {
                    a.reportAvailable = false;
                }
                int timeNow = Convert.ToInt32(DateTime.Now.Hour);
                int appTime = (Convert.ToInt32((a.timings).Substring(0, 2)));

                if (((a.appointment_Date).ToShortDateString().Equals((DateTime.Now.AddDays(1).ToShortDateString())) && (appTime > timeNow)) || (a.appointment_Date > DateTime.Now))
                {
                    a.canCancel = true;
                }
            }



            if (filterID == 1)
            {
                appointments = appointments.Where(a => ((a.appointment_Date).ToShortDateString().Equals((DateTime.Now).ToShortDateString())));// && a.appointment_Date > DateTime.Now.AddDays(-1) && a.appointment_Date <= DateTime.Now ));


                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "-Select", Value = "0"
                });
                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "Today", Value = "1"
                });
                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "Tomorrow", Value = "2"
                });
                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "All", Value = "3"
                });
            }
            else if (filterID == 2)
            {
                appointments = appointments.Where(a => ((a.appointment_Date).ToShortDateString().Equals(DateTime.Now.AddDays(1).ToShortDateString())));// && a.appointment_Date > DateTime.Now));



                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "-Select", Value = "0"
                });
                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "Today", Value = "1"
                });
                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "Tomorrow", Value = "2"
                });
                appointments.First().filterApps.Add(new SelectListItem {
                    Text = "All", Value = "3"
                });
            }
            //else if (id == 3)
            //{

            //}
            if (filterID == 3 || filterID == 0)
            {
                return(RedirectToAction("GetAppointments"));
            }

            if (appointments != null)
            {
                return(View("~/Views/Doctor/DoctorViewAppointments.cshtml", appointments.OrderBy(a => a.appointment_Date)));
            }
            return(View("~/Views/Error.cshtml"));
        }