| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.coffee.bus.mapper.BusClinicMapper">
- <resultMap id="stats" type="com.coffee.bus.service.dto.ClinicStatsQueryResult">
- <result column="continue_dose" property="continueDose"/>
- <result column="append_dose" property="appendDose"/>
- <result column="input_dose" property="inputDose"/>
- <result column="valid_count" property="validCount"/>
- <result column="invalid_count" property="inValidCount"/>
- <result column="upload_time" property="uploadTime"/>
- </resultMap>
- <resultMap id="queryResult" type="com.coffee.bus.service.dto.ClinicResult">
- <result column="clinic_id" property="clinicId"/>
- <result column="patient_code" property="patientCode"/>
- <result column="patient_name" property="patientName"/>
- <result column="ward" property="ward"/>
- <result column="bed_no" property="bedNo"/>
- <result column="surgery_name" property="surgeryName"/>
- <result column="surgery_doctor" property="surgeryDoctor"/>
- <result column="ana_doctor" property="anaDoctor"/>
- <result column="monitor_type" property="monitorType"/>
- <result column="finished" property="finished"/>
- <result column="clinic_start_time" property="clinicStartTime"/>
- <result column="monitor_start_time" property="monitorStartTime"/>
- <result column="monitor_end_time" property="monitorEndTime"/>
- <result column="monitor_alarm" property="monitorAlarm"/>
- <result column="infusion_count" property="infusionCount"/>
- <result column="eval_count" property="evalCount"/>
- </resultMap>
- <select id="stats" resultMap="stats">
- SELECT
- <if test="query.continueDose!=false">
- h.continue_dose as continue_dose,
- </if>
- <if test="query.appendDose!=false">
- h.append_dose as append_dose,
- </if>
- <if test="query.inputDose!=false">
- h.input_dose as input_dose,
- </if>
- <if test="query.validCount!=false">
- h.pca_valid_count as valid_count,
- </if>
- <if test="query.inValidCount!=false">
- h.pca_invalid_count as invalid_count,
- </if>
- h.upload_time
- FROM
- (select id from bus_infusion_history
- <where>
- <if test="query.clinicId!=null">
- and clinic_id = #{query.clinicId}
- </if>
- <if test="query.infusionId!=null">
- and id = #{query.infusionId}
- </if>
- <if test="query.deviceId!=null">
- and device_id = #{query.deviceId}
- </if>
- </where>)
- as i
- left JOIN (select * from bus_device_history
- <where>
- <if test="query.infusionModifyIds != null and query.infusionModifyIds.size > 0">
- and infusion_modify_id in
- <foreach item="infusionModifyId" index="index" collection="query.infusionModifyIds" open="(" separator="," close=")">
- #{infusionModifyId, jdbcType=VARCHAR}
- </foreach>
- </if>
- </where>
- ) as h on h.infusion_id=i.id
- order by h.upload_time asc
- </select>
- <select id="pageQuery" resultMap="queryResult" parameterType="com.coffee.bus.service.dto.ClinicQuery">
- select
- c.id as clinic_id,
- c.patient_code as patient_code,
- c.patient_name as patient_name,
- c.ward as ward,
- c.bed_no as bed_no,
- c.`name` as surgery_name,
- c.surgery_doctor as surgery_doctor,
- c.ana_doctor as ana_doctor,
- c.monitor_type as monitor_type,
- c.finished as finished,
- c.start_time as clinic_start_time,
- c.monitor_start_time as monitor_start_time,
- c.end_time as monitor_end_time,
- i.infusion_count as infusion_count,
- eval.eval_count as eval_count
- from (select * from bus_clinic
- <where>
- <if test="query.monitorType!=null">
- and monitor_type=#{query.monitorType}
- </if>
- <if test="query.surgeryName!=null">
- and name like concat('%',#{query.surgeryName},'%')
- </if>
- <if test="query.patientName!=null">
- and patient_name like concat('%',#{query.patientName},'%')
- </if>
- <if test="query.patientCode!=null">
- and patient_code like concat('%',#{query.patientCode},'%')
- </if>
- <if test="query.ward!=null">
- and ward=#{query.ward}
- </if>
- <if test="query.bedNo!=null">
- and bed_no like concat('%',#{query.bedNo},'%')
- </if>
- <if test="query.timeRange != null and query.timeRange.size >0">
- and monitor_start_time > #{query.timeRange[0]} and monitor_start_time < #{query.timeRange[1]}
- </if>
- </where>
- ) as c
- left join bus_patient as p on c.id=p.clinic_id
- left join (select clinic_id,count(1) as infusion_count from bus_infusion_history GROUP BY clinic_id) as i on i.clinic_id=c.id
- left join (select clinic_id,count(1) as eval_count from bus_evaluation GROUP BY clinic_id) as eval on eval.clinic_id=c.id
- order by c.monitor_start_time desc
- </select>
- </mapper>
|