Pārlūkot izejas kodu

简易门诊接诊时候,如果医生属于多个科室,首先根据排班所在科室修改简易门诊科室编码

hurugang 2 gadi atpakaļ
vecāks
revīzija
375712c746

+ 2 - 34
src/main/java/cn/hnthyy/thmz/controller/api/MedicalViewApiController.java

@@ -1681,7 +1681,7 @@ public class MedicalViewApiController {
                 results.put("resultMessage", "科室编码不能为空");
                 return results;
             }
-            List<String> ampms = getNotUsedWorkTimes(requestDay);
+            List<String> ampms = mzZdWorkTimeService.getNotUsedWorkTimes(requestDay);
             Date requestDayD = DateUtil.pase(requestDay, "yyyy-MM-dd");
             Date toDay = DateUtil.pase(new Date(), "yyyy-MM-dd");
             if (requestDayD.before(toDay)) {
@@ -1787,7 +1787,7 @@ public class MedicalViewApiController {
                 results.put("resultMessage", "医生编码不能为空");
                 return results;
             }
-            List<String> ampms = getNotUsedWorkTimes(requestDay);
+            List<String> ampms = mzZdWorkTimeService.getNotUsedWorkTimes(requestDay);
             Date requestDayD = DateUtil.pase(requestDay, "yyyy-MM-dd");
             if (requestDayD == null) {
                 results.put("resultCode", -1);
@@ -1870,38 +1870,6 @@ public class MedicalViewApiController {
         }
     }
 
-    /**
-     * 获取不能使用的时间区间
-     *
-     * @param requestDay
-     * @return
-     */
-    private List<String> getNotUsedWorkTimes(String requestDay) {
-        List<String> ampms = null;
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        String now = simpleDateFormat.format(new Date());
-        if (requestDay.equals(now)) {
-            int flg = DateUtil.IsAfternoon(java.util.Calendar.getInstance().getTime().getHours());
-            if (flg >= 0) {
-                ampms = new ArrayList<>();
-                ampms.add(Constants.AM);
-            }
-            List<MzZdWorkTime> mzZdWorkTimes = mzZdWorkTimeService.queryAllMzZdWorkTimeBeforeNow();
-            if (mzZdWorkTimes != null && mzZdWorkTimes.size() > 0) {
-                for (MzZdWorkTime mzZdWorkTime : mzZdWorkTimes) {
-                    if (mzZdWorkTime == null || mzZdWorkTime.getCode() == null || StringUtils.isBlank(mzZdWorkTime.getCode())) {
-                        continue;
-                    }
-                    if (ampms == null) {
-                        ampms = new ArrayList<>();
-                    }
-                    ampms.add(mzZdWorkTime.getCode());
-                }
-            }
-        }
-        return ampms;
-    }
-
     /**
      * 根据排班主键和生日查询挂号费用  (费用确认低于7岁儿童增加挂号费 上调50%)
      *

+ 13 - 2
src/main/java/cn/hnthyy/thmz/controller/mz/MzChargeDetailController.java

@@ -56,6 +56,10 @@ public class MzChargeDetailController {
     private ZyZdAuditItemService zyZdAuditItemService;
     @Autowired
     private ZdChargeItemService zdChargeItemService;
+    @Autowired
+    private MzyRequestService mzyRequestService;
+    @Autowired
+    private MzZdWorkTimeService mzZdWorkTimeService;
     //    @Autowired
 //    private MzChargeDetailYbService mzChargeDetailYbService;
     @Autowired
@@ -1618,8 +1622,15 @@ public class MzChargeDetailController {
                 }
             }
             if (!deptCodes.contains(mzPrescriptionVo.getVisitDeptCode())) {
-                //如果设置的医生接诊科室不在医生的科室列表中,说明是取的该患者上一次就诊医生所属科室,将当前医生的第一个科室替换成实际接诊科室
-                mzPrescriptionVo.setVisitDeptCode(deptCodes.get(0));
+                String requestDay=DateUtil.paseToString(DateUtil.getFirstSecond(),"yyyy-MM-dd");
+                List<String> ampms = mzZdWorkTimeService.getNotUsedWorkTimes(requestDay);
+                List<String> requestDepts=mzyRequestService.queryUnitCodeByRequestDayAndDoctor(requestDay,tokenUser.getUserIdCode(),ampms);
+                if(requestDepts!=null && requestDepts.size()>0){
+                    mzPrescriptionVo.setVisitDeptCode(requestDepts.get(0));
+                }else {
+                    //如果设置的医生接诊科室不在医生的科室列表中,说明是取的该患者上一次就诊医生所属科室,将当前医生的第一个科室替换成实际接诊科室
+                    mzPrescriptionVo.setVisitDeptCode(deptCodes.get(0));
+                }
             }
             mzPrescriptionVo.setDoctorCode(tokenUser.getUserIdCode());
             mzPrescriptionVo.setJzFlag(YesNoEnum.NO.code);

+ 9 - 2
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzyRequestMapper.java

@@ -79,8 +79,15 @@ public interface MzyRequestMapper {
      * @param requestDay
      * @return
      */
-    @Select("SELECT  rtrim(unit_code) unit_code from mzy_request_new WITH(NOLOCK) where request_day =#{requestDay,jdbcType=DATE} and doctor_code =#{doctorCode}")
-    List<String> selectUnitCodeByRequestDayAndDoctor(@Param("requestDay") String requestDay, @Param("doctorCode") String doctorCode);
+    @Select({"<script>","SELECT  rtrim(unit_code) unit_code from mzy_request_new WITH(NOLOCK) where request_day =#{requestDay,jdbcType=DATE} and doctor_code =#{doctorCode}",
+            "<when test='ampms!=null'>",
+            " and ampm  not in ",
+            "<foreach item='item' index='index' collection='ampms' open='(' separator=',' close=')'>",
+            "#{item}",
+            "</foreach>",
+            "</when>",
+            "</script>"})
+    List<String> selectUnitCodeByRequestDayAndDoctor(@Param("requestDay") String requestDay, @Param("doctorCode") String doctorCode, @Param("ampms") List<String> ampms);
 
     /**
      * 更新新号表剩余卡号与当前就诊号

+ 7 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/MzZdWorkTimeService.java

@@ -31,4 +31,11 @@ public interface MzZdWorkTimeService {
      * @return
      */
     List<MzZdWorkTime> queryAllMzZdWorkTimeBeforeNow();
+
+    /**
+     * 获取日期中不能使用的时间段
+     * @param requestDay
+     * @return
+     */
+    List<String> getNotUsedWorkTimes(String requestDay);
 }

+ 4 - 3
src/main/java/cn/hnthyy/thmz/service/his/mz/MzyRequestService.java

@@ -166,9 +166,10 @@ public interface MzyRequestService {
 
     /**
      * 按日期和医生编码查询可以挂号的科室编号
-     *
-     * @param requestDay
+     * @param requestDay 当前日期
+     * @param doctorCode 医生编码
+     * @param ampms 不能使用的日期区间
      * @return
      */
-    List<String> queryUnitCodeByRequestDayAndDoctor(String requestDay, String doctorCode);
+    List<String> queryUnitCodeByRequestDayAndDoctor(String requestDay, String doctorCode,List<String> ampms);
 }

+ 33 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzZdWorkTimeServiceImpl.java

@@ -1,11 +1,17 @@
 package cn.hnthyy.thmz.service.impl.his.mz;
 
+import cn.hnthyy.thmz.Utils.DateUtil;
+import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.his.mz.MzZdWorkTime;
 import cn.hnthyy.thmz.mapper.his.mz.MzZdWorkTimeMapper;
 import cn.hnthyy.thmz.service.his.mz.MzZdWorkTimeService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 @Service
 public class MzZdWorkTimeServiceImpl implements MzZdWorkTimeService {
@@ -31,4 +37,31 @@ public class MzZdWorkTimeServiceImpl implements MzZdWorkTimeService {
     public List<MzZdWorkTime> queryAllMzZdWorkTimeBeforeNow() {
         return mzZdWorkTimeMapper.selectAllMzZdWorkTimeBeforeNow();
     }
+
+    @Override
+    public List<String> getNotUsedWorkTimes(String requestDay) {
+        List<String> ampms = null;
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String now = simpleDateFormat.format(new Date());
+        if (requestDay.equals(now)) {
+            int flg = DateUtil.IsAfternoon(java.util.Calendar.getInstance().getTime().getHours());
+            if (flg >= 0) {
+                ampms = new ArrayList<>();
+                ampms.add(Constants.AM);
+            }
+            List<MzZdWorkTime> mzZdWorkTimes = mzZdWorkTimeMapper.selectAllMzZdWorkTimeBeforeNow();
+            if (mzZdWorkTimes != null && mzZdWorkTimes.size() > 0) {
+                for (MzZdWorkTime mzZdWorkTime : mzZdWorkTimes) {
+                    if (mzZdWorkTime == null || mzZdWorkTime.getCode() == null || StringUtils.isBlank(mzZdWorkTime.getCode())) {
+                        continue;
+                    }
+                    if (ampms == null) {
+                        ampms = new ArrayList<>();
+                    }
+                    ampms.add(mzZdWorkTime.getCode());
+                }
+            }
+        }
+        return ampms;
+    }
 }

+ 2 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzyRequestServiceImpl.java

@@ -252,7 +252,7 @@ public class MzyRequestServiceImpl implements MzyRequestService {
     }
 
     @Override
-    public List<String> queryUnitCodeByRequestDayAndDoctor(String requestDay, String doctorCode) {
-        return mzyRequestMapper.selectUnitCodeByRequestDayAndDoctor(requestDay,doctorCode);
+    public List<String> queryUnitCodeByRequestDayAndDoctor(String requestDay, String doctorCode,List<String> ampms) {
+        return mzyRequestMapper.selectUnitCodeByRequestDayAndDoctor(requestDay,doctorCode,ampms);
     }
 }

+ 19 - 3
src/main/java/cn/hnthyy/thmz/service/impl/thmz/ClinicServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.service.impl.thmz;
 
+import cn.hnthyy.thmz.Utils.DateUtil;
 import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.mz.Employee;
@@ -11,13 +12,16 @@ import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.enums.ClinicStatusEnum;
 import cn.hnthyy.thmz.enums.MzfzStatusEnum;
 import cn.hnthyy.thmz.enums.YesNoEnum;
+import cn.hnthyy.thmz.mapper.his.mz.MzZdWorkTimeMapper;
 import cn.hnthyy.thmz.mapper.his.mz.MzfzPatientOrderMapper;
 import cn.hnthyy.thmz.mapper.his.mz.MzyReqrecMapper;
+import cn.hnthyy.thmz.mapper.his.mz.MzyRequestMapper;
 import cn.hnthyy.thmz.mapper.thmz.ClinicMapper;
 import cn.hnthyy.thmz.mapper.thmz.TurnToConsultationMapper;
 import cn.hnthyy.thmz.mapper.thmz.UserDeptRelationMapper;
 import cn.hnthyy.thmz.service.his.mz.EmployeeService;
 import cn.hnthyy.thmz.service.his.mz.MzVisitTableService;
+import cn.hnthyy.thmz.service.his.mz.MzZdWorkTimeService;
 import cn.hnthyy.thmz.service.thmz.ClinicService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +53,11 @@ public class ClinicServiceImpl implements ClinicService {
     @SuppressWarnings("all")
     @Autowired
     private UserDeptRelationMapper userDeptRelationMapper;
+    @Autowired
+    private MzZdWorkTimeService mzZdWorkTimeService;
+    @SuppressWarnings("all")
+    @Autowired
+    private MzyRequestMapper mzyRequestMapper;
     @Override
     public int saveClinic(Clinic clinic) {
         //存在就不插入
@@ -145,9 +154,16 @@ public class ClinicServiceImpl implements ClinicService {
         updateMzfzPatientOrder.setDoctorCode(tokenUser.getUserIdCode());
         if(Constants.JY_EXEC_CODE.equals(mzfzPatientOrder.getDeptCode())){
             //简易门诊将医生的科室设置到分诊记录
-            List<String> deptNos=userDeptRelationMapper.selectAllByUserIdCode(tokenUser.getUserIdCode());
-            if(deptNos!=null && deptNos.size()>0){
-                updateMzfzPatientOrder.setDeptCode(deptNos.get(0));
+            String requestDay=DateUtil.paseToString(DateUtil.getFirstSecond(),"yyyy-MM-dd");
+            List<String> ampms = mzZdWorkTimeService.getNotUsedWorkTimes(requestDay);
+            List<String> requestDepts=mzyRequestMapper.selectUnitCodeByRequestDayAndDoctor(requestDay,tokenUser.getUserIdCode(),ampms);
+            if(requestDepts!=null && requestDepts.size()>0){
+                updateMzfzPatientOrder.setDeptCode(requestDepts.get(0));
+            }else {
+                List<String> deptNos=userDeptRelationMapper.selectAllByUserIdCode(tokenUser.getUserIdCode());
+                if(deptNos!=null && deptNos.size()>0){
+                    updateMzfzPatientOrder.setDeptCode(deptNos.get(0));
+                }
             }
         }
         return mzfzPatientOrderMapper.updateMzfzPatientOrder(updateMzfzPatientOrder);