| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 |
- <?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.nb.web.service.bus.mapper.BusPatientMapper">
- <resultMap id="repeatDeviceResult" type="com.nb.web.service.bus.entity.PatientDeviceRepeatDomain">
- <result column="patient_id" property="patientId"/>
- <result column="name" property="name"/>
- <result column="gender" property="gender"/>
- <result column="code" property="code"/>
- <result column="age" property="age"/>
- <result column="ward" property="ward"/>
- <result column="bed_no" property="bedNo"/>
- <result column="clinic_name" property="clinicName"/>
- <result column="device_id" property="deviceId"/>
- <result column="device_alias" property="deviceAlias"/>
- <result column="device_run_state" property="deviceRunState"/>
- <result column="clinic_id" property="clinicId"/>
- <result column="device_alarm" property="deviceAlarm" />
- <result column="infusion_start_time" property="infusionStartTime"/>
- <result column="infusion_id" property="infusionId"/>
- <result column="master_infusion_id" property="masterInfusionId"/>
- </resultMap>
- <resultMap id="monitorResult" type="com.nb.web.api.feign.result.PatientMonitorResult">
- <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="infusion_id" property="infusionId"/>
- <result column="patient_alarm" property="patientAlarm"/>
- <result column="classification" property="classification"/>
- <result column="data_num" property="dataNum"/>
- <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="infusion_finished" property="infusionFinished"/>
- <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="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="last_upload_time" property="lastUploadTime"/>
- <result column="product_no" property="productNo"/>
- <!--<result column="self_control_count" property="selfControlCount"/>-->
- <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="electric_quantity" property="electricQuantity"/>
- <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="device_alarm" property="deviceAlarm"/>
- <result column="infusion_start_time" property="infusionStartTime"/>
- <result column="remark" property="remark"/>
- <result column="device_type" property="deviceType"/>
- <result column="anal_type" property="analType"/>
- <result column="ana_doctor" property="anaDoctor"/>
- <result column="ana_type" property="anaType"/>
- <result column="surgery_doctor" property="surgeryDoctor"/>
- <result column="surgery_name" property="surgeryName"/>
- <result column="finished" property="clinicFinished"/>
- <result column="monitor_end_time" property="monitorEndTime"/>
- <result column="monitor_start_time" property="monitorStartTime"/>
- <result column="eval_time" property="evalTime"/>
- <result column="patient_id" property="patientId"/>
- <result column="manage_type" property="manageType"/>
- <result column="block1" property="block1"/>
- <result column="block2" property="block2"/>
- <result column="block_status" property="blockStatus"/>
- </resultMap>
- <resultMap id="deviceNone" type="com.nb.web.service.bus.service.dto.PatientDeviceNoneResult">
- <result column="patient_id" property="patientId"/>
- <result column="clinic_id" property="clinicId"/>
- <result column="name" property="name"/>
- <result column="gender" property="gender"/>
- <result column="code" property="code"/>
- <result column="age" property="age"/>
- <result column="ward" property="ward"/>
- <result column="bed_no" property="bedNo"/>
- <result column="surgery_name" property="surgeryName"/>
- <result column="weight" property="weight"/>
- <result column="height" property="height"/>
- <result column="ana_doctor" property="anaDoctor"/>
- <result column="ana_type" property="anaType"/>
- <result column="anal_type" property="analType"/>
- <result column="surgery_doctor" property="surgeryDoctor"/>
- <result column="asa" property="asa"/>
- <result column="formula" property="formula" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
- <result column="finished" property="finished"/>
- <result column="config_person" property="configPerson"/>
- </resultMap>
- <resultMap id="contactMap" type="com.nb.web.api.feign.result.ContactPatientResult">
- <result column="patient_id" property="patientId"/>
- <result column="patient_name" property="patientName"/>
- <result column="sex" property="patientSex"/>
- <result column="patient_code" property="patientCode"/>
- <result column="patient_age" property="patientAge"/>
- </resultMap>
- <select id="selectRepeatDevice" resultMap="repeatDeviceResult">
- SELECT
- p.id as patient_id,
- p.code as code,
- p.infusion_id as master_infusion_id,
- c.patient_gender as gender,
- c.`patient_name` as name,
- c.patient_age as age,
- c.ward,
- c.bed_no,
- c.id as clinic_id,
- c.`surgery_name` as clinic_name,
- i.device_id as device_id,
- i.id as infusion_id,
- d.alias as device_alias,
- i.run_state as device_run_state,
- i.alarm as device_alarm,
- i.start_time as infusion_start_time
- FROM (SELECT `name`,gender,infusion_id,CODE,id FROM bus_patient
- <where>
- bus_patient.`alarm`=1
- <if test="tenantId != null and tenantId != ''">
- and tenant_id=#{tenantId}
- </if>
- </where>
- ) AS p
- join (select * from bus_infusion_history where is_undo=0 and finished=0) as i on i.patient_id=p.id
- join (select device_id,alias from bus_device) as d on d.device_id=i.device_id
- join (SELECT * FROM bus_clinic WHERE finished=0 and monitor_type=1) AS c ON c.`patient_id`=p.id
- </select>
- <select id="selectNoneDevice" resultMap="deviceNone">
- SELECT
- p.id as patient_id,
- p.code as code,
- c.id as clinic_id,
- c.patient_gender as gender,
- c.`patient_name` as name,
- c.patient_age as age,
- c.ward as ward,
- c.bed_no as bed_no,
- c.`surgery_name` as surgery_name,
- c.weight as weight,
- c.height as height,
- c.ana_doctor as ana_doctor,
- c.ana_type as ana_type,
- c.anal_type as anal_type,
- c.surgery_doctor as surgery_doctor,
- c.asa as asa,
- c.formula as formula,
- c.finished as finished,
- c.monitor_start_time as monitor_start_time,
- c.config_person as config_person
- FROM (SELECT `name`,gender,CODE,tenant_id,id FROM bus_patient WHERE bus_patient.`alarm`=2 ) AS p
- join (SELECT * FROM bus_clinic WHERE finished=0 and monitor_type=1) AS c ON c.`patient_id`=p.id
- <where>
- <if test="tenantId != null and tenantId != ''">
- and p.tenant_id=#{tenantId}
- </if>
- </where>
- order by c.monitor_start_time desc;
- </select>
- <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.alarm as patient_alarm,
- i.id as infusion_id,
- i.device_id as device_id,
- i.clinic_id as clinic_id,
- i.classification as classification,
- i.data_number as data_num,
- i.total_dose as total_dose,
- i.first_dose as first_dose,
- i.remain_dose as remain_dose,
- i.input_dose as input_dose,
- i.append_dose as append_dose,
- i.append_lock_time as append_lock_time,
- i.max_dose as max_dose,
- i.finished as infusion_finished,
- i.electric_quantity as electric_quantity,
- i.warn_flow as warn_flow,
- i.self_control_count as self_control_count,
- i.self_control_lock_time as self_control_lock_time,
- i.pca_valid_count as pca_valid_count,
- i.pca_invalid_count as pca_invalid_count,
- i.pca_total_count as pca_total_count,
- i.continue_dose as continue_dose,
- i.pulse_dose as pulse_dose,
- i.pulse_lock_time as pulse_lock_time,
- i.pulse_first_lock_time as pulse_first_lock_time,
- i.flow_up_cycle as flow_up_cycle,
- i.flow_down_cycle as flow_down_cycle,
- i.flow_count as flow_count,
- i.flow_up_limit as flow_up_limit,
- i.flow_down_limit as flow_down_limit,
- i.flow_adjust_rate as flow_adjust_rate,
- i.run_state as run_state,
- i.warn_will_finished as warn_will_finished,
- i.warn_analgesic_poor as warn_analgesic_poor,
- i.warn_low_battery as warn_low_battery,
- i.alarm as device_alarm,
- i.data_number as data_number,
- i.start_time as infusion_start_time,
- i.remark as remark,
- i.type as device_type,
- i.last_upload_time as last_upload_time,
- i.block1 as block1,
- i.block2 as block2,
- i.block_status as block_status,
- <!--d.alias as device_alias,-->
- <!--d.product_no as product_no ,-->
- c.patient_gender as patient_gender,
- c.`patient_name` as patient_name,
- c.finished as finished,
- c.monitor_start_time as monitor_start_time,
- c.end_time as monitor_end_time,
- c.ana_doctor as ana_doctor,
- c.patient_age as patient_age,
- c.ana_type as ana_type,
- c.anal_type as anal_type,
- c.surgery_doctor as surgery_doctor,
- c.surgery_name as surgery_name,
- c.ward as ward,
- c.bed_no as bed_no,
- c.eval_time as eval_time,
- c.manage_type as manage_type
- from
- (select * from bus_patient
- <where>
- <if test="query.tenantId!=null">
- and tenant_id=#{query.tenantId}
- </if>
- </where>
- )
- as p
- join
- (select * from bus_infusion_history
- <where>
- is_undo='0'
- <if test="query.infusionFinished != null and query.andFinished == true ">
- and finished=#{query.infusionFinished}
- </if>
- <if test="query.types != null and query.types.size > 0">
- and type in
- <foreach item="type" index="index" collection="query.types" open="(" separator="," close=")">
- #{type, jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.tenantId!=null">
- and tenant_id=#{query.tenantId}
- </if>
- <choose>
- <when test="query.deviceStatus != null and query.deviceStatus.size > 0">
- and (
- run_state in
- <foreach item="status" index="index" collection="query.deviceStatus" open="(" separator=","
- close=")">
- #{status, jdbcType=VARCHAR}
- </foreach>
- <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
- or alarm in
- <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator=","
- close=")">
- #{alarm, jdbcType=VARCHAR}
- </foreach>
- </if>
- <if test="query.infusionFinished != null and query.andFinished == false ">
- or finished=#{query.infusionFinished}
- </if>
- )
- </when>
- <otherwise>
- <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
- and alarm in
- <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator="," close=")">
- #{alarm, jdbcType=VARCHAR}
- </foreach>
- </if>
- </otherwise>
- </choose>
- <choose>
- <when test="query.warnWillFinished != false or query.warnAnalgesicPoor != false or query.warnLowBattery != false">
- and (
- <choose>
- <when test="query.warnWillFinished != false">warn_will_finished=1</when>
- <otherwise>0=1</otherwise>
- </choose>
- <if test="query.warnAnalgesicPoor != false">or warn_analgesic_poor=1 </if>
- <if test="query.warnLowBattery != false"> or warn_low_battery=1 </if>
- <if test="query.warnFlow !=null and query.warnFlow.size > 0 ">
- or warn_flow in
- <foreach item="wf" index="index" collection="query.warnFlow" open="(" separator="," close=")">
- #{wf, jdbcType=VARCHAR}
- </foreach>
- </if>
- )
- </when>
- <otherwise>
- <if test="query.warnFlow !=null and query.warnFlow.size > 0 ">
- and warn_flow in
- <foreach item="wf" index="index" collection="query.warnFlow" open="(" separator="," close=")">
- #{wf, jdbcType=VARCHAR}
- </foreach>
- </if>
- </otherwise>
- </choose>
- </where>
- ) as i on p.infusion_id=i.id
- <!--left join-->
- <!--(select device_id,alias,product_no-->
- <!--from bus_device-->
- <!--<where>-->
- <!--<if test="query.tenantId!=null">-->
- <!--and tenant_id=#{query.tenantId}-->
- <!--</if>-->
- <!--</where>-->
- <!--) as d on d.device_id=i.device_id-->
- join (select * from bus_clinic
- <where>
- finished=0
- <if test="query.wards != null and query.wards.size > 0">
- and ward in
- <foreach item="ward" index="index" collection="query.wards" open="(" separator="," close=")">
- #{ward, jdbcType=VARCHAR}
- </foreach>
- </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>
- <if test="query.tenantId!=null">
- and tenant_id=#{query.tenantId}
- </if>
- <if test="query.manageType!=null">
- and manage_type=#{query.manageType}
- </if>
- </where>
- ) c on p.clinic_id=c.id
- <!--<if test="query.bedNo!=null || query.name!=null || query.code!=null || query.anaDoctor!=null || query.surgeName!=null ||query.gender!=null ||query.anaType!=null || query.deviceId != null || query.productNo!=null">-->
- <!--<where>-->
- <!--(1=0-->
- <!--<if test="query.bedNo!=null">-->
- <!--or c.bed_no LIKE concat('%', #{query.bedNo}, '%')-->
- <!--</if>-->
- <!--<if test="query.name!=null">-->
- <!--or c.`patient_name` LIKE concat('%', #{query.name}, '%')-->
- <!--</if>-->
- <!--<if test="query.code!=null">-->
- <!--or p.`code` LIKE concat('%', #{query.code}, '%')-->
- <!--</if>-->
- <!--<if test="query.anaDoctor!=null">-->
- <!--or c.`ana_doctor` like concat('%', #{query.anaDoctor}, '%')-->
- <!--</if>-->
- <!--<if test="query.surgeName!=null">-->
- <!--or c.`surgery_name` like concat('%',#{query.surgeName}, '%')-->
- <!--</if>-->
- <!--<if test="query.gender!=null">-->
- <!--or c.patient_gender LIKE concat('%', #{query.gender}, '%')-->
- <!--</if>-->
- <!--<if test="query.anaType!=null">-->
- <!--or c.ana_type LIKE concat('%', #{query.anaType}, '%')-->
- <!--</if>)-->
- <!--<!–<if test="query.deviceId!=null">–>-->
- <!--<!–or i.device_id like concat('%', #{query.deviceId}, '%')–>-->
- <!--<!–</if>–>-->
- <!--<!–<if test="query.deviceAlias!=null">–>-->
- <!--<!–or d.alias like concat('%', #{query.deviceAlias}, '%')–>-->
- <!--<!–</if>–>-->
- <!--</where>-->
- <!--</if>-->
- order by c.monitor_start_time desc
- </select>
- <select id="findByPatientId" resultMap="monitorResult">
- select
- p.id as patient_id,
- p.`code` as patient_code,
- p.alarm as patient_alarm,
- i.id as infusion_id,
- i.device_id as device_id,
- i.clinic_id as clinic_id,
- i.classification as classification,
- i.data_number as data_num,
- i.total_dose as total_dose,
- i.first_dose as first_dose,
- i.remain_dose as remain_dose,
- i.input_dose as input_dose,
- i.append_dose as append_dose,
- i.append_lock_time as append_lock_time,
- i.max_dose as max_dose,
- i.finished as infusion_finished,
- i.electric_quantity as electric_quantity,
- i.warn_flow as warn_flow,
- i.self_control_count as self_control_count,
- i.self_control_lock_time as self_control_lock_time,
- i.pca_valid_count as pca_valid_count,
- i.pca_invalid_count as pca_invalid_count,
- i.pca_total_count as pca_total_count,
- i.continue_dose as continue_dose,
- i.pulse_dose as pulse_dose,
- i.pulse_lock_time as pulse_lock_time,
- i.pulse_first_lock_time as pulse_first_lock_time,
- i.flow_up_cycle as flow_up_cycle,
- i.flow_down_cycle as flow_down_cycle,
- i.flow_count as flow_count,
- i.flow_up_limit as flow_up_limit,
- i.flow_down_limit as flow_down_limit,
- i.flow_adjust_rate as flow_adjust_rate,
- i.run_state as run_state,
- i.last_upload_time as last_upload_time,
- i.warn_will_finished as warn_will_finished,
- i.warn_analgesic_poor as warn_analgesic_poor,
- i.warn_low_battery as warn_low_battery,
- i.alarm as device_alarm,
- i.start_time as infusion_start_time,
- i.remark as remark,
- i.type as device_type,
- d.alias as device_alias,
- d.product_no as product_no ,
- c.patient_gender as patient_gender,
- c.`patient_name` as patient_name,
- c.finished as finished,
- c.monitor_start_time as monitor_start_time,
- c.end_time as monitor_end_time,
- c.ana_doctor as ana_doctor,
- c.patient_age as patient_age,
- c.ana_type as ana_type,
- c.anal_type as anal_type,
- c.surgery_doctor as surgery_doctor,
- c.surgery_name as surgery_name,
- c.ward as ward,
- c.bed_no as bed_no,
- c.eval_time as eval_time
- from
- (select * from bus_patient
- <where>
- <if test="tenantId!=null">
- and tenant_id=#{tenantId}
- </if>
- <if test="patientId!=null">
- and id=#{patientId}
- </if>
- </where>
- )
- as p
- left join
- bus_infusion_history as i on p.infusion_id=i.id
- left join (select device_id,alias,product_no from bus_device) as d on d.device_id=i.device_id
- left join (select * from bus_clinic where monitor_type=1) c on p.clinic_id=c.id
- limit 1
- </select>
- <select id="selectAlarmCount" resultType="long">
- select count(1) from (select * from bus_patient
- <where>
- <if test="tenantId!=null">
- and tenant_id=#{tenantId}
- </if>
- </where>
- ) as p
- join (select * from bus_clinic
- <where>
- finished=0
- and monitor_type=1
- <if test="tenantId!=null">
- and tenant_id=#{tenantId}
- </if>
- </where>
- ) as c on p.id=c.patient_id
- <where>
- <if test="alarmValue!=null">
- and p.alarm=#{alarmValue}
- </if>
- </where>
- </select>
- <select id="monitorTotalCount" resultType="long">
- 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="device_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"/>
- <result column="assist_id" property="assistId"/>
- <result column="assist_nickname" property="assistNickname"/>
- <result column="abnormal" property="abnormal"/>
- </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 ana_doctor,
- c.surgery_name AS surge_name,
- c.ana_type AS ana_type,
- c.eval_time AS eval_time, <!-- 评价时间 -->
- c.manage_type AS manage_type,
- c.abnormal as abnormal,
- <!-- 设备与输注信息 -->
- i.device_id AS device_id,
- d.alias AS device_alias, <!-- 假设来自设备表,若未关联需调整 -->
- i.clinic_id AS clinic_id,
- i.total_dose AS total_dose,
- i.first_dose AS first_dose,
- i.remain_dose AS remain_dose,
- i.input_dose AS input_dose,
- i.append_dose AS append_dose,
- i.append_lock_time AS append_lock_time,
- i.max_dose AS max_dose,
- i.self_control_lock_time AS self_control_lock_time,
- i.pca_valid_count AS pca_valid_count,
- i.pca_invalid_count AS pca_invalid_count,
- i.pca_total_count AS pca_total_count,
- i.continue_dose AS continue_dose,
- i.pulse_dose AS pulse_dose,
- i.pulse_first_lock_time AS pulse_first_lock_time,
- i.pulse_lock_time AS pulse_lock_time,
- i.flow_up_cycle AS flow_up_cycle,
- i.flow_down_cycle AS flow_down_cycle,
- i.flow_count AS flow_count,
- i.flow_up_limit AS flow_up_limit,
- i.flow_down_limit AS flow_down_limit,
- i.flow_adjust_rate AS flow_adjust_rate,
- i.run_state AS device_run_state,
- i.alarm AS device_alarm,
- i.electric_quantity as electric_quantity,
- i.start_time AS infusion_start_time,
- i.type AS device_type,
- i.warn_flow AS warn_flow,
- i.warn_analgesic_poor AS warn_analgesic_poor,
- i.warn_low_battery AS warn_low_battery,
- <if test="query.consult != null and query.consult == true">
- aub.assist_id as assist_id,
- aub.assist_nickname as assist_nickname,
- </if>
- i.warn_will_finished AS warn_will_finished
- 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
- <if test="query.consult != null and query.consult == true">
- LEFT JOIN (select * from assistant_user_bind where status = '1' and doctor_id = #{query.userId}) aub on aub.patient_id = p.id
- </if>
- <where>
- i.is_undo='0' and c.finished=0 and p.tenant_id = #{query.tenantId}
- <!-- 患者基础条件 -->
- <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>
- <!--todo-->
- <if test="query.abnormal != null">
- AND c.abnormal = #{query.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 LIKE CONCAT('%', #{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 LIKE CONCAT('%', #{query.anaType}, '%')
- </if>
- <!-- 设备与输注条件 -->
- <if test="query.types != null and query.types.size > 0">
- AND i.type IN
- <foreach item="type" collection="query.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 query.alarm == false">
- AND i.alarm = 0
- </if>
- <!-- 有报警 -->
- <if test="query.alarm != null and query.alarm == true">
- AND i.alarm != 0
- </if>
- <!--无提醒-->
- <if test="query.warn != null and query.warn == false">
- AND (i.warn_flow is null and i.warn_low_battery = 0 and i.warn_will_finished =0 and i.warn_analgesic_poor=0)
- </if>
- <!--有提醒-->
- <if test="query.warn != null and query.warn == true">
- AND (i.warn_flow = 1 or i.warn_low_battery = 1 or i.warn_will_finished=1 or i.warn_analgesic_poor=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.evaluate != null and query.evaluate == 1">
- and c.eval_time is not null
- </if>
- <!-- 待评价 -->
- <if test="query.evaluate != null and query.evaluate == 2">
- and c.eval_time is not null and DATE_ADD(c.eval_time,INTERVAL #{query.interval} MINUTE) > NOW()
- </if>
- <!-- 未评价 -->
- <if test="query.evaluate != null and query.evaluate == 3">
- AND c.eval_time is null
- </if>
- <!-- 管理类型 -->
- <if test="query.manageType != null">
- AND c.manage_type = #{query.manageType}
- </if>
- </where>
- <!-- 排序逻辑 -->
- <if test="query.orderType == 0">
- order by i.start_time DESC <!-- 默认按输注开始时间倒序 -->
- </if>
- <if test="query.orderType == 1">
- order by c.bed_no ASC <!-- 按病区和床号升序 -->
- </if>
- </select>
- </mapper>
|