public ActionResult Appointment(string id = "", int AppointmentId = 0, string status = "", string fromDate = "", string toDate = "", string msg = "")
        {
            int DoctorId = int.Parse(new EncryptDecrypt().Decrypt(id));

            DoctorAppointmentViewModel data = new DoctorAppointmentViewModel();

            AppointmentAPIController aController = new AppointmentAPIController();
            ReturnObject             ro          = new ReturnObject();

            using (var db = new ddiarydbEntities())
            {
                var doctor = db.Doctor_Master.Where(x => x.Doctor_id == DoctorId).FirstOrDefault();

                if (AppointmentId > 0)
                {
                    ro = aController.Update_Appointment(AppointmentId, status, msg);
                }

                var appointments = new List <Appointment>();

                ro = aController.Get_Appointments(0, DoctorId, fromDate, toDate);

                try
                {
                    appointments = (List <Appointment>)ro.data2;
                }
                catch (Exception)
                {
                    appointments = null;
                }

                if (doctor != null)
                {
                    data.Doctor = new DoctorViewModel().DoctorModel_to_ViewModel(doctor);

                    data.Appointments = new List <AppointmentViewModel>();
                    foreach (var item in appointments)
                    {
                        var temp = item.PatientName.Split(' ');
                        if (temp.Length > 1)
                        {
                            item.SessionId = temp[0].Substring(0, 1) + temp[1].Substring(0, 1);
                        }
                        else
                        {
                            item.SessionId = temp[0].Substring(0, 1);
                        }

                        data.Appointments.Add(new AppointmentViewModel().AppointmentModel_to_ViewModel(item));
                    }
                }
            }

            return(View(data));
        }
        /// <summary>
        /// Purpose: Find Patient details By Mobile Number
        /// Created By: Vishal Chudasama on 25 Aug 2020
        /// </summary>
        /// <returns> Patient details </returns>
        /// <param name="mobile"> mobile number </param>

        public JsonResult FindPatientByMobile(string mobile)
        {
            ReturnObject returnData = new ReturnObject();

            AppointmentAPIController aController = new AppointmentAPIController();

            returnData = aController.FindPatientByMobile(mobile);

            var data = new
            {
                message     = returnData.message,
                status_code = returnData.status_code,
                data1       = ((returnData.data1 != null) ? JsonConvert.SerializeObject(returnData.data1) : "")
            };

            return(Json(JsonConvert.SerializeObject(data), JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public ActionResult Login(PatientLoginViewModel obj)
        {
            obj.dateTime = DateTime.Now;

            if (obj.OTP != null)
            {
                ReturnObject ro = new AppointmentAPIController().VerifyMobile(obj.MobileNo, obj.OTP);

                if (ro.status_code == 1)
                {
                    using (var db = new ddiarydbEntities())
                    {
                        var patient = db.Patient_Master.Where(x => x.Patient_contact == obj.MobileNo).FirstOrDefault();

                        if (patient != null)
                        {
                            Session["UserID"]   = new EncryptDecrypt().Encrypt(patient.Patient_Id.ToString());;
                            Session["UserName"] = patient.Patient_name.ToString();
                        }
                        else
                        {
                            Session["UserMobile"] = obj.MobileNo;
                        }
                    }

                    return(RedirectToAction("Details"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Please Enter a valid OTP.");
                }
            }
            else
            {
                ModelState.AddModelError(string.Empty, "Please Enter a OTP.");
            }

            return(View(obj));
        }
        /// <summary>
        /// Purpose: Find Doctors Shift
        /// Created By: Vishal Chudasama on 25 Aug 2020
        /// </summary>
        /// <returns> Doctor Shift Details </returns>
        /// <param name="id"> Doctor Id </param>

        public JsonResult GetDoctorsShift(string DoctorId, string dateString)
        {
            int id = int.Parse(new EncryptDecrypt().Decrypt(DoctorId));

            var data = "";
            AppointmentAPIController aController = new AppointmentAPIController();
            ReturnObject             ro          = new ReturnObject();


            ro = aController.Get_DoctorsShift(id);

            try
            {
                var docShifts = ro.data1;

                var DATE = DateTime.Parse(dateString);

                ro = aController.Get_DoctorBookedSlot(id, DATE);

                var bookedSlot = ro.data1;

                var x = new
                {
                    docShifts,
                    bookedSlot
                };

                data = JsonConvert.SerializeObject(x);
            }
            catch (Exception ex)
            {
                var x = "";

                data = JsonConvert.SerializeObject(x);
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Purpose: Find Doctor
        /// Created By: Vishal Chudasama on 25 Aug 2020
        /// </summary>
        /// <returns> Doctor Details in List </returns>
        /// <param name="str"> Doctor Name </param>

        public JsonResult GetDoctors(string str = "")
        {
            var data = "";
            AppointmentAPIController aController = new AppointmentAPIController();
            ReturnObject             ro          = new ReturnObject();

            if (str.Length > 2)
            {
                var list = new List <DoctorViewModel>();

                ro = aController.FindDoctorsByString(str);

                List <Doctor_Master> datalist = new List <Doctor_Master>();
                try
                {
                    datalist = (List <Doctor_Master>)ro.data1;

                    foreach (var doctor in datalist)
                    {
                        list.Add(new DoctorViewModel()
                        {
                            Doctor_id        = 0,
                            Doctor_name      = doctor.Doctor_name,
                            Doctor_address   = doctor.Doctor_address,
                            DoctorId_Encrypt = new EncryptDecrypt().Encrypt(doctor.Doctor_id.ToString())
                        });
                    }
                }
                catch (Exception)
                {
                    datalist = null;
                }

                data = JsonConvert.SerializeObject(list);
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Booking(AppointmentViewModel appointment)
        {
            appointment.Status = "Pending";

            var startend = appointment.SessionId.Split('-');

            var date = Convert.ToDateTime(appointment.DateStart);

            var datetimeStart = date.ToShortDateString() + " " + startend[0];
            var datetimeEnd   = date.ToShortDateString() + " " + startend[1];

            appointment.DateStart = DateTime.Parse(datetimeStart);
            appointment.DateEnd   = DateTime.Parse(datetimeEnd);

            appointment.SessionId = appointment.DateStart.ToString("ddMMyyyyHHmm") + appointment.DateEnd.ToString("HHmm");

            try
            {
                using (var db = new ddiarydbEntities())
                {
                    Appointment obj = new MappingService().Map <AppointmentViewModel, Appointment>(appointment);
                    obj.DoctorId = int.Parse(new EncryptDecrypt().Decrypt(appointment.Doctor.DoctorId_Encrypt));

                    //db.Appointments.Add(obj);
                    //db.SaveChanges();
                    AppointmentAPIController aController  = new AppointmentAPIController();
                    ReturnObject             returnObject = new ReturnObject();

                    if (appointment.Id != 0)
                    {
                        returnObject = aController.Update_Appointment(obj);
                    }
                    else
                    {
                        returnObject = aController.Insert_Appointment(obj);
                    }

                    try
                    {
                        if (returnObject != null)
                        {
                            Appointment a = (Appointment)returnObject.data1;

                            var doctor = db.Doctor_Master.Where(x => x.Doctor_id == obj.DoctorId).FirstOrDefault();

                            TempData["DoctorName"] = doctor.Doctor_name;

                            string id = new EncryptDecrypt().Encrypt(a.Id.ToString());

                            return(Redirect("AppointmentDetails?id=" + id));
                        }

                        return(Redirect("Booking?id=" + appointment.Doctor.DoctorId_Encrypt));
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError(string.Empty, "Something Wrong.!");
                        return(View(appointment));
                    }
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "Something Wrong.!");
                return(View(appointment));
            }
        }