|
@@ -1,6 +1,7 @@
|
|
|
package cn.hnthyy.thmz.service.impl.his;
|
|
|
|
|
|
import cn.hnthyy.thmz.Utils.CloneUtil;
|
|
|
+import cn.hnthyy.thmz.Utils.DateUtil;
|
|
|
import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.common.SpringUtil;
|
|
|
import cn.hnthyy.thmz.entity.MzException;
|
|
@@ -59,6 +60,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
private MzDepositFileService mzDepositFileService;
|
|
|
@Autowired
|
|
|
private MzReceiptSerialService mzReceiptSerialService;
|
|
|
+ @Autowired
|
|
|
+ private YpZdDictService ypZdDictService;
|
|
|
@SuppressWarnings("all")
|
|
|
@Autowired
|
|
|
private MzDepositFileMapper mzDepositFileMapper;
|
|
@@ -1787,8 +1790,25 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- private Integer formatSupplyFee(List<MzChargeDetail> mzChargeDetails, List<MzChargeDetail> mzChargeDetailList, Integer itemNo, Integer receiptNo) {
|
|
|
+ private Integer formatSupplyFee(List<MzChargeDetail> mzChargeDetails, List<MzChargeDetail> mzChargeDetailList, Integer itemNo, Integer receiptNo) throws MzException {
|
|
|
for (MzChargeDetail mcd : mzChargeDetailList) {
|
|
|
+ YpZdDict ypZdDict = ypZdDictService.queryYpZdDictByCode(mcd.getChargeItemCode(), mcd.getSerial());
|
|
|
+ if (ypZdDict != null && ypZdDict.getMzRestrict()!=null ) {
|
|
|
+ //当前处方购药量
|
|
|
+ BigDecimal thisQuantity =BigDecimal.valueOf(mcd.getQuantity()).multiply(BigDecimal.valueOf(mcd.getDrugWin()));
|
|
|
+ //本月已经购买量
|
|
|
+ Integer quantityDb=mzChargeDetailMapper.selectTotalQuantityForMonth(mcd.getPatientId(),mcd.getChargeItemCode(),mcd.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+"】请联系医生修改处方限制购药品种的数量");
|
|
|
+ }
|
|
|
+ }
|
|
|
//非口服用药方式,需要写入收费记录
|
|
|
if (StringUtils.isNotBlank(mcd.getSupplyCode()) && !Constants.KOU_FU_SUPPLY_CODE.equals(mcd.getSupplyCode())) {
|
|
|
List<MzZdSupplyCharge> mzZdSupplyChargeList = mzZdSupplyChargeService.queryMzZdSupplyChargeByCode(mcd.getSupplyCode());
|