Browse Source

复诊优化

lihong 1 năm trước cách đây
mục cha
commit
34665fd21f

+ 4 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzyReqrecMapper.java

@@ -455,7 +455,11 @@ public interface MzyReqrecMapper {
     @Select(" select max(dis_date) from zy_inactpatient a,a_patient_mi b where a.inpatient_no=b.inpatient_no and a.zk_ward=#{visitDept} and b.mz_no=#{patientId}")
     Date selectMaxDisDateByZkWardAndMzNo(MzyReqrec reqrec);
     @Select(" select visit_dept =(select name from zd_unit_code where code = visit_dept) from mzy_reqrec where patient_id=#{patientId} and visit_date is not null and visit_date >= #{visitTime}" +
+            " union " +
+            "  select visit_dept =(select name from zd_unit_code where code = unit_code) from mzy_reqrec where patient_id=#{patientId} and isnull(visit_date,request_day)>=  #{visitTime} " +
             " union " +
             "  select visit_dept=(select name from zd_unit_code where code =a.zk_ward) from zy_inactpatient a,a_patient_mi b where a.inpatient_no=b.inpatient_no   and b.mz_no=#{patientId} and a.dis_date >= #{disTime}")
     List<String> selectFzDept(@Param("patientId") String patientId, @Param("visitTime") String visitTime,@Param("disTime") String disTime);
+    @Select(" select max(isnull(visit_date,request_day))  from mzy_reqrec where charge_type !='11' and patient_id=#{patientId} and unit_code=#{visitDept} ")
+    Date selectMaxRequestDateByPatientIdAndUnitCode(MzyReqrec reqrec);
 }

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

@@ -1102,8 +1102,9 @@ public class MzyReqrecServiceImpl implements MzyReqrecService {
         if(Constants.FZ_CODE.equals(reqrec.getChargeType())){
             Date now = new Date();
             Date visitDate = mzyReqrecMapper.selectMaxVisitDateByPatientIdAndVisitDept(reqrec);
+            Date requestDate = mzyReqrecMapper.selectMaxRequestDateByPatientIdAndUnitCode(reqrec);
             Date disDate = mzyReqrecMapper.selectMaxDisDateByZkWardAndMzNo(reqrec);
-            if ((visitDate != null && cn.hutool.core.date.DateUtil.between(visitDate, now, DateUnit.SECOND) <= 60*60*24*3) || (disDate != null && cn.hutool.core.date.DateUtil.between(disDate, now, DateUnit.SECOND) <= 60*60*24*15)) {
+            if ((requestDate != null && cn.hutool.core.date.DateUtil.between(requestDate, now, DateUnit.SECOND) <= 60*60*24*3)||(visitDate != null && cn.hutool.core.date.DateUtil.between(visitDate, now, DateUnit.SECOND) <= 60*60*24*3) || (disDate != null && cn.hutool.core.date.DateUtil.between(disDate, now, DateUnit.SECOND) <= 60*60*24*15)) {
                 return R.ok();
             }else {
                 String visitTime = cn.hutool.core.date.DateUtil.formatDateTime(cn.hutool.core.date.DateUtil.offsetDay(now, -3));
@@ -1112,7 +1113,7 @@ public class MzyReqrecServiceImpl implements MzyReqrecService {
                 if(CollUtil.isEmpty(deptList)){
                     return R.error("不满足挂复诊条件, 该患者初诊后3天之内或出院后15天之内没有就诊记录");
                 }
-                return R.error(StrUtil.format("不满足挂复诊条件, 该患者初诊后3天之内或出院后15天之内的就诊科室有[{}];本次挂号科室不在其内",CollUtil.join(deptList,",")));
+                return R.error(StrUtil.format("不满足挂复诊条件, 本次可以挂复诊号的科室为【{}】",CollUtil.join(deptList,",")));
             }
         }
         return R.ok();