Преглед на файлове

自动化正负相抵功能,取消手动操作接口。

lighter преди 4 години
родител
ревизия
b11bd40e4f

+ 9 - 2
src/main/java/thyyxxk/webserver/controller/yibao/DictionaryController.java

@@ -5,6 +5,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.constants.ResponceType;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.dictionary.PureCodeName;
 import thyyxxk.webserver.entity.dictionary.SearchDataParam;
@@ -14,6 +15,9 @@ import thyyxxk.webserver.utils.ResultVoUtil;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * @author dj
+ */
 @RestController
 @RequestMapping("/dictionary")
 public class DictionaryController {
@@ -35,13 +39,16 @@ public class DictionaryController {
         return service.searchData(param);
     }
 
+    /**
+     * 这是给病案首页填医保诊断用的
+     * */
     @PassToken
-    @PostMapping("/searchYbDiag") // *这是给病案首页填医保诊断用的*
+    @PostMapping("/searchYbDiag")
     public ResultVo<List<PureCodeName>> searchYbDiag(@RequestBody SearchDataParam param) {
         if (null == param.getResponceType()) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保身份不能为空!");
         }
-        if (!param.getResponceType().equals("04") && null == param.getYbType()) {
+        if (!param.getResponceType().equals(ResponceType.NEW_RURAL_COOPERATIVE_MEDICAL_INSURANCE) && null == param.getYbType()) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保类别不能为空!");
         }
         List<PureCodeName> list = service.searchYbDiag(param);

+ 0 - 7
src/main/java/thyyxxk/webserver/controller/yibao/PatientController.java

@@ -8,7 +8,6 @@ import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.yibao.patient.*;
 import thyyxxk.webserver.entity.yibao.admiss.YbRegisterInfoParam;
 import thyyxxk.webserver.service.yibao.PatientService;
-import thyyxxk.webserver.utils.TokenUtil;
 
 import java.util.HashMap;
 import java.util.List;
@@ -65,12 +64,6 @@ public class PatientController {
         return service.getIdCardInfo(inpatientNo, admissTimes);
     }
 
-    @PostMapping("/updateTransFlag")
-    public ResultVo<String> updateTransFlag(@RequestBody UpdateTransFlagParam param) {
-        param.setStaffId(TokenUtil.getTokenUserId());
-        return service.updateTransFlag(param);
-    }
-
     @GetMapping("/getCancelRegisterRequests")
     public ResultVo<List<ToYbkRequest>> getCancelRegisterRequests(@Param("inpatientNo") String inpatientNo,
                                                                   @Param("admissTimes") Integer admissTimes,

+ 17 - 8
src/main/java/thyyxxk/webserver/controller/yibao/YiBaoController.java

@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.constants.ResponceType;
 import thyyxxk.webserver.dao.his.yibao.Routines;
 import thyyxxk.webserver.entity.*;
 import thyyxxk.webserver.entity.yibao.patient.Overview;
@@ -22,9 +23,13 @@ import java.util.List;
 import static thyyxxk.webserver.utils.YibaoHttpUtil.equalizeUpload;
 import static thyyxxk.webserver.utils.YibaoHttpUtil.httpPost;
 
+/**
+ * @author dj
+ */
 @RestController
 @RequestMapping("/yibao")
 @Slf4j
+@SuppressWarnings("unchecked")
 public class YiBaoController {
     private final SettleService settleService;
     private final Routines routines;
@@ -45,7 +50,7 @@ public class YiBaoController {
 
     @PostMapping("/register")
     public ResultVo<Object> inpatientRegister(@RequestBody Patient param) {
-        if (param.getResponceType().equals("04")) {
+        if (param.getResponceType().equals(ResponceType.NEW_RURAL_COOPERATIVE_MEDICAL_INSURANCE)) {
             routines.updateYbRegisterDate(param.getInpatientNo(), param.getYbRegisterDate());
         }
         param.setStaffId(TokenUtil.getTokenUserId());
@@ -74,14 +79,16 @@ public class YiBaoController {
     public ResultVo<Object> multipleUploadFee(@RequestBody List<Overview> patients) {
         String responce = patients.get(0).getResponceType();
         for (Overview item : patients) {
-            item.setStaffId(TokenUtil.getTokenUserId());
             Integer ledgerSn = routines.getLedgerSn(item.getInpatientNo(), item.getAdmissTimes());
             routines.hisRecount(item.getInpatientNo(), item.getAdmissTimes(), ledgerSn);
+            item.setStaffId(TokenUtil.getTokenUserId());
+            item.setLedgerSn(ledgerSn);
+            settleService.posNegOffset(item);
         }
-        if (responce.equals("04")) {
+        if (responce.equals(ResponceType.NEW_RURAL_COOPERATIVE_MEDICAL_INSURANCE)) {
             return httpPost("multipleUploadFee", patients, responce);
         } else {
-            if (responce.equals("03") || responce.equals("09")) {
+            if (ResponceType.isChangShaCityMedicalInsurance(responce)) {
                 return equalizeUpload("cssyb", "multiple", patients, null, responce);
             } else {
                 return equalizeUpload("hnsyb", "multiple", patients, null, responce);
@@ -92,16 +99,18 @@ public class YiBaoController {
     @PostMapping("/singleUpload")
     public ResultVo<Object> uploadFeeDetail(@RequestBody Overview overview) {
         String responce = overview.getResponceType();
-        if (responce.equals("01")) {
+        if (responce.equals(ResponceType.NO_MEDICAL_INSURANCE)) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "自费患者无需上传费用!");
         }
-        overview.setStaffId(TokenUtil.getTokenUserId());
         Integer ledgerSn = routines.getLedgerSn(overview.getInpatientNo(), overview.getAdmissTimes());
         routines.hisRecount(overview.getInpatientNo(), overview.getAdmissTimes(), ledgerSn);
-        if (responce.equals("04")) {
+        overview.setStaffId(TokenUtil.getTokenUserId());
+        overview.setLedgerSn(ledgerSn);
+        settleService.posNegOffset(overview);
+        if (responce.equals(ResponceType.NEW_RURAL_COOPERATIVE_MEDICAL_INSURANCE)) {
             return httpPost("uploadFee", overview, responce);
         } else {
-            if (responce.equals("03") || responce.equals("09")) {
+            if (ResponceType.isChangShaCityMedicalInsurance(responce)) {
                 return equalizeUpload("cssyb", "single", null, overview, responce);
             } else {
                 return equalizeUpload("hnsyb", "single", null, overview, responce);

+ 16 - 0
src/main/java/thyyxxk/webserver/dao/his/yibao/AdvanceUploadDao.java

@@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.yibao.patient.AdvanceUpload;
 import thyyxxk.webserver.entity.yibao.patient.Fee;
+import thyyxxk.webserver.entity.yibao.patient.FeeCounteract;
 
+import java.util.LinkedList;
 import java.util.List;
 
 /**
@@ -46,4 +49,17 @@ public interface AdvanceUploadDao {
                           @Param("inpatientNo") String inpatientNo,
                           @Param("admissTimes") Integer admissTimes,
                           @Param("ledgerSn") Integer ledgerSn);
+
+    @Select("select detail_sn,rtrim(charge_code_mx) as chargeCodeMx,charge_fee from zy_detail_charge " +
+            "where inpatient_no=#{zyh} and admiss_times=#{zycs} and ledger_sn=#{sn} " +
+            "and isnull(infant_flag,0)!=1 and isnull(trans_flag_yb,0) not in (1,2)")
+    LinkedList<FeeCounteract> selectAllNotUploadedFees(@Param("zyh") String zyh, @Param("zycs") Integer zycs, @Param("sn") Integer sn);
+
+    @Update("update zy_detail_charge set trans_flag_yb=2 where inpatient_no=#{zyh} and " +
+            "admiss_times=#{zycs} and detail_sn=#{sn}")
+    void updateYbTransFlag(@Param("zyh") String zyh, @Param("zycs") Integer zycs, @Param("sn") Integer sn);
+
+    @Update("update zy_detail_charge set trans_flag_yb=2 where inpatient_no=#{zyh} and " +
+            "admiss_times=#{zycs} and detail_sn in (#{sn}, #{sn2})")
+    void updateYbTransFlagInPair(@Param("zyh") String zyh, @Param("zycs") Integer zycs, @Param("sn") Integer sn, @Param("sn2") Integer sn2);
 }

+ 8 - 0
src/main/java/thyyxxk/webserver/entity/yibao/patient/Overview.java

@@ -2,6 +2,9 @@ package thyyxxk.webserver.entity.yibao.patient;
 
 import lombok.Data;
 
+/**
+ * @author dj
+ */
 @Data
 public class Overview {
     private String bedNo;
@@ -13,4 +16,9 @@ public class Overview {
     private String responceType;
     private String sid;
     private String staffId;
+    private Integer ledgerSn;
+
+    public String getLogBody() {
+        return "【住院号:" + inpatientNo + ",住院次数:" + admissTimes + ",操作员:" + staffId + "】";
+    }
 }

+ 0 - 13
src/main/java/thyyxxk/webserver/entity/yibao/patient/UpdateTransFlagParam.java

@@ -1,13 +0,0 @@
-package thyyxxk.webserver.entity.yibao.patient;
-
-import lombok.Data;
-
-/**
- * @author dj
- */
-@Data
-public class UpdateTransFlagParam {
-    private String staffId;
-    private String inpatientNo;
-    private Integer admissTimes;
-}

+ 4 - 72
src/main/java/thyyxxk/webserver/service/yibao/PatientService.java

@@ -172,6 +172,8 @@ public class PatientService {
             return queryXnhyb(param);
         }
     }
+
+    @SuppressWarnings("unchecked")
     private ResultVo<Object> queryHnsyb(YbRegisterInfoParam param) {
         ResultVo<Object> resultVo = httpPost("getPersonInfo", param, ResponceType.HUNAN_PROVINCIAL_MEDICAL_INSURANCE);
         if (resultVo.getCode() == ExceptionEnum.SUCCESS.getCode()) {
@@ -198,6 +200,7 @@ public class PatientService {
         }
     }
 
+    @SuppressWarnings("unchecked")
     private ResultVo<Object> queryCssyb(YbRegisterInfoParam param) {
         String registerDate = param.getFromDate();
         if (null == registerDate) {
@@ -239,6 +242,7 @@ public class PatientService {
         }
     }
 
+    @SuppressWarnings("unchecked")
     private ResultVo<Object> queryXnhyb(YbRegisterInfoParam param) {
         String memberSysNo = dao.getMemberSysNo(param.getInpatientNo());
         if (StringUtil.isBlank(memberSysNo)) {
@@ -277,78 +281,6 @@ public class PatientService {
         return ResultVoUtil.success(map);
     }
 
-    public ResultVo<String> updateTransFlag(UpdateTransFlagParam param) {
-        log.info("正负相抵操作:{}", param);
-        int ledgerSn = dao.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes());
-        Queue<FeeCounteract> fees = dao.selectAllNotUploadedFees(param.getInpatientNo(), param.getAdmissTimes(), ledgerSn);
-        if (null == fees || fees.isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有可以进行正负相抵的费用。");
-        }
-        Map<String, Map<String, List<FeeCounteract>>> feeMap = new HashMap<>(Capacity.DEFAULT);
-        while (!fees.isEmpty()) {
-            FeeCounteract fee = fees.poll();
-            String chargeCodeMx = fee.getChargeCodeMx();
-            if (feeMap.containsKey(chargeCodeMx)) {
-                if (fee.getChargeFee().startsWith("-")) {
-                    feeMap.get(chargeCodeMx).get("negative").add(fee);
-                } else {
-                    feeMap.get(chargeCodeMx).get("positive").add(fee);
-                }
-            } else {
-                Map<String, List<FeeCounteract>> tempMap = new HashMap<>();
-                tempMap.put("positive", new ArrayList<>());
-                tempMap.put("negative", new ArrayList<>());
-                if (fee.getChargeFee().startsWith("-")) {
-                    tempMap.get("negative").add(fee);
-                } else {
-                    tempMap.get("positive").add(fee);
-                }
-                feeMap.put(chargeCodeMx, tempMap);
-            }
-        }
-        for (Map.Entry<String, Map<String, List<FeeCounteract>>> entry : feeMap.entrySet()) {
-            List<FeeCounteract> negativeList = entry.getValue().get("negative");
-            if (negativeList.isEmpty()) {
-                continue;
-            }
-            List<FeeCounteract> positiveList = entry.getValue().get("positive");
-            List<Integer> updatedSn = new ArrayList<>();
-            for (FeeCounteract negativeFee : negativeList) {
-                boolean found = false;
-                for (FeeCounteract positiveFee : positiveList) {
-                    if (updatedSn.contains(positiveFee.getDetailSn())) {
-                        continue;
-                    }
-                    if (DecimalUtil.negativeAndPositive(positiveFee.getChargeFee(), negativeFee.getChargeFee())) {
-                        found = true;
-                        updatedSn.add(positiveFee.getDetailSn());
-                        dao.updateYbTransFlagInPair(param.getInpatientNo(), param.getAdmissTimes(),
-                                negativeFee.getDetailSn(), positiveFee.getDetailSn());
-                        break;
-                    }
-                }
-                if (!found) {
-                    String positiveAmt = "0.00";
-                    List<Integer> detailSnList = new ArrayList<>();
-                    for (FeeCounteract positiveFee : positiveList) {
-                        if (updatedSn.contains(positiveFee.getDetailSn())) {
-                            continue;
-                        }
-                        detailSnList.add(positiveFee.getDetailSn());
-                        updatedSn.add(positiveFee.getDetailSn());
-                        positiveAmt = DecimalUtil.add(positiveAmt, positiveFee.getChargeFee());
-                        if (DecimalUtil.negativeAndPositive(positiveAmt, negativeFee.getChargeFee())) {
-                            dao.updateYbTransFlag(param.getInpatientNo(), param.getAdmissTimes(), negativeFee.getDetailSn());
-                            detailSnList.forEach(detailSn -> dao.updateYbTransFlag(param.getInpatientNo(), param.getAdmissTimes(),detailSn));
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        return ResultVoUtil.success();
-    }
-
     /**
      * requestType: 1 - 取消医保登记申请  2 - 出院结算申请
      * */

+ 84 - 2
src/main/java/thyyxxk/webserver/service/yibao/SettleService.java

@@ -6,14 +6,19 @@ import org.springframework.http.*;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.constants.Capacity;
+import thyyxxk.webserver.dao.his.yibao.AdvanceUploadDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.yibao.dismiss.YbSettleFee;
+import thyyxxk.webserver.entity.yibao.patient.FeeCounteract;
+import thyyxxk.webserver.entity.yibao.patient.Overview;
 import thyyxxk.webserver.entity.yibao.patient.Patient;
+import thyyxxk.webserver.utils.DecimalUtil;
 import thyyxxk.webserver.utils.FilterUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.YbLinksUtil;
 
-import java.util.HashMap;
+import java.util.*;
 
 /**
  * @author dj
@@ -22,12 +27,89 @@ import java.util.HashMap;
 @Service
 public class SettleService {
     private final DismissService service;
+    private final AdvanceUploadDao dao;
 
     @Autowired
-    public SettleService(DismissService service) {
+    public SettleService(DismissService service, AdvanceUploadDao dao) {
         this.service = service;
+        this.dao = dao;
     }
 
+    public void posNegOffset(Overview overview) {
+        Queue<FeeCounteract> fees = dao.selectAllNotUploadedFees(overview.getInpatientNo(), overview.getAdmissTimes(), overview.getLedgerSn());
+        if (null == fees || fees.isEmpty()) {
+            return;
+        }
+        int count = 0;
+        Map<String, Map<String, List<FeeCounteract>>> feeMap = new HashMap<>(Capacity.DEFAULT);
+        while (!fees.isEmpty()) {
+            FeeCounteract fee = fees.poll();
+            String chargeCodeMx = fee.getChargeCodeMx();
+            if (feeMap.containsKey(chargeCodeMx)) {
+                if (fee.getChargeFee().startsWith("-")) {
+                    feeMap.get(chargeCodeMx).get("negative").add(fee);
+                } else {
+                    feeMap.get(chargeCodeMx).get("positive").add(fee);
+                }
+            } else {
+                Map<String, List<FeeCounteract>> tempMap = new HashMap<>();
+                tempMap.put("positive", new ArrayList<>());
+                tempMap.put("negative", new ArrayList<>());
+                if (fee.getChargeFee().startsWith("-")) {
+                    tempMap.get("negative").add(fee);
+                } else {
+                    tempMap.get("positive").add(fee);
+                }
+                feeMap.put(chargeCodeMx, tempMap);
+            }
+        }
+        for (Map.Entry<String, Map<String, List<FeeCounteract>>> entry : feeMap.entrySet()) {
+            List<FeeCounteract> negativeList = entry.getValue().get("negative");
+            if (negativeList.isEmpty()) {
+                continue;
+            }
+            List<FeeCounteract> positiveList = entry.getValue().get("positive");
+            List<Integer> updatedSn = new ArrayList<>();
+            for (FeeCounteract negativeFee : negativeList) {
+                boolean found = false;
+                for (FeeCounteract positiveFee : positiveList) {
+                    if (updatedSn.contains(positiveFee.getDetailSn())) {
+                        continue;
+                    }
+                    if (DecimalUtil.negativeAndPositive(positiveFee.getChargeFee(), negativeFee.getChargeFee())) {
+                        found = true;
+                        updatedSn.add(positiveFee.getDetailSn());
+                        dao.updateYbTransFlagInPair(overview.getInpatientNo(), overview.getAdmissTimes(),
+                                negativeFee.getDetailSn(), positiveFee.getDetailSn());
+                        count += 2;
+                        break;
+                    }
+                }
+                if (!found) {
+                    String positiveAmt = "0.00";
+                    List<Integer> detailSnList = new ArrayList<>();
+                    for (FeeCounteract positiveFee : positiveList) {
+                        if (updatedSn.contains(positiveFee.getDetailSn())) {
+                            continue;
+                        }
+                        detailSnList.add(positiveFee.getDetailSn());
+                        updatedSn.add(positiveFee.getDetailSn());
+                        positiveAmt = DecimalUtil.add(positiveAmt, positiveFee.getChargeFee());
+                        if (DecimalUtil.negativeAndPositive(positiveAmt, negativeFee.getChargeFee())) {
+                            dao.updateYbTransFlag(overview.getInpatientNo(), overview.getAdmissTimes(), negativeFee.getDetailSn());
+                            detailSnList.forEach(detailSn ->
+                                    dao.updateYbTransFlag(overview.getInpatientNo(), overview.getAdmissTimes(), detailSn));
+                            count += (detailSnList.size() + 1);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        log.info("正负相抵完成:{},共抵消 {} 条费用。", overview.getLogBody(), count);
+    }
+
+    @SuppressWarnings({"rawtypes","unchecked"})
     public ResultVo<String> calculateCost(Patient param, String responce) {
         final String url = YbLinksUtil.getCompleteUrl("calculateCost", responce);
         if ("selfPay".equals(url)) {

+ 1 - 0
src/main/java/thyyxxk/webserver/service/yibao/YbVerifyService.java

@@ -30,6 +30,7 @@ public class YbVerifyService {
         this.dao = dao;
     }
 
+    @SuppressWarnings("unchecked")
     public ResultVo<String> approveYbsf(Patient param) {
         log.info("医保身份审核通过 => 操作员:{},住院号:{},住院次数:{}", TokenUtil.getTokenUserId(),
                 param.getInpatientNo(), param.getAdmissTimes());