|
@@ -34,9 +34,9 @@ import thyyxxk.webserver.service.redislike.RedisLikeService;
|
|
|
import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -65,6 +65,8 @@ public class YiZhuLuRuServer {
|
|
|
*/
|
|
|
private final String ZK_CODE = "06286";
|
|
|
private final String ONCE = "ONCE";
|
|
|
+ private final int 出院带药限制天数 = 15;
|
|
|
+ private final int 出院带药限制数量 = 4;
|
|
|
|
|
|
private final String ITEM = "00";
|
|
|
private final String SMALL_PACKAGE = "01";
|
|
@@ -545,23 +547,22 @@ public class YiZhuLuRuServer {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVo<String> voidOrders(String orderNo, String reasonForCancellation) {
|
|
|
XinZhenYzActOrder yz = dao.getActOrderNoOne(orderNo);
|
|
|
-
|
|
|
if (yz == null) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "原医嘱找不到了。");
|
|
|
}
|
|
|
-
|
|
|
if ("6".equals(yz.getStatusFlag())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医嘱已作废了。");
|
|
|
}
|
|
|
-
|
|
|
UserInfo userInfo = redisLikeService.getUserInfoByToken();
|
|
|
-
|
|
|
if (!DateUtil.within24Hours(yz.getStartTime())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "只能对24小时内的医嘱进行作废处理");
|
|
|
}
|
|
|
|
|
|
List<String> list = dao.getTheDoctorSDepartment(userInfo.getDeptCode());
|
|
|
list.add(userInfo.getDeptCode());
|
|
|
+ if (publicServer.needRule(1)) {
|
|
|
+ list.add(yz.getWardCode());
|
|
|
+ }
|
|
|
|
|
|
if (!list.contains(yz.getWardCode())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "非本科室开的医嘱不可作废");
|
|
@@ -576,9 +577,9 @@ public class YiZhuLuRuServer {
|
|
|
// 患者最大的 detail_sn
|
|
|
int maxDetailSn = publicServer.getMaxDetailSn(yz.getInpatientNo(), yz.getAdmissTimes());
|
|
|
dao.cancelMedicalTechnologyAssuranceFee(TokenUtil.getTokenUserId(), orderNo, yz.getInpatientNo(), yz.getAdmissTimes());
|
|
|
-
|
|
|
// 如果是药品的话就需要自动退费
|
|
|
if (!yz.getSerial().equals(ITEM)) {
|
|
|
+ // 获取父子医嘱同时退费
|
|
|
List<String> parentNoList = dao.getParentChildOrders(orderNo);
|
|
|
parentNoList.add(orderNo);
|
|
|
List<ZyDetailCharge> feeList = dao.getExpenseData(yz.getInpatientNo(), yz.getAdmissTimes(), parentNoList);
|
|
@@ -927,7 +928,12 @@ public class YiZhuLuRuServer {
|
|
|
}
|
|
|
item.setDrugOcc(DecimalUtil.divide(item.getDose(), feiYongXinXi.getPackSize(), 2));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ BigDecimal a = new BigDecimal("1");
|
|
|
+ BigDecimal b = new BigDecimal("0.2");
|
|
|
+ System.out.println(DecimalUtil.divide(a, b));
|
|
|
}
|
|
|
|
|
|
private Map<String, Object> checkData(XinZhenYzActOrder item, Map<String, XinZhenYzActOrder> drug, Map<String, List<XinZhenYzActOrder>> project, XinZhenYiZhu huanZheXinXi, Integer 医生级别) {
|
|
@@ -961,9 +967,12 @@ public class YiZhuLuRuServer {
|
|
|
if (StringUtil.isBlank(feiYongXinXi.getNationalCode())) {
|
|
|
警告信息.add("该药品没有医保编码");
|
|
|
}
|
|
|
- if (feiYongXinXi.getStockAmount() != null && BigUtils.bigXiaoYu(feiYongXinXi.getStockAmount(), 10)) {
|
|
|
+ if (BigUtils.bigXiaoYu(feiYongXinXi.getStockAmount(), 10)) {
|
|
|
警告信息.add(String.format("该药品剩余数量为:【%s】", feiYongXinXi.getStockAmount().stripTrailingZeros().toPlainString()));
|
|
|
}
|
|
|
+ if (BigUtils.bigDaYu(item.getDrugQuan(), feiYongXinXi.getStockAmount())) {
|
|
|
+ 错误信息.add("药品领量大于药品的库存,当前库存量" + feiYongXinXi.getStockAmount().stripTrailingZeros().toPlainString());
|
|
|
+ }
|
|
|
if (严格校验) {
|
|
|
if (feiYongXinXi.getDeptRestrictions() > 0) {
|
|
|
错误信息.add("该药品禁止在患者所在的科室使用。");
|
|
@@ -1001,24 +1010,23 @@ public class YiZhuLuRuServer {
|
|
|
long cha = item.getEndTime().getTime() - item.getStartTime().getTime();
|
|
|
long nd = 1000 * 24 * 60 * 60;
|
|
|
day = (int) (cha / nd);
|
|
|
- if (day > 15) {
|
|
|
+ if (day > 出院带药限制天数) {
|
|
|
错误信息.add("出院带药天数不得超过 15 天,计算方式结束时间减去开始时间。");
|
|
|
}
|
|
|
}
|
|
|
BigDecimal total = getTotal(item, day);
|
|
|
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));
|
|
|
-
|
|
|
+ item.setDrugQuan(DecimalUtil.multiply(item.getDose(), total).divide(feiYongXinXi.getDrugWeight(), 0, RoundingMode.UP));
|
|
|
+ item.setDrugOcc(item.getDrugQuan());
|
|
|
} 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));
|
|
|
+ item.setDrugQuan(DecimalUtil.multiply(item.getDose(), total).divide(feiYongXinXi.getDrugVolume(), 0, RoundingMode.UP));
|
|
|
+ item.setDrugOcc(item.getDrugQuan());
|
|
|
} else if (StringUtil.notBlank(feiYongXinXi.getPackUnit()) && item.getDoseUnit().trim().equals(feiYongXinXi.getPackUnit())) {
|
|
|
if (new BigDecimal(item.getDose().intValue()).compareTo(item.getDose()) != 0) {
|
|
|
错误信息.add("已经是最小单位了请不要带小数点");
|
|
|
}
|
|
|
- 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(item.getDose(), total).divide(feiYongXinXi.getPackSize(), 0, RoundingMode.UP));
|
|
|
+ item.setDrugOcc(item.getDrugQuan());
|
|
|
}
|
|
|
} else {
|
|
|
// 计算普通药品的领量 durg_quan durg_occ
|
|
@@ -1118,7 +1126,7 @@ public class YiZhuLuRuServer {
|
|
|
private BigDecimal getTotal(XinZhenYzActOrder item, int day) {
|
|
|
// 计算出院带药的领量
|
|
|
Map<String, Short> numberOfTimesADay = dao.numberOfTimesADay(item.getFrequCode());
|
|
|
- int times = 1;
|
|
|
+ int times = 0;
|
|
|
for (Map.Entry<String, Short> entry : numberOfTimesADay.entrySet()) {
|
|
|
if (entry.getValue() != null) {
|
|
|
times += entry.getValue();
|
|
@@ -1566,7 +1574,7 @@ public class YiZhuLuRuServer {
|
|
|
.eq("isnull(a.self_buy,'0')", "4");
|
|
|
XinZhenYiZhu patInfo = dao.huoQuHuanZheXinXi(patNo, times);
|
|
|
patInfo.setList(dao.huoQuYiZhuShuJu(qw));
|
|
|
- if (dao.obtainTheNumberOfDischargedDrugs(patNo, times) > 4) {
|
|
|
+ if (dao.obtainTheNumberOfDischargedDrugs(patNo, times) > 出院带药限制数量) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "出院带药医嘱不得超过 4 种,且不得超过 15 天。");
|
|
|
}
|
|
|
String userCode = TokenUtil.getTokenUserId();
|
|
@@ -1588,15 +1596,14 @@ public class YiZhuLuRuServer {
|
|
|
// 计算出院带药的领量
|
|
|
BigDecimal total = getTotal(item, day);
|
|
|
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));
|
|
|
-
|
|
|
+ item.setDrugQuan(DecimalUtil.multiply(item.getDose(), total).divide(feiYongXinXi.getDrugWeight(), 0, RoundingMode.UP));
|
|
|
+ item.setDrugOcc(item.getDrugQuan());
|
|
|
} 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));
|
|
|
+ item.setDrugQuan(DecimalUtil.multiply(item.getDose(), total).divide(feiYongXinXi.getDrugVolume(), 0, RoundingMode.UP));
|
|
|
+ item.setDrugOcc(item.getDrugQuan());
|
|
|
} 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));
|
|
|
+ item.setDrugQuan(DecimalUtil.multiply(item.getDose(), total).divide(feiYongXinXi.getPackSize(), 0, RoundingMode.UP));
|
|
|
+ item.setDrugOcc(item.getDrugQuan());
|
|
|
}
|
|
|
// 在这里更新出院带药领量
|
|
|
dao.updateThePickup(item);
|
|
@@ -1615,8 +1622,8 @@ public class YiZhuLuRuServer {
|
|
|
Map<String, Object> check = batchVerification(patInfo.getList(), patInfo, true);
|
|
|
if (check.isEmpty()) {
|
|
|
for (XinZhenYzActOrder order : patInfo.getList()) {
|
|
|
- // 确认医嘱
|
|
|
- dao.confirmOrders(order.getActOrderNo(), userCode, new Date());
|
|
|
+ // 出院带药 确认了直接停止医嘱
|
|
|
+ dao.takeMedicineAfterDischargeStopOrder(order.getActOrderNo(), userCode, new Date());
|
|
|
}
|
|
|
// 生成药单
|
|
|
dischargeMedicineList(takeTheMedicineList, patInfo);
|