public async Task <IActionResult> GetAppointmentPageListAsync([FromQuery] GetAppointmentPageListRequestDto requestDto) { requestDto.HospitalGuid = UserID; var result = await new DoctorAppointmentBiz().GetAppointmentPageListAsync(requestDto); return(Success(result)); }
/// <summary> /// 获取诊所挂号列表 /// </summary> /// <returns></returns> public async Task <GetAppointmentPageListResponseDto> GetAppointmentPageListAsync(GetAppointmentPageListRequestDto requestDto) { var sqlWhere = string.Empty; if (requestDto.AppointmentStatus != null) { sqlWhere = $"{sqlWhere} and a.`status`=@AppointmentStatus"; } if (!string.IsNullOrWhiteSpace(requestDto.OfficeGuid)) { sqlWhere = $"{sqlWhere} and d.office_guid=@OfficeGuid"; } if (!string.IsNullOrWhiteSpace(requestDto.DoctorGuid)) { sqlWhere = $"{sqlWhere} and a.doctor_guid=@DoctorGuid"; } if (!string.IsNullOrWhiteSpace(requestDto.Keyword)) { sqlWhere = $"{sqlWhere} and (a.patient_name = @Keyword or a.patient_phone = @Keyword or a.appointment_no = @Keyword )"; } if (requestDto.StartDate.HasValue && requestDto.EndDate.HasValue) { requestDto.StartDate = requestDto.StartDate.Value.Date; requestDto.EndDate = requestDto.EndDate.Value.Date.AddDays(1).AddSeconds(-1); sqlWhere = $"{sqlWhere} AND(a.appointment_time BETWEEN @StartDate and @EndDate)"; } if (requestDto.IsExport) { requestDto.PageIndex = 1; requestDto.PageSize = int.MaxValue; } var sql = $@"SELECT a.appointment_guid, a.appointment_no , a.patient_name, a.patient_gender, TIMESTAMPDIFF( YEAR, a.patient_birthday, NOW()) AS patient_age, a.appointment_time, a.appointment_deadline, d.office_name, b.user_name AS doctor_name, a.patient_phone, a.`status` AS appointment_status FROM t_consumer_doctor_appointment a LEFT JOIN t_utility_user b ON b.user_guid = a.doctor_guid LEFT JOIN t_doctor c ON a.doctor_guid = c.doctor_guid LEFT JOIN t_doctor_office d ON d.office_guid = c.office_guid WHERE a.hospital_guid = @HospitalGuid {sqlWhere} ORDER BY a.appointment_time" ; return(await MySqlHelper.QueryByPageAsync <GetAppointmentPageListRequestDto, GetAppointmentPageListResponseDto, GetAppointmentPageListItemDto>(sql, requestDto)); }