|
|
|
@ -94,7 +94,21 @@ |
|
|
|
COUNT(ee.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, |
|
|
|
ud.dept_name as hospitalName |
|
|
|
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 |
|
|
|
@ -155,25 +169,33 @@ |
|
|
|
</when> |
|
|
|
</choose> |
|
|
|
</if> |
|
|
|
<choose> |
|
|
|
<when test="dataScope == 5"> |
|
|
|
and (pp.create_by = #{userName} or ae.tester_id = #{userId}) |
|
|
|
</when> |
|
|
|
<!-- 当前医院不区分多级,所以本部门及以下权限和本部门数据权限使用相同的查询语句 --> |
|
|
|
<when test="dataScope == 3 or dataScope == 4"> |
|
|
|
and uu.dept_id = (SELECT dept_id FROM ums_user WHERE user_id = #{userId}) |
|
|
|
</when> |
|
|
|
<when test="dataScope == 2"> |
|
|
|
and uu.dept_id in ( |
|
|
|
SELECT pud.dept_id FROM ums_user u |
|
|
|
LEFT JOIN ums_dept ud ON ud.dept_id = u.dept_id |
|
|
|
LEFT JOIN ums_dept pud ON pud.dept_id = ud.parent_id |
|
|
|
WHERE u.user_id = #{userId} |
|
|
|
UNION ALL |
|
|
|
SELECT u.dept_id FROM ums_user u WHERE u.user_id = #{userId} |
|
|
|
) |
|
|
|
</when> |
|
|
|
</choose> |
|
|
|
<if test="userId != null"> |
|
|
|
<!-- 权限 总测评师和测评师都是本部门及以下 --> |
|
|
|
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)) |
|
|
|
WHERE user_id = #{userId} |
|
|
|
) |
|
|
|
</if> |
|
|
|
<!-- <choose>--> |
|
|
|
<!-- <when test="dataScope == 5">--> |
|
|
|
<!-- and (pp.create_by = #{userName} or ae.tester_id = #{userId})--> |
|
|
|
<!-- </when>--> |
|
|
|
<!-- <!– 当前医院不区分多级,所以本部门及以下权限和本部门数据权限使用相同的查询语句 –>--> |
|
|
|
<!-- <when test="dataScope == 3 or dataScope == 4">--> |
|
|
|
<!-- and uu.dept_id = (SELECT dept_id FROM ums_user WHERE user_id = #{userId})--> |
|
|
|
<!-- </when>--> |
|
|
|
<!-- <when test="dataScope == 2">--> |
|
|
|
<!-- and uu.dept_id in (--> |
|
|
|
<!-- SELECT pud.dept_id FROM ums_user u--> |
|
|
|
<!-- LEFT JOIN ums_dept ud ON ud.dept_id = u.dept_id--> |
|
|
|
<!-- LEFT JOIN ums_dept pud ON pud.dept_id = ud.parent_id--> |
|
|
|
<!-- WHERE u.user_id = #{userId}--> |
|
|
|
<!-- UNION ALL--> |
|
|
|
<!-- SELECT u.dept_id FROM ums_user u WHERE u.user_id = #{userId}--> |
|
|
|
<!-- )--> |
|
|
|
<!-- </when>--> |
|
|
|
<!-- </choose>--> |
|
|
|
GROUP BY pp.id |
|
|
|
order by pp.create_time desc |
|
|
|
</select> |
|
|
|
@ -264,6 +286,7 @@ |
|
|
|
from |
|
|
|
pms_patient_body b |
|
|
|
left join pms_patient p on b.patient_id = p.id |
|
|
|
left join ums_user uu on p.create_by = uu.user_name |
|
|
|
<where> |
|
|
|
b.del_flag = 0 and p.del_flag = 0 |
|
|
|
<if test="param.visitType != null"> |
|
|
|
@ -281,6 +304,14 @@ |
|
|
|
<if test="param.diagnosisCode != null and param.diagnosisCode != ''"> |
|
|
|
and b.diagnosis_code like concat('%',#{param.diagnosisCode},'%') |
|
|
|
</if> |
|
|
|
<if test="userId != null"> |
|
|
|
<!-- 权限 总测评师和测评师都是本部门及以下 --> |
|
|
|
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)) |
|
|
|
WHERE user_id = #{userId} |
|
|
|
) |
|
|
|
</if> |
|
|
|
</where> |
|
|
|
order by b.id desc |
|
|
|
</select> |
|
|
|
|