针灸质控中心平台
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.
 
 
 
 
 

175 lines
6.1 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
p.id,
p.name,
p.gender,
p.birth_date as birthDate,
p.ethnicity,
p.education_years as educationYears,
p.phone,
p.id_card_type as idCardType,
p.id_card as idCard,
p.source,
p.current_illness_history as currentIllnessHistory,
p.current_illness_history_qt as currentIllnessHistoryQt,
p.tenant_id as tenantId,
p.create_by as createBy,
p.create_time as createTime,
p.weight,
p.height,
t.name as tenantName,
p.weight_id as weightMachineId
FROM
pms_patient p
left join
dms_tenant t
on
p.tenant_id = t.id
<where>
p.del_flag = 0
<if test="query.tenantId != null">
AND p.tenant_id = #{query.tenantId}
</if>
<if test="query.gender != null">
AND p.gender = #{query.gender}
</if>
<if test="query.phone != null and query.phone != ''">
AND p.phone = #{query.phone}
</if>
<if test="query.idCard != null and query.idCard != ''">
AND p.id_card = #{query.idCard}
</if>
<if test="query.sourceId != null">
AND p.source = #{query.sourceId}
</if>
<if test="query.startAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), p.birth_date)), '%Y') + 0 &gt;= #{query.startAge}
</if>
<if test="query.endAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), p.birth_date)), '%Y') + 0 &lt;= #{query.endAge}
</if>
<if test="query.keywords != null and query.keywords != ''">
AND (
p.name LIKE CONCAT('%', #{query.keywords}, '%')
OR p.pinyin_full LIKE CONCAT('%', #{query.keywords}, '%')
OR p.pinyin_simple LIKE CONCAT('%', #{query.keywords}, '%')
or p.id_card LIKE CONCAT('%', #{query.keywords}, '%')
or p.phone LIKE CONCAT('%', #{query.keywords}, '%')
)
</if>
</where>
group by p.id
order by p.create_time desc
</select>
<select id="adminQuery" resultType="com.acupuncture.system.domain.vo.PmsPatientVo$PatientResult"
parameterType="com.acupuncture.system.domain.dto.PmsPatientDto$PatientQuery">
SELECT
p.id,
p.name,
p.gender,
p.birth_date as birthDate,
p.ethnicity,
p.education_years as educationYears,
p.phone,
p.id_card_type as idCardType,
p.id_card as idCard,
p.source,
p.current_illness_history as currentIllnessHistory,
p.current_illness_history_qt as currentIllnessHistoryQt,
p.tenant_id as tenantId,
p.create_by as createBy,
p.create_time as createTime,
p.weight,
p.height,
t.name as tenantName
FROM
v_pms_patient p
left join
dms_tenant t
on
p.tenant_id = t.id
<where>
p.del_flag = 0
<if test="query.tenantId != null">
AND p.tenant_id = #{query.tenantId}
</if>
<if test="query.gender != null">
AND p.gender = #{query.gender}
</if>
<if test="query.phone != null and query.phone != ''">
AND p.phone = #{query.phone}
</if>
<if test="query.idCard != null and query.idCard != ''">
AND p.id_card = #{query.idCard}
</if>
<if test="query.sourceId != null">
AND p.source = #{query.sourceId}
</if>
<if test="query.startAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), p.birth_date)), '%Y') + 0 &gt;= #{query.startAge}
</if>
<if test="query.endAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), p.birth_date)), '%Y') + 0 &lt;= #{query.endAge}
</if>
<if test="query.keywords != null and query.keywords != ''">
AND (
p.name LIKE CONCAT('%', #{query.keywords}, '%')
OR p.pinyin_full LIKE CONCAT('%', #{query.keywords}, '%')
OR p.pinyin_simple LIKE CONCAT('%', #{query.keywords}, '%')
or p.id_card LIKE CONCAT('%', #{query.keywords}, '%')
or p.phone LIKE CONCAT('%', #{query.keywords}, '%')
)
</if>
</where>
order by p.create_time desc
</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,
tenant_id,
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.tenantId},
#{patient.currentIllnessHistory},
#{patient.createBy},
#{patient.createTime}
)
</foreach>
</insert>
</mapper>