//Used to get aptmts for patients with no room booking
        public List <SelectListItem> GetApptsForRooms(int patientID)
        {
            Patient_Api     patientApi = new Patient_Api();
            Appointment_Api app        = new Appointment_Api();

            IEnumerable <AppointmentModel> patientAppointments = patientApi.GetAppointmentsForBookedRooms(patientID).Where(a => a.appointment_Date > DateTime.Now && a.cancelled == false);               //apts with no rooms
            IEnumerable <AppointmentModel> patAptsNoBilling    = app.GetAppointmentsWithNoBilling().Where(a => (a.paitent_ID == patientID && a.appointment_Date > DateTime.Now && a.cancelled == false)); //not billed apts

            List <int> aptsInt = new List <int>();

            foreach (var a in patientAppointments)
            {
                aptsInt.Add(a.appointment_ID);
            }

            List <int> aptsIntNoBilling = new List <int>();

            foreach (var a in patAptsNoBilling)
            {
                aptsIntNoBilling.Add(a.appointment_ID);
            }

            PatientModel patModel = new PatientModel();

            patModel.pid = patientID;
            TreatmentRoom_Api trApi = new TreatmentRoom_Api();
            var bookedAppointments  = trApi.GetBookedRooms(patModel); //apts with room booked

            List <int> bookedaptsInt = new List <int>();

            foreach (var a in bookedAppointments)
            {
                bookedaptsInt.Add(a.appointment_ID);
            }

            IEnumerable <int> finalApts = aptsIntNoBilling.Concat(aptsInt);//aptsIntNoBilling.Except(bookedaptsInt).ToList();

            finalApts = finalApts.Except(bookedaptsInt).ToList();


            List <SelectListItem> appts = new List <SelectListItem>();

            foreach (var a in finalApts)
            {
                appts.Add(new SelectListItem {
                    Text = a.ToString(), Value = a.ToString()
                });
            }
            return(appts);
        }
        public ActionResult ViewAppointments(int patientID)
        {
            int         id         = (int)Session["UserId"];
            Patient_Api patientApi = new Patient_Api();

            IEnumerable <AppointmentModel> patientAppointments = patientApi.GetAppointmentsForBookedRooms(patientID).Where(a => a.appointment_Date < DateTime.Now);
            //IEnumerable<AppointmentModel> patientAppointments = patientApi.GetAppointmentsForBookedRooms(patientID);

            List <SelectListItem> appts = new List <SelectListItem>();

            foreach (var a in patientAppointments)
            {
                appts.Add(new SelectListItem {
                    Text = a.appointment_ID.ToString(), Value = a.appointment_ID.ToString()
                });
            }
            return(Json(appts, JsonRequestBehavior.AllowGet));
        }