Files
his/openhis-server/openhis-application/src/main/resources/mapper/patientmanage/PatientManageMapper.xml
liuhongrui 2b0d8a963f up
2025-02-28 11:05:23 +08:00

100 lines
3.8 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.patientmanage.mapper.PatientManageMapper">
<select id="getPatientPage" resultType="com.openhis.web.patientmanage.dto.PatientInformationDto">
SELECT
pt.id,
pt.active_flag,
pt.temp_flag,
pt.name,
pt.name_json,
pt.bus_no,
pt.gender_enum,
pt.birth_date,
pt.deceased_date,
pt.marital_status_enum,
pt.prfs_enum,
pt.phone,
pt.address,
pt.address_province,
pt.address_city,
pt.address_district,
pt.address_street,
pt.address_json,
pt.nationality_code,
pt.id_card,
pt.py_str,
pt.wb_str,
pt.blood_abo,
pt.blood_rh,
pt.work_company,
pt.native_place,
pt.country_code,
pt.link_name,
pt.link_relation_code,
pt.link_telcom,
pt.link_jsons,
pt.organization_id,
pt.create_time
FROM adm_patient pt
<!-- 类型不一致把organization_id转换成字符串类型-->
LEFT JOIN adm_organization ogt ON CAST(pt.organization_id AS VARCHAR) = ogt.bus_no
<where>
<!-- 如果传入busNo参数且不为空 -->
<if test="busNo != null and busNo != ''">
AND pt.bus_no LIKE CONCAT('%',#{busNo}, '%')
</if>
<!-- 如果传入name参数且不为空 -->
<if test="name != null and name != ''">
<choose>
<!-- 如果name参数中包含汉字 -->
<when test="name.matches('.*[\u4e00-\u9fa5].*')">
AND pt.name LIKE CONCAT('%', #{name}, '%')
</when>
<!-- 如果name参数中只包含字母 -->
<when test="name.matches('^[a-zA-Z]+$')">
AND pt.py_str LIKE CONCAT('%', #{name}, '%')
</when>
<!-- 如果name参数中既包含汉字又包含字母 -->
<otherwise>
AND (pt.name LIKE CONCAT('%', #{name}, '%') OR pt.py_str LIKE CONCAT('%', #{name}, '%'))
</otherwise>
</choose>
</if>
</where>
ORDER BY pt.bus_no
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="countPatients" resultType="long">
SELECT COUNT(*)
FROM adm_patient pt
<!-- 类型不一致把organization_id转换成字符串类型-->
LEFT JOIN adm_organization ogt ON CAST(pt.organization_id AS VARCHAR) = ogt.bus_no
<where>
<!-- 如果传入busNo参数且不为空 -->
<if test="busNo != null and busNo != ''">
AND pt.bus_no LIKE CONCAT('%',#{busNo}, '%')
</if>
<!-- 如果传入name参数且不为空 -->
<if test="name != null and name != ''">
<choose>
<!-- 如果name参数中包含汉字 -->
<when test="name.matches('.*[\u4e00-\u9fa5].*')">
AND pt.name LIKE CONCAT('%', #{name}, '%')
</when>
<!-- 如果name参数中只包含字母 -->
<when test="name.matches('^[a-zA-Z]+$')">
AND pt.py_str LIKE CONCAT('%', #{name}, '%')
</when>
<!-- 如果name参数中既包含汉字又包含字母 -->
<otherwise>
AND (pt.name LIKE CONCAT('%', #{name}, '%') OR pt.py_str LIKE CONCAT('%', #{name}, '%'))
</otherwise>
</choose>
</if>
</where>
</select>
</mapper>