Procházet zdrojové kódy

修复超时结算的问题

lighter před 7 měsíci
rodič
revize
62e160fb66

+ 10 - 0
src/main/java/thyyxxk/simzfeeoprnsystm/controller/SiMzFeeController.java

@@ -59,6 +59,11 @@ public class SiMzFeeController {
         return service.outpatientSettlement(p);
     }
 
+    @PostMapping("/timeoutSetl")
+    public ResultVo<FundDetail> timeoutSetl(@RequestBody MzPatientInfo p) {
+        return service.timeoutSetl(p);
+    }
+
     @PostMapping("/revokeOutpatientSettlement")
     public ResultVo<FundDetail> revokeOutpatientSettlement(@RequestBody MzPatientInfo p) {
         return service.revokeOutpatientSettlement(p);
@@ -74,6 +79,11 @@ public class SiMzFeeController {
         return service.isPatientDuringSiSettle(patientId);
     }
 
+    @PostMapping("/createRxPdf")
+    public ResultVo<String> createRxPdf(@RequestBody RxPreCheckRequest request) throws Exception {
+        return ResultVoUtil.success(rxService.createRxPdf(request));
+    }
+
     @PostMapping("/rxPreCheck")
     public ResultVo<JSONObject> rxPreCheck(@RequestBody RxPreCheckRequest request) throws Exception {
         return rxService.rxPreCheck(request);

+ 74 - 24
src/main/java/thyyxxk/simzfeeoprnsystm/service/SiMzFeeService.java

@@ -2,6 +2,7 @@ package thyyxxk.simzfeeoprnsystm.service;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.simzfeeoprnsystm.dao.*;
@@ -55,14 +56,24 @@ public class SiMzFeeService {
     }
 
     public ResultVo<String> outpatientRegistration(MzPatientInfo p) {
-        Regstrtn regstrtn = mzDao.selectRegstrtn(p.getPatNo(), p.getTimes());
+        Regstrtn regstrtn;
+        if (null != p.getVisitDate() && StringUtil.notBlank(p.getDeptCode())
+                && StringUtil.notBlank(p.getDoctorCode())) {
+            regstrtn = mzDao.selectRegstrtn2(p);
+            if (null != regstrtn) {
+                regstrtn.setBegntime(p.getVisitDate());
+                regstrtn.setDeptCode(p.getDeptCode());
+            }
+        } else {
+            regstrtn = mzDao.selectRegstrtn(p.getPatNo(), p.getTimes());
+        }
+
         if (null == regstrtn) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
-                    "mz_visit_table患者信息为空,请联系医生重开处方。");
+                    "mz_visit_table或t_si_pat_info 信息为空,请联系医生重开处方。");
         }
         if (StringUtil.notBlank(regstrtn.getMdtrtId())) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "本次就诊已有医保登记[mdtrtId:" +
-                    regstrtn.getMdtrtId() + "],请勿重复办理。");
+            return ResultVoUtil.success("本次就诊已有医保登记[mdtrtId:" + regstrtn.getMdtrtId() + "],请勿重复办理。");
         }
 
         if (!p.abortBeforeUploadFees()) {
@@ -177,20 +188,25 @@ public class SiMzFeeService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
     }
 
-    public ResultVo<String> uploadOutpatientInfo(SpcChrDiseAcct spcChrDiseAcct, SiPatInfo siPatInfo) {
+    public ResultVo<String> uploadOutpatientInfo(MzPatientInfo mzptnt, SpcChrDiseAcct spcChrDiseAcct, SiPatInfo siPatInfo) {
         JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.UPLOAD_OUTPATIENT_INFO,
                 siPatInfo.getInsuplcAdmdvs(), spcChrDiseAcct.getStaffId());
         JSONObject mdtrtinfo = new JSONObject();
         List<Diagnoses> diagnosesList = new ArrayList<>();
         String icdCodeNew = mzDao.selectIcdCodeNew(siPatInfo.getPatNo(), siPatInfo.getTimes());
-        if (StringUtil.isBlank(icdCodeNew)) {
-            diagnosesList = mzDao.selectMzDiags(siPatInfo.getPatNo(), siPatInfo.getTimes());
-            if (null == diagnosesList || diagnosesList.isEmpty()) {
-                log.info("【{}】 上传就诊信息失败,门诊诊断为空。", siPatInfo.getPatNo());
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的门诊诊断为空,请联系医生填写。");
-            }
-        } else {
+        if (StringUtil.isBlank(icdCodeNew) && null != mzptnt) {
+            icdCodeNew = mzptnt.getIcdCodeNew();
+        }
+        if (StringUtil.notBlank(icdCodeNew)) {
             Diagnoses base = mzDao.selectDiseinfo(siPatInfo.getPatNo(), siPatInfo.getTimes());
+            if (null == base && null != mzptnt) {
+                CodeName dor = mzDao.getDorCodeAndName(mzptnt.getDoctorCode());
+                base = new Diagnoses();
+                base.setDiagDept(mzptnt.getDeptCode());
+                base.setDiagTime(mzptnt.getVisitDate());
+                base.setDiseDorNo(dor.getCode());
+                base.setDiseDorName(dor.getName());
+            }
             String[] icds = icdCodeNew.split(",");
             for (int i = 0; i < icds.length; i++) {
                 String icd = icds[i];
@@ -207,6 +223,12 @@ public class SiMzFeeService {
                 diag.setDiseDorName(base.getDiseDorName());
                 diagnosesList.add(diag);
             }
+        } else {
+            diagnosesList = mzDao.selectMzDiags(siPatInfo.getPatNo(), siPatInfo.getTimes());
+            if (null == diagnosesList || diagnosesList.isEmpty()) {
+                log.info("【{}】 上传就诊信息失败,门诊诊断为空。", siPatInfo.getPatNo());
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的门诊诊断为空,请联系医生填写。");
+            }
         }
         if (siPatInfo.getMedType().equals("14") || siPatInfo.getMedType().equals("51")) {
             if (StringUtil.isBlank(spcChrDiseAcct.getOpspDiseCode())) {
@@ -249,7 +271,7 @@ public class SiMzFeeService {
                     "】未找到此患者的医保挂号信息,请核实。");
         }
         if (!p.getFromDirectReg()) {
-            ResultVo<String> uplRes = uploadOutpatientInfo(p, siPatInfo);
+            ResultVo<String> uplRes = uploadOutpatientInfo(null, p, siPatInfo);
             if (null != uplRes && uplRes.getCode() != ExceptionEnum.SUCCESS.getCode()) {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, uplRes.getMessage());
             }
@@ -521,17 +543,28 @@ public class SiMzFeeService {
         }
         String errMsg = result.getString(ERROR_MESSAGE);
         if (errMsg.contains("服务提供者后端服务响应超时")) {
-            SiSetlinfo setlEntity = querySettlementInfo(p);
-            if (null != setlEntity) {
-                return dealSetlEntity(p, setlEntity);
-            }
+            return timeoutSetl(p);
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, errMsg);
     }
 
+    public ResultVo<FundDetail> timeoutSetl(MzPatientInfo p) {
+        if (StringUtil.isBlank(p.getMdtrtId())) {
+            p.setMdtrtId(mzDao.getMdtrtId(p.getPatNo(), p.getTimes()));
+        }
+        if (StringUtil.isBlank(p.getMdtrtId())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到患者的医保就诊信息!");
+        }
+        SiSetlinfo setlEntity = querySettlementInfo(p);
+        if (null != setlEntity) {
+            return dealSetlEntity(p, setlEntity);
+        }
+        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "超时结算失败。");
+    }
+
     private ResultVo<FundDetail> dealSetlEntity(MzPatientInfo p, SiSetlinfo setlEntity) {
         saveSetlinfoToDatabase(setlEntity, p);
-        if (!p.getStraitSettle() && BigDecimal.ZERO.compareTo(BigDecimal.valueOf(setlEntity.getPsnCashPay())) == 0) {
+        if (!p.getStraitSettle() && BigDecimal.ZERO.compareTo(setlEntity.getPsnCashPay()) == 0) {
             ResultVo<String> mzChargeResponse = mzHisChargeProcess(p.getPatNo(), p.getTimes(),
                     String.valueOf(setlEntity.getMedfeeSumamt()));
             if (mzChargeResponse.getCode() != ExceptionEnum.SUCCESS.getCode()) {
@@ -548,11 +581,21 @@ public class SiMzFeeService {
         JSONObject params = new JSONObject();
         params.put("psnNo", p.getPsnNo());
         params.put("mdtrtId", p.getMdtrtId());
-        ResultVo<SiSetlinfo> vo = new RestTemplate().postForObject(url, params, ResultVo.class);
+        ResultVo<LinkedHashMap> vo = new RestTemplate().postForObject(url, params, ResultVo.class);
         if (null == vo || vo.getCode() != ExceptionEnum.SUCCESS.getCode()) {
             return null;
         }
-        return vo.getData();
+        LinkedHashMap resMap = vo.getData();
+        SiSetlinfo entity = JSONObject.parseObject(JSON.toJSONString(resMap), SiSetlinfo.class);
+        entity.setInsuplcAdmdvs(resMap.get("insuOptins").toString());
+        if (null == entity.getPsnPartAmt()) {
+            entity.setPsnPartAmt(new BigDecimal(resMap.get("psnPay").toString()));
+        }
+        if (null == entity.getPsnCashPay()) {
+            entity.setPsnCashPay(new BigDecimal(resMap.get("cashPayamt").toString()));
+        }
+
+        return entity;
     }
 
     private void saveSetlinfoToDatabase(SiSetlinfo setlEntity, MzPatientInfo p) {
@@ -562,7 +605,9 @@ public class SiMzFeeService {
         setlEntity.setStaffId(p.getStaffId());
         setlEntity.setRevoked(YesOrNo.NO.getCode());
         setlEntity.setSetlType(ClrType.OUTPATIENT.getCode());
-        setlEntity.setInsuplcAdmdvs(p.getInsuplcAdmdvs());
+        if (StringUtil.isBlank(setlEntity.getInsuplcAdmdvs())) {
+            setlEntity.setInsuplcAdmdvs(p.getInsuplcAdmdvs());
+        }
         setlEntity.setBegntime(mzDao.selectBegntime(p.getPatNo(), p.getTimes()));
         setlEntity.setEndtime(setlEntity.getSetlTime());
         setlEntity.setMzSaved(p.getSaved());
@@ -581,7 +626,7 @@ public class SiMzFeeService {
             }
             setldetailDao.insert(detail);
         }
-        setlEntity.setHospPartAmt(hospitalPart.doubleValue());
+        setlEntity.setHospPartAmt(hospitalPart);
         setlinfoDao.insert(setlEntity);
         setlinfoDao.updateSiZyInfoSetlId(p.getPatNo(), p.getTimes(), 0, setlEntity.getSetlId(),
                 setlEntity.getMedinsSetlId(), setlEntity.getMedinsSetlId());
@@ -614,7 +659,7 @@ public class SiMzFeeService {
             }
         }
 
-        if (BigDecimal.ZERO.compareTo(BigDecimal.valueOf(setlinfo.getPsnCashPay())) == 0
+        if (BigDecimal.ZERO.compareTo(setlinfo.getPsnCashPay()) == 0
                 && !Objects.equals(staffDept, "3060000")) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "本次结算【个人现金支付为0】,请到收费窗口做退费操作。");
         }
@@ -719,6 +764,11 @@ public class SiMzFeeService {
         mzptnt.setAcctUsedFlag(param.getAcctUsedFlag());
         mzptnt.setStraitSettle(param.getStraitSettle());
         mzptnt.setAbortBeforeUploadFees(param.abortBeforeUploadFees());
+        mzptnt.setVisitDate(param.getVisitDate());
+        mzptnt.setDeptCode(param.getVisitDeptCode());
+        mzptnt.setDoctorCode(param.getDoctorCode());
+        mzptnt.setIcdCodeNew(param.getIcdCodeNew());
+        mzptnt.setIcdTextNew(param.getIcdTextNew());
         if (!param.abortBeforeUploadFees()) {
             // 生成医保费用
             String mzReceipts = generateSiMzFees(mzptnt);
@@ -768,7 +818,7 @@ public class SiMzFeeService {
         spcChrDiseAcct.setOpspDiseCode(param.getOpspDiseCode());
         spcChrDiseAcct.setOpspDiseName(param.getOpspDiseName());
         spcChrDiseAcct.setExpContent(param.getExpContent());
-        ResultVo<String> upldMdtrtRes = uploadOutpatientInfo(spcChrDiseAcct, siPatInfo);
+        ResultVo<String> upldMdtrtRes = uploadOutpatientInfo(mzptnt, spcChrDiseAcct, siPatInfo);
         if (upldMdtrtRes.getCode() != ExceptionEnum.SUCCESS.getCode()) {
             revokeOutpatientRegistration(mzptnt);
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, upldMdtrtRes.getMessage());