|
@@ -1863,24 +1863,26 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
if (ypZdDict != null) {
|
|
|
//当前处方购药量
|
|
|
BigDecimal thisQuantity = BigDecimal.valueOf(mzChargeDetail.getQuantity()).multiply(BigDecimal.valueOf(mzChargeDetail.getDrugWin()));
|
|
|
- if (ypZdDict.getMzRestrict() != null) {
|
|
|
- //本月已经购买量
|
|
|
- Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getFirstSecondForMonth(new Date()));
|
|
|
- quantityDb = quantityDb == null ? 0 : quantityDb;
|
|
|
- BigDecimal totalQuantity = thisQuantity.add(BigDecimal.valueOf(quantityDb));
|
|
|
- if (totalQuantity.compareTo(BigDecimal.valueOf(ypZdDict.getMzRestrict())) == 1) {
|
|
|
- //当前还可以购药量,小于0时为0
|
|
|
- BigDecimal tempCount = BigDecimal.valueOf(ypZdDict.getMzRestrict()).subtract(BigDecimal.valueOf(quantityDb));
|
|
|
- if (tempCount.compareTo(BigDecimal.ZERO) == -1) {
|
|
|
- tempCount = BigDecimal.ZERO;
|
|
|
+ if(needVerify){
|
|
|
+ if (ypZdDict.getMzRestrict() != null) {
|
|
|
+ //本月已经购买量
|
|
|
+ Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getFirstSecondForMonth(new Date()));
|
|
|
+ quantityDb = quantityDb == null ? 0 : quantityDb;
|
|
|
+ BigDecimal totalQuantity = thisQuantity.add(BigDecimal.valueOf(quantityDb));
|
|
|
+ if (totalQuantity.compareTo(BigDecimal.valueOf(ypZdDict.getMzRestrict())) == 1) {
|
|
|
+ //当前还可以购药量,小于0时为0
|
|
|
+ BigDecimal tempCount = BigDecimal.valueOf(ypZdDict.getMzRestrict()).subtract(BigDecimal.valueOf(quantityDb));
|
|
|
+ if (tempCount.compareTo(BigDecimal.ZERO) == -1) {
|
|
|
+ tempCount = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最大购买量为【" + ypZdDict.getMzRestrict() + "】,本月已购买量为【" + quantityDb + "】,本次最大可购量为【" + tempCount + "】,当前处方购药数量【" + thisQuantity + "】请修改处方限制购药品种的数量");
|
|
|
}
|
|
|
- throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最大购买量为【" + ypZdDict.getMzRestrict() + "】,本月已购买量为【" + quantityDb + "】,本次最大可购量为【" + tempCount + "】,当前处方购药数量【" + thisQuantity + "】请修改处方限制购药品种的数量");
|
|
|
}
|
|
|
- }
|
|
|
- if (ypZdDict.getPrescriptionLimitDays() != null && ypZdDict.getPrescriptionLimitDays() > 0) {
|
|
|
- Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getDateFromNow(-ypZdDict.getPrescriptionLimitDays()));
|
|
|
- if (quantityDb != null && quantityDb > 0) {
|
|
|
- throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最近"+ypZdDict.getPrescriptionLimitDays()+"天已经购买过该药品!");
|
|
|
+ if (ypZdDict.getPrescriptionLimitDays() != null && ypZdDict.getPrescriptionLimitDays() > 0) {
|
|
|
+ Integer quantityDb = mzChargeDetailMapper.selectTotalQuantityForDate(mzChargeDetail.getPatientId(), mzChargeDetail.getChargeItemCode(), mzChargeDetail.getSerial(), DateUtil.getDateFromNow(-ypZdDict.getPrescriptionLimitDays()));
|
|
|
+ if (quantityDb != null && quantityDb > 0) {
|
|
|
+ throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过限购量,最近"+ypZdDict.getPrescriptionLimitDays()+"天已经购买过该药品!");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
String chargeBillCode = Constants.BILL_ITEM_CODE_prev + ypZdDict.getBillItemMz().substring(1);
|
|
@@ -1899,12 +1901,14 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
if (StringUtils.isBlank(mzChargeDetail.getFrequency())) {
|
|
|
throw new MzException("保存处方失败,第" + itemNo + "行药品频率不能为空");
|
|
|
}
|
|
|
- YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), Constants.XY_ZCY_GROUP_NO);
|
|
|
- if (ypBaseYf == null) {
|
|
|
- throw new MzException("无药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的库存信息!");
|
|
|
- }
|
|
|
- if(thisQuantity.compareTo(ypBaseYf.getStockAmountVirtual()==null?BigDecimal.ZERO:BigDecimal.valueOf(ypBaseYf.getStockAmountVirtual()))==1){
|
|
|
- throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过库存数量,该药品实际库存"+(ypBaseYf.getStockAmountVirtual()==null?0:ypBaseYf.getStockAmountVirtual())+"请调整该药品数量!");
|
|
|
+ if(needVerify){
|
|
|
+ YpBaseYf ypBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), Constants.XY_ZCY_GROUP_NO);
|
|
|
+ if (ypBaseYf == null) {
|
|
|
+ throw new MzException("无药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的库存信息!");
|
|
|
+ }
|
|
|
+ if(thisQuantity.compareTo(ypBaseYf.getStockAmountVirtual()==null?BigDecimal.ZERO:BigDecimal.valueOf(ypBaseYf.getStockAmountVirtual()))==1){
|
|
|
+ throw new MzException("药品【" + ypZdDict.getName() + "】编码【" + ypZdDict.getCode() + "】的药品超过库存数量,该药品实际库存"+(ypBaseYf.getStockAmountVirtual()==null?0:ypBaseYf.getStockAmountVirtual())+"请调整该药品数量!");
|
|
|
+ }
|
|
|
}
|
|
|
if (Constants.CLF.equals(ypZdDict.getBillItemMz())) {
|
|
|
YpBaseYf ycBaseYf = ypBaseYfMapper.selectYpBaseYf(ypZdDict.getCode(), ypZdDict.getSerial(), Constants.YC_GROUP_NO);
|