コード例 #1
0
        public async Task <IActionResult> GetLastAppointmentAsync()
        {
            DoctorAppointmentBiz doctorAppointmentBiz = new DoctorAppointmentBiz();
            var response = await doctorAppointmentBiz.GetLastAppointmentAsync(UserID);

            return(Success(response));
        }
コード例 #2
0
        public async Task <IActionResult> GetAppointmentDoctorAsync([FromQuery] GetAppointmentDoctorRequestDto requestDto)
        {
            DoctorAppointmentBiz doctorAppointmentBiz = new DoctorAppointmentBiz();
            var response = await doctorAppointmentBiz.GetAppointmentDoctorPageListAsync(UserID, requestDto);

            return(Success(response));
        }
コード例 #3
0
        public async Task <IActionResult> GetHospitalDepartmentsAsync(string hospitalGuid)
        {
            DoctorAppointmentBiz doctorAppointmentBiz = new DoctorAppointmentBiz();

            if (string.IsNullOrWhiteSpace(hospitalGuid))
            {
                return(Failed(ErrorCode.UserData, "医院Id不能为空"));
            }
            var response = await doctorAppointmentBiz.GetHospitalDepartmentsAsync(hospitalGuid);

            if (response != null)
            {
                //查找最近用户去过的科室
                string been = await doctorAppointmentBiz.GetBeenDepartmentsAsync(UserID);

                if (!string.IsNullOrWhiteSpace(been))
                {
                    foreach (var item in response)
                    {
                        if (item.OfficeGuid == been)
                        {
                            item.IsBeen = true;
                        }
                    }
                }
            }
            return(Success(response));
        }
コード例 #4
0
        public async Task <IActionResult> CancelAppointmentAsync(string appointGuid)
        {
            if (string.IsNullOrWhiteSpace(appointGuid))
            {
                return(Failed(ErrorCode.DataBaseError, "参数不能为空"));
            }
            var biz   = new DoctorAppointmentBiz();
            var model = await biz.GetAsync(appointGuid);

            if (model == null || model.UserGuid != UserID)
            {
                return(Failed(ErrorCode.UserData, "未找到记录"));
            }
            if (model.Status != AppointmentStatusEnum.Waiting.ToString())
            {
                return(Failed(ErrorCode.UserData, "只有待诊状态才可以取消"));
            }
            //检查累计是否超过二次连续取消或者爽约
            var           checkList     = await new DoctorAppointmentBiz().GetDoctorAppointmentListAsync(UserID);
            ConsumerModel consumerModel = null;

            if (checkList != null)
            {
                int missCount = 0;
                foreach (var item in checkList)
                {
                    if (item.Status == AppointmentStatusEnum.Cancel.ToString() || item.Status == AppointmentStatusEnum.Miss.ToString() || (item.Status == AppointmentStatusEnum.Waiting.ToString() && DateTime.Now.Date > item.AppointmentTime.Date))
                    {
                        missCount += 1;
                    }
                    else
                    {
                        missCount = 0;
                    }
                    if (missCount >= 2)
                    {
                        consumerModel = await new ConsumerBiz().GetModelAsync(UserID);
                        if (consumerModel != null)
                        {
                            consumerModel.LastUpdatedBy   = UserID;
                            consumerModel.LastUpdatedDate = DateTime.Now;
                            //三个月之后才可以预约
                            consumerModel.NoAppointmentDate = DateTime.Now.Date.AddMonths(3);
                        }
                        break;
                    }
                }
            }
            model.LastUpdatedBy   = UserID;
            model.LastUpdatedDate = DateTime.Now;
            model.Status          = AppointmentStatusEnum.Cancel.ToString();
            var result = await biz.CancelAppointmentAsync(model, consumerModel);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "取消挂号失败"));
        }
コード例 #5
0
        public async Task <IActionResult> CreatePrescription([FromBody] ProcessPrescriptionRequestDto request)
        {
            Logger.Info($"{nameof(CreatePrescription)}: {JsonConvert.SerializeObject(request)}");

            var context = new PrescriptionContext(request);

            var appointmentBiz = new DoctorAppointmentBiz();
            var appointment    = await appointmentBiz.GetAsync(request.AppointmentGuid);

            if (appointment is null)
            {
                return(Failed(ErrorCode.Empty, "预约不存在,请检查"));
            }

            var informationBiz          = new PrescriptionInformationBiz();
            var prescriptionInformation = await informationBiz.ExistInformation(appointment.AppointmentGuid);

            if (prescriptionInformation != null)
            {
                return(Failed(ErrorCode.Empty, "该处方已提交,请勿重复提交"));
            }
            context.AppointmentModel = appointment;

            var validateResult = Validate(context);

            if (validateResult.Code != ErrorCode.Success)
            {
                return(validateResult);
            }
            context.AppointmentModel.Status = AppointmentStatusEnum.Treated.ToString();

            var prescriptionBiz = new PrescriptionBiz();
            var result          = await prescriptionBiz.CreatePrescription(context);

            if (!result)
            {
                return(Failed(ErrorCode.DataBaseError, "创建处方记录失败,请稍后重试"));
            }

            var response = new SubmitPrescriptionSuccessResponseDto
            {
                InformationGuid     = context.InformationModel.InformationGuid,
                PrescriptionSuccess = context.PrescriptionModels.Select(d => new SubmitPrescriptionSuccessItemDto()
                {
                    PrescriptionGuid = d.PrescriptionGuid,
                    PrescriptionName = d.PrescriptionName
                })
            };

            return(Success(response));
        }
コード例 #6
0
        public async Task <IActionResult> GetDoctorRecommendAsync(string doctorGuid)
        {
            if (string.IsNullOrWhiteSpace(doctorGuid))
            {
                return(Failed(ErrorCode.UserData, "医生Id不能为空"));
            }
            var doctorBiz = new DoctorBiz();
            var model     = doctorBiz.GetDoctor(doctorGuid);

            if (model == null)
            {
                return(Failed(ErrorCode.UserData, "医生不存在"));
            }
            DoctorAppointmentBiz doctorAppointmentBiz = new DoctorAppointmentBiz();
            var response = await doctorAppointmentBiz.GetDoctorRecommendAsync(UserID, model.OfficeGuid, model.HospitalGuid);

            return(Success(response));
        }
コード例 #7
0
        public async Task <IActionResult> ChangeMissedAppointmentToWaiting(string appointmentGuid)
        {
            var biz   = new DoctorAppointmentBiz();
            var model = await biz.GetAsync(appointmentGuid);

            if (model == null)
            {
                return(Failed(ErrorCode.UserData, "当前预约记录不存在"));
            }
            if (model.Status != AppointmentStatusEnum.Miss.ToString())
            {
                return(Failed(ErrorCode.UserData, "当前预约记录不是过号状态,请核对"));
            }
            model.Status          = AppointmentStatusEnum.Treated.ToString();
            model.LastUpdatedBy   = UserID;
            model.LastUpdatedDate = DateTime.Now;
            var result = await biz.UpdateAsync(model);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "过号操作失败"));
        }
コード例 #8
0
        public async Task <IActionResult> GetReceptionPersonTimeTodayStatisticsAsync()
        {
            var biz = new DoctorAppointmentBiz();
            var todayAppointmentTotal = await biz.GetAppointmentTotalOneDayAsync(DateTime.Now, UserID, AppointmentStatusEnum.Treated);

            var yesterdayAppointmentTotal = await biz.GetAppointmentTotalOneDayAsync(DateTime.Now.AddDays(-1), UserID, AppointmentStatusEnum.Treated);

            var increase = yesterdayAppointmentTotal > 0 ? ((todayAppointmentTotal - yesterdayAppointmentTotal) / (decimal)yesterdayAppointmentTotal) : 1M;

            if (todayAppointmentTotal == 0 && yesterdayAppointmentTotal == 0)
            {
                increase = 0M;
            }
            var result = new GetReceptionPersonTimeTodayStatisticsResponseDto
            {
                ReceptionTotal = todayAppointmentTotal,
                Increase       = Math.Round(increase, 2) * 100
            };

            return(Success(result));
        }
コード例 #9
0
        public async Task <IActionResult> GetAppointmentDoctorDetailAsync([FromQuery] GetAppointmentDoctorScheduleDetailRequest requestDto)
        {
            if (requestDto.ScheduleDate.Date < DateTime.Now.Date || requestDto.ScheduleDate.Date > DateTime.Now.Date.AddDays(6))
            {
                return(Failed(ErrorCode.UserData, "排班时间必须在7天内时间查询"));
            }
            DoctorAppointmentBiz doctorAppointmentBiz = new DoctorAppointmentBiz();
            var response = await doctorAppointmentBiz.GetAppointmentDoctorDetailAsync(requestDto);

            if (response != null)
            {
                foreach (var item in response)
                {
                    var appointmentEndTime = Convert.ToDateTime($"{item.ScheduleDate.ToString("yyyy-MM-dd")} {item.EndTime.ToString()}");
                    if (DateTime.Now >= appointmentEndTime)
                    {
                        item.IsOvertime = true;
                    }
                }
            }
            return(Success(response));
        }
コード例 #10
0
        public async Task <IActionResult> ConfirmAppointmentReceivables(string appointmentGuid)
        {
            if (string.IsNullOrEmpty(appointmentGuid))
            {
                return(Failed(ErrorCode.UserData, "用户预约参数未提供"));
            }

            var appointmentBiz = new DoctorAppointmentBiz();

            var appointment = await appointmentBiz.GetAsync(appointmentGuid);

            if (appointment is null)
            {
                return(Failed(ErrorCode.UserData, "预约不存在,请检查参数是否正确"));
            }

            var prescriptionBiz = new PrescriptionBiz();

            var result = await prescriptionBiz.UpdateReceptionStatus(appointmentGuid);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "更新收款状态失败"));
        }
コード例 #11
0
        public async Task <IActionResult> DeleteAppointmentAsync(string appointGuid)
        {
            if (string.IsNullOrWhiteSpace(appointGuid))
            {
                return(Failed(ErrorCode.DataBaseError, "参数不能为空"));
            }
            var biz   = new DoctorAppointmentBiz();
            var model = await biz.GetAsync(appointGuid);

            if (model == null || model.UserGuid != UserID)
            {
                return(Failed(ErrorCode.UserData, "未找到记录"));
            }
            if (model.Status == AppointmentStatusEnum.Waiting.ToString())
            {
                return(Failed(ErrorCode.UserData, "待就诊状态无法删除"));
            }
            model.LastUpdatedBy   = UserID;
            model.LastUpdatedDate = DateTime.Now;
            model.Enable          = false;
            var result = await biz.UpdateAsync(model);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "删除挂号记录失败"));
        }
コード例 #12
0
        public async Task <IActionResult> GetAppointmentDoctorInfoAsync(string doctorGuid)
        {
            DoctorAppointmentBiz doctorAppointmentBiz = new DoctorAppointmentBiz();

            if (string.IsNullOrWhiteSpace(doctorGuid))
            {
                return(Failed(ErrorCode.UserData, "医生Id不能为空"));
            }
            List <DateTime> dateList = new List <DateTime>();

            for (int i = 0; i < 7; i++)
            {
                dateList.Add(DateTime.Now.Date.AddDays(i));
            }
            var response = await doctorAppointmentBiz.GetAppointmentDoctorInfoAsync(doctorGuid);

            List <GetAppointmentDoctorInfoListResponse> result = new List <GetAppointmentDoctorInfoListResponse>();

            if (response != null)
            {
                result = response.GroupBy(s => s.ScheduleDate).Select(s => new GetAppointmentDoctorInfoListResponse
                {
                    ScheduleDate = s.Key,
                    List         = s.ToList().Select(sl => new GetAppointmentDoctorInfo
                    {
                        WorkshiftType    = sl.WorkshiftType,
                        AppointmentCount = sl.AppointmentCount
                    }).ToList()
                }).ToList();
                if (result != null)
                {
                    foreach (var item in result)
                    {
                        if (item.List != null)
                        {
                            if (item.List.Where(s => s.WorkshiftType == "AM").FirstOrDefault() == null)
                            {
                                item.List.Add(new GetAppointmentDoctorInfo()
                                {
                                    WorkshiftType = "AM"
                                });
                            }
                            else
                            {
                                if (item.List.Where(s => s.WorkshiftType == "PM").FirstOrDefault() == null)
                                {
                                    item.List.Add(new GetAppointmentDoctorInfo()
                                    {
                                        WorkshiftType = "PM"
                                    });
                                }
                            }
                            item.List = item.List.OrderBy(s => s.WorkshiftType).ToList();
                        }
                    }
                }
            }
            var emptySchedule = new List <GetAppointmentDoctorInfo> {
                new GetAppointmentDoctorInfo {
                    WorkshiftType = "AM"
                },
                new GetAppointmentDoctorInfo {
                    WorkshiftType = "PM"
                }
            };

            result = dateList.GroupJoin(result, l => l, r => r.ScheduleDate, (l, gs) => new GetAppointmentDoctorInfoListResponse
            {
                ScheduleDate = l,
                List         = (gs.FirstOrDefault()) == null ? emptySchedule : gs.FirstOrDefault().List
            }).OrderBy(a => a.ScheduleDate).ToList();
            return(Success(result));
        }
コード例 #13
0
        public async Task <IActionResult> UpdatePrescription([FromBody]
                                                             ProcessPrescriptionRequestDto request)
        {
            if (string.IsNullOrEmpty(request.InformationGuid))
            {
                return(Failed(ErrorCode.Empty, "预约不存在,请检查"));
            }

            Logger.Info($"{nameof(UpdatePrescription)}: {JsonConvert.SerializeObject(request)}");

            var context = new PrescriptionContext(request);

            var appointmentBiz = new DoctorAppointmentBiz();
            var appointment    = await appointmentBiz.GetAsync(request.AppointmentGuid);

            if (appointment is null)
            {
                return(Failed(ErrorCode.Empty, "预约不存在,请检查"));
            }
            context.AppointmentModel = appointment;

            var informationBiz = new PrescriptionInformationBiz();
            var information    = await informationBiz.GetAsync(request.InformationGuid);

            if (information is null)
            {
                return(Failed(ErrorCode.Empty, "用户信息不存在,请检查"));
            }

            if (!information.AppointmentGuid.Equals(request.AppointmentGuid))
            {
                return(Failed(ErrorCode.Empty, "预约记录和用户信息不一致,无法操作"));
            }

            context.InformationModel = information;

            var prescriptionBiz = new PrescriptionBiz();

            var prescriptionModels = await prescriptionBiz.GetAllPrescriptionsAsync(information.InformationGuid);

            prescriptionModels = prescriptionModels.Where(d =>
                                                          d.Status != PrescriptionStatusEnum.Cancellation.ToString()).ToList();

            context.dbPrescriptionModels = prescriptionModels;

            var validateResult = Validate(context);

            if (validateResult.Code != ErrorCode.Success)
            {
                return(validateResult);
            }

            context.dbPrescriptionModels = prescriptionModels
                                           .Concat(context.PrescriptionModels).ToList();

            UpdatePrescriptionInformationPaidStatus(context);

            var result = await prescriptionBiz.UpdatePrescription(context);

            if (!result)
            {
                return(Failed(ErrorCode.DataBaseError, "更新处方记录失败"));
            }

            var prescriptions = prescriptionModels.Where(d => d.Status != PrescriptionStatusEnum.Cancellation.ToString())
                                .OrderBy(d => d.CreationDate)
                                .Concat(context.PrescriptionModels)
                                .Select(d => new SubmitPrescriptionSuccessItemDto()
            {
                PrescriptionGuid = d.PrescriptionGuid,
                PrescriptionName = d.PrescriptionName
            });

            var response = new SubmitPrescriptionSuccessResponseDto()
            {
                InformationGuid     = information.InformationGuid,
                PrescriptionSuccess = prescriptions
            };

            return(Success(response));
        }