|
@@ -177,7 +177,33 @@ public class SiManageService {
|
|
|
fillInstStlLdgChk(instStlLdgChk, setlBrfs);
|
|
|
|
|
|
if (instStlLdgChk.getMode() == 2) {
|
|
|
- List<InstSetlLdgChkBrf> hisBrfs = dao.selectLedgerBrfsForHisCheck(startdate, enddate);
|
|
|
+ if (instStlLdgChk.getClrType().equals("11")) {
|
|
|
+ List<String> mzVisitIds = dao.selectHisMzBrfsForHisCheck(startdate, enddate);
|
|
|
+ List<String> unfoundTempList = new ArrayList<>();
|
|
|
+ for (InstSetlLdgChkBrf setl : setlBrfs) {
|
|
|
+ if (!mzVisitIds.contains(setl.getVisitId())) {
|
|
|
+ unfoundTempList.add(setl.getVisitId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (unfoundTempList.size() == 0) {
|
|
|
+ return ResultVoUtil.success("对账结果:平。对账结果说明:结算笔数:" + setlBrfs.size());
|
|
|
+ }
|
|
|
+ int offset = 0;
|
|
|
+ for (String visitId : unfoundTempList) {
|
|
|
+ String[] arr = visitId.split("_");
|
|
|
+ if (dao.mzDepositCount(arr[0], arr[1]) == 0) {
|
|
|
+ log.info("not found visitId: {}", visitId);
|
|
|
+ offset += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (offset == 0) {
|
|
|
+ return ResultVoUtil.success("对账结果:平。对账结果说明:结算笔数:" + setlBrfs.size());
|
|
|
+ }
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
|
|
|
+ "对账结果:不平。对账结果说明:有" + offset + "条医保结算没有找到对应的HIS门诊收费。");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<InstSetlLdgChkBrf> hisBrfs = dao.selectHisZyBrfsForHisCheck(startdate, enddate);
|
|
|
if (hisBrfs.size() != setlBrfs.size()) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
|
|
|
"对账结果:不平。对账结果说明:医保结算笔数:" + setlBrfs.size() + ";HIS结算笔数:" + hisBrfs.size());
|
|
@@ -240,10 +266,12 @@ public class SiManageService {
|
|
|
private void fillInstStlLdgChk(InstStlLdgChk instStlLdgChk, List<InstSetlLdgChkBrf> brfs) {
|
|
|
BigDecimal medfeesum = new BigDecimal("0");
|
|
|
BigDecimal acctpaysum = new BigDecimal("0");
|
|
|
+ BigDecimal psnCashPay = new BigDecimal("0");
|
|
|
BigDecimal fundpaysum = new BigDecimal("0");
|
|
|
for (InstSetlLdgChkBrf brf : brfs) {
|
|
|
medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
|
|
|
acctpaysum = DecimalUtil.add(acctpaysum, brf.getAcctPay());
|
|
|
+ psnCashPay = DecimalUtil.add(psnCashPay, brf.getPsnCashPay());
|
|
|
fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
|
|
|
if (null != brf.getHospPartAmt()) {
|
|
|
fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPartAmt());
|
|
@@ -251,42 +279,60 @@ public class SiManageService {
|
|
|
}
|
|
|
instStlLdgChk.setMedfeeSumamt(medfeesum);
|
|
|
instStlLdgChk.setAcctPay(acctpaysum);
|
|
|
+ instStlLdgChk.setCashPayamt(psnCashPay);
|
|
|
instStlLdgChk.setFundPaySumamt(fundpaysum);
|
|
|
instStlLdgChk.setFixmedinsSetlCnt(brfs.size());
|
|
|
}
|
|
|
|
|
|
- public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChk insSetlDetlChk) {
|
|
|
+ public ResultVo<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InstStlLdgChk setlChk) {
|
|
|
+ String startdate = DateUtil.getDayStartTime(setlChk.getStmtBegndate());
|
|
|
+ String enddate = DateUtil.getDayEndTime(setlChk.getStmtEnddate());
|
|
|
+ if (setlChk.getMode() == 2) {
|
|
|
+ if (setlChk.getClrType().equals("11")) {
|
|
|
+ return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "门诊暂不支持HIS与医保的明细对账。");
|
|
|
+ }
|
|
|
+ List<InstSetlLdgChkBrf> setlBrfs = dao.selectSetlinfoBrfsForHisCheck(setlChk.getClrType(), startdate, enddate);
|
|
|
+ List<InstSetlLdgChkBrf> hisBrfs = dao.selectHisZyBrfsForHisCheck(startdate, enddate);
|
|
|
+ Map<String, InstSetlLdgChkBrf> hisMap = new HashMap<>();
|
|
|
+ for (InstSetlLdgChkBrf brf : hisBrfs) {
|
|
|
+ hisMap.put(brf.getVisitId(), brf);
|
|
|
+ }
|
|
|
+ List<InsSetlDetlChkRslt> list = new ArrayList<>();
|
|
|
+ for (InstSetlLdgChkBrf setl : setlBrfs) {
|
|
|
+ InstSetlLdgChkBrf temp = hisMap.remove(setl.getVisitId());
|
|
|
+ if (null != temp) {
|
|
|
+ setl.setMedfeeSumamt2(temp.getMedfeeSumamt());
|
|
|
+ setl.setFundPaySumamt2(temp.getFundPaySumamt());
|
|
|
+ }
|
|
|
+ list.add(new InsSetlDetlChkRslt(setl));
|
|
|
+ }
|
|
|
+ if (hisMap.size() > 0) {
|
|
|
+ for (Map.Entry<String, InstSetlLdgChkBrf> entry : hisMap.entrySet()) {
|
|
|
+ InstSetlLdgChkBrf value = entry.getValue();
|
|
|
+ value.setMedfeeSumamt2(value.getMedfeeSumamt());
|
|
|
+ value.setFundPaySumamt2(value.getFundPaySumamt());
|
|
|
+ value.setMedfeeSumamt(null);
|
|
|
+ value.setFundPaySumamt(null);
|
|
|
+ list.add(new InsSetlDetlChkRslt(value));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<InstSetlLdgChkBrf> setlBrfs = dao.selectSetlChkBrfs(setlChk.getClrType(),
|
|
|
+ setlChk.getSetlOptins(), startdate, enddate);
|
|
|
+ fillInstStlLdgChk(setlChk, setlBrfs);
|
|
|
String snowId = SnowFlakeId.instance().nextId();
|
|
|
String filename = snowId + ".txt";
|
|
|
StringBuilder fsIn = new StringBuilder();
|
|
|
- String startdate = DateUtil.getDayStartTime(insSetlDetlChk.getStmtBegndate());
|
|
|
- String enddate = DateUtil.getDayEndTime(insSetlDetlChk.getStmtEnddate());
|
|
|
- List<InstSetlLdgChkBrf> brfs = dao.selectSetlChkBrfs(insSetlDetlChk.getClrType(),
|
|
|
- insSetlDetlChk.getSetlOptins(), startdate, enddate);
|
|
|
- BigDecimal medfeesum = new BigDecimal("0");
|
|
|
- BigDecimal psnCashPay = new BigDecimal("0");
|
|
|
- BigDecimal fundpaysum = new BigDecimal("0");
|
|
|
- for (InstSetlLdgChkBrf brf : brfs) {
|
|
|
- medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt());
|
|
|
- psnCashPay = DecimalUtil.add(psnCashPay, brf.getPsnCashPay());
|
|
|
- fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt());
|
|
|
- if (null != brf.getHospPartAmt()) {
|
|
|
- fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPartAmt());
|
|
|
- brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPartAmt()));
|
|
|
- }
|
|
|
- }
|
|
|
- insSetlDetlChk.setMedfeeSumamt(medfeesum);
|
|
|
- insSetlDetlChk.setCashPayamt(psnCashPay);
|
|
|
- insSetlDetlChk.setFundPaySumamt(fundpaysum);
|
|
|
- insSetlDetlChk.setFixmedinsSetlCnt(brfs.size());
|
|
|
- for (InstSetlLdgChkBrf item : brfs) {
|
|
|
+ for (InstSetlLdgChkBrf item : setlBrfs) {
|
|
|
fsIn.append(item.getSetlId()).append("\t")
|
|
|
.append(item.getMdtrtId()).append("\t")
|
|
|
.append(item.getPsnNo()).append("\t")
|
|
|
.append(item.getMedfeeSumamt()).append("\t")
|
|
|
.append(item.getFundPaySumamt()).append("\t")
|
|
|
.append(item.getAcctPay()).append("\t")
|
|
|
- .append(insSetlDetlChk.getRefdSetlFlag()).append("\n");
|
|
|
+ .append(setlChk.getRefdSetlFlag()).append("\n");
|
|
|
}
|
|
|
try {
|
|
|
Files.write(Paths.get(filename), fsIn.toString().getBytes());
|
|
@@ -297,13 +343,13 @@ public class SiManageService {
|
|
|
ResultVo<String> uplRes = upldServcie.uploadFile(JSONObject.parseObject(fsUploadIn), filename);
|
|
|
ZipUtil.deleteFile(zipFile);
|
|
|
if (uplRes.getCode().equals(ExceptionEnum.SUCCESS.getCode())) {
|
|
|
- insSetlDetlChk.setFileQuryNo(uplRes.getData());
|
|
|
+ setlChk.setFileQuryNo(uplRes.getData());
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
log.error("医药机构费用结算对明细账出错", e);
|
|
|
}
|
|
|
JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK);
|
|
|
- String ref = JSONObject.toJSONStringWithDateFormat(insSetlDetlChk, "yyyy-MM-dd");
|
|
|
+ String ref = JSONObject.toJSONStringWithDateFormat(setlChk, "yyyy-MM-dd");
|
|
|
input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
|
|
|
JSONObject result = exec.executeTrade(input, SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK);
|
|
|
log.info("【操作员:{}】,医药机构费用结算对明细账:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
|