Browse Source

复诊号提示,住院证

lihong 1 year ago
parent
commit
bb0c83ca6f

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

@@ -51,12 +51,12 @@ public interface MzZyReqMapper {
     List<MzZyReq> selectMzZyReqByDoctorCode(@Param("patientId") String patientId,@Param("doctorCode") String doctorCode);
 
     /**
-     * 删除该医生未确认的住院证
+     * 删除该医生未确认的住院证 只删除3天内的
      * @param patientId
      * @param doctorCode
      * @return
      */
-    @Delete("delete from mz_zy_req where patient_id=#{patientId} and req_status = 0 and doctor_code=#{doctorCode}")
+    @Delete("delete from mz_zy_req where patient_id=#{patientId} and req_status = 0 and doctor_code=#{doctorCode} and DATEDIFF(day,visit_date,getdate()) <=3")
     int deleteMzZyReqByDoctorCode(@Param("patientId") String patientId,@Param("doctorCode") String doctorCode);
 
     /**

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

@@ -454,4 +454,8 @@ 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 =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);
 }

+ 9 - 7
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -1186,11 +1186,13 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             mzYjReqMapper.deleteNotPayYjReByPatientId(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
             mzBlRecordMapper.deleteNotPayBlRecordByPatientId(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
             clinicMapper.deleteById(dbClinic.getId());
-            List<MzZyReq> zyReqList= mzZyReqMapper.selectMzZyReqByDoctorCode(mzPrescriptionVo.getPatientId(),dbClinic.getDoctorCode());
-            if(zyReqList!=null && zyReqList.size()>0){
-                mzZyReqMapper.deleteMzZyReqByDoctorCode(mzPrescriptionVo.getPatientId(),dbClinic.getDoctorCode());
-                for(MzZyReq mzZyReq:zyReqList){
-                    zyBedPreMsgMappper.deleteMzZyReqByDoctorCode(mzPrescriptionVo.getPatientId(),mzZyReq.getVisitDate());
+            if(mzPrescriptionVo.getMzZyReq() != null && StrUtil.isNotBlank(mzPrescriptionVo.getMzZyReq().getReqDept())){
+                List<MzZyReq> zyReqList= mzZyReqMapper.selectMzZyReqByDoctorCode(mzPrescriptionVo.getPatientId(),dbClinic.getDoctorCode());
+                if(zyReqList!=null && zyReqList.size()>0){
+                    mzZyReqMapper.deleteMzZyReqByDoctorCode(mzPrescriptionVo.getPatientId(),dbClinic.getDoctorCode());
+                    for(MzZyReq mzZyReq:zyReqList){
+                        zyBedPreMsgMappper.deleteMzZyReqByDoctorCode(mzPrescriptionVo.getPatientId(),mzZyReq.getVisitDate());
+                    }
                 }
             }
             List<OpRecord> opRecordList= opRecordMapper.selectOpRecordByPatientIdAndTimes(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
@@ -6349,13 +6351,13 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = {Exception.class,BizException.class,MzException.class})
     public Clinic savePrescriptionAndCharge(MzPrescriptionVo mzPrescriptionVo, Clinic dbClinic) throws MzException{
        if(zyActpatientService.checkZaiYuan(mzPrescriptionVo.getPatientId())){
-           throw new BizException("病人已经在住院,不能再开门诊处方");
+           throw new MzException("病人已经在住院,不能再开门诊处方");
        }
         //计算处方总金额是否为0
         Map<String, Object> tempPrescription = getMzChargeDetailService().getAmountForTempPrescription(mzPrescriptionVo);
         BigDecimal totalFee = (BigDecimal) tempPrescription.get("amount");
         Clinic insertClinic;
-        if(totalFee.compareTo(BigDecimal.ZERO) == 0){
+        if(totalFee.compareTo(BigDecimal.ZERO) == 0 && (CollUtil.isNotEmpty(mzPrescriptionVo.getMzYjReqList()) || CollUtil.isNotEmpty(mzPrescriptionVo.getMzChargeDetailList()))){
             insertClinic = getMzChargeDetailService().savePrescription(mzPrescriptionVo, dbClinic, false);
             if(insertClinic !=null && insertClinic.getId() != null){
                 MzDepositFileVo mzDepositFileVo = new MzDepositFileVo();

+ 9 - 1
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzyReqrecServiceImpl.java

@@ -24,8 +24,10 @@ import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.thmz.*;
 import cn.hnthyy.thmz.vo.MzyReqrecVo;
 import cn.hnthyy.thmz.vo.ThmzmxsrParamsVo;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.util.DesensitizedUtil;
+import cn.hutool.core.util.StrUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -1104,7 +1106,13 @@ public class MzyReqrecServiceImpl implements MzyReqrecService {
             if ((visitDate != null && cn.hutool.core.date.DateUtil.between(visitDate, now, DateUnit.DAY) <= 3) || (disDate != null && cn.hutool.core.date.DateUtil.between(disDate, now, DateUnit.DAY) <= 15)) {
                 return R.ok();
             }else {
-                return R.error("不满足挂复诊条件, 初诊后3天之内或出院后15天之内才可以挂复诊");
+                String visitTime = cn.hutool.core.date.DateUtil.formatDateTime(cn.hutool.core.date.DateUtil.offsetDay(now, -3));
+                String disTime = cn.hutool.core.date.DateUtil.formatDateTime(cn.hutool.core.date.DateUtil.offsetDay(now, -15));
+                List<String> deptList = mzyReqrecMapper.selectFzDept(reqrec.getPatientId(), visitTime, disTime);
+                if(CollUtil.isEmpty(deptList)){
+                    return R.error("不满足挂复诊条件, 该患者初诊后3天之内或出院后15天之内没有就诊记录");
+                }
+                return R.error(StrUtil.format("不满足挂复诊条件, 该患者初诊后3天之内或出院后15天之内的就诊科室有[{}];本次挂号科室不在其内",CollUtil.join(deptList,",")));
             }
         }
         return R.ok();

+ 3 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/zy/APatientMiServiceImpl.java

@@ -98,8 +98,8 @@ public class APatientMiServiceImpl implements APatientMiService {
     @Override
     public List<APatientMi> queryByKeyWard(String keyWard) {
         List<APatientMi> aPatientMis = aPatientMiMapper.selectByKeyWard(keyWard);
-        Tools.trimCollectionStrField(aPatientMis);
         if(CollUtil.isNotEmpty(aPatientMis)){
+            Tools.trimCollectionStrField(aPatientMis);
             return aPatientMis;
         }else {
             //门诊号用身份证再查询下
@@ -108,7 +108,8 @@ public class APatientMiServiceImpl implements APatientMiService {
                 if(mzPatientMi != null && StrUtil.isNotBlank(mzPatientMi.getSocialNo())){
                     List<APatientMi> aPatientMis1 = aPatientMiMapper.selectAPatientBySocialNo(mzPatientMi.getSocialNo());
                     if(CollUtil.isNotEmpty(aPatientMis1)){
-                       aPatientMis1.get(0).setMzNo(keyWard);
+                        aPatientMis1.forEach(item->item.setMzNo(keyWard));
+                        aPatientMis1.removeIf(item -> StrUtil.isNotBlank(item.getInpatientNo()) && item.getInpatientNo().startsWith("S"));
                        Tools.trimCollectionStrField(aPatientMis1);
                     }
                     return aPatientMis1;

+ 4 - 2
src/main/resources/static/js/zy/hospitalized.js

@@ -1366,8 +1366,10 @@ function fillZyPatientInfo(patNo) {
                     initCity(4, cityCode);
                     initDistrict(4, cityCode, birthPlace);
                 }
-                $("#cardNo").val(res.data.mzNo);
-                $("#cardNo").blur();
+                if(stringNotBlank(res.data.mzNo)){
+                    $("#cardNo").val(res.data.mzNo);
+                    $("#cardNo").blur();
+                }
                 $("#userName").val(res.data.name);
                 $("#userName").blur();
                 $("#userNameReadOnly").val(res.data.name);