public void EmailBooking(AppointmentModel app)
        {
            try
            {
                Email_Api       emailApi     = new Email_Api();
                Appointment_Api aptms        = new Appointment_Api();
                var             apppointment = aptms.GetAllAppointments().Where(a => a.appointment_ID == app.appointment_ID).First();
                var             patients     = emailApi.GetPatientsAppointments();

                Admin_Api adminApi   = new Admin_Api();
                var       patDetails = (adminApi.GetAllPatients()).Where(p => p.pid == apppointment.paitent_ID).First();

                MailMessage mailMessage = new MailMessage("*****@*****.**", patDetails.emailID);
                // Specify the email body
                mailMessage.Body = "Dear Patient you have booked appointment with Doctor " + app.doctorName +
                                   " Appointment ID is " + app.appointment_ID + " appointment time is " + app.timings;
                mailMessage.Subject = "Success Booking";
                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                smtpClient.Credentials = new System.Net.NetworkCredential()
                {
                    UserName = "******",
                    Password = "******"
                };
                smtpClient.EnableSsl = true;
                smtpClient.Send(mailMessage);
            }
            catch (Exception ex)
            {
                Utils.Logging(ex, 2);
            }
        }
Beispiel #2
0
        public ActionResult EditAppointment(AppointmentModel appModel)
        {
            if (Convert.ToString(Session["key"]) != "patient")
            {
                return(RedirectToAction("Login", "Home"));
            }
            Appointment_Api apmtApi = new Appointment_Api();

            apmtApi.UpdateApnmt_Api(appModel);

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
        public JsonResult fillPatientList(string text)
        {
            Appointment_Api   app     = new Appointment_Api();
            TreatmentRoom_Api roomApi = new TreatmentRoom_Api();
            var model     = roomApi.GetAllTreatmentRoomRecs().Where(t => (t.date == DateTime.Parse(text) && t.isBooked == true)).GroupBy(g => g.patient_ID).Select(s => s.First()).ToList();
            var allAptmts = app.GetAllAppointments();

            var apps = allAptmts.Where(a => a.appointment_Date > DateTime.Now).GroupBy(g => g.paitent_ID).Select(s => s.First()).ToList();

            TreatmentRoomModel trModelPats = new TreatmentRoomModel();

            TreatmentRoomModel trModel = new TreatmentRoomModel();

            //var allApts = app.GetAllAppointments();

            foreach (var p in model)
            {
                trModelPats.patientDropDown.Add(new SelectListItem
                {
                    Text  = p.patientFirstName,
                    Value = Convert.ToString(p.patient_ID)
                });
            }

            foreach (var p in apps)
            {
                trModel.patientDropDown.Add(new SelectListItem
                {
                    Text  = p.patientName,
                    Value = Convert.ToString(p.paitent_ID)
                });
            }

            trModel.patientDropDown = (from t in trModel.patientDropDown
                                       where trModelPats.patientDropDown.All(o => o.Text != t.Text) select t).ToList();
            List <SelectListItem> patientList = new List <SelectListItem>();

            foreach (var p in trModel.patientDropDown)
            {
                patientList.Add(p);
            }

            foreach (var t in trModel.patientDropDown)
            {
                if ((GetApptsForRooms(Convert.ToInt32(t.Value))).Count() == 0)
                {
                    patientList.Remove(t);
                }
            }

            return(Json(patientList, JsonRequestBehavior.AllowGet));
        }
        //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 GetReqReportNotes(int aptId)
        {
            if (Convert.ToString(Session["key"]) != "labIncharge")
            {
                return(RedirectToAction("Login", "Home"));
            }
            Patient_Api patientApi = new Patient_Api();

            Appointment_Api  appApi   = new Appointment_Api();
            AppointmentModel appModel = new AppointmentModel();

            appModel.appointment_ID = aptId;
            var appDetails = appApi.GetApnmt_Api(appModel);

            return(Json(appDetails.reqReportNotes, JsonRequestBehavior.AllowGet));
        }
        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));
        }