| 
														
															@@ -9,7 +9,6 @@ import lombok.extern.slf4j.Slf4j; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.apache.commons.collections4.ListUtils; 
														 | 
														
														 | 
														
															 import org.apache.commons.collections4.ListUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
														
														 | 
														
															 import org.springframework.stereotype.Service; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.transaction.annotation.Transactional; 
														 | 
														
														 | 
														
															 import org.springframework.transaction.annotation.Transactional; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import org.springframework.web.client.RestTemplate; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import thyyxxk.webserver.config.exception.BizException; 
														 | 
														
														 | 
														
															 import thyyxxk.webserver.config.exception.BizException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import thyyxxk.webserver.config.exception.ExceptionEnum; 
														 | 
														
														 | 
														
															 import thyyxxk.webserver.config.exception.ExceptionEnum; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import thyyxxk.webserver.constants.Capacity; 
														 | 
														
														 | 
														
															 import thyyxxk.webserver.constants.Capacity; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -221,9 +220,12 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      */ 
														 | 
														
														 | 
														
															      */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public ResultVo<Map<String, Object>> confirmOrders(XinZhenYiZhu param) { 
														 | 
														
														 | 
														
															     public ResultVo<Map<String, Object>> confirmOrders(XinZhenYiZhu param) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         QueryWrapper<?> qw = new QueryWrapper<>(); 
														 | 
														
														 | 
														
															         QueryWrapper<?> qw = new QueryWrapper<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        qw.eq("a.inpatient_no", param.getInpatientNo()).eq("a.admiss_times", param.getAdmissTimes()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        qw.eq("a.status_flag", "1"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        qw.eq("a.enter_oper", TokenUtil.getTokenUserId()); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        qw.eq("a.inpatient_no", param.getInpatientNo()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .eq("a.admiss_times", param.getAdmissTimes()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .eq("a.status_flag", "1") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .eq("a.enter_oper", TokenUtil.getTokenUserId()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                // 排除出院带药的医嘱 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .ne("a.self_buy", "4"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         param.setList(dao.huoQuYiZhuShuJu(qw)); 
														 | 
														
														 | 
														
															         param.setList(dao.huoQuYiZhuShuJu(qw)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<XinZhenYzActOrder> yiZhuList = param.getList(); 
														 | 
														
														 | 
														
															         List<XinZhenYzActOrder> yiZhuList = param.getList(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (ListUtil.isBlank(yiZhuList)) { 
														 | 
														
														 | 
														
															         if (ListUtil.isBlank(yiZhuList)) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -233,8 +235,6 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         Set<String> yaoPingCode = new HashSet<>(); 
														 | 
														
														 | 
														
															         Set<String> yaoPingCode = new HashSet<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         // 项目的 code 
														 | 
														
														 | 
														
															         // 项目的 code 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         Set<String> xiangMuCode = new HashSet<>(); 
														 | 
														
														 | 
														
															         Set<String> xiangMuCode = new HashSet<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        // 出院带药需要生成药单 key 是不同的药房。不同的药房就要 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        Map<String, List<XinZhenYzActOrder>> takeTheMedicineList = new HashMap<>(Capacity.TWO); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (XinZhenYzActOrder item : yiZhuList) { 
														 | 
														
														 | 
														
															         for (XinZhenYzActOrder item : yiZhuList) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (ITEM.equals(item.getSerial())) { 
														 | 
														
														 | 
														
															             if (ITEM.equals(item.getSerial())) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -242,16 +242,6 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } else { 
														 | 
														
														 | 
														
															             } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 yaoPingCode.add(item.getOrderCode().trim() + item.getSerial().trim()); 
														 | 
														
														 | 
														
															                 yaoPingCode.add(item.getOrderCode().trim() + item.getSerial().trim()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            // 费用标志为 4 的就是出院带药 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if ("4".equals(item.getSelfBuy())) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                if (takeTheMedicineList.containsKey(item.getGroupNo())) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    takeTheMedicineList.get(item.getGroupNo()).add(item); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    List<XinZhenYzActOrder> temp = new ArrayList<>(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    temp.add(item); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    takeTheMedicineList.put(item.getGroupNo(), temp); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         // 合理用药校验 
														 | 
														
														 | 
														
															         // 合理用药校验 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -301,10 +291,11 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 if (!isThereAnyErrorMessage && errorMessageMap.containsKey("error")) { 
														 | 
														
														 | 
														
															                 if (!isThereAnyErrorMessage && errorMessageMap.containsKey("error")) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     isThereAnyErrorMessage = true; 
														 | 
														
														 | 
														
															                     isThereAnyErrorMessage = true; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                map.put(item.getId(), errorMessageMap); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 errorMessageMap.put("data", item); 
														 | 
														
														 | 
														
															                 errorMessageMap.put("data", item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                map.put(item.getId(), errorMessageMap); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (isThereAnyErrorMessage) { 
														 | 
														
														 | 
														
															         if (isThereAnyErrorMessage) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             return ResultVoUtil.fail(ExceptionEnum.ERROR_MESSAGE, "请修改错误的医嘱", map); 
														 | 
														
														 | 
														
															             return ResultVoUtil.fail(ExceptionEnum.ERROR_MESSAGE, "请修改错误的医嘱", map); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -316,7 +307,6 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             dao.stopOrder(param.getInpatientNo(), param.getAdmissTimes(), excludeOrders, userCode, orderNo); 
														 | 
														
														 | 
														
															             dao.stopOrder(param.getInpatientNo(), param.getAdmissTimes(), excludeOrders, userCode, orderNo); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        dischargeMedicineList(takeTheMedicineList, huanZheXinXi); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (BigDecimal decimal : confirmOrderInformation) { 
														 | 
														
														 | 
														
															         for (BigDecimal decimal : confirmOrderInformation) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             dao.confirmOrders(decimal, userCode, new Date()); 
														 | 
														
														 | 
														
															             dao.confirmOrders(decimal, userCode, new Date()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -344,7 +334,6 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             dao.summarySheetOfDrugs(pageNo, huanZheXinXi, userCode, entry.getKey()); 
														 | 
														
														 | 
														
															             dao.summarySheetOfDrugs(pageNo, huanZheXinXi, userCode, entry.getKey()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             dao.insertDetailedMedicineList(pageNo, huanZheXinXi, userCode, entry.getKey(), entry.getValue()); 
														 | 
														
														 | 
														
															             dao.insertDetailedMedicineList(pageNo, huanZheXinXi, userCode, entry.getKey(), entry.getValue()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -378,7 +367,6 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if (data.getParentNo() != null) { 
														 | 
														
														 | 
														
															         if (data.getParentNo() != null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             data.setSupplyCode("044"); 
														 | 
														
														 | 
														
															             data.setSupplyCode("044"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         // 药品的 code 
														 | 
														
														 | 
														
															         // 药品的 code 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         Set<String> yaoPingCode = new HashSet<>(); 
														 | 
														
														 | 
														
															         Set<String> yaoPingCode = new HashSet<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         // 项目的 code 
														 | 
														
														 | 
														
															         // 项目的 code 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -1062,10 +1050,6 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                         item.setDrugOcc(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getPackSize(), 2), total)); 
														 | 
														
														 | 
														
															                         item.setDrugOcc(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getPackSize(), 2), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                         item.setDrugQuan(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getPackSize()), total)); 
														 | 
														
														 | 
														
															                         item.setDrugQuan(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getPackSize()), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     } 
														 | 
														
														 | 
														
															                     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    dao.updateThePickup(item); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    log.info("领量:{},occ:{},天数:{},服用次数:{}", item.getDrugQuan(), item.getDrugOcc(), day, total); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    log.info("出院带药确认频次:{},一天服用次数:{}", item.getFrequCode(), times); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } else { 
														 | 
														
														 | 
														
															                 } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     // 计算普通药品的领量 durg_quan durg_occ 
														 | 
														
														 | 
														
															                     // 计算普通药品的领量 durg_quan durg_occ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     calculateDrugAmount(item, feiYongXinXi, 错误信息); 
														 | 
														
														 | 
														
															                     calculateDrugAmount(item, feiYongXinXi, 错误信息); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -1520,4 +1504,145 @@ public class YiZhuLuRuServer { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 批量检验医嘱是否正确 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param list         医嘱数据 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param huanZheXinXi 患者信息 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param rationalUse  是否要用合理用药 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public Map<String, Object> batchVerification(List<XinZhenYzActOrder> list, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                                                 XinZhenYiZhu huanZheXinXi, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                                                 boolean rationalUse) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, Object> returnMap = new HashMap<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // 药品 code 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Set<String> yaoPingCode = new HashSet<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // 项目的 code 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Set<String> xiangMuCode = new HashSet<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        huanZheXinXi.setList(list); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // 合理用药校验 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, List<String>> rationalUseOfMedicine = rationalUse ? rationalUseServer.jiaoYan(huanZheXinXi) : new HashMap<>(list.size()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (XinZhenYzActOrder item : list) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (ITEM.equals(item.getSerial())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                xiangMuCode.add(item.getOrderCode()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                yaoPingCode.add(item.getOrderCode().trim() + item.getSerial().trim()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String userCode = TokenUtil.getTokenUserId(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // 获取医生开药品的权限 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Integer doctorLevel = dao.huoQuYiShenDengJi(userCode); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, XinZhenYzActOrder> drug = getDrugInformation(yaoPingCode, huanZheXinXi.getZkWard()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, List<XinZhenYzActOrder>> project = getProjectInformation(xiangMuCode); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (XinZhenYzActOrder item : list) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String key = item.getId(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            Map<String, Object> errorMessageMap = checkData(item, drug, project, huanZheXinXi, doctorLevel); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (rationalUseOfMedicine.containsKey(key)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                List<String> temp = (List<String>) errorMessageMap.get("error"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (temp == null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    errorMessageMap.put("error", rationalUseOfMedicine.get(key)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    temp.addAll(rationalUseOfMedicine.get(key)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (!errorMessageMap.isEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (errorMessageMap.get("error") != null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    errorMessageMap.put("data", item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    returnMap.put(item.getId(), errorMessageMap); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return returnMap; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 确认出院带药医嘱 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param patNo 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @param times 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * @return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public ResultVo<Map<String, Object>> confirmTheDoctorSOrderWithMedicine(String patNo, Integer times) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        QueryWrapper<?> qw = new QueryWrapper<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        qw.eq("a.inpatient_no", patNo) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .eq("a.admiss_times", times) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .eq("a.status_flag", "1") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .eq("a.enter_oper", TokenUtil.getTokenUserId()) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                .eq("a.self_buy", "4"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        XinZhenYiZhu patInfo = dao.huoQuHuanZheXinXi(patNo, times); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        patInfo.setList(dao.huoQuYiZhuShuJu(qw)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (dao.obtainTheNumberOfDischargedDrugs(patNo, times) > 4) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "出院带药医嘱不得超过 4 种,且不得超过 15 天。"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String userCode = TokenUtil.getTokenUserId(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        // 出院带药需要生成药单 key 是不同的药房。不同的药房就要 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, List<XinZhenYzActOrder>> takeTheMedicineList = new HashMap<>(Capacity.TWO); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (XinZhenYzActOrder item : patInfo.getList()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            XinZhenYzActOrder feiYongXinXi = dao.getDrugOne(item.getOrderCode() + item.getSerial(), item.getGroupNo()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int day = 1; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 如果是临时医嘱 开了就结束了. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if ("ONCE".equals(item.getFrequCode())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                item.setEndTime(item.getStartTime()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (item.getStartTime() != null && item.getEndTime() != null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                long cha = item.getEndTime().getTime() - item.getStartTime().getTime(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                long nd = 1000 * 24 * 60 * 60; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                day = (int) (cha / nd); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 计算出院带药的领量 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            Map<String, Short> numberOfTimesADay = dao.numberOfTimesADay(item.getFrequCode()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            int tempTimes = 1; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            for (Map.Entry<String, Short> entry : numberOfTimesADay.entrySet()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (entry.getValue() != null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    tempTimes += entry.getValue(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 最小天数一天 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            BigDecimal total = new BigDecimal((day <= 0 ? 1 : day) * tempTimes); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (StringUtil.notBlank(feiYongXinXi.getDrugWeightUnit()) && item.getDoseUnit().trim().equals(feiYongXinXi.getDrugWeightUnit().trim())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                item.setDrugOcc(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getDrugWeight(), 2), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                item.setDrugQuan(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getDrugWeight()), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } else if (StringUtil.notBlank(feiYongXinXi.getDrugVolUnit()) && item.getDoseUnit().trim().equals(feiYongXinXi.getDrugVolUnit())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                item.setDrugOcc(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getDrugVolume(), 2), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                item.setDrugQuan(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getDrugVolume()), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } else if (StringUtil.notBlank(feiYongXinXi.getPackUnit()) && item.getDoseUnit().trim().equals(feiYongXinXi.getPackUnit())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                item.setDrugOcc(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getPackSize(), 2), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                item.setDrugQuan(DecimalUtil.multiply(DecimalUtil.divide(item.getDose(), feiYongXinXi.getPackSize()), total)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 在这里更新出院带药领量 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            dao.updateThePickup(item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 费用标志为 4 的就是出院带药 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if ("4".equals(item.getSelfBuy())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (takeTheMedicineList.containsKey(item.getGroupNo())) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    takeTheMedicineList.get(item.getGroupNo()).add(item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    List<XinZhenYzActOrder> temp = new ArrayList<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    temp.add(item); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    takeTheMedicineList.put(item.getGroupNo(), temp); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Map<String, Object> check = batchVerification(patInfo.getList(), patInfo, true); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (check.isEmpty()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            for (XinZhenYzActOrder order : patInfo.getList()) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                // 确认医嘱 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                dao.confirmOrders(order.getActOrderNo(), userCode, new Date()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            // 生成药单 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            dischargeMedicineList(takeTheMedicineList, patInfo); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } else { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            return ResultVoUtil.fail(ExceptionEnum.ERROR_MESSAGE, "请修改有错误的医嘱。", check); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 |