Ciallo 9 months ago
parent
commit
2855b3f45e

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/domain/dto/PatientCardDto.java

@@ -21,6 +21,8 @@ public class PatientCardDto extends BaseData {
     @ApiModelProperty(value = "主治医生姓名")
     private String physician;
 
+    @ApiModelProperty(value = "主治医生姓名")
+    private String doctorCode;
 
     @ApiModelProperty(value = "出院方式")
     private String dischargeMethod;

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/work/mapper/VisitMapper.java

@@ -28,4 +28,8 @@ public interface VisitMapper extends BaseMapper<Visit>{
     List<Visit> selectVisitsByIdAndUserName(@Param("deptId") Long deptId,@Param("userName") String userName);
 
     List<PatientCardDto> getPatientCardByNameOrDepartmentOrPhysician(PatientCardDto patientCardDto);
+
+    Long isRole(Long userId);
+
+    List<PatientCardDto> getPatientCardByUserId(String doctorCode);
 }

+ 16 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/work/service/impl/VisitServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.system.mapper.SysDeptMapper;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.web.work.domain.*;
@@ -39,7 +40,21 @@ public class VisitServiceImpl extends ServiceImpl<VisitMapper, Visit> implements
     @Override
     @DataScope(deptAlias = "v")
     public List<PatientCardDto> getPatientCardByNameOrDepartmentOrPhysician(PatientCardDto patientCardDto) {
-        return visitMapper.getPatientCardByNameOrDepartmentOrPhysician(patientCardDto);
+        //根据userId判断医生是普通医生还是科室主任,或者管理员
+        Long userId= SecurityUtils.getUserId();
+        Long roleId=visitMapper.isRole(userId);
+        if (roleId==4){
+            //非科室主任
+            return visitMapper.getPatientCardByUserId(SecurityUtils.getUsername());
+        } else if (roleId==7){
+            //科室主任
+            return visitMapper.getPatientCardByNameOrDepartmentOrPhysician(patientCardDto);
+        } else {
+            //管理员
+            return visitMapper.getPatientCardByNameOrDepartmentOrPhysician(patientCardDto);
+        }
+
+
     }
 
 

+ 0 - 5
ruoyi-admin/src/main/resources/mapper/work/PatientMapper.xml

@@ -30,11 +30,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
-    <select id="getPatientCardByNameOrRoomOrEntity" resultType="com.ruoyi.web.work.domain.dto.PatientCardDto">
-
-    </select>
-
-
 
     <select id="getPatientByDepartment" resultType="com.ruoyi.web.work.domain.dto.PatientCardDto">
         SELECT

+ 40 - 3
ruoyi-admin/src/main/resources/mapper/work/VisitMapper.xml

@@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and admission_time BETWEEN #{startTime} AND #{endTime}
             </if>
             <if test="deptId != null and deptId != 0">
-                 AND (v.dept_id = #{deptId} OR v.dept_id IN (SELECT s.dept_id FROM sys_dept s WHERE s.parent_id in (SELECT s.dept_id FROM sys_dept s WHERE find_in_set( 100, parent_id ))))
+                 AND (v.dept_id = #{deptId} OR v.dept_id IN (SELECT s.dept_id FROM sys_dept s WHERE s.parent_id in (SELECT s.dept_id FROM sys_dept s WHERE find_in_set( #{deptId}, parent_id ))))
             </if>
         </where>
         <!-- 数据范围过滤 -->
@@ -56,10 +56,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         JOIN tb_orc_report ON tb_orc_report.visit_id=v.id
         LEFT JOIN tb_patient ON v.pat_id = tb_patient.id
         LEFT JOIN sys_dept d ON d.dept_id = v.dept_id
+
         <where>
             v.hospital_status = '3'
             <if test="name!='' and name!=null">
-               AND tb_patient.`name` like concat('%', #{patientName}, '%')
+               AND tb_patient.`name` like concat('%', #{name}, '%')
             </if>
             <if test="department!='' and department!= null">
                 AND v.department =#{department}
@@ -68,7 +69,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 AND v.physician like concat('%', #{physician}, '%')
             </if>
             <if test="deptId !=null and deptId != 0">
-            AND (v.dept_id = #{deptId} OR v.dept_id IN (SELECT s.dept_id FROM sys_dept s WHERE s.parent_id in (SELECT s.dept_id FROM sys_dept s WHERE find_in_set( 100, parent_id ))))
+                <choose>
+                    <when test="deptId ==100">
+                        AND (v.dept_id = #{deptId} OR v.dept_id IN (SELECT s.dept_id FROM sys_dept s WHERE s.parent_id in (SELECT s.dept_id FROM sys_dept s WHERE find_in_set( #{deptId}, parent_id ))))
+                    </when>
+                    <otherwise>
+                        AND (v.dept_id = #{deptId} AND v.dept_id IN(SELECT s.dept_id FROM sys_dept s WHERE find_in_set( #{deptId}, dept_id )))
+                    </otherwise>
+                </choose>
+
             </if>
             <if test="startTime!=null and endTime!=null ">
                 AND v.discharge_time BETWEEN #{startTime} AND DATE_ADD(#{endTime},INTERVAL 1 day)
@@ -140,4 +149,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             d.dept_id = #{deptId}
         AND u.user_name = #{userName}
     </select>
+
+
+
+    <select id="getPatientCardByUserId" resultType="com.ruoyi.web.work.domain.dto.PatientCardDto">
+        SELECT
+            v.department,
+            v.physician,
+            tb_patient.`name`,
+            v.discharge_method,
+            v.discharge_time,
+            v.id as visit_id,
+            v.pat_id,
+            v.card_id
+        FROM
+            tb_visit v
+                JOIN tb_orc_report ON tb_orc_report.visit_id=v.id
+                LEFT JOIN tb_patient ON v.pat_id = tb_patient.id
+        <where>
+            <if test="doctorCode!=null and doctorCode!=''">
+                and v.doctor_code=#{doctorCode}
+            </if>
+        </where>
+    </select>
+
+    <select id="isRole" resultType="java.lang.Long">
+        SELECT sys_user_role.role_id from sys_user_role where sys_user_role.user_id=#{userId}
+    </select>
+
 </mapper>