|
|
@ -23,140 +23,36 @@ |
|
|
update pms_patient_personal set del_flag = 1 where patient_id = #{patientId}; |
|
|
update pms_patient_personal set del_flag = 1 where patient_id = #{patientId}; |
|
|
</delete> |
|
|
</delete> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="queryPatientList" resultType="com.ccsens.system.domain.vo.PmsPatientVo$PatientList"> |
|
|
<select id="queryPatientList" resultType="com.ccsens.system.domain.vo.PmsPatientVo$PatientList"> |
|
|
SELECT DISTINCT |
|
|
SELECT |
|
|
a.patientId, |
|
|
DISTINCT |
|
|
a.patientName, |
|
|
pp.id as patientId, |
|
|
a.sex, |
|
|
pp.`name` as patientName, |
|
|
a.idcard, |
|
|
|
|
|
a.phone, -- 核心修复:将 a.mobile 改为 a.phone(与内层别名一致) |
|
|
|
|
|
a.educationalStatus, |
|
|
|
|
|
a.independentLivingSkills, |
|
|
|
|
|
a.birthNumber, |
|
|
|
|
|
a.dwellingState, |
|
|
|
|
|
a.lastEvaluationTime, |
|
|
|
|
|
a.lastTesterName, -- 修正之前的笔误(原 astTesterName) |
|
|
|
|
|
a.evaluationCount, |
|
|
|
|
|
a.createBy, |
|
|
|
|
|
a.createTime, |
|
|
|
|
|
a.hospitalName, |
|
|
|
|
|
a.birthday, |
|
|
|
|
|
a.career, |
|
|
|
|
|
a.maritalStatus, |
|
|
|
|
|
a.domicile, |
|
|
|
|
|
a.nation, |
|
|
|
|
|
a.nativePlace, |
|
|
|
|
|
a.contactName, |
|
|
|
|
|
a.contactRelation, |
|
|
|
|
|
a.contactMobile, |
|
|
|
|
|
a.address, |
|
|
|
|
|
a.belief, |
|
|
|
|
|
a.hobby, |
|
|
|
|
|
a.aboBloodType, |
|
|
|
|
|
a.rhBloodType |
|
|
|
|
|
FROM |
|
|
|
|
|
( |
|
|
|
|
|
SELECT DISTINCT |
|
|
|
|
|
pp.id AS patientId, |
|
|
|
|
|
pp.`name` AS patientName, |
|
|
|
|
|
pp.sex, |
|
|
|
|
|
pp.idcard, |
|
|
|
|
|
pp.mobile AS phone, -- 内层别名是 phone |
|
|
|
|
|
pp.educational_status AS educationalStatus, |
|
|
|
|
|
pp.independent_living_skills AS independentLivingSkills, |
|
|
|
|
|
pp.birth_number AS birthNumber, |
|
|
|
|
|
pp.dwelling_state AS dwellingState, |
|
|
|
|
|
MAX(ee.create_time) AS lastEvaluationTime, |
|
|
|
|
|
uu.nick_name AS lastTesterName, |
|
|
|
|
|
COUNT(ee.id) AS evaluationCount, |
|
|
|
|
|
(SELECT nick_name FROM ums_user WHERE user_name = pp.create_by AND del_flag = 0) AS createBy, |
|
|
|
|
|
pp.create_time AS createTime, |
|
|
|
|
|
ud.dept_name AS hospitalName, |
|
|
|
|
|
pp.birthday, |
|
|
|
|
|
pp.career, |
|
|
|
|
|
pp.marital_status AS maritalStatus, |
|
|
|
|
|
pp.domicile, |
|
|
|
|
|
pp.nation, |
|
|
|
|
|
pp.native_place AS nativePlace, |
|
|
|
|
|
pp.contact_name AS contactName, |
|
|
|
|
|
pp.contact_relation AS contactRelation, |
|
|
|
|
|
pp.contact_mobile AS contactMobile, |
|
|
|
|
|
pp.address, |
|
|
|
|
|
pp.belief, |
|
|
|
|
|
pp.hobby, |
|
|
|
|
|
pp.abo_blood_type AS aboBloodType, |
|
|
|
|
|
pp.rh_blood_type AS rhBloodType |
|
|
|
|
|
FROM |
|
|
|
|
|
pms_patient pp |
|
|
|
|
|
LEFT JOIN ems_evaluation ee ON pp.id = ee.patient_id AND ee.del_flag = 0 |
|
|
|
|
|
LEFT JOIN ums_user uu ON ee.tester_id = uu.user_id |
|
|
|
|
|
LEFT JOIN ums_dept ud ON pp.hospital_id = ud.dept_id |
|
|
|
|
|
WHERE |
|
|
|
|
|
pp.del_flag = 0 |
|
|
|
|
|
<if test="deptIdList != null and deptIdList.size()>0"> |
|
|
|
|
|
<if test="deptIdList != null and deptIdList.size()>0"> |
|
|
|
|
|
and pp.hospital_id IN |
|
|
|
|
|
<foreach item="item" collection="deptIdList" open="(" separator="," close=")"> |
|
|
|
|
|
#{item} |
|
|
|
|
|
</foreach> |
|
|
|
|
|
</if> |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test="searchValue != null and searchValue != ''"> |
|
|
|
|
|
and ( |
|
|
|
|
|
pp.name like CONCAT('%',#{searchValue},'%') |
|
|
|
|
|
or |
|
|
|
|
|
pp.name_initial like CONCAT('%',LOWER(#{searchValue}),'%') |
|
|
|
|
|
or |
|
|
|
|
|
pp.name_full like CONCAT('%',LOWER(#{searchValue}),'%') |
|
|
|
|
|
or |
|
|
|
|
|
pp.idcard like CONCAT('%',#{searchValue},'%') |
|
|
|
|
|
or |
|
|
|
|
|
pb.outpatient_no like CONCAT('%',#{searchValue},'%') |
|
|
|
|
|
) |
|
|
|
|
|
</if> |
|
|
|
|
|
<if test="idcard != null and idcard != ''"> |
|
|
|
|
|
and (pp.idcard = #{idcard} or pp.idcard = #{idcardEncrypt}) |
|
|
|
|
|
</if> |
|
|
|
|
|
GROUP BY |
|
|
|
|
|
pp.id |
|
|
|
|
|
UNION ALL |
|
|
|
|
|
SELECT DISTINCT |
|
|
|
|
|
pp.id AS patientId, |
|
|
|
|
|
pp.`name` AS patientName, |
|
|
|
|
|
pp.sex, |
|
|
pp.sex, |
|
|
pp.idcard, |
|
|
pp.idcard, |
|
|
pp.mobile AS phone, -- 内层别名统一为 phone |
|
|
pp.mobile as phone, |
|
|
pp.educational_status AS educationalStatus, |
|
|
pp.birth_year as birthYear, |
|
|
pp.independent_living_skills AS independentLivingSkills, |
|
|
|
|
|
pp.birth_number AS birthNumber, |
|
|
|
|
|
pp.dwelling_state AS dwellingState, |
|
|
|
|
|
MAX(ee.create_time) AS lastEvaluationTime, |
|
|
|
|
|
uu.nick_name AS lastTesterName, |
|
|
|
|
|
COUNT(ee.id) AS evaluationCount, |
|
|
|
|
|
(SELECT nick_name FROM ums_user WHERE user_name = pp.create_by AND del_flag = 0) AS createBy, |
|
|
|
|
|
pp.create_time AS createTime, |
|
|
|
|
|
ud.dept_name AS hospitalName, |
|
|
|
|
|
pp.birthday, |
|
|
pp.birthday, |
|
|
pp.career, |
|
|
|
|
|
pp.marital_status AS maritalStatus, |
|
|
|
|
|
pp.domicile, |
|
|
|
|
|
pp.nation, |
|
|
|
|
|
pp.native_place AS nativePlace, |
|
|
|
|
|
pp.contact_name AS contactName, |
|
|
|
|
|
pp.contact_relation AS contactRelation, |
|
|
|
|
|
pp.contact_mobile AS contactMobile, |
|
|
|
|
|
pp.address, |
|
|
|
|
|
pp.belief, |
|
|
pp.belief, |
|
|
pp.hobby, |
|
|
pp.hobby, |
|
|
pp.abo_blood_type AS aboBloodType, |
|
|
pp.contact_name as contactName, |
|
|
pp.rh_blood_type AS rhBloodType |
|
|
pp.contact_relation as contactRelation, |
|
|
|
|
|
pp.contact_mobile as contactMobile, |
|
|
|
|
|
pp.contact_other as contactOther, |
|
|
|
|
|
pp.id_card_type as idCardType, |
|
|
|
|
|
pp.id_card_type_other as idCardTypeOther, |
|
|
|
|
|
pp.abo_blood_type as aboBloodType, |
|
|
|
|
|
pp.rh_blood_type as rhBloodType, |
|
|
|
|
|
MAX(ae.create_time) as lastEvaluationTime, |
|
|
|
|
|
uu.nick_name as lastTesterName, |
|
|
|
|
|
COUNT(ae.id) as evaluationCount, |
|
|
|
|
|
(select nick_name from ums_user where user_name = pp.create_by and del_flag = 0) as creatorName, |
|
|
|
|
|
pp.create_time as createTime |
|
|
FROM |
|
|
FROM |
|
|
pms_patient pp |
|
|
pms_patient pp |
|
|
LEFT JOIN pms_patient_body pb ON pb.patient_id = pp.id AND pb.del_flag = 0 |
|
|
LEFT JOIN ems_evaluation ae on pp.id = ae.patient_id |
|
|
LEFT JOIN ems_evaluation ee ON pp.id = ee.patient_id AND ee.del_flag = 0 |
|
|
LEFT JOIN ums_user uu on pp.create_by = uu.user_name |
|
|
LEFT JOIN ums_user uu ON ee.tester_id = uu.user_id |
|
|
left join pms_patient_body pb on pp.id = pb.patient_id |
|
|
LEFT JOIN ums_dept ud ON pp.hospital_id = ud.dept_id |
|
|
|
|
|
WHERE |
|
|
WHERE |
|
|
pp.del_flag = 0 |
|
|
pp.del_flag = 0 |
|
|
<if test="searchValue != null and searchValue != ''"> |
|
|
<if test="searchValue != null and searchValue != ''"> |
|
|
@ -172,25 +68,16 @@ |
|
|
pb.outpatient_no like CONCAT('%',#{searchValue},'%') |
|
|
pb.outpatient_no like CONCAT('%',#{searchValue},'%') |
|
|
) |
|
|
) |
|
|
</if> |
|
|
</if> |
|
|
<if test="idcard != null and idcard != ''"> |
|
|
<if test="idcard != null and idcard != ''"> |
|
|
and (pp.idcard = #{idcard} or pp.idcard = #{idcardEncrypt}) |
|
|
and (pp.idcard = #{idcard} or pp.idcard = #{idcardEncrypt}) |
|
|
</if> |
|
|
</if> |
|
|
<if test="deptIdList != null and deptIdList.size()>0"> |
|
|
<!-- 权限 总测评师和测评师都是本部门及以下 --> |
|
|
<if test="deptIdList != null and deptIdList.size()>0"> |
|
|
and uu.dept_id IN ( SELECT d.dept_id FROM ums_user u LEFT JOIN ums_dept d on (d.dept_id = u.dept_id or FIND_IN_SET(u.dept_id,ancestors)) |
|
|
and pp.hospital_id IN |
|
|
WHERE user_id = #{userId} |
|
|
<foreach item="item" collection="deptIdList" open="(" separator="," close=")"> |
|
|
) |
|
|
#{item} |
|
|
GROUP BY pp.id |
|
|
</foreach> |
|
|
order by pp.create_time desc |
|
|
</if> |
|
|
|
|
|
</if> |
|
|
|
|
|
GROUP BY |
|
|
|
|
|
pp.id |
|
|
|
|
|
) a |
|
|
|
|
|
group by a.patientId |
|
|
|
|
|
ORDER BY a.createTime DESC |
|
|
|
|
|
</select> |
|
|
</select> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="queryPatientByIdCard" resultType="com.ccsens.system.domain.vo.PmsPatientVo$PatientInfo"> |
|
|
<select id="queryPatientByIdCard" resultType="com.ccsens.system.domain.vo.PmsPatientVo$PatientInfo"> |
|
|
SELECT |
|
|
SELECT |
|
|
DISTINCT |
|
|
DISTINCT |
|
|
|