针灸质控中心平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.2 KiB

<?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.acupuncture.system.persist.dao.PmsPatientDao">
<select id="query" resultType="com.acupuncture.system.domain.vo.PmsPatientVo$PatientResult"
parameterType="com.acupuncture.system.domain.dto.PmsPatientDto$PatientQuery">
SELECT
id,
name,
gender,
birth_date as birthDate,
ethnicity,
education_years as educationYears,
phone,
id_card_type as idCardType,
id_card as idCard,
source,
current_illness_history as currentIllnessHistory,
create_by as createBy,
create_time as createTime
FROM
pms_patient
<where>
del_flag = 0
<if test="query.tenantId != null">
AND tenant_id = #{query.tenantId}
</if>
<if test="query.gender != null">
AND gender = #{query.gender}
</if>
<if test="query.phone != null and query.phone != ''">
AND phone = #{query.phone}
</if>
<if test="query.idCard != null and query.idCard != ''">
AND id_card = #{query.idCard}
</if>
<if test="query.sourceId != null">
AND source = #{query.source}
</if>
<if test="query.startAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), birth_date)), '%Y') + 0 &gt;= #{query.startAge}
</if>
<if test="query.endAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), birth_date)), '%Y') + 0 &lt;= #{query.endAge}
</if>
<if test="query.keywords != null and query.keywords != ''">
AND (
name LIKE CONCAT('%', #{query.keywords}, '%')
OR pinyin_full LIKE CONCAT('%', #{query.keywords}, '%')
OR pinyin_simple LIKE CONCAT('%', #{query.keywords}, '%')
)
</if>
</where>
</select>
<insert id="batchInsert">
replace into pms_patient(
id,
name,
pinyin_full,
pinyin_simple,
gender,
birth_date,
ethnicity,
education_years,
phone,
id_card_type,
id_card,
source,
current_illness_history,
create_by,
create_time
)
values
<foreach collection="pmsPatientList" item="patient" separator=",">
(
#{patient.id},
#{patient.name},
#{patient.pinyinFull},
#{patient.pinyinSimple},
#{patient.gender},
#{patient.birthDate},
#{patient.ethnicity},
#{patient.educationYears},
#{patient.phone},
#{patient.idCardType},
#{patient.idCard},
#{patient.source},
#{patient.currentIllnessHistory},
#{patient.createBy},
#{patient.createTime}
)
</foreach>
</insert>
</mapper>