Sfoglia il codice sorgente

完善门特处方获取方式。

lighter 4 anni fa
parent
commit
7840b76419

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>6.5</version>
+    <version>6.6</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
 

+ 3 - 27
src/main/java/thyyxxk/webserver/dao/his/markmtfees/MarkMtFeesDao.java

@@ -102,34 +102,10 @@ public interface MarkMtFeesDao {
     MzVisit selectMzVisit(@Param("patientId") String patientId,
                           @Param("times") Integer times);
 
-    @Select("SELECT drugname=b.name,a.patient_id,a.times,a.receipt_no,a.order_no,a.item_no,a.charge_item_code," +
-            "a.charge_bill_code,a.quantity,a.unit_price,a.orig_price,a.pay_mark,a.serial,a.serial_no,a.charge_date," +
-            "a.group_no,specification=b.specification,a.confirm_flag,a.print_flag,a.exec_dept,a.warn_dept,a.drug_win," +
-            "a.supply_code,a.drug_quan,a.drug_unit,a.frequency,a.price_id,a.price_time,dosage=b.dosage,a.windows_no_yf," +
-            "a.bill_item_code,doctor_code,cash_id,a.name,responce_type,a.tc_no,tc_name,a.instruction_text," +
-            "doctorName=(select rtrim(name) from a_employee_mi where code=doctor_code)," +
-            "del_flag=case when isnull(b.del_flag,'0')='1' or isnull(e.visible_flag_mz,'0')='1' then '1' else '0' end " +
-            "FROM mz_charge_detail a,yp_zd_dict b,yp_base_yf e,mz_zd_supply_type c WHERE a.charge_item_code=b.code and " +
-            "a.serial=b.serial and a.charge_item_code*=e.charge_code and a.serial*=e.serial and a.group_no*=e.group_no " +
-            "and a.patient_id=#{patientId} AND a.times=#{times} and a.group_no='71' and a.receipt_no=#{receiptNo} and " +
-            "a.supply_code*=c.supply_code " +
-            "union all " +
-            "SELECT drugname=case when a.bill_item_code='TC' then tc_name else b.name end,a.patient_id,a.times," +
-            "a.receipt_no,a.order_no,a.item_no,a.charge_item_code,a.charge_bill_code,a.quantity,a.unit_price,a.orig_price," +
-            "a.pay_mark,a.serial,a.serial_no,a.charge_date,a.group_no," +
-            "specification=case when a.bill_item_code='TC' then '处方套餐' else b.charge_unit end," +
-            "a.confirm_flag,a.print_flag,a.exec_dept,a.warn_dept,a.drug_win,a.supply_code,a.drug_quan,a.drug_unit," +
-            "a.frequency,a.price_id,a.price_time,dosage=char(4),a.windows_no_yf,a.bill_item_code,doctor_code,cash_id," +
-            "a.name,responce_type,tc_no,tc_name,a.instruction_text," +
-            "doctorName=(select rtrim(name) from a_employee_mi where code=doctor_code)," +
-            "del_flag=isnull(b.del_flag,'0') FROM mz_charge_detail a,zd_charge_item " +
-            "b,mz_zd_supply_type c WHERE a.charge_item_code*=b.code and a.patient_id=#{patientId} AND a.times=#{times} and " +
-            "a.receipt_no=#{receiptNo} and a.group_no='00' and a.supply_code*=c.supply_code")
-    List<MzReceipt> selectMzReceipts(@Param("patientId") String patientId,
-                                     @Param("times") Integer times,
-                                     @Param("receiptNo") Integer receiptNo);
-
     @Select("select top 1 responce_type from mt_part_info where patient_id=#{patientId} and times=#{times}")
     String selectResponceType(@Param("patientId") String patientId,
                               @Param("times") Integer times);
+
+    @Select("select rtrim(name) from a_employee_mi where code=#{code}")
+    String selectDoctorName(@Param("code") String code);
 }

+ 65 - 12
src/main/java/thyyxxk/webserver/service/markmtfees/MarkMtFeesService.java

@@ -7,6 +7,7 @@ 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.constants.HrgAddr;
 import thyyxxk.webserver.constants.ResponceType;
 import thyyxxk.webserver.dao.his.markmtfees.MarkMtFeesDao;
 import thyyxxk.webserver.entity.ResultVo;
@@ -129,25 +130,77 @@ public class MarkMtFeesService {
         }
         map.put("mzPatient", mzPatients.get(0));
         map.put("mzVisit", mzVisit);
-        List<MzReceipt> mzReceipts = dao.selectMzReceipts(patientId, times, mzVisit.getReceiptNo());
-        mzReceipts.removeIf(item -> "TC".equals(item.getBillItemCode()) || item.getPayMark() != 5 || "BILL99".equals(item.getChargeItemCode()));
-        Map<Integer, List<MzReceipt>> temp = new HashMap<>(Capacity.DEFAULT);
-        mzReceipts.forEach(item -> {
-            item.setChecked(true);
-            if (!temp.containsKey(item.getOrderNo())) {
+        JSONObject queryMzChargeList = new JSONObject();
+        queryMzChargeList.put("patCardType", 21);
+        queryMzChargeList.put("patCardNo", patientId);
+        queryMzChargeList.put("hisOrdNum", "");
+        RestTemplate template = new RestTemplate();
+        Map<String, Object> mzChargeListMap = template.postForObject(HrgAddr.GET_MZ_CHARGE_DETAIL_FOR_UN_PAID, queryMzChargeList, 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, String>> mzChargeList = FilterUtil.cast(mzChargeListMap.get("data"));
+        List<Map<String, Object>> mzChargeDetailList = new ArrayList<>();
+        mzChargeList.forEach(item -> {
+            String hisOrdNum = item.get("hisOrdNum");
+            if (null != hisOrdNum) {
+                String[] hisOrdNumParts = hisOrdNum.split("_");
+                if (Integer.parseInt(hisOrdNumParts[1]) == times) {
+                    JSONObject queryMzChargeDetail = new JSONObject();
+                    queryMzChargeDetail.put("patientId", patientId);
+                    queryMzChargeDetail.put("times", times);
+                    queryMzChargeDetail.put("receiptNo", hisOrdNumParts[2]);
+                    Map<String, Object> mzChargeDetailMap = template.postForObject(HrgAddr.UN_PAID_TO_FULL_CHARGE_DETAIL,
+                            queryMzChargeDetail, Map.class);
+                    if (null != mzChargeDetailMap && 0 == (int) mzChargeDetailMap.get("resultCode")) {
+                        List<Map<String, Object>> detail = FilterUtil.cast(mzChargeDetailMap.get("data"));
+                        mzChargeDetailList.addAll(detail);
+                    }
+                }
+            }
+        });
+        mzChargeDetailList.removeIf(item -> "TC".equals(item.get("billItemCode")) ||
+                !"5".equals(item.get("payMark")) || "BILL99".equals(item.get("chargeItemCode")) ||
+                "四舍五入".equals(item.get("tcName")));
+        Map<Integer, List<MzReceipt>> orderReceiptsMap = new HashMap<>(Capacity.DEFAULT);
+        String doctorName = dao.selectDoctorName(mzChargeDetailList.get(0).get("doctorCode").toString());
+        mzChargeDetailList.forEach(item -> {
+            MzReceipt receipt = new MzReceipt();
+            receipt.setChecked(!item.get("tcName").toString().contains("外送艾迪康"));
+            receipt.setPatientId(patientId);
+            receipt.setTimes(times);
+            receipt.setReceiptNo((int) item.get("receiptNo"));
+            receipt.setOrderNo((int) item.get("orderNo"));
+            receipt.setItemNo((int) item.get("itemNo"));
+            receipt.setDrugName(item.get("tcName").toString());
+            receipt.setChargeItemCode(item.get("chargeItemCode").toString());
+            receipt.setPriceTime(DateUtil.formatPriceTime(item.get("priceTime").toString()));
+            receipt.setUnitPrice(new BigDecimal(item.get("unitPrice").toString()).setScale(4, BigDecimal.ROUND_HALF_UP));
+            receipt.setQuantity((double) item.get("quantity"));
+            receipt.setDrugWin((int) item.get("drugWin"));
+            receipt.setDoctorCode(item.get("doctorCode").toString());
+            receipt.setDoctorName(doctorName);
+            receipt.setSerialNo(item.get("serialNo").toString());
+            receipt.setGroupNo(item.get("groupNo").toString());
+            receipt.setBillItemCode(item.get("billItemCode").toString());
+            receipt.setChargeBillCode(item.get("chargeBillCode").toString());
+            if (!orderReceiptsMap.containsKey(receipt.getOrderNo())) {
                 List<MzReceipt> list = new ArrayList<>();
-                list.add(item);
-                temp.put(item.getOrderNo(), list);
+                list.add(receipt);
+                orderReceiptsMap.put(receipt.getOrderNo(), list);
             } else {
-                temp.get(item.getOrderNo()).add(item);
+                orderReceiptsMap.get(receipt.getOrderNo()).add(receipt);
             }
         });
         List<OrderNo> orderNos = new ArrayList<>();
-        for (Map.Entry<Integer, List<MzReceipt>> entry : temp.entrySet()) {
+        for (Map.Entry<Integer, List<MzReceipt>> entry : orderReceiptsMap.entrySet()) {
             OrderNo orderNo = new OrderNo();
             orderNo.setPatientId(patientId);
             orderNo.setTimes(times);
-            orderNo.setReceiptNo(mzVisit.getReceiptNo());
+            orderNo.setReceiptNo(entry.getValue().get(0).getReceiptNo());
             orderNo.setOrderNo(entry.getKey());
             BigDecimal total = new BigDecimal("0.00");
             for (MzReceipt item : entry.getValue()) {
@@ -159,7 +212,7 @@ public class MarkMtFeesService {
             orderNos.add(orderNo);
         }
         map.put("orderNos", orderNos);
-        map.put("mzReceipts", temp);
+        map.put("mzReceipts", orderReceiptsMap);
         return ResultVoUtil.success(map);
     }