예제 #1
0
        public ActionResult ViewAppointmentDetails()
        {
            int mid = Convert.ToInt32(Session["MemberId"]);

            using (ProjectEntities db = new ProjectEntities())
            {
                var id      = db.Patients.FirstOrDefault(a => a.MemberId == mid);
                int pid     = id.PatientId;
                var getdata = db.DoctorAppointments.Where(a => a.PatientId == pid);

                List <DoctorAppointmentModel> lst = new List <DoctorAppointmentModel>();
                foreach (var item in getdata)
                {
                    lst.Add(new DoctorAppointmentModel
                    {
                        DoctorName        = item.Doctor.FirstName,
                        Subject           = item.Subject,
                        Description       = item.Description,
                        AppointmentDate   = Convert.ToDateTime(item.AppointmentDate),
                        AppointmentStatus = item.AppointmentStatus
                    });
                }

                DoctorAppointmentModel model = new DoctorAppointmentModel();
                model.lstAppointment = lst;
                return(View(model));
            }
        }
        public ActionResult PostAppointmentDecision(DoctorAppointmentModel model)
        {
            int aid = model.AppointmentId;

            using (ProjectEntities db = new ProjectEntities())
            {
                if (model.DoctorDecision != null)
                {
                    var    getdata = db.DoctorAppointments.SingleOrDefault(a => a.AppointmentId == aid);
                    string status  = getdata.AppointmentStatus;
                    if (status == "Requested")
                    {
                        db.UpdateAppointmentStatus(model.AppointmentId, model.DoctorDecision);

                        return(Json("Appointment Status Updated"));
                    }
                    else
                    {
                        return(Json("Decision Already Taken"));
                    }
                }
                else
                {
                    return(Json("Choose Your Decision Wisely"));
                }
            }
        }
예제 #3
0
        public async Task <IActionResult> CreateAppointmentAsync([FromBody] CreateAppointmentRequestDto requestDto)
        {
            var doctorModel = await new DoctorBiz().GetAsync(requestDto.DoctorGuid);

            if (doctorModel == null)
            {
                return(Failed(ErrorCode.UserData, "未查询到此医生"));
            }
            if (!doctorModel.Enable || string.Equals(doctorModel.Status, StatusEnum.Draft.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                return(Failed(ErrorCode.UserData, "未查询到此医生"));
            }
            var scheduleModel = await new DoctorScheduleBiz().GetAsync(requestDto.ScheduleGuid);

            if (scheduleModel == null || !scheduleModel.Enable)
            {
                return(Failed(ErrorCode.UserData, "未查询到此排班信息"));
            }
            var userModel = new UserBiz().GetUserByPhone(requestDto.Phone);

            if (userModel == null)
            {
                return(Failed(ErrorCode.UserData, "通过手机号未查询到用户,请注册"));
            }
            var doctorWorkshiftDetailModel = await new DoctorWorkshiftDetailBiz().GetAsync(scheduleModel.WorkshiftDetailGuid);
            var appointmentTime            = Convert.ToDateTime($"{scheduleModel.ScheduleDate.ToString("yyyy-MM-dd")} {doctorWorkshiftDetailModel.StartTime.ToString()}");
            var appointmentEndTime         = Convert.ToDateTime($"{scheduleModel.ScheduleDate.ToString("yyyy-MM-dd")} {doctorWorkshiftDetailModel.EndTime.ToString()}");

            if (DateTime.Now >= appointmentEndTime)
            {
                return(Failed(ErrorCode.UserData, "当前时间不可大于就诊截止时间,请重新挂号"));
            }
            var model = new DoctorAppointmentModel
            {
                AppointmentGuid     = Guid.NewGuid().ToString("N"),
                HospitalGuid        = doctorModel.HospitalGuid,
                UserGuid            = userModel.UserGuid,
                AppointmentNo       = "",
                ScheduleGuid        = requestDto.ScheduleGuid,
                DoctorGuid          = requestDto.DoctorGuid,
                OfficeGuid          = doctorModel.OfficeGuid,
                AppointmentTime     = appointmentTime,
                AppointmentDeadline = appointmentEndTime,
                PatientGuid         = null,
                PatientName         = requestDto.PatientName,
                PatientPhone        = requestDto.Phone,
                PatientGender       = requestDto.PatientGender.ToString(),
                PatientBirthday     = requestDto.PatientBirthday,
                PatientCardno       = requestDto.PatientCardNo,
                Status        = AppointmentStatusEnum.Waiting.ToString(),
                CreatedBy     = UserID,
                LastUpdatedBy = UserID,
                OrgGuid       = string.Empty
            };
            var result = await new DoctorAppointmentBiz().CreateAppointmentAsync(model, doctorWorkshiftDetailModel.AppointmentNoPrefix, true);

            return(result ? Success() : Failed(ErrorCode.UserData, "挂号失败"));
        }
예제 #4
0
        public ActionResult PostMessageToDoctor(InboxMessageModel model)
        {
            int mid = Convert.ToInt32(Session["MemberId"]);

            using (ProjectEntities db = new ProjectEntities())
            {
                var    getdata     = db.MemberLogins.FirstOrDefault(a => a.MemberId == mid);
                string Fromemailid = getdata.EmailId;
                int    docid       = Convert.ToInt32(model.ToEmailId);
                var    data        = (from d in db.Doctors join m in db.MemberLogins
                                      on d.MemberId equals m.MemberId
                                      where d.DoctorId == docid
                                      select new { m.EmailId }).FirstOrDefault();

                model.ToEmailId = data.EmailId;
                DateTime msgdate = DateTime.Now;
                int      rid     = 0;
                bool     isread  = false;

                if (model.ToEmailId != null)
                {
                    db.InsertMessage(Fromemailid, model.ToEmailId, model.Subject, model.MessageDetail, msgdate, rid, isread);
                    ViewBag.Message = "Message Sent To Doctor";
                }
                else
                {
                    ViewBag.Message = "Select Your Doctor";
                }
            }

            List <SelectListItem> lst = new List <SelectListItem>();     // populate ddlDoctor after submit

            using (ProjectEntities db = new ProjectEntities())
            {
                var getdata = db.Doctors.ToList();
                foreach (var item in getdata)
                {
                    lst.Add(new SelectListItem
                    {
                        Value = item.DoctorId.ToString(),
                        Text  = item.FirstName
                    });
                }
            }

            DoctorAppointmentModel model1 = new DoctorAppointmentModel();

            model1.lstDoctor = lst;
            return(View("DoctorAppointment", model1));
        }
예제 #5
0
        public ActionResult PostAppointment(DoctorAppointmentModel model)
        {
            int    mid      = Convert.ToInt32(Session["MemberId"]);
            string apStatus = "Requested";

            using (ProjectEntities db = new ProjectEntities())
            {
                var pid = db.Patients.FirstOrDefault(a => a.MemberId == mid);
                int id  = pid.PatientId;
                if (model.AppointmentDate > DateTime.Now)
                {
                    db.InsertDoctorAppointment(id, model.DoctorId, model.Subject,
                                               model.Description, model.AppointmentDate, apStatus);

                    ViewBag.Message = "Appointment Fixed";
                }
                else
                {
                    ViewBag.Message = "Appointment date must be in future";
                }
            }
            List <SelectListItem> lst = new List <SelectListItem>();     // populate ddlDoctor after submit

            using (ProjectEntities db = new ProjectEntities())
            {
                var getdata = db.Doctors.ToList();
                foreach (var item in getdata)
                {
                    lst.Add(new SelectListItem
                    {
                        Value = item.DoctorId.ToString(),
                        Text  = item.FirstName
                    });
                }
            }

            DoctorAppointmentModel model1 = new DoctorAppointmentModel();

            model1.lstDoctor = lst;
            return(View("DoctorAppointment", model1));
        }
예제 #6
0
        public ActionResult DoctorAppointment()
        {
            List <SelectListItem> lst = new List <SelectListItem>();

            using (ProjectEntities db = new ProjectEntities())
            {
                var getdata = db.Doctors.ToList();
                foreach (var item in getdata)
                {
                    lst.Add(new SelectListItem
                    {
                        Value = item.DoctorId.ToString(),
                        Text  = item.FirstName
                    });
                }
            }

            DoctorAppointmentModel model = new DoctorAppointmentModel();

            model.lstDoctor = lst;
            return(View(model));
        }
예제 #7
0
        public async Task <IActionResult> AddAppointmentAsync([FromBody] AddAppointmentRequestDto requestDto)
        {
            var doctorModel = await new DoctorBiz().GetAsync(requestDto.DoctorGuid);

            if (doctorModel == null)
            {
                return(Failed(ErrorCode.UserData, "未查询到此医生"));
            }
            if (!doctorModel.Enable || string.Equals(doctorModel.Status, StatusEnum.Draft.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                return(Failed(ErrorCode.UserData, "未查询到此医生"));
            }
            var scheduleModel = await new DoctorScheduleBiz().GetAsync(requestDto.ScheduleGuid);

            if (scheduleModel == null || !scheduleModel.Enable)
            {
                return(Failed(ErrorCode.UserData, "未查询到此排班信息"));
            }
            if (scheduleModel.ScheduleDate.Date < DateTime.Now.Date || scheduleModel.ScheduleDate.Date > DateTime.Now.AddDays(6))
            {
                return(Failed(ErrorCode.UserData, "此时间段排班目前无法预约"));
            }
            var patientMemberModel = await new PatientMemberBiz().GetAsync(requestDto.PatientGuid);

            if (patientMemberModel == null || !patientMemberModel.Enable || patientMemberModel.UserGuid != UserID)
            {
                return(Failed(ErrorCode.UserData, "未查询到就诊人信息"));
            }
            //判断当前就诊人是否已经预约过
            var checkPatient = await new DoctorAppointmentBiz().GetDoctorAppointmentAsync(requestDto.DoctorGuid, scheduleModel.ScheduleDate, patientMemberModel.PatientGuid);

            if (checkPatient != null)
            {
                return(Failed(ErrorCode.UserData, "就诊人当天已经预约过该医生"));
            }
            //查询当前用户是否允许当天挂号
            ConsumerModel consumerModel = await new ConsumerBiz().GetModelAsync(UserID);

            if (consumerModel != null)
            {
                if (consumerModel.NoAppointmentDate.HasValue && consumerModel.NoAppointmentDate > DateTime.Now.Date)
                {
                    return(Failed(ErrorCode.UserData, "您在一个月内有连续爽约或取消超过3次的记录" + consumerModel.NoAppointmentDate.Value.ToString("yyyy-MM-dd") + "才可再次预约"));
                }
            }
            //检查累计是否超过二次连续取消或者爽约
            var checkList = await new DoctorAppointmentBiz().GetThreeMonthsDoctorAppointmentListAsync(UserID);

            if (checkList != null)
            {
                List <DateTime> resultList = new List <DateTime>();
                var             group      = checkList.GroupBy(s => s.CreationDate.ToString("yyyy-MM"));
                foreach (var items in group)
                {
                    foreach (var item in items)
                    {
                        if (item.Status == AppointmentStatusEnum.Cancel.ToString() || item.Status == AppointmentStatusEnum.Miss.ToString() || (item.Status == AppointmentStatusEnum.Waiting.ToString() && DateTime.Now.Date > item.AppointmentTime.Date))
                        {
                            resultList.Add(item.AppointmentTime.Date);
                        }
                        else
                        {
                            resultList.Clear();
                        }
                        if (resultList.Count >= 3 && DateTime.Now.Date < resultList.LastOrDefault().Date.AddMonths(3))
                        {
                            return(Failed(ErrorCode.UserData, "您在一个月内有连续爽约或取消超过3次的记录" + resultList.LastOrDefault().Date.AddMonths(3).ToString("yyyy-MM-dd") + "才可再次预约"));
                        }
                    }
                }
            }
            var doctorWorkshiftDetailModel = await new DoctorWorkshiftDetailBiz().GetAsync(scheduleModel.WorkshiftDetailGuid);
            var appointmentTime            = Convert.ToDateTime($"{scheduleModel.ScheduleDate.ToString("yyyy-MM-dd")} {doctorWorkshiftDetailModel.StartTime.ToString()}");
            var appointmentEndTime         = Convert.ToDateTime($"{scheduleModel.ScheduleDate.ToString("yyyy-MM-dd")} {doctorWorkshiftDetailModel.EndTime.ToString()}");

            if (DateTime.Now >= appointmentEndTime)
            {
                return(Failed(ErrorCode.UserData, "当前时间不可大于就诊截止时间,请重新挂号"));
            }
            var model = new DoctorAppointmentModel
            {
                AppointmentGuid     = Guid.NewGuid().ToString("N"),
                HospitalGuid        = doctorModel.HospitalGuid,
                UserGuid            = UserID,
                AppointmentNo       = "",
                ScheduleGuid        = requestDto.ScheduleGuid,
                DoctorGuid          = requestDto.DoctorGuid,
                OfficeGuid          = doctorModel.OfficeGuid,
                AppointmentTime     = appointmentTime,
                AppointmentDeadline = appointmentEndTime,
                PatientGuid         = patientMemberModel.PatientGuid,
                PatientName         = patientMemberModel.Name,
                PatientPhone        = patientMemberModel.Phone,
                PatientGender       = patientMemberModel.Gender,
                PatientBirthday     = patientMemberModel.Birthday,
                PatientCardno       = patientMemberModel.CardNo,
                PatientRelationship = patientMemberModel.Relationship,
                Status        = AppointmentStatusEnum.Waiting.ToString(),
                CreatedBy     = UserID,
                LastUpdatedBy = UserID,
                OrgGuid       = string.Empty
            };

            if (!string.IsNullOrWhiteSpace(requestDto.Phone))
            {
                model.PatientPhone = requestDto.Phone;
            }
            var result = await new DoctorAppointmentBiz().CreateAppointmentAsync(model, doctorWorkshiftDetailModel.AppointmentNoPrefix, false);

            if (!result)
            {
                return(Failed(ErrorCode.UserData, "挂号失败"));
            }
            var doctorAppointmentModel = await new DoctorAppointmentBiz().GetAppointmentAsync(model.AppointmentGuid);

            if (doctorAppointmentModel == null)
            {
                return(Failed(ErrorCode.UserData, "挂号失败"));
            }
            return(Success(doctorAppointmentModel));
        }