|
@@ -538,8 +538,22 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
ypMzFytjList = ypMzFytjMapper.selectXyTyYpMzFytj(patientId, refundTimes);
|
|
|
if (ypMzFytjList != null && ypMzFytjList.size() > 0) {
|
|
|
for (YpMzFytj ypMzFytj : ypMzFytjList) {
|
|
|
- MzChargeDetail mzChargeDetail = mzChargeDetailMapper.selectMzChargeDetailByChargeItemCode(ypMzFytj.getPatientId(), ypMzFytj.getTimes(), ypMzFytj.getChargeItemCode());
|
|
|
+ MzChargeDetail mzChargeDetail = mzChargeDetailMapper.selectMzChargeDetailByChargeItemCode(ypMzFytj.getPatientId(), ypMzFytj.getTimes(), ypMzFytj.getChargeItemCode(),ypMzFytj.getOrderNo());
|
|
|
Integer syCount = BigDecimal.valueOf(mzChargeDetail.getQuantity()).subtract(mzChargeDetail.getDecAmount()==null?BigDecimal.ZERO:mzChargeDetail.getDecAmount()).intValue();
|
|
|
+ //皮试药特别逻辑
|
|
|
+ if(Constants.XYF.equals(mzChargeDetail.getBillItemCode())){
|
|
|
+ BigDecimal origPrice= mzChargeDetail.getOrigPrice();
|
|
|
+ origPrice=origPrice==null?BigDecimal.ZERO:origPrice;
|
|
|
+ BigDecimal unitPrice= mzChargeDetail.getUnitPrice();
|
|
|
+ unitPrice=unitPrice==null?BigDecimal.ZERO:unitPrice;
|
|
|
+ //如果原价大于单价,说明是皮试自备
|
|
|
+ if(origPrice.compareTo(unitPrice)==1){
|
|
|
+ if (Integer.valueOf(1).equals(syCount)){
|
|
|
+ syCount=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (syCount <= 0) {
|
|
|
continue;
|
|
|
}
|
|
@@ -833,6 +847,13 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
if (lastMzVisitTable != null && lastMzVisitTable.getTimes() != null && lastMzVisitTable.getTimes() > times) {
|
|
|
times = lastMzVisitTable.getTimes();
|
|
|
}
|
|
|
+ MzPatientMi mzPatientMi=mzPatientMiMapper.selectByPatientId(mzDepositFileVo.getPatientId());
|
|
|
+ if(mzPatientMi==null){
|
|
|
+ throw new MzException("当前病人信息不存在,请先保存病人信息!");
|
|
|
+ }
|
|
|
+ if(mzPatientMi.getTimes()!=null && mzPatientMi.getTimes()>times){
|
|
|
+ times = mzPatientMi.getTimes();
|
|
|
+ }
|
|
|
times++;
|
|
|
if (YesNoEnum.YES.equals(yesNo)) {
|
|
|
MzVisitTable newMzVisitTable = getMzVisitTable(opId, mzChargeDetails, times, now);
|
|
@@ -845,15 +866,29 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
int receiptNo = 1;
|
|
|
for (MzChargeDetail md : mzChargeDetails) {
|
|
|
MzChargeDetail temp = null;
|
|
|
- if (chargeItemCodeList.contains(md.getChargeItemCode())) {
|
|
|
+ if (chargeItemCodeList.contains(md.getOrderNo()+"_"+md.getChargeItemCode())) {
|
|
|
if (Constants.XYF.equals(md.getBillItemCode())) {
|
|
|
if (ConfirmFlagEnum.DONE.code.equals(md.getConfirmFlag()) && md.getDecAmount() != null && md.getDecAmount().compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ Double oriQuantity=md.getQuantity();
|
|
|
BigDecimal surplus = BigDecimal.valueOf(md.getQuantity()).subtract(md.getDecAmount());
|
|
|
if (surplus.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
temp = CloneUtil.clone(md);
|
|
|
temp.setQuantity(surplus.doubleValue());
|
|
|
BigDecimal proportion = BigDecimal.valueOf(md.getQuantity()).divide(BigDecimal.valueOf(md.getSupplyAmount()));
|
|
|
temp.setSupplyAmount(BigDecimal.valueOf(md.getQuantity()).divide(proportion).intValue());
|
|
|
+ BigDecimal origPrice= temp.getOrigPrice();
|
|
|
+ origPrice=origPrice==null?BigDecimal.ZERO:origPrice;
|
|
|
+ BigDecimal unitPrice= temp.getUnitPrice();
|
|
|
+ unitPrice=unitPrice==null?BigDecimal.ZERO:unitPrice;
|
|
|
+ //如果原价大于单价,说明是皮试自备
|
|
|
+ if(origPrice.compareTo(unitPrice)==1){
|
|
|
+ //如果只剩一直,单价为0
|
|
|
+ if (surplus.compareTo(BigDecimal.ONE) == 0) {
|
|
|
+ temp.setUnitPrice(BigDecimal.ZERO);
|
|
|
+ }else {
|
|
|
+ temp.setUnitPrice(BigDecimal.valueOf(oriQuantity).multiply(md.getUnitPrice()).subtract(md.getDecAmount().multiply(md.getOrigPrice())).divide(surplus));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}else if(Constants.CYF.equals(md.getBillItemCode())){
|
|
@@ -894,9 +929,6 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
List<MzChargeDetail> supplyFeeMzChargeDetails = new ArrayList<>();
|
|
|
//重新计算给药方式费用
|
|
|
itemNo = formatSupplyFee(supplyFeeMzChargeDetails, newMzChargeDetailList, itemNo);
|
|
|
- MzPatientMi mzPatientMi = new MzPatientMi();
|
|
|
- mzPatientMi.setName(mzChargeDetails.get(0).getName());
|
|
|
- mzPatientMi.setResponseType(mzChargeDetails.get(0).getResponceType());
|
|
|
formatPriceRoundDetail(new MzChargeDetail(mzDepositFileVo.getPatientId(), times), supplyFeeMzChargeDetails, mzPatientMi, newMzChargeDetailList, 127, itemNo, receiptNo);
|
|
|
List<String> supplyList = supplyFeeMzChargeDetails.stream().filter(u -> StringUtils.isNotBlank(u.getChargeItemCode())).map(u -> u.getChargeItemCode()).collect(Collectors.toList());
|
|
|
List<MzChargeDetail> removeList = new ArrayList<>();
|