ソースを参照

优化门特处方获取 。

lighter 4 年 前
コミット
11f14a1e1a

+ 83 - 75
src/main/java/thyyxxk/webserver/service/markmtfees/MarkMtFeesService.java

@@ -116,27 +116,26 @@ public class MarkMtFeesService {
         return ResultVoUtil.success();
     }
 
+    @SuppressWarnings("unchecked")
     public ResultVo<List<Map<String, Object>>> getMtReceipts(String patientId) {
         List<MzPatient> mzPatients = dao.selectMzPatient(patientId);
         if (null == mzPatients || mzPatients.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【门诊号:" + patientId + "】未找到此患者的个人基本信息,请核实。");
         }
-        JSONObject queryMzChargeList = new JSONObject();
-        queryMzChargeList.put("patCardType", 21);
-        queryMzChargeList.put("patCardNo", patientId);
-        queryMzChargeList.put("hisOrdNum", "");
+        JSONObject queryMzChargeListParam = new JSONObject();
+        queryMzChargeListParam.put("patCardType", 21);
+        queryMzChargeListParam.put("patCardNo", patientId);
+        queryMzChargeListParam.put("hisOrdNum", "");
         RestTemplate template = new RestTemplate();
-        Map<String, Object> mzChargeListMap = template.postForObject(ExternalAddr.GET_MZ_CHARGE_DETAIL_FOR_UN_PAID, queryMzChargeList, Map.class);
+        Map<String, Object> mzChargeListMap = template.postForObject(ExternalAddr.GET_MZ_CHARGE_DETAIL_FOR_UN_PAID, queryMzChargeListParam, Map.class);
         if (null == mzChargeListMap) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
         }
         if (0 != (int) mzChargeListMap.get("resultCode")) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, mzChargeListMap.get("resultMessage").toString());
         }
-
         List<Map<String, Object>> finalResult = new ArrayList<>();
         List<Map<String, String>> mzChargeList = FilterUtil.cast(mzChargeListMap.get("data"));
-
         for (Map<String, String> item : mzChargeList) {
             String hisOrdNum = item.get("hisOrdNum");
             if (null != hisOrdNum) {
@@ -150,16 +149,15 @@ public class MarkMtFeesService {
                 childResult.put("times", times);
                 childResult.put("mzPatient", mzPatients.get(0));
                 childResult.put("mzVisit", mzVisit);
-                JSONObject queryMzChargeDetail = new JSONObject();
-                queryMzChargeDetail.put("patientId", patientId);
-                queryMzChargeDetail.put("times", times);
-                queryMzChargeDetail.put("receiptNo", hisOrdNumParts[2]);
+                JSONObject queryMzChargeDetailParam = new JSONObject();
+                queryMzChargeDetailParam.put("patientId", patientId);
+                queryMzChargeDetailParam.put("times", times);
+                queryMzChargeDetailParam.put("receiptNo", hisOrdNumParts[2]);
                 mzVisit.setReceiptNo(Integer.parseInt(hisOrdNumParts[2]));
                 Map<String, Object> mzChargeDetailMap = template.postForObject(ExternalAddr.UN_PAID_TO_FULL_CHARGE_DETAIL,
-                        queryMzChargeDetail, Map.class);
+                        queryMzChargeDetailParam, Map.class);
                 if (null != mzChargeDetailMap && 0 == (int) mzChargeDetailMap.get("resultCode")) {
                     List<Map<String, Object>> mzChargeDetailList = FilterUtil.cast(mzChargeDetailMap.get("data"));
-
                     mzChargeDetailList.removeIf(detail -> "TC".equals(detail.get("billItemCode")) ||
                             !"5".equals(detail.get("payMark")) || "BILL99".equals(detail.get("chargeItemCode")) ||
                             "四舍五入".equals(detail.get("tcName")));
@@ -169,55 +167,10 @@ public class MarkMtFeesService {
                     Map<Integer, List<MzReceipt>> orderReceiptsMap = new HashMap<>(Capacity.DEFAULT);
                     String doctorName = dao.selectDoctorName(mzChargeDetailList.get(0).get("doctorCode").toString());
                     mzChargeDetailList.forEach(detail -> {
-                        MzReceipt receipt = new MzReceipt();
-                        receipt.setChecked(!detail.get("tcName").toString().contains("外送艾迪康"));
+                        MzReceipt receipt = fillMzReceipt(detail);
                         receipt.setPatientId(patientId);
                         receipt.setTimes(times);
-                        receipt.setReceiptNo((int) detail.get("receiptNo"));
-                        receipt.setOrderNo((int) detail.get("orderNo"));
-                        receipt.setItemNo((int) detail.get("itemNo"));
-                        receipt.setDrugName(detail.get("tcName").toString());
-                        receipt.setChargeItemCode(detail.get("chargeItemCode").toString());
-                        receipt.setPriceTime(DateUtil.formatPriceTime(detail.get("priceTime").toString()));
-                        receipt.setUnitPrice(new BigDecimal(detail.get("unitPrice").toString()).setScale(4, BigDecimal.ROUND_HALF_UP));
-                        receipt.setQuantity((double) detail.get("quantity"));
-                        receipt.setDrugWin((int) detail.get("drugWin"));
-                        receipt.setDoctorCode(detail.get("doctorCode").toString());
                         receipt.setDoctorName(doctorName);
-                        receipt.setSerialNo(detail.get("serialNo").toString());
-                        receipt.setGroupNo(detail.get("groupNo").toString());
-                        receipt.setBillItemCode(detail.get("billItemCode").toString());
-                        receipt.setChargeBillCode(detail.get("chargeBillCode").toString());
-                        if (null != detail.get("instructionText")) {
-                            receipt.setInstructionText(detail.get("instructionText").toString());
-                        }
-                        if (null != detail.get("specification")) {
-                            receipt.setSpecification(detail.get("specification").toString());
-                        }
-                        if (null != detail.get("frequency")) {
-                            receipt.setFrequency(detail.get("frequency").toString());
-                        }
-                        if (null != detail.get("drugQuan")) {
-                            receipt.setDrugQuan((Double) detail.get("drugQuan"));
-                        }
-                        if (null != detail.get("orderDays")) {
-                            receipt.setOrderDays((Integer) detail.get("orderDays"));
-                        }
-                        // groupNo:00-项目;其他-药品
-                        if ("00".equals(receipt.getGroupNo())) {
-                            receipt.setDrugUnit(dao.selectXmChargeUnit(receipt.getChargeItemCode()));
-                        } else {
-                            if (null != detail.get("serial")) {
-                                receipt.setSerial(detail.get("serial").toString());
-                                receipt.setSpecification(dao.selectSpecification(receipt.getChargeItemCode(), receipt.getSerial()));
-                            }
-                            if (null != detail.get("supplyCode")) {
-                                receipt.setSupplyCode(dao.selectSupplyName(detail.get("supplyCode").toString()));
-                            }
-                            if (null != detail.get("drugUnit")) {
-                                receipt.setDrugUnit(dao.selectDrugUnit(detail.get("drugUnit").toString()));
-                            }
-                        }
                         if (!orderReceiptsMap.containsKey(receipt.getOrderNo())) {
                             List<MzReceipt> list = new ArrayList<>();
                             list.add(receipt);
@@ -226,22 +179,7 @@ public class MarkMtFeesService {
                             orderReceiptsMap.get(receipt.getOrderNo()).add(receipt);
                         }
                     });
-                    List<OrderNo> orderNos = new ArrayList<>();
-                    for (Map.Entry<Integer, List<MzReceipt>> entry : orderReceiptsMap.entrySet()) {
-                        OrderNo orderNo = new OrderNo();
-                        orderNo.setPatientId(patientId);
-                        orderNo.setTimes(times);
-                        orderNo.setReceiptNo(entry.getValue().get(0).getReceiptNo());
-                        orderNo.setOrderNo(entry.getKey());
-                        BigDecimal total = new BigDecimal("0.00");
-                        for (MzReceipt receipt : entry.getValue()) {
-                            total = total.add(receipt.getChargeFee());
-                        }
-                        orderNo.setTotalFee(total);
-                        int count = dao.selectFeeCount(patientId, times, mzVisit.getReceiptNo(), entry.getKey());
-                        orderNo.setStatus(count > 0);
-                        orderNos.add(orderNo);
-                    }
+                    List<OrderNo> orderNos = getOrderNos(patientId, times, mzVisit.getReceiptNo(), orderReceiptsMap);
                     childResult.put("orderNos", orderNos);
                     childResult.put("mzReceipts", orderReceiptsMap);
                     finalResult.add(childResult);
@@ -251,6 +189,76 @@ public class MarkMtFeesService {
         return ResultVoUtil.success(finalResult);
     }
 
+    private List<OrderNo> getOrderNos(String patientId, int times, int receiptNo, Map<Integer, List<MzReceipt>> orderReceiptsMap) {
+        List<OrderNo> orderNos = new ArrayList<>();
+        for (Map.Entry<Integer, List<MzReceipt>> entry : orderReceiptsMap.entrySet()) {
+            OrderNo orderNo = new OrderNo();
+            orderNo.setPatientId(patientId);
+            orderNo.setTimes(times);
+            orderNo.setReceiptNo(entry.getValue().get(0).getReceiptNo());
+            orderNo.setOrderNo(entry.getKey());
+            BigDecimal total = new BigDecimal("0.00");
+            for (MzReceipt receipt : entry.getValue()) {
+                total = total.add(receipt.getChargeFee());
+            }
+            orderNo.setTotalFee(total);
+            int count = dao.selectFeeCount(patientId, times, receiptNo, entry.getKey());
+            orderNo.setStatus(count > 0);
+            orderNos.add(orderNo);
+        }
+        return orderNos;
+    }
+
+    private MzReceipt fillMzReceipt(Map<String, Object> detail) {
+        MzReceipt receipt = new MzReceipt();
+        receipt.setChecked(!detail.get("tcName").toString().contains("外送艾迪康"));
+        receipt.setReceiptNo((int) detail.get("receiptNo"));
+        receipt.setOrderNo((int) detail.get("orderNo"));
+        receipt.setItemNo((int) detail.get("itemNo"));
+        receipt.setDrugName(detail.get("tcName").toString());
+        receipt.setChargeItemCode(detail.get("chargeItemCode").toString());
+        receipt.setPriceTime(DateUtil.formatPriceTime(detail.get("priceTime").toString()));
+        receipt.setUnitPrice(new BigDecimal(detail.get("unitPrice").toString()).setScale(4, BigDecimal.ROUND_HALF_UP));
+        receipt.setQuantity((double) detail.get("quantity"));
+        receipt.setDrugWin((int) detail.get("drugWin"));
+        receipt.setDoctorCode(detail.get("doctorCode").toString());
+        receipt.setSerialNo(detail.get("serialNo").toString());
+        receipt.setGroupNo(detail.get("groupNo").toString());
+        receipt.setBillItemCode(detail.get("billItemCode").toString());
+        receipt.setChargeBillCode(detail.get("chargeBillCode").toString());
+        if (null != detail.get("instructionText")) {
+            receipt.setInstructionText(detail.get("instructionText").toString());
+        }
+        if (null != detail.get("specification")) {
+            receipt.setSpecification(detail.get("specification").toString());
+        }
+        if (null != detail.get("frequency")) {
+            receipt.setFrequency(detail.get("frequency").toString());
+        }
+        if (null != detail.get("drugQuan")) {
+            receipt.setDrugQuan((Double) detail.get("drugQuan"));
+        }
+        if (null != detail.get("orderDays")) {
+            receipt.setOrderDays((Integer) detail.get("orderDays"));
+        }
+        // groupNo:00-项目;其他-药品
+        if ("00".equals(receipt.getGroupNo())) {
+            receipt.setDrugUnit(dao.selectXmChargeUnit(receipt.getChargeItemCode()));
+        } else {
+            if (null != detail.get("serial")) {
+                receipt.setSerial(detail.get("serial").toString());
+                receipt.setSpecification(dao.selectSpecification(receipt.getChargeItemCode(), receipt.getSerial()));
+            }
+            if (null != detail.get("supplyCode")) {
+                receipt.setSupplyCode(dao.selectSupplyName(detail.get("supplyCode").toString()));
+            }
+            if (null != detail.get("drugUnit")) {
+                receipt.setDrugUnit(dao.selectDrugUnit(detail.get("drugUnit").toString()));
+            }
+        }
+        return receipt;
+    }
+
     public ResultVo<String> insertMtFees(MarkMtFeeParam param) {
         if (param.getResponceType().equals(ResponceType.HUNAN_PROVINCIAL_MEDICAL_INSURANCE)) {
             param.setYbType("13");