public async Task <IActionResult> GetHistoryPrescriptionRecordPageListAsync([FromQuery] GetHistoryPrescriptionRecordsRequestDto requestDto)
        {
            var appointment = await new DoctorAppointmentBiz().GetAsync(requestDto.AppointmentGuid);

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

            requestDto.UserGuid = appointment.UserGuid;

            var result = await new PrescriptionInformationBiz().GetHistoryPrescriptionRecordsAsync(requestDto);

            return(Success(result));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取历史处方记录分页列表
        /// </summary>
        /// <param name="requestDto"></param>
        /// <returns></returns>
        public async Task <GetHistoryPrescriptionRecordsResponseDto> GetHistoryPrescriptionRecordsAsync(GetHistoryPrescriptionRecordsRequestDto requestDto)
        {
            var sqlWhere = string.Empty;

            requestDto.StartDate = requestDto.StartDate.Date;
            requestDto.EndDate   = requestDto.EndDate.Date.AddDays(1).AddSeconds(-1);

            if (!string.IsNullOrWhiteSpace(requestDto.Keyword))
            {
                sqlWhere = $@"{sqlWhere} AND (
                            a.clinical_diagnosis LIKE CONCAT(@Keyword,'%') 
							OR d.item_name LIKE CONCAT(@Keyword,'%') 
							OR u.user_name LIKE CONCAT(@Keyword,'%') 
			                OR c.prescription_no = @Keyword 
							OR a.patient_name LIKE CONCAT(@Keyword,'%') 
						) "                        ;
            }

            var sql = $@"SELECT
							a.information_guid,
                            da.appointment_guid,
							da.patient_relationship,
							a.patient_name,
							a.patient_gender,
							a.patient_phone,
							a.clinical_diagnosis,
							a.reception_type,
							a.creation_date AS reception_time,
							a.total_cost,
                            a.paid_status,
							u.user_name as doctor_name,
							GROUP_CONCAT( distinct c.prescription_no SEPARATOR '/' ) AS prescription_nos 
						FROM
							t_doctor_prescription_information a
							LEFT JOIN t_doctor_prescription c ON a.information_guid = c.information_guid 
							AND c.`status` <> 'Cancellation' 
							AND c.`enable` = 1 
							left join t_doctor_prescription_recipe d on d.prescription_guid  = c.prescription_guid
							left join t_consumer_doctor_appointment da on da.appointment_guid = a.appointment_guid
							left join t_utility_user u on u.user_guid = a.doctor_guid
						WHERE
							a.`enable` = 1 {sqlWhere}
                            and da.user_guid = @UserGuid and a.creation_date BETWEEN @StartDate and @EndDate
						GROUP BY
							a.information_guid,
                            da.appointment_guid,
							da.patient_relationship,
							a.patient_name,
							a.patient_gender,
							a.patient_phone,
							a.clinical_diagnosis,
							a.reception_type,
							a.creation_date,
							a.total_cost,
							u.user_name
						ORDER BY a.creation_date desc "                        ;

            var result = await MySqlHelper.QueryByPageAsync <GetHistoryPrescriptionRecordsRequestDto, GetHistoryPrescriptionRecordsResponseDto, GetHistoryPrescriptionRecordsItemDto>(sql, requestDto);

            return(result);
        }