|
@@ -334,7 +334,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
getMzChargeDetailService().saveMzChargeDetail(mzChargeDetails);
|
|
|
mzChargeDetail.setPrintFlag(YesNoEnum.NO.code.toString());
|
|
|
mzChargeDetail.setReceiptNo(receiptNo);
|
|
|
- mzChargeDetailMapper.setTempDataReceiptNo(mzChargeDetail.getPatientId(),mzChargeDetail.getTimes(),receiptNo);
|
|
|
+ mzChargeDetailMapper.setTempDataReceiptNo(mzChargeDetail.getPatientId(), mzChargeDetail.getTimes(), receiptNo);
|
|
|
mzChargeDetailMapper.updatePayMakAndPrintFlag(mzChargeDetail);
|
|
|
//入库收费明细数据结束
|
|
|
|
|
@@ -535,9 +535,6 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
m.setCashId(opId);
|
|
|
m.setChargeDate(now);
|
|
|
m.setPayMark(PayMarkEnum.CHARGED.code);
|
|
|
- if (Constants.BYJZ.equals(chequeType)) {
|
|
|
- m.setRealNo(Integer.valueOf("1" + serialNo));
|
|
|
- }
|
|
|
setChargeDetail(mzDrugWinMap, yffyNoMap, orderNoMap, m);
|
|
|
mzChargeDetailMapper.updateMzChargeDetail(m);
|
|
|
itemNoMap.put(m.getChargeItemCode().trim(), m.getItemNo());
|
|
@@ -703,12 +700,13 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
//updateMzReceiptSerial.setPayMark(PayMarkEnum.RETURN_PREMIUM.code);
|
|
|
updateMzReceiptSerial.setTfFlag(YesNoEnum.YES.code);
|
|
|
mzReceiptSerialMapper.updateMzReceiptSerial(updateMzReceiptSerial);
|
|
|
- List<MzDepositFile> newMzDepositFiles = new ArrayList<>();
|
|
|
+ //包含退费的付款方式
|
|
|
+ List<MzDepositFile> fullNewMzDepositFiles = new ArrayList<>();
|
|
|
int times = 0;
|
|
|
if (allRefund) {
|
|
|
- getDeposFiles(opId, mzDepositFileVo, now, 0, 0, null, null, newMzDepositFiles, allRefund);
|
|
|
+ getDeposFiles(opId, mzDepositFileVo, now, 0, 0, null, null, fullNewMzDepositFiles, allRefund,null);
|
|
|
//新增收费方式记录
|
|
|
- mzDepositFileMapper.batchInsertMzDepositFile(newMzDepositFiles);
|
|
|
+ mzDepositFileMapper.batchInsertMzDepositFile(fullNewMzDepositFiles);
|
|
|
times = 0;
|
|
|
} else {
|
|
|
times = mzChargeDetails.get(0).getTimes();
|
|
@@ -751,11 +749,17 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
//实际应付金额
|
|
|
BigDecimal totalPayable = getTotalPayable(mzChargeDetails, feeMap);
|
|
|
MzReceiptSerial mzReceiptSerial = new MzReceiptSerial();
|
|
|
+ //退费后新的收款方式
|
|
|
+ List<MzDepositFile> newMzDepositFiles = new ArrayList<>();
|
|
|
String payWay = Constants.CASH;
|
|
|
- payWay = getDeposFiles(opId, mzDepositFileVo, now, times, serialNo, totalPayable, payWay, newMzDepositFiles, allRefund);
|
|
|
- setMzReceiptSerial(opId, mzDepositFileVo.getPatientId(), times, windows, mzChargeDetails.get(0).getResponceType(), feeMap, now, serialNo, mzReceiptSerial, payWay, totalPayable, 1);
|
|
|
+ payWay = getDeposFiles(opId, mzDepositFileVo, now, times, serialNo, totalPayable, payWay, fullNewMzDepositFiles, allRefund,newMzDepositFiles);
|
|
|
+ //setMzReceiptSerial(opId, mzDepositFileVo.getPatientId(), times, windows, mzChargeDetails.get(0).getResponceType(), feeMap, now, serialNo, mzReceiptSerial, payWay, totalPayable, 1);
|
|
|
+ MzPatientMi mzPatientMi = mzPatientMiService.queryByPatientId(mzDepositFileVo.getPatientId());
|
|
|
+ mzDepositFileVo.setMzDepositFiles(newMzDepositFiles);
|
|
|
+ mzDepositFileVo.setTimes(times);
|
|
|
+ getHadPayable(opId, mzDepositFileVo, windows, mzPatientMi, feeMap, now, serialNo, mzReceiptSerial, 1);
|
|
|
getMzChargeDetailService().updateChargeFlag(opId, mzDepositFileVo.getPatientId(), times, mzChargeDetails.get(0).getName(), mzChargeDetails, now, serialNo, payWay, mzDepositFileVo.getTimes());
|
|
|
- getMzChargeDetailService().afterChargeFee(mzDepositFileVo.getPatientId(), times, newMzDepositFiles, now, serialNo, mzReceiptSerial, totalPayable);
|
|
|
+ getMzChargeDetailService().afterChargeFee(mzDepositFileVo.getPatientId(), times, fullNewMzDepositFiles, now, serialNo, mzReceiptSerial, totalPayable);
|
|
|
MzPatientMi updateMzPatientMi = new MzPatientMi();
|
|
|
updateMzPatientMi.setPatientId(mzDepositFileVo.getPatientId());
|
|
|
updateMzPatientMi.setTimes(times);
|
|
@@ -810,7 +814,11 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mz.setCharge18(BigDecimal.ZERO.subtract(mz.getCharge18()));
|
|
|
mz.setCharge19(BigDecimal.ZERO.subtract(mz.getCharge19()));
|
|
|
mz.setCharge20(BigDecimal.ZERO.subtract(mz.getCharge20()));
|
|
|
- mz.setChequeType(Constants.CASH);
|
|
|
+ if(Constants.BYJZ.equals(mz.getChequeType())){
|
|
|
+ mz.setChequeType(Constants.BYJZ);
|
|
|
+ }else {
|
|
|
+ mz.setChequeType(Constants.CASH);
|
|
|
+ }
|
|
|
mz.setDcountNo(YesNoEnum.NO.code);
|
|
|
mz.setDcountDate(null);
|
|
|
mz.setChargeDcountDate(null);
|
|
@@ -864,12 +872,17 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
* @param serialNo
|
|
|
* @param totalPayable
|
|
|
* @param payWay
|
|
|
+ * @param fullNewMzDepositFiles
|
|
|
* @param newMzDepositFiles
|
|
|
* @return
|
|
|
*/
|
|
|
- private String getDeposFiles(String opId, MzDepositFileVo mzDepositFileVo, Date now, int times, int serialNo, BigDecimal totalPayable, String payWay, List<MzDepositFile> newMzDepositFiles, boolean allRefund) {
|
|
|
+ private String getDeposFiles(String opId, MzDepositFileVo mzDepositFileVo, Date now, int times, int serialNo, BigDecimal totalPayable, String payWay, List<MzDepositFile> fullNewMzDepositFiles, boolean allRefund,List<MzDepositFile> newMzDepositFiles) {
|
|
|
List<MzDepositFile> mzDepositFiles = mzDepositFileMapper.selectMzDepositFileByTimes(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
|
if (mzDepositFiles != null || mzDepositFiles.size() > 0) {
|
|
|
+ //本院记账总额
|
|
|
+ BigDecimal byjzAmount = BigDecimal.ZERO;
|
|
|
+ //非本院记账总额
|
|
|
+ BigDecimal notByjzAmount = BigDecimal.ZERO;
|
|
|
MzDepositFile temp = CloneUtil.clone(mzDepositFiles.get(0));
|
|
|
temp.setReceiptNo(-temp.getReceiptNo());
|
|
|
temp.setAmount(BigDecimal.ZERO.subtract(temp.getAmount()));
|
|
@@ -885,17 +898,28 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
temp.setPsordnum(null);
|
|
|
temp.setAgtordnum(null);
|
|
|
temp.setHisrefundnum(null);
|
|
|
- newMzDepositFiles.add(temp);
|
|
|
- BigDecimal amount = BigDecimal.ZERO;
|
|
|
for (MzDepositFile ms : mzDepositFiles) {
|
|
|
if (ms != null) {
|
|
|
- if (StringUtils.isNotBlank(ms.getChequeType())) {
|
|
|
- payWay = ms.getChequeType();
|
|
|
+ if (Constants.BYJZ.equals(ms.getChequeType())) {
|
|
|
+ byjzAmount = byjzAmount.add(ms.getAmount());
|
|
|
+ } else {
|
|
|
+ notByjzAmount = notByjzAmount.add(ms.getAmount());
|
|
|
}
|
|
|
- amount = amount.add(ms.getAmount());
|
|
|
}
|
|
|
}
|
|
|
- temp.setAmount(BigDecimal.ZERO.subtract(amount));
|
|
|
+ temp.setAmount(BigDecimal.ZERO.subtract(notByjzAmount));
|
|
|
+ //复制一个本院记账的退款记录
|
|
|
+ MzDepositFile byjzTemp = CloneUtil.clone(temp);
|
|
|
+ byjzTemp.setChequeType(Constants.BYJZ);
|
|
|
+ byjzTemp.setAmount(BigDecimal.ZERO.subtract(byjzAmount));
|
|
|
+ //如果有本院记账的退款金额,本院记账记录保持入库
|
|
|
+ if (byjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ fullNewMzDepositFiles.add(byjzTemp);
|
|
|
+ }
|
|
|
+ //如果有非本院记账的退款金额,非本院记账记录保持入库
|
|
|
+ if (notByjzAmount.compareTo(BigDecimal.ZERO) == 1) {
|
|
|
+ fullNewMzDepositFiles.add(temp);
|
|
|
+ }
|
|
|
if (!allRefund) {
|
|
|
MzDepositFile m = mzDepositFiles.get(0);
|
|
|
m.setTimes(times);
|
|
@@ -907,12 +931,30 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
m.setOpId(opId);
|
|
|
m.setReceiptSn(serialNo);
|
|
|
m.setSerialNo(serialNo);
|
|
|
- m.setChequeType(Constants.CASH);
|
|
|
- m.setAmount(totalPayable);
|
|
|
m.setPsordnum(null);
|
|
|
m.setAgtordnum(null);
|
|
|
m.setHisrefundnum(null);
|
|
|
- newMzDepositFiles.add(m);
|
|
|
+ //应付小于等于实际已经支付的非记账总额
|
|
|
+ if (totalPayable.compareTo(notByjzAmount) <= 0) {
|
|
|
+ m.setAmount(totalPayable);
|
|
|
+ m.setChequeType(Constants.CASH);
|
|
|
+ fullNewMzDepositFiles.add(m);
|
|
|
+ //应付大于实际已经支付的非记账总额,需要用记账收一部分
|
|
|
+ payWay = Constants.CASH;
|
|
|
+ newMzDepositFiles.add(m);
|
|
|
+ } else if (totalPayable.compareTo(notByjzAmount) == 1) {
|
|
|
+ m.setAmount(notByjzAmount);
|
|
|
+ m.setChequeType(Constants.CASH);
|
|
|
+ fullNewMzDepositFiles.add(m);
|
|
|
+ //复制一个本院记账的收款记录
|
|
|
+ MzDepositFile byjzNeedPayTemp = CloneUtil.clone(m);
|
|
|
+ byjzNeedPayTemp.setChequeType(Constants.BYJZ);
|
|
|
+ byjzNeedPayTemp.setAmount(totalPayable.subtract(notByjzAmount).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
+ fullNewMzDepositFiles.add(byjzNeedPayTemp);
|
|
|
+ newMzDepositFiles.add(m);
|
|
|
+ newMzDepositFiles.add(byjzNeedPayTemp);
|
|
|
+ payWay = Constants.BYJZ;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return payWay;
|
|
@@ -1254,20 +1296,22 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
//排除本院记账的金额
|
|
|
BigDecimal excludeByjzPay = BigDecimal.ZERO;
|
|
|
for (MzDepositFile m : mzDepositFileVo.getMzDepositFiles()) {
|
|
|
- m.setPatientId(mzDepositFileVo.getPatientId());
|
|
|
- m.setTimes(mzDepositFileVo.getTimes());
|
|
|
- m.setReceiptNo(receiptNo);
|
|
|
- m.setPayMark(PayMarkEnum.CHARGED.code);
|
|
|
- m.setChargeDate(now);
|
|
|
- m.setDcountNo(YesNoEnum.NO.code);
|
|
|
- m.setOpId(opId);
|
|
|
- m.setReceiptSn(serialNo);
|
|
|
- m.setSerialNo(serialNo);
|
|
|
- m.setResponceType(mzPatientMi == null ? "" : mzPatientMi.getResponseType());
|
|
|
- m.setDeptNo(windows.getDeptNo());
|
|
|
+ if(m.getPatientId()==null){
|
|
|
+ //此时是直接收费,需要设置相关参数
|
|
|
+ m.setPatientId(mzDepositFileVo.getPatientId());
|
|
|
+ m.setTimes(mzDepositFileVo.getTimes());
|
|
|
+ m.setReceiptNo(receiptNo);
|
|
|
+ m.setPayMark(PayMarkEnum.CHARGED.code);
|
|
|
+ m.setChargeDate(now);
|
|
|
+ m.setDcountNo(YesNoEnum.NO.code);
|
|
|
+ m.setOpId(opId);
|
|
|
+ m.setReceiptSn(serialNo);
|
|
|
+ m.setSerialNo(serialNo);
|
|
|
+ m.setResponceType(mzPatientMi == null ? "" : mzPatientMi.getResponseType());
|
|
|
+ m.setDeptNo(windows.getDeptNo());
|
|
|
+ }
|
|
|
hadPayable = hadPayable.add(m.getAmount());
|
|
|
if (Constants.BYJZ.equals(m.getChequeType())) {
|
|
|
- m.setReceiptSn(Integer.valueOf("1" + serialNo));
|
|
|
if (chequeType == null) {
|
|
|
chequeType = Constants.BYJZ;
|
|
|
}
|
|
@@ -1328,14 +1372,8 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
mzReceiptSerial.setTotalCharge(hadPayable);
|
|
|
mzReceiptSerial.setChargeDate(now);
|
|
|
mzReceiptSerial.setChequeType(chequeType);
|
|
|
- if (Constants.BYJZ.equals(chequeType)) {
|
|
|
- String str = serialNo + patientId.split("-")[0] + times + "1";
|
|
|
- mzReceiptSerial.setReceiptBill(str);
|
|
|
- mzReceiptSerial.setReceiptSn(Integer.valueOf("1" + serialNo));
|
|
|
- } else {
|
|
|
- mzReceiptSerial.setReceiptSn(serialNo);
|
|
|
- mzReceiptSerial.setReceiptBill("");
|
|
|
- }
|
|
|
+ mzReceiptSerial.setReceiptSn(serialNo);
|
|
|
+ mzReceiptSerial.setReceiptBill("");
|
|
|
mzReceiptSerial.setWindowsNo(windows.getWindowsNo().toString());
|
|
|
mzReceiptSerial.setDcountNo(YesNoEnum.NO.code);
|
|
|
mzReceiptSerial.setChargeDcountNo(YesNoEnum.NO.code);
|
|
@@ -1446,7 +1484,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
private List<MzDepositFile> getMzDepositFiles(MzDepositFileVo mzDepositFileVo, Date now, int serialNo, String opId) {
|
|
|
List<MzDepositFile> newList = new ArrayList<>();
|
|
|
List<MzDepositFile> mzDepositFiles = mzDepositFileMapper.selectMzDepositFileByTimes(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
|
- if(mzDepositFiles==null || mzDepositFiles.size()==0){
|
|
|
+ if (mzDepositFiles == null || mzDepositFiles.size() == 0) {
|
|
|
mzDepositFiles = mzDepositFileMapper.selectMzDepositFileByTimesInHisData(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo());
|
|
|
}
|
|
|
if (mzDepositFiles != null && mzDepositFiles.size() > 0) {
|
|
@@ -1793,20 +1831,20 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
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 ) {
|
|
|
+ if (ypZdDict != null && ypZdDict.getMzRestrict() != null) {
|
|
|
//当前处方购药量
|
|
|
- BigDecimal thisQuantity =BigDecimal.valueOf(mcd.getQuantity()).multiply(BigDecimal.valueOf(mcd.getDrugWin()));
|
|
|
+ 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){
|
|
|
+ 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;
|
|
|
+ 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 + "】请联系医生修改处方限制购药品种的数量");
|
|
|
}
|
|
|
}
|
|
|
//非口服用药方式,需要写入收费记录
|
|
@@ -1849,7 +1887,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
|
|
|
newMzChargeDetail.setTcName(zdChargeItem.getName());
|
|
|
newMzChargeDetail.setBillItemCode(Constants.ZLF);
|
|
|
//给药方式执行次数如果为空,默认为1次
|
|
|
- newMzChargeDetail.setQuantity(Double.valueOf(newMzChargeDetail.getSupplyAmount()==null?1:newMzChargeDetail.getSupplyAmount()));
|
|
|
+ newMzChargeDetail.setQuantity(Double.valueOf(newMzChargeDetail.getSupplyAmount() == null ? 1 : newMzChargeDetail.getSupplyAmount()));
|
|
|
newMzChargeDetail.setSupplyAmount(null);
|
|
|
mzChargeDetails.add(newMzChargeDetail);
|
|
|
}
|