示例#1
0
        public async Task <IActionResult> GetAppointmentPageListTodayAsync([FromQuery] GetAppointmentPageListTodayRequestDto requestDto)
        {
            if (string.IsNullOrWhiteSpace(requestDto.DoctorGuid))
            {
                requestDto.DoctorGuid = UserID;
            }
            var result = await new DoctorAppointmentBiz().GetAppointmentPageListTodayAsync(requestDto);

            return(Success(result));
        }
示例#2
0
        /// <summary>
        /// 获取诊所今日挂号列表
        /// </summary>
        /// <returns></returns>
        public async Task <GetAppointmentPageListTodayResponseDto> GetAppointmentPageListTodayAsync(GetAppointmentPageListTodayRequestDto requestDto)
        {
            var sqlWhere = string.Empty;

            if (requestDto.AppointmentStatus == null)
            {
                sqlWhere = $"{sqlWhere} AND a.`status` in('Waiting','Treated','Miss') ";
            }
            else
            {
                sqlWhere = $"{sqlWhere} and a.`status`=@AppointmentStatus";
            }

            if (!string.IsNullOrWhiteSpace(requestDto.Keyword))
            {
                sqlWhere = $"{sqlWhere} and (a.patient_name = @Keyword or a.patient_phone = @Keyword or a.appointment_no = @Keyword )";
            }
            //   var sql = $@"SELECT
            //                a.appointment_guid,
            //                   a.appointment_no ,
            //                a.patient_name,
            //                a.patient_gender,
            //                   a.user_guid,
            //                TIMESTAMPDIFF(
            //                 YEAR,
            //                 a.patient_birthday,
            //                NOW()) AS patient_age,
            //                a.appointment_time,
            //                d.office_name,
            //                b.user_name AS doctor_name,
            //                a.patient_phone,
            //                a.`status` AS appointment_status,
            //                   (
            // SELECT
            //   CASE WHEN (p.`status` = 1) THEN 0 ELSE 1 END as paidStatus
            //                      FROM t_doctor_prescription as p
            //INNER JOIN t_doctor_prescription_information AS pi
            //                                       ON p.information_guid = pi.information_guid
            // WHERE pi.appointment_guid = a.appointment_guid AND p.`status` IN(1,2)
            // ORDER BY p.`status` LIMIT 1
            //) as paid_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.doctor_guid=@DoctorGuid
            //                   AND ( a.appointment_time BETWEEN '{DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss")}' AND '{DateTime.Now.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss")}' )
            //                {sqlWhere}
            //               ORDER BY
            //                a.appointment_time";
            var sql = $@"SELECT
	                        a.appointment_guid,
	                        a.appointment_no,
	                        a.patient_name,
	                        a.patient_gender,
	                        a.user_guid,
	                        TIMESTAMPDIFF(
		                        YEAR,
		                        a.patient_birthday,
	                        NOW()) AS patient_age,
	                        a.appointment_time,
	                        d.office_name,
	                        b.user_name AS doctor_name,
	                        a.patient_phone,
	                        a.`status` AS appointment_status,
                            CASE
		                        WHEN count( DISTINCT f.prescription_guid )> 0 THEN
		                        0 ELSE 1 
	                        END AS paid_status,
	                        ifnull( sum( f.total_cost ), 0 ) AS obligation_amount 
                        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
	                        LEFT JOIN t_doctor_prescription_information e ON e.appointment_guid = a.appointment_guid
	                        LEFT JOIN t_doctor_prescription f ON f.information_guid = e.information_guid 
	                        AND f.`status` = 1 
	                            WHERE
                                a.doctor_guid = @DoctorGuid 
                                AND ( a.appointment_time BETWEEN '{DateTime.Now.Date.ToString("yyyy-MM-dd HH:mm:ss")}' AND '{DateTime.Now.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss")}' ) 
		                        {sqlWhere}	
	                        GROUP BY
		                        a.appointment_guid,
		                        a.appointment_no,
		                        a.patient_name,
		                        a.patient_gender,
		                        a.user_guid,
		                        patient_age,
		                        a.appointment_time,
		                        d.office_name,
		                        b.user_name,
		                        a.patient_phone,
		                        a.`status` 
                        ORDER BY
	                        a.appointment_time,a.appointment_guid"    ;

            return(await MySqlHelper.QueryByPageAsync <GetAppointmentPageListTodayRequestDto, GetAppointmentPageListTodayResponseDto, GetAppointmentPageListTodayItemDto>(sql, requestDto));
        }