PostDischargePatientManage/postdischarge-manage/src/main/resources/mapper/manage/signpatientmanageroute/SignPatientManageRouteMapper.xml

398 lines
17 KiB
XML
Raw Normal View History

<?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.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMapper">
<resultMap type="com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute" id="SignPatientManageRouteResult">
<result property="id" column="id"/>
<result property="signPatientRecordId" column="sign_patient_record_id"/>
<result property="patientId" column="patient_id"/>
<result property="patientName" column="patient_name"/>
<result property="departmentId" column="department_id"/>
<result property="departmentName" column="department_name"/>
<result property="servicePackageId" column="service_package_id"/>
<result property="packageName" column="package_name"/>
<result property="diseaseTypeId" column="disease_type_id"/>
<result property="diseaseTypeName" column="disease_type_name"/>
<result property="routeId" column="route_id"/>
<result property="routeName" column="route_name"/>
<result property="taskCreateType" column="task_create_type"/>
<result property="version" column="version"/>
<result property="routeClassify" column="route_classify"/>
<result property="suitRange" column="suit_range"/>
<result property="routeSort" column="route_sort"/>
<result property="routeRemark" column="route_remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectSignPatientManageRouteVo">
select id, sign_patient_record_id, patient_id, patient_name, department_id, department_name, service_package_id, package_name, disease_type_id, disease_type_name, route_id, route_name, task_create_type, version, route_classify, suit_range, route_sort, route_remark, create_by, create_time, update_by, update_time from sign_patient_manage_route
</sql>
<select id="selectSignPatientManageRouteList" parameterType="com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute" resultMap="SignPatientManageRouteResult">
<include refid="selectSignPatientManageRouteVo"/>
<where>
<if test="signPatientRecordId != null ">
and sign_patient_record_id = #{signPatientRecordId}
</if>
<if test="patientId != null ">
and patient_id = #{patientId}
</if>
<if test="patientName != null and patientName != ''">
and patient_name like concat('%', #{patientName}, '%')
</if>
<if test="departmentId != null ">
and department_id = #{departmentId}
</if>
<if test="departmentName != null and departmentName != ''">
and department_name like concat('%', #{departmentName}, '%')
</if>
<if test="servicePackageId != null ">
and service_package_id = #{servicePackageId}
</if>
<if test="packageName != null and packageName != ''">
and package_name like concat('%', #{packageName}, '%')
</if>
<if test="diseaseTypeId != null ">
and disease_type_id = #{diseaseTypeId}
</if>
<if test="diseaseTypeName != null and diseaseTypeName != ''">
and disease_type_name like concat('%', #{diseaseTypeName}, '%')
</if>
<if test="routeName != null and routeName != ''">
and route_name like concat('%', #{routeName}, '%')
</if>
<if test="taskCreateType != null and taskCreateType != ''">
and task_create_type = #{taskCreateType}
</if>
<if test="version != null and version != ''">
and version = #{version}
</if>
<if test="routeClassify != null and routeClassify != ''">
and route_classify = #{routeClassify}
</if>
<if test="suitRange != null and suitRange != ''">
and suit_range = #{suitRange}
</if>
<if test="routeSort != null ">
and route_sort = #{routeSort}
</if>
<if test="routeRemark != null and routeRemark != ''">
and route_remark = #{routeRemark}
</if>
</where>
</select>
<select id="selectSignPatientManageRouteById" parameterType="Long"
resultMap="SignPatientManageRouteResult">
<include refid="selectSignPatientManageRouteVo"/>
where id = #{id}
</select>
2024-04-02 17:23:32 +08:00
<select id="selectManualFollowUpList"
resultType="com.xinelu.manage.vo.manualfollowup.ManualFollowUpVO">
SELECT
2024-04-07 17:14:44 +08:00
pi.id AS 'patientId',
2024-04-02 17:23:32 +08:00
pi.patient_name,
pi.patient_phone,
pi.sex,
pi.hospital_agency_id,
pi.hospital_agency_name,
pi.campus_agency_id,
pi.campus_agency_name,
pi.department_id,
pi.department_name,
pi.ward_id,
pi.ward_name,
pi.in_hospital_number,
pi.visit_serial_number,
pi.main_diagnosis,
2024-04-07 17:14:44 +08:00
pvr.id AS 'visitRecordId',
2024-04-02 17:23:32 +08:00
pvr.surgical_name,
pi.attending_physician_id,
pi.attending_physician_name,
2024-04-07 14:00:45 +08:00
pi.patient_type,
2024-04-02 17:23:32 +08:00
IF(pi.visit_method = 'OUTPATIENT_SERVICE',NULL,pi.admission_time) AS 'admissionTime',
IF(pi.visit_method = 'OUTPATIENT_SERVICE',pi.visit_date,pi.discharge_time) AS 'visitOrDischargeTime',
pter.execute_time AS 'executeTime',
2024-04-07 14:00:45 +08:00
spmr.id AS 'manageRouteId',
spmrn.id AS 'manageRouteNodeId',
spmrn.manage_route_name AS 'manageRouteName',
spmrn.route_node_name AS 'routeNodeName',
2024-04-02 17:23:32 +08:00
spmrn.task_type,
CASE
WHEN spmrn.task_type = 'PHONE_OUTBOUND' THEN spmrn.phone_template_name
WHEN spmrn.task_type = 'QUESTIONNAIRE_SCALE' THEN spmrn.questionnaire_name
WHEN spmrn.task_type = 'ARTIFICIAL_FOLLOW_UP' THEN spmrn.follow_template_name
END AS 'templateName',
CASE
WHEN spmrn.task_type = 'PHONE_OUTBOUND' THEN spmrn.phone_template_id
WHEN spmrn.task_type = 'QUESTIONNAIRE_SCALE' THEN spmrn.question_info_id
WHEN spmrn.task_type = 'ARTIFICIAL_FOLLOW_UP' THEN spmrn.follow_template_id
END AS 'templateId'
FROM
sign_patient_manage_route spmr
LEFT JOIN sign_patient_manage_route_node spmrn ON spmr.id = spmrn.manage_route_id
LEFT JOIN patient_task_execute_record pter on spmr.id = pter.manage_route_id and spmrn.id = pter.manage_route_node_id
LEFT JOIN patient_info pi ON spmr.patient_id = pi.id
LEFT JOIN patient_visit_record pvr ON pi.patient_visit_record_id = pvr.id
<where>
2024-04-07 14:00:45 +08:00
pi.del_flag = '0' AND spmr.task_create_type = 'MANUAL_CREATE'
AND spmrn.node_execute_status = 'UNEXECUTED'
2024-04-02 21:32:31 +08:00
AND spmrn.task_type in ('PHONE_OUTBOUND','QUESTIONNAIRE_SCALE','ARTIFICIAL_FOLLOW_UP')
2024-04-02 17:23:32 +08:00
<if test="patientName != null and patientName != ''">
2024-04-02 21:32:31 +08:00
AND pi.patient_name LIKE concat('%', #{patientName}, '%')
2024-04-02 17:23:32 +08:00
</if>
<if test="patientPhone != null and patientPhone != ''">
2024-04-02 21:32:31 +08:00
AND pi.patient_phone LIKE concat('%', #{patientPhone}, '%')
2024-04-02 17:23:32 +08:00
</if>
<if test="hospitalAgencyId != null">
AND pi.hospital_agency_id = #{hospitalAgencyId}
</if>
2024-04-02 21:32:31 +08:00
<if test="campusAgencyId != null">
AND pi.campus_agency_id = #{campusAgencyId}
</if>
<if test="departmentId != null">
AND pi.department_id = #{departmentId}
</if>
<if test="wardId != null">
AND pi.ward_id = #{wardId}
2024-04-02 17:23:32 +08:00
</if>
2024-04-07 14:00:45 +08:00
<if test="patientType != null and patientType != ''">
AND pi.patient_type = #{patientType}
2024-04-02 17:23:32 +08:00
</if>
<if test="visitSerialNumber != null and visitSerialNumber != ''">
2024-04-02 21:32:31 +08:00
AND pi.visit_serial_number LIKE concat('%', #{visitSerialNumber}, '%')
2024-04-02 17:23:32 +08:00
</if>
<if test="clinicalStartTime != null">
AND pi.visit_date >= #{clinicalStartTime}
</if>
<if test="clinicalEndTime != null">
AND pi.visit_date &lt;= #{clinicalEndTime}
</if>
<if test="dischargeStartTime != null">
AND pi.discharge_time >= #{dischargeStartTime}
</if>
<if test="dischargeEndTime != null">
AND pi.discharge_time &lt;= #{dischargeEndTime}
</if>
<if test="admissionStartTime != null">
AND pi.admission_time >= #{admissionStartTime}
</if>
<if test="admissionEndTime != null">
AND pi.admission_time &lt;= #{admissionEndTime}
</if>
<if test="mainDiagnosis != null and mainDiagnosis != ''">
AND pi.main_diagnosis LIKE concat('%', #{mainDiagnosis}, '%')
</if>
<if test="attendingPhysicianId != null">
AND pi.attending_physician_id = #{attendingPhysicianId}
</if>
<if test="attendingPhysicianName != null and attendingPhysicianName != ''">
2024-04-02 21:32:31 +08:00
AND pi.attending_physician_name LIKE concat('%',#{attendingPhysicianName}, '%')
2024-04-02 17:23:32 +08:00
</if>
</where>
</select>
2024-04-07 14:00:45 +08:00
<select id="selectFollowPatientInfo"
resultType="com.xinelu.manage.vo.manualfollowup.ManualFollowPatientVO">
SELECT
ri.id,
ri.patient_name,
ri.patient_phone,
ri.family_member_phone,
ri.birth_date,
ri.card_no,
ri.sex,
ri.address,
ri.avatar_picture_url,
p.id AS 'patientId',
spmr.service_package_id,
spmr.package_name
FROM
sign_patient_manage_route spmr
LEFT JOIN patient_info p ON spmr.patient_id = p.id
LEFT JOIN resident_info ri ON p.resident_id = ri.id
WHERE
p.del_flag = 0
AND ri.del_flag = 0 AND spmr.id = #{id}
</select>
<insert id="insertSignPatientManageRoute" parameterType="com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute" useGeneratedKeys="true"
keyProperty="id">
insert into sign_patient_manage_route
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="signPatientRecordId != null">sign_patient_record_id,
</if>
<if test="patientId != null">patient_id,
</if>
<if test="patientName != null">patient_name,
</if>
<if test="departmentId != null">department_id,
</if>
<if test="departmentName != null">department_name,
</if>
<if test="servicePackageId != null">service_package_id,
</if>
<if test="packageName != null">package_name,
</if>
<if test="diseaseTypeId != null">disease_type_id,
</if>
<if test="diseaseTypeName != null">disease_type_name,
</if>
<if test="routeId != null">route_id,
</if>
<if test="routeName != null">route_name,
</if>
<if test="taskCreateType != null">task_create_type,
</if>
<if test="version != null">version,
</if>
<if test="routeClassify != null">route_classify,
</if>
<if test="suitRange != null">suit_range,
</if>
<if test="routeSort != null">route_sort,
</if>
<if test="routeRemark != null">route_remark,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="signPatientRecordId != null">#{signPatientRecordId},
</if>
<if test="patientId != null">#{patientId},
</if>
<if test="patientName != null">#{patientName},
</if>
<if test="departmentId != null">#{departmentId},
</if>
<if test="departmentName != null">#{departmentName},
</if>
<if test="servicePackageId != null">#{servicePackageId},
</if>
<if test="packageName != null">#{packageName},
</if>
<if test="diseaseTypeId != null">#{diseaseTypeId},
</if>
<if test="diseaseTypeName != null">#{diseaseTypeName},
</if>
<if test="routeId != null">#{routeId},
</if>
<if test="routeName != null">#{routeName},
</if>
<if test="taskCreateType != null">#{taskCreateType},
</if>
<if test="version != null">#{version},
</if>
<if test="routeClassify != null">#{routeClassify},
</if>
<if test="suitRange != null">#{suitRange},
</if>
<if test="routeSort != null">#{routeSort},
</if>
<if test="routeRemark != null">#{routeRemark},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
</trim>
</insert>
<update id="updateSignPatientManageRoute" parameterType="com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute">
update sign_patient_manage_route
<trim prefix="SET" suffixOverrides=",">
<if test="signPatientRecordId != null">sign_patient_record_id =
#{signPatientRecordId},
</if>
<if test="patientId != null">patient_id =
#{patientId},
</if>
<if test="patientName != null">patient_name =
#{patientName},
</if>
<if test="departmentId != null">department_id =
#{departmentId},
</if>
<if test="departmentName != null">department_name =
#{departmentName},
</if>
<if test="servicePackageId != null">service_package_id =
#{servicePackageId},
</if>
<if test="packageName != null">package_name =
#{packageName},
</if>
<if test="diseaseTypeId != null">disease_type_id =
#{diseaseTypeId},
</if>
<if test="diseaseTypeName != null">disease_type_name =
#{diseaseTypeName},
</if>
<if test="routeId != null">route_id =
#{routeId},
</if>
<if test="routeName != null">route_name =
#{routeName},
</if>
<if test="taskCreateType != null">task_create_type =
#{taskCreateType},
</if>
<if test="version != null">version =
#{version},
</if>
<if test="routeClassify != null">route_classify =
#{routeClassify},
</if>
<if test="suitRange != null">suit_range =
#{suitRange},
</if>
<if test="routeSort != null">route_sort =
#{routeSort},
</if>
<if test="routeRemark != null">route_remark =
#{routeRemark},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSignPatientManageRouteById" parameterType="Long">
delete from sign_patient_manage_route where id = #{id}
</delete>
<delete id="deleteSignPatientManageRouteByIds" parameterType="String">
delete from sign_patient_manage_route where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>