|
|
@@ -184,7 +184,7 @@
|
|
|
<select id="selectMonitor" resultMap="monitorResult" parameterType="com.nb.web.api.feign.query.PatientMonitorQuery">
|
|
|
select
|
|
|
p.id as patient_id,
|
|
|
- p.`code` as patient_code,
|
|
|
+ p.code as patient_code,
|
|
|
p.alarm as patient_alarm,
|
|
|
i.id as infusion_id,
|
|
|
i.device_id as device_id,
|
|
|
@@ -500,4 +500,181 @@
|
|
|
select count(1) from (select * from bus_patient where tenant_id=#{tenantId}) as p JOIN (select * from bus_clinic where finished=0 and tenant_id=#{tenantId}) as c on p.clinic_id=c.id
|
|
|
</select>
|
|
|
|
|
|
+
|
|
|
+ <resultMap id="doctorMonitorResult" type="com.nb.web.api.feign.result.DoctorPatientMonitorResult">
|
|
|
+ <result column="patient_id" property="patientId"/>
|
|
|
+ <result column="patient_name" property="patientName"/>
|
|
|
+ <result column="patient_code" property="patientCode"/>
|
|
|
+ <result column="patient_age" property="patientAge"/>
|
|
|
+ <result column="gender" property="gender"/>
|
|
|
+ <result column="patient_alarm" property="patientAlarm"/>
|
|
|
+ <result column="device_id" property="deviceId"/>
|
|
|
+ <result column="device_alias" property="deviceAlias"/>
|
|
|
+ <result column="clinic_id" property="clinicId"/>
|
|
|
+ <result column="patient_gender" property="gender"/>
|
|
|
+ <result column="ward" property="ward"/>
|
|
|
+ <result column="bed_no" property="bedNo"/>
|
|
|
+ <result column="total_dose" property="totalDose"/>
|
|
|
+ <result column="first_dose" property="firstDose"/>
|
|
|
+ <result column="electric_quantity" property="electricQuantity"/>
|
|
|
+ <result column="remain_dose" property="remainDose"/>
|
|
|
+ <result column="input_dose" property="inputDose"/>
|
|
|
+ <result column="append_dose" property="appendDose"/>
|
|
|
+ <result column="append_lock_time" property="appendLockTime"/>
|
|
|
+ <result column="max_dose" property="maxDose"/>
|
|
|
+ <result column="self_control_lock_time" property="selfControlLockTime"/>
|
|
|
+ <result column="pca_valid_count" property="pcaValidCount"/>
|
|
|
+ <result column="pca_invalid_count" property="pcaInvalidCount"/>
|
|
|
+ <result column="pca_total_count" property="pcaTotalCount"/>
|
|
|
+ <result column="continue_dose" property="continueDose"/>
|
|
|
+ <result column="pulse_dose" property="pulseDose"/>
|
|
|
+ <result column="pulse_first_lock_time" property="pulseFirstLockTime"/>
|
|
|
+ <result column="pulse_lock_time" property="pulseLockTime"/>
|
|
|
+ <result column="flow_up_cycle" property="flowUpCycle"/>
|
|
|
+ <result column="flow_down_cycle" property="flowDownCycle"/>
|
|
|
+ <result column="flow_count" property="flowCount"/>
|
|
|
+ <result column="flow_up_limit" property="flowUpLimit"/>
|
|
|
+ <result column="flow_down_limit" property="flowDownLimit"/>
|
|
|
+ <result column="flow_adjust_rate" property="flowAdjustRate"/>
|
|
|
+ <result column="run_state" property="deviceRunState"/>
|
|
|
+ <result column="device_alarm" property="deviceAlarm"/>
|
|
|
+ <result column="infusion_start_time" property="infusionStartTime"/>
|
|
|
+ <result column="device_type" property="deviceType"/>
|
|
|
+ <result column="eval_time" property="evalTime"/>
|
|
|
+ <result column="warn_flow" property="warnFlow"/>
|
|
|
+ <result column="warn_analgesic_poor" property="warnAnalgesicPoor"/>
|
|
|
+ <result column="warn_low_battery" property="warnLowBattery"/>
|
|
|
+ <result column="warn_will_finished" property="warnWillFinished"/>
|
|
|
+ <result column="manage_type" property="manageType"/>
|
|
|
+ </resultMap>
|
|
|
+ <select id="doctorSelectPatientList" resultMap="doctorMonitorResult">
|
|
|
+ SELECT
|
|
|
+ <!-- 患者基础信息 -->
|
|
|
+ c.patient_id AS patient_id,
|
|
|
+ c.patient_code AS patient_code,
|
|
|
+ c.patient_age AS patient_age, <!-- 补充:假设 patient_age 对应实体类中的年龄字段(result 中有 patient_age) -->
|
|
|
+ c.patient_gender AS gender, <!-- 注意:patient_gender 映射到实体类的 gender 属性(可能存在冗余,需确认表结构) -->
|
|
|
+ <!-- 临床信息 -->
|
|
|
+ c.patient_name AS patient_name,
|
|
|
+ c.ward AS ward,
|
|
|
+ c.bed_no AS bed_no,
|
|
|
+ c.ana_doctor AS anaDoctor,
|
|
|
+ c.surgery_name AS surgeName,
|
|
|
+ c.ana_type AS anaType,
|
|
|
+ c.eval_time AS evalTime, <!-- 评价时间 -->
|
|
|
+ c.manage_type AS manageType,
|
|
|
+ <!-- 设备与输注信息 -->
|
|
|
+ i.device_id AS deviceId,
|
|
|
+ d.alias AS deviceAlias, <!-- 假设来自设备表,若未关联需调整 -->
|
|
|
+ i.clinic_id AS clinicId,
|
|
|
+ i.total_dose AS totalDose,
|
|
|
+ i.first_dose AS firstDose,
|
|
|
+ i.remain_dose AS remainDose,
|
|
|
+ i.input_dose AS inputDose,
|
|
|
+ i.append_dose AS appendDose,
|
|
|
+ i.append_lock_time AS appendLockTime,
|
|
|
+ i.max_dose AS maxDose,
|
|
|
+ i.self_control_lock_time AS selfControlLockTime,
|
|
|
+ i.pca_valid_count AS pcaValidCount,
|
|
|
+ i.pca_invalid_count AS pcaInvalidCount,
|
|
|
+ i.pca_total_count AS pcaTotalCount,
|
|
|
+ i.continue_dose AS continueDose,
|
|
|
+ i.pulse_dose AS pulseDose,
|
|
|
+ i.pulse_first_lock_time AS pulseFirstLockTime,
|
|
|
+ i.pulse_lock_time AS pulseLockTime,
|
|
|
+ i.flow_up_cycle AS flowUpCycle,
|
|
|
+ i.flow_down_cycle AS flowDownCycle,
|
|
|
+ i.flow_count AS flowCount,
|
|
|
+ i.flow_up_limit AS flowUpLimit,
|
|
|
+ i.flow_down_limit AS flowDownLimit,
|
|
|
+ i.flow_adjust_rate AS flowAdjustRate,
|
|
|
+ i.run_state AS deviceRunState,
|
|
|
+ i.alarm AS deviceAlarm,
|
|
|
+ i.start_time AS infusionStartTime,
|
|
|
+ i.type AS deviceType,
|
|
|
+ i.warn_flow AS warnFlow,
|
|
|
+ i.warn_analgesic_poor AS warnAnalgesicPoor,
|
|
|
+ i.warn_low_battery AS warnLowBattery,
|
|
|
+ i.warn_will_finished AS warnWillFinished
|
|
|
+ FROM
|
|
|
+ bus_patient p
|
|
|
+ JOIN bus_clinic c ON p.clinic_id = c.id <!-- 患者与临床信息关联 -->
|
|
|
+ JOIN bus_infusion_history i ON p.infusion_id = i.id <!-- 患者与输注记录关联 -->
|
|
|
+ <!-- 设备表左连接(若 device_alias 来自设备表) -->
|
|
|
+ LEFT JOIN bus_device d ON i.device_id = d.id
|
|
|
+ <where>
|
|
|
+ i.is_undo='0' and c.finished=0
|
|
|
+ <!-- 租户过滤(必选) -->
|
|
|
+ <if test="query.tenantId != null">
|
|
|
+ AND p.tenant_id = #{query.tenantId}
|
|
|
+ </if>
|
|
|
+ <!-- 患者基础条件 -->
|
|
|
+ <if test="query.patientCode != null">
|
|
|
+ AND p.code LIKE CONCAT('%', #{query.patientCode}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="query.patientName != null">
|
|
|
+ AND c.patient_name LIKE CONCAT('%', #{query.patientName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="query.abnormal != null">
|
|
|
+ AND p.patient_abnormal = #{query.abnormal} <!-- 假设患者异常字段为 patient_abnormal -->
|
|
|
+ </if>
|
|
|
+ <!-- 临床与病区条件 -->
|
|
|
+ <if test="query.wards != null and query.wards.size > 0">
|
|
|
+ AND c.ward IN
|
|
|
+ <foreach item="ward" collection="query.wards" open="(" separator="," close=")">
|
|
|
+ #{ward}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="query.bedNo != null">
|
|
|
+ AND c.bed_no = #{query.bedNo}
|
|
|
+ </if>
|
|
|
+ <if test="query.anaDoctor != null">
|
|
|
+ AND c.ana_doctor LIKE CONCAT('%', #{query.anaDoctor}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="query.surgeName != null">
|
|
|
+ AND c.surgery_name LIKE CONCAT('%', #{query.surgeName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="query.anaType != null">
|
|
|
+ AND c.ana_type = #{query.anaType}
|
|
|
+ </if>
|
|
|
+ <!-- 设备与输注条件 -->
|
|
|
+ <if test="query.types != null and types.size > 0">
|
|
|
+ AND i.device_type IN
|
|
|
+ <foreach item="type" collection="types" open="(" separator="," close=")">
|
|
|
+ #{type}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="query.deviceStatus != null and query.deviceStatus.size > 0">
|
|
|
+ AND i.run_state IN
|
|
|
+ <foreach item="status" collection="query.deviceStatus" open="(" separator="," close=")">
|
|
|
+ #{status}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="query.alarm != null">
|
|
|
+ AND i.device_alarm = #{query.alarm} <!-- 是否有报警 -->
|
|
|
+ </if>
|
|
|
+ <if test="query.warn != null">
|
|
|
+ <!-- 简化提醒条件,可根据实际字段扩展 -->
|
|
|
+ AND (i.warn_flow = 1 OR i.warn_low_battery = 1)
|
|
|
+ </if>
|
|
|
+ <if test="query.timeRange != null and query.timeRange.size == 1">
|
|
|
+ AND c.monitor_start_time >= #{query.timeRange[0]}
|
|
|
+ </if>
|
|
|
+ <!-- 时间区间查询 -->
|
|
|
+ <if test="query.timeRange != null and query.timeRange.size > 1">
|
|
|
+ AND c.monitor_start_time <= #{query.timeRange[1]}
|
|
|
+ </if>
|
|
|
+ <!-- 管理类型 -->
|
|
|
+ <if test="query.manageType != null">
|
|
|
+ AND c.manage_type = #{query.manageType}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ <!-- 排序逻辑 -->
|
|
|
+ <if test="query.orderType == 0">
|
|
|
+ order by i.infusion_start_time DESC <!-- 默认按输注开始时间倒序 -->
|
|
|
+ </if>
|
|
|
+ <if test="query.orderType == 1">
|
|
|
+ order by c.ward ASC, c.bed_no ASC <!-- 按病区和床号升序 -->
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|