//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 GetAppointmentsWithNoBilling(int patientID)
        {
            //int id = (int)Session["UserId"];
            Appointment_Api   app = new Appointment_Api();
            IEnumerable <int> patientAppointments = app.GetAppointmentsWithNoBilling().Where(a => (a.paitent_ID == patientID && a.appointment_Date < DateTime.Now)).Select(a => a.appointment_ID); //apts with no billing
            TreatmentRoom_Api trApi    = new TreatmentRoom_Api();
            PatientModel      patModel = new PatientModel();

            patModel.pid = patientID;
            var AptWithRoomInFuture = trApi.GetBookedRooms(patModel).Where(t => t.date > DateTime.Now).Select(t => t.appointment_ID); //apts with rooms in future

            patientAppointments = patientAppointments.Except(AptWithRoomInFuture);


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

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