This commit is contained in:
liuhongrui
2025-03-10 19:35:45 +08:00
parent c773e79d0e
commit 959c515b02

View File

@@ -0,0 +1,120 @@
<?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.openhis.web.outpatientmanage.mapper.OutpatientManageMapper">
<!-- 门诊皮试记录相关查询-->
<select id="getOutpatientSkinTestRecord"
parameterType="com.openhis.web.outpatientmanage.dto.OutpatientSkinTestRecordSearchParam"
resultType="com.openhis.web.outpatientmanage.dto.OutpatientSkinTestRecordDto">
SELECT
sr.prescription_no, --处方号
e.bus_no as encounterBusNo, --就诊号
pt.name AS patientName, --病人姓名
pt.bus_no AS patientBusNo, --病人ID前台显示用
sr.patient_id, --病人ID
md.bus_no || ' ' || md.name || ' <br>规格:' || COALESCE(m.total_volume, '') AS medicationDetail,--药品
m.lot_number AS medicationLotNumber, --药品批次号
mr.status_enum, --药品状态
sr.performer_id, --执行护士
sr.performer_check_id,--核对人
sr.occurrence_start_time, --预计执行时间
sr.occurrence_end_time,--预计结束时间
ai.clinical_status_enum, --皮试结果
ai.verification_status_enum, --皮试检查项目状态
ai.note --备注
FROM
wor_service_request sr
LEFT JOIN adm_encounter e ON e.id = sr.encounter_id
LEFT JOIN adm_patient pt ON pt.id = sr.patient_id
LEFT JOIN wor_activity_definition ad ON ad.id = sr.activity_id
LEFT JOIN med_medication_request mr ON mr.prescription_no = sr.prescription_no
LEFT JOIN med_medication_definition md ON md.id = mr.medication_id
LEFT JOIN med_medication m ON m.medication_def_id = md.id
LEFT JOIN adm_encounter_participant ep ON ep.encounter_id = sr.encounter_id
LEFT JOIN cli_allergy_intolerance ai ON ai.request_id = sr.id
<where>
ad.bus_no = 'ps001' -- 皮试检查的编号todo编号未定后期修改
AND mr.skin_test_flag = 1
AND md.skin_test_flag = 1
AND ep.type_code = '1' --首诊医生
<!-- 门诊号 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.encounterBusNo != null and OutpatientSkinTestRecordSearchParam.encounterBusNo != ''">
AND e.bus_no LIKE CONCAT('%',#{encounterBusNo}, '%')
</if>
<!-- 处方号 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.prescriptionNo != null and OutpatientSkinTestRecordSearchParam.prescriptionNo != ''">
AND sr.prescription_no LIKE CONCAT('%',#{prescriptionNo}, '%')
</if>
<!-- 手机号 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.phone != null and OutpatientSkinTestRecordSearchParam.phone != ''">
AND pt.phone LIKE CONCAT('%',#{OutpatientRecordSearchParam.phone}, '%')
</if>
<!-- 时间筛选 -->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.beginTime != null and OutpatientSkinTestRecordSearchParam.endTime != null">
AND ai.recorded_date BETWEEN
TO_TIMESTAMP(#{OutpatientSkinTestRecordSearchParam.beginTime} || ' 00:00:00', 'YYYY-MM-DD HH24:MI:SS') AND
TO_TIMESTAMP(#{OutpatientSkinTestRecordSearchParam.endTime} || ' 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
<!-- 皮试项目检查状态 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.status != null and OutpatientSkinTestRecordSearchParam.status != null">
AND ai.verification_status_enum = #{OutpatientSkinTestRecordSearchParam.status}
</if>
</where>
ORDER BY sr.prescription_no,e.bus_no,md.bus_no
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="countOutpatientSkinTestRecords" resultType="long">
SELECT COUNT(*)
FROM
wor_service_request sr
LEFT JOIN adm_encounter e ON e.id = sr.encounter_id
LEFT JOIN adm_patient pt ON pt.id = sr.patient_id
LEFT JOIN wor_activity_definition ad ON ad.id = sr.activity_id
LEFT JOIN med_medication_request mr ON mr.prescription_no = sr.prescription_no
LEFT JOIN med_medication_definition md ON md.id = mr.medication_id
LEFT JOIN med_medication m ON m.medication_def_id = md.id
LEFT JOIN adm_encounter_participant ep ON ep.encounter_id = sr.encounter_id
LEFT JOIN cli_allergy_intolerance ai ON ai.request_id = sr.id
<where>
ad.bus_no = 'ps001' -- 皮试检查的编号todo编号未定后期修改
AND mr.skin_test_flag = 1
AND md.skin_test_flag = 1
AND ep.type_code = '1' --首诊医生
<!-- 门诊号 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.encounterBusNo != null and OutpatientSkinTestRecordSearchParam.encounterBusNo != ''">
AND e.bus_no LIKE CONCAT('%',#{encounterBusNo}, '%')
</if>
<!-- 处方号 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.prescriptionNo != null and OutpatientSkinTestRecordSearchParam.prescriptionNo != ''">
AND sr.prescription_no LIKE CONCAT('%',#{prescriptionNo}, '%')
</if>
<!-- 手机号 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.phone != null and OutpatientSkinTestRecordSearchParam.phone != ''">
AND pt.phone LIKE CONCAT('%',#{OutpatientRecordSearchParam.phone}, '%')
</if>
<!-- 时间筛选 -->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.beginTime != null and OutpatientSkinTestRecordSearchParam.endTime != null">
AND ai.recorded_date BETWEEN
TO_TIMESTAMP(#{OutpatientSkinTestRecordSearchParam.beginTime} || ' 00:00:00', 'YYYY-MM-DD HH24:MI:SS') AND
TO_TIMESTAMP(#{OutpatientSkinTestRecordSearchParam.endTime} || ' 23:59:59', 'YYYY-MM-DD HH24:MI:SS')
</if>
<!-- 皮试项目检查状态 查询条件-->
<if test="OutpatientSkinTestRecordSearchParam != null and OutpatientSkinTestRecordSearchParam.status != null and OutpatientSkinTestRecordSearchParam.status != null">
AND ai.verification_status_enum = #{OutpatientSkinTestRecordSearchParam.status}
</if>
</where>
</select>
<!-- 门诊皮试记录相关更新-->
</mapper>