| | |
| | | |
| | | <select id="selectTimelyRateBatch" parameterType="com.smartor.domain.ServiceSubtask" resultType="map"> |
| | | SELECT |
| | | <if test="deptcode != null">deptcode as groupKey,</if> |
| | | <if test="leavehospitaldistrictcode != null">leavehospitaldistrictcode as groupKey,</if> |
| | | <if test="drcode != null">drcode as groupKey,</if> |
| | | <if test="groupKey != null and groupKey != ''"> |
| | | ${groupKey} as groupKey, |
| | | </if> |
| | | SUM(CASE WHEN DATE(visit_time) < DATE(IFNULL(finishtime, NOW())) THEN 1 ELSE 0 END) / COUNT(*) as rate |
| | | FROM service_subtask |
| | | WHERE del_flag = 0 |
| | | AND visit_time >= #{starttime} |
| | | AND visit_time < DATE_ADD(#{endtime}, INTERVAL 1 DAY) |
| | | <if test="orgid != null">AND orgid = #{orgid}</if> |
| | | GROUP BY groupKey |
| | | <if test="starttime == null and endtime==null"> |
| | | AND visit_time < NOW() |
| | | </if> |
| | | <if test="starttime != null and endtime!=null"> |
| | | AND visit_time >= #{starttime} |
| | | AND visit_time < DATE_ADD(#{endtime}, INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="orgid != null and orgid != ''">and orgid = #{orgid}</if> |
| | | <if test="deptcode != null and deptcode != ''">and deptcode = #{deptcode}</if> |
| | | <if test="deptname != null and deptname != ''">and deptname = #{deptname}</if> |
| | | <if test="isabnormal != null">and isabnormal = #{isabnormal}</if> |
| | | <if test="leavehospitaldistrictcode != null and leavehospitaldistrictcode != ''">and |
| | | leavehospitaldistrictcode = #{leavehospitaldistrictcode} |
| | | </if> |
| | | <if test="leavehospitaldistrictname != null and leavehospitaldistrictname != ''">and |
| | | leavehospitaldistrictname = #{leavehospitaldistrictname} |
| | | </if> |
| | | <if test="managementDoctorCode != null">and management_doctor_code = #{managementDoctorCode}</if> |
| | | <if test="managementDoctor != null">and management_doctor like concat('%',#{managementDoctor}, '%')</if> |
| | | <if test="groupKey != null and groupKey != ''"> |
| | | AND ${groupKey} IN |
| | | <foreach collection="groupKeyList" item="key" open="(" separator="," |
| | | close=")"> |
| | | #{key} |
| | | </foreach> |
| | | GROUP BY ${groupKey} |
| | | </if> |
| | | </select> |
| | | |
| | | |