SiZyService.java 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. package thyyxxk.webserver.service.medicalinsurance;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.beans.factory.annotation.Value;
  9. import org.springframework.stereotype.Service;
  10. import thyyxxk.webserver.config.envionment.MedinsurConfig;
  11. import thyyxxk.webserver.config.exception.BizException;
  12. import thyyxxk.webserver.config.exception.ExceptionEnum;
  13. import thyyxxk.webserver.constants.sidicts.*;
  14. import thyyxxk.webserver.constants.YesOrNo;
  15. import thyyxxk.webserver.dao.his.inpatient.PatientDao;
  16. import thyyxxk.webserver.dao.his.medicalinsurance.*;
  17. import thyyxxk.webserver.entity.ResultVo;
  18. import thyyxxk.webserver.entity.inpatient.patient.NotUploadedFee;
  19. import thyyxxk.webserver.entity.medicalinsurance.log.SiLog;
  20. import thyyxxk.webserver.entity.medicalinsurance.inpatient.*;
  21. import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
  22. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetldetail;
  23. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
  24. import thyyxxk.webserver.entity.inpatient.dismiss.MedinsSettleFee;
  25. import thyyxxk.webserver.entity.inpatient.patient.Overview;
  26. import thyyxxk.webserver.service.externalhttp.SiZySrvc;
  27. import thyyxxk.webserver.service.inpatient.DismissService;
  28. import thyyxxk.webserver.utils.*;
  29. import java.math.BigDecimal;
  30. import java.util.*;
  31. /**
  32. * @description: 住院医保交易
  33. * @author: DingJie
  34. * @create: 2021-05-14 16:28:16
  35. **/
  36. @Slf4j
  37. @Service
  38. public class SiZyService {
  39. private static final String RESULT_CODE = "infcode";
  40. private static final String ERROR_MESSAGE = "err_msg";
  41. private static final String OUTPUT = "output";
  42. private final SiZyDao dao;
  43. private final PatientDao patientDao;
  44. private final SiQueryService queryService;
  45. private final SiQueryDao queryDao;
  46. private final SiSetlinfoDao setlinfodao;
  47. private final SiSetldetailDao setldetldao;
  48. private final SiChargeTempDao chrgtmpdao;
  49. private final SiLogDao logDao;
  50. private final ExecService exec;
  51. private final DismissService dismissService;
  52. private final SiZySrvc zySrvc;
  53. private final MedinsurConfig cfg;
  54. @Value("${si-zy-fee-url}")
  55. private String siZyFeeUrl;
  56. @Autowired
  57. public SiZyService(SiZyDao dao, PatientDao patientDao, SiQueryService queryService, SiQueryDao queryDao, SiSetlinfoDao setlinfoDao,
  58. SiSetldetailDao setldetldao, SiChargeTempDao chrgtmpdao, SiLogDao logDao, ExecService exec,
  59. DismissService dismissService, SiZySrvc zySrvc, MedinsurConfig cfg) {
  60. this.dao = dao;
  61. this.patientDao = patientDao;
  62. this.queryService = queryService;
  63. this.queryDao = queryDao;
  64. this.setlinfodao = setlinfoDao;
  65. this.setldetldao = setldetldao;
  66. this.chrgtmpdao = chrgtmpdao;
  67. this.logDao = logDao;
  68. this.exec = exec;
  69. this.dismissService = dismissService;
  70. this.zySrvc = zySrvc;
  71. this.cfg = cfg;
  72. }
  73. public String admissRegister(ZyPatientInfo p, ZyOrJzYbData ybData) {
  74. AdmMdtrtinfo admMdtrtinfo = ybData.getAdmMdtrtinfo(p);
  75. List<AdmDiseinfo> admDiseinfos = ybData.getAdmDiseinfo(p.getInpatientNo(), p.getAdmissTimes());
  76. admDiseinfos.forEach(item -> {
  77. item.setDiseDorNo(admMdtrtinfo.getAtddrNo());
  78. item.setDiseDorName(admMdtrtinfo.getChfpdrName());
  79. });
  80. ReadCardBizType readCardBizType = ReadCardBizType.get(p.getReadCardBizType());
  81. if (readCardBizType != ReadCardBizType.ADMISSION) {
  82. String bizarea = cfg.getHospArea();
  83. if (StringUtil.notBlank(bizarea) && bizarea.length() > 2) {
  84. String areaHeader = bizarea.substring(0, 2);
  85. if (!p.getInsuplcAdmdvs().startsWith(areaHeader)) {
  86. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "省外异地的患者请读社保卡登记!");
  87. }
  88. }
  89. }
  90. if (readCardBizType == ReadCardBizType.ADMISSION) {
  91. MdtrtCertType mdtrtCertType = MdtrtCertType.getByLabel(p.getMdtrtCertType());
  92. admMdtrtinfo.setMdtrtCertType(mdtrtCertType.getCode());
  93. if (mdtrtCertType.getCode().equals(MdtrtCertType.SOCIAL_SECURITY_CARD.getCode())) {
  94. String[] out = p.getReadCardResult().split("\\|");
  95. if (!p.getName().trim().equals(out[4].trim())) {
  96. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "社保卡姓名与HIS姓名不一致,请确认是否人证相符。");
  97. }
  98. admMdtrtinfo.setMdtrtCertNo(out[2]);
  99. admMdtrtinfo.setCardSn(out[3]);
  100. } else if (mdtrtCertType.getCode().equals(MdtrtCertType.MEDICAL_INSURANCE_ELECTRONIC_VOUCHER.getCode())) {
  101. JSONObject qrinfo = JSONObject.parseObject(p.getReadCardResult());
  102. if (!p.getName().trim().equals(qrinfo.getString("userName").trim())) {
  103. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "电子医保凭证姓名与HIS姓名不一致,请确认是否人证相符。");
  104. }
  105. if (!p.getSocialNo().trim().equals(qrinfo.getString("idNo").trim())) {
  106. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "电子医保凭证身份证与HIS身份证不一致,请确认是否人证相符。");
  107. }
  108. admMdtrtinfo.setMdtrtCertNo(qrinfo.getString("ecToken"));
  109. }
  110. }
  111. if (StringUtil.isBlank(admMdtrtinfo.getDiseCodg())) {
  112. admMdtrtinfo.setDiseCodg(admDiseinfos.get(0).getDiagCode());
  113. admMdtrtinfo.setDiseName(admDiseinfos.get(0).getDiagName());
  114. }
  115. admMdtrtinfo.setInsutype(p.getInsutype());
  116. admMdtrtinfo.setAdmDiagDscr(admDiseinfos.get(0).getDiagName());
  117. admMdtrtinfo.setDscgMaindiagCode(admDiseinfos.get(0).getDiagCode());
  118. admMdtrtinfo.setDscgMaindiagName(admDiseinfos.get(0).getDiagName());
  119. admMdtrtinfo.setMatnType(p.getMatnType());
  120. admMdtrtinfo.setLatechbFlag(p.getLatechbFlag());
  121. admMdtrtinfo.setPretFlag(p.getPretFlag());
  122. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.ADMISSION_REGISTRATION, p.getInsuplcAdmdvs());
  123. String ref = JSONObject.toJSONStringWithDateFormat(admMdtrtinfo, "yyyy-MM-dd HH:mm:ss");
  124. input.getJSONObject("input").put("mdtrtinfo", JSONObject.parseObject(ref));
  125. String diseRef = JSONArray.toJSONStringWithDateFormat(admDiseinfos, "yyyy-MM-dd HH:mm:ss");
  126. input.getJSONObject("input").put("diseinfo", JSONArray.parse(diseRef));
  127. JSONObject result = exec.executeTrade(input, SiFunction.ADMISSION_REGISTRATION);
  128. if (null == result) {
  129. throw new BizException(ExceptionEnum.NETWORK_ERROR, "网络异常");
  130. }
  131. Integer infcode = result.getInteger(RESULT_CODE);
  132. if (null == infcode) {
  133. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  134. }
  135. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, admMdtrtinfo.getPsnNo()));
  136. if (result.getIntValue(RESULT_CODE) == 0) {
  137. JSONObject output = result.getJSONObject(OUTPUT);
  138. String mdtrtId = output.getJSONObject("result").getString("mdtrt_id");
  139. p.setMdtrtId(mdtrtId);
  140. p.setAdmRegMsgid(input.getString("msgid"));
  141. dao.afterAdmissRegister(p);
  142. String restype = dao.selectResponceType(admMdtrtinfo.getMedType());
  143. dao.updateResponceType(restype, admMdtrtinfo.getMedType(), p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  144. return "入院登记成功,就诊号为:" + mdtrtId;
  145. }
  146. throw new BizException(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  147. }
  148. public ResultVo<String> modifyAdmissionInfo(ZyPatientInfo p) {
  149. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  150. if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
  151. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者医保不在院!");
  152. }
  153. List<AdmDiseinfo> admDiseinfos = dao.selectAdmDiags(p.getInpatientNo(), p.getAdmissTimes());
  154. if (null == admDiseinfos || admDiseinfos.isEmpty()) {
  155. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请填写医保入院诊断!");
  156. }
  157. admDiseinfos.forEach(item -> item.setMdtrtId(siPatInfo.getMdtrtId()));
  158. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.MODIFY_ADMISSION_INFO, siPatInfo.getInsuplcAdmdvs());
  159. JSONObject adminfo = new JSONObject();
  160. adminfo.put("mdtrt_id", siPatInfo.getMdtrtId());
  161. adminfo.put("psn_no", siPatInfo.getPsnNo());
  162. adminfo.put("begntime", DateUtil.formatDatetime(p.getYbRegisterDate()));
  163. adminfo.put("mdtrt_cert_type", MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
  164. adminfo.put("med_type", siPatInfo.getMedType());
  165. adminfo.put("ipt_otp_no", p.getInpatientNo());
  166. adminfo.put("atddr_no", p.getReferPhysician());
  167. adminfo.put("chfpdr_name", p.getReferPhysicianName());
  168. adminfo.put("adm_diag_dscr", admDiseinfos.get(0).getDiagCode());
  169. adminfo.put("adm_dept_codg", p.getSmallDept());
  170. adminfo.put("adm_dept_name", p.getSmallDeptName());
  171. adminfo.put("adm_bed", p.getBedNo());
  172. adminfo.put("dscg_maindiag_code", admDiseinfos.get(0).getDiagCode());
  173. adminfo.put("dscg_maindiag_name", admDiseinfos.get(0).getDiagName());
  174. input.getJSONObject("input").put("adminfo", adminfo);
  175. String diseRef = JSONArray.toJSONStringWithDateFormat(admDiseinfos, "yyyy-MM-dd HH:mm:ss");
  176. input.getJSONObject("input").put("diseinfo", JSONArray.parse(diseRef));
  177. JSONObject result = exec.executeTrade(input, SiFunction.MODIFY_ADMISSION_INFO);
  178. Integer infcode = result.getInteger(RESULT_CODE);
  179. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, siPatInfo.getPsnNo()));
  180. return SiUtil.makeReturnWithoutOutput(result, "变更住院信息成功。");
  181. }
  182. public String revokeAdmission(ZyPatientInfo p) {
  183. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  184. if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
  185. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
  186. }
  187. revokeUploadFees(p);
  188. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.REVOKE_ADMISSION, siPatInfo.getInsuplcAdmdvs());
  189. JSONObject data = new JSONObject();
  190. data.put("mdtrt_id", siPatInfo.getMdtrtId());
  191. data.put("psn_no", siPatInfo.getPsnNo());
  192. input.getJSONObject("input").put("data", data);
  193. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_ADMISSION);
  194. if (null == result) {
  195. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  196. }
  197. Integer infcode = result.getInteger(RESULT_CODE);
  198. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, siPatInfo.getPsnNo()));
  199. if (null == infcode) {
  200. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  201. }
  202. if (infcode == 0) {
  203. queryDao.clearMdtrtIdForZy(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn(), null);
  204. dao.updateResponceType("01", null, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  205. return "取消入院登记成功。";
  206. }
  207. throw new BizException(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  208. }
  209. public ResultVo<String> uploadFeeDetail(Overview o) {
  210. o.setStaffId(TokenUtil.getInstance().getTokenUserId());
  211. return zySrvc.uploadFeeDetail(siZyFeeUrl, o);
  212. }
  213. public ResultVo<String> multipleUpload(List<Overview> overviews) {
  214. for (Overview o : overviews) {
  215. if (o.getStatus() == 0) {
  216. String message = String.format("【%s床,%s,%s】未进行医保登记,无法进行费用上传。",
  217. o.getBedNo(), o.getInpatientNo(), o.getName());
  218. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, message);
  219. }
  220. if (invalidMultipleUploadPatient(o.getMedType())) {
  221. String message = String.format("【%s床,%s,%s】是工伤患者,不支持批量上传。",
  222. o.getBedNo(), o.getInpatientNo(), o.getName());
  223. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, message);
  224. }
  225. o.setStaffId(TokenUtil.getInstance().getTokenUserId());
  226. }
  227. return zySrvc.uploadMultiplePatientFees(siZyFeeUrl, overviews);
  228. }
  229. private boolean invalidMultipleUploadPatient(String medtype) {
  230. MedType medType = MedType.get(medtype);
  231. return null == medType || medType == MedType.SELF_PAY;
  232. }
  233. public String hospitalizationPreSettlement(ZyPatientInfo p, ZyOrJzYbData ybData) {
  234. PreSetlmt preSetlmt = ybData.getPreSetlmt(p);
  235. preSetlmt.setMdtrtCertType(MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
  236. preSetlmt.setPsnSetlway(p.getDbg() ? PsnSetlWay.SETTLE_BY_QUOTA.getCode() : PsnSetlWay.SETTLE_BY_ITEMS.getCode());
  237. preSetlmt.setAcctUsedFlag(YesOrNo.NO.getCodeStr());
  238. preSetlmt.setMidSetlFlag(YesOrNo.NO.getCodeStr());
  239. preSetlmt.setMdtrtareaAdmvs(exec.getInstitutionArea(preSetlmt.getInsuplcAdmdvs()));
  240. preSetlmt.setDscgTime(dao.selectActOrderDisDate(p.getInpatientNo(), p.getAdmissTimes()));
  241. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.HOSPITALIZATION_PRE_SETTLEMENT, preSetlmt.getInsuplcAdmdvs());
  242. String ref = JSONObject.toJSONStringWithDateFormat(preSetlmt, "yyyy-MM-dd");
  243. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  244. JSONObject result = exec.executeTrade(input, SiFunction.HOSPITALIZATION_PRE_SETTLEMENT);
  245. if (null == result) {
  246. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  247. }
  248. Integer infcode = result.getInteger(RESULT_CODE);
  249. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, preSetlmt.getPsnNo()));
  250. if (null == infcode) {
  251. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  252. }
  253. if (infcode == 0) {
  254. JSONObject setlinfo = result.getJSONObject(OUTPUT).getJSONObject("setlinfo");
  255. String fundPay = setlinfo.getString("fund_pay_sumamt");
  256. dao.updateFundPay(fundPay, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  257. patientDao.recountDeposit(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  258. patientDao.updateBalance(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  259. String balance = patientDao.selectLedgerBalance(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  260. if (StringUtil.isBlank(balance)) {
  261. balance = "0";
  262. }
  263. patientDao.updateZyActPatientBalance(p.getInpatientNo(), balance);
  264. return "患者【" + p.getName() + "】院内总费用与医保中心总费用一致,医保报销金额为:¥ " + fundPay + "。";
  265. }
  266. throw new BizException(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  267. }
  268. public String revokeUploadFees(ZyPatientInfo p) {
  269. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  270. if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
  271. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的医保在院信息!");
  272. }
  273. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS, siPatInfo.getInsuplcAdmdvs());
  274. JSONArray data = new JSONArray();
  275. if (null == p.getDetailSns() || p.getDetailSns().isEmpty()) {
  276. JSONObject item = new JSONObject();
  277. item.put("feedetl_sn", "0000");
  278. item.put("mdtrt_id", siPatInfo.getMdtrtId());
  279. item.put("psn_no", siPatInfo.getPsnNo());
  280. data.add(item);
  281. } else {
  282. p.getDetailSns().forEach(detailSn -> {
  283. JSONObject item = new JSONObject();
  284. item.put("feedetl_sn", detailSn);
  285. item.put("mdtrt_id", siPatInfo.getMdtrtId());
  286. item.put("psn_no", siPatInfo.getPsnNo());
  287. data.add(item);
  288. });
  289. }
  290. input.getJSONObject("input").put("data", data);
  291. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS);
  292. if (null == result) {
  293. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  294. }
  295. Integer infcode = result.getInteger(RESULT_CODE);
  296. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, siPatInfo.getPsnNo()));
  297. if (null == infcode) {
  298. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  299. }
  300. if (infcode == 0) {
  301. QueryWrapper<SiChargeTemp> wrapper = new QueryWrapper<>();
  302. wrapper.eq("pat_no", p.getInpatientNo());
  303. wrapper.eq("times", p.getAdmissTimes());
  304. wrapper.eq("ledger_sn", p.getLedgerSn());
  305. if (null == p.getDetailSns() || p.getDetailSns().isEmpty()) {
  306. dao.revokeAllUploadFee(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  307. dao.resetFundpayAmt(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  308. chrgtmpdao.delete(wrapper);
  309. } else {
  310. wrapper.in("feedetl_sn", p.getDetailSns());
  311. chrgtmpdao.delete(wrapper);
  312. dao.revokePartUploadFee(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), p.getDetailSns());
  313. }
  314. return "撤销费用上传成功。";
  315. }
  316. throw new BizException(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  317. }
  318. public ResultVo<String> pairNegativeFee(NotUploadedFee fee) {
  319. if (null == fee.getOriDetailSn()) {
  320. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请先处理违规退费。");
  321. }
  322. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(fee.getPatNo(), fee.getTimes(), fee.getLedgerSn());
  323. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS,
  324. siPatInfo.getInsuplcAdmdvs());
  325. JSONArray data = new JSONArray();
  326. JSONObject item = new JSONObject();
  327. item.put("feedetl_sn", fee.getOriDetailSn());
  328. item.put("mdtrt_id", siPatInfo.getMdtrtId());
  329. item.put("psn_no", siPatInfo.getPsnNo());
  330. data.add(item);
  331. input.getJSONObject("input").put("data", data);
  332. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS);
  333. if (null == result) {
  334. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  335. }
  336. Integer infcode = result.getInteger(RESULT_CODE);
  337. logDao.insert(new SiLog(input, result, fee.getPatNo(), fee.getTimes(), fee.getLedgerSn(), infcode, siPatInfo.getPsnNo()));
  338. if (null == infcode) {
  339. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  340. }
  341. if (infcode == 0) {
  342. QueryWrapper<SiChargeTemp> wrapper = new QueryWrapper<>();
  343. wrapper.eq("pat_no", fee.getPatNo());
  344. wrapper.eq("times", fee.getTimes());
  345. wrapper.eq("ledger_sn", fee.getLedgerSn());
  346. wrapper.eq("feedetl_sn", fee.getOriDetailSn());
  347. dao.updateTransFlag(fee.getPatNo(), fee.getTimes(), fee.getDetailSn(), fee.getOriDetailSn());
  348. chrgtmpdao.delete(wrapper);
  349. }
  350. return ResultVoUtil.success("退费处理成功。");
  351. }
  352. public ResultVo<String> revokeSingleCharge(String patNo, int times, int ledgerSn, int detailSn) {
  353. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(patNo, times, ledgerSn);
  354. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS,
  355. siPatInfo.getInsuplcAdmdvs());
  356. JSONArray data = new JSONArray();
  357. JSONObject item = new JSONObject();
  358. item.put("feedetl_sn", detailSn);
  359. item.put("mdtrt_id", siPatInfo.getMdtrtId());
  360. item.put("psn_no", siPatInfo.getPsnNo());
  361. data.add(item);
  362. input.getJSONObject("input").put("data", data);
  363. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS);
  364. if (null == result) {
  365. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  366. }
  367. Integer infcode = result.getInteger(RESULT_CODE);
  368. logDao.insert(new SiLog(input, result, patNo, times, ledgerSn, infcode, siPatInfo.getPsnNo()));
  369. if (null == infcode) {
  370. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  371. }
  372. if (infcode == 0) {
  373. QueryWrapper<SiChargeTemp> wrapper = new QueryWrapper<>();
  374. wrapper.eq("pat_no", patNo);
  375. wrapper.eq("times", times);
  376. wrapper.eq("ledger_sn", ledgerSn);
  377. wrapper.eq("feedetl_sn", detailSn);
  378. chrgtmpdao.delete(wrapper);
  379. }
  380. return ResultVoUtil.success("处理成功。");
  381. }
  382. public String dischargeProcessing(ZyPatientInfo p, ZyOrJzYbData ybData) {
  383. if (null == p.getLedgerSn()) {
  384. p.setLedgerSn(dao.selectMaxLedgerSn(p.getInpatientNo(), p.getAdmissTimes()));
  385. }
  386. Dscginfo dscginfo = ybData.getDscginfo(p);
  387. List<SetlDiseinfo> setlDises = ybData.getSetlDiseinfo(p);
  388. if (null == p.getStaffId()) {
  389. p.setStaffId(TokenUtil.getInstance().getTokenUserId());
  390. }
  391. if (StringUtil.isBlank(p.getAcctUsedFlag())) {
  392. p.setAcctUsedFlag(YesOrNo.NO.getCodeStr());
  393. }
  394. dscginfo.setDiseCodg(setlDises.get(0).getDiagCode());
  395. dscginfo.setDiseName(setlDises.get(0).getDiagName());
  396. dscginfo.setDscgWay(DscgWay.ORDER_TO_LEAVE_HOSPITAL.getCode());
  397. String ref = JSONObject.toJSONStringWithDateFormat(dscginfo, "yyyy-MM-dd HH:mm:ss");
  398. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.DISCHARGE_PROCESSING,
  399. dao.selectAdmdvs(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn()));
  400. input.getJSONObject("input").put("dscginfo", JSONObject.parseObject(ref));
  401. String diseRef = JSONArray.toJSONStringWithDateFormat(setlDises, "yyyy-MM-dd HH:mm:ss");
  402. input.getJSONObject("input").put("diseinfo", JSONArray.parse(diseRef));
  403. JSONObject result = exec.executeTrade(input, SiFunction.DISCHARGE_PROCESSING);
  404. if (null == result) {
  405. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  406. }
  407. Integer infcode = result.getInteger(RESULT_CODE);
  408. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, dscginfo.getPsnNo()));
  409. if (null == infcode) {
  410. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  411. }
  412. if (infcode == 0) {
  413. if (p.getStopHere()) {
  414. return "出院办理成功。";
  415. }
  416. p.setDismissDate(dscginfo.getEndtime());
  417. return inpatientSettlement(p, ybData);
  418. }
  419. String errMsg = result.getString(ERROR_MESSAGE);
  420. if (null != errMsg && errMsg.contains("该人员已经是出院状态")) {
  421. p.setDismissDate(dscginfo.getEndtime());
  422. return inpatientSettlement(p, ybData);
  423. }
  424. throw new BizException(ExceptionEnum.LOGICAL_ERROR, errMsg);
  425. }
  426. public String revokeDischarge(ZyPatientInfo p) {
  427. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  428. if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getMdtrtId())) {
  429. throw new BizException("此患者没有在院的医保业务。");
  430. }
  431. p.setMdtrtId(siPatInfo.getMdtrtId());
  432. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.REVOKE_DISCHARGE, siPatInfo.getInsuplcAdmdvs());
  433. JSONObject data = new JSONObject();
  434. data.put("mdtrt_id", siPatInfo.getMdtrtId());
  435. data.put("psn_no", siPatInfo.getPsnNo());
  436. input.getJSONObject("input").put("data", data);
  437. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_DISCHARGE);
  438. if (null == result) {
  439. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  440. }
  441. Integer infcode = result.getInteger(RESULT_CODE);
  442. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, siPatInfo.getPsnNo()));
  443. if (null == infcode) {
  444. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  445. }
  446. if (infcode == 0) {
  447. dao.deleteSetlInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  448. dao.deleteSetlDetail(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  449. transbackTables(p);
  450. return "取消医保出院办理成功。";
  451. }
  452. throw new BizException(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  453. }
  454. private void fillBeginTimeAndEndTime(ZyPatientInfo p) {
  455. if (null == p.getYbRegisterDate()) {
  456. Date beginTime = dismissService.getBegntime(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), "zy_actpatient");
  457. p.setYbRegisterDate(beginTime);
  458. }
  459. if (null == p.getDismissDate()) {
  460. Date disdate = dao.selectDisdate(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  461. if (null == disdate) {
  462. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "请先提交出院申请!");
  463. }
  464. p.setDismissDate(disdate);
  465. }
  466. }
  467. private String inpatientSettlement(ZyPatientInfo p, ZyOrJzYbData ybData) {
  468. fillBeginTimeAndEndTime(p);
  469. PreSetlmt preSetlmt = ybData.getSetlmt(p);
  470. ReadCardBizType readCardBizType = ReadCardBizType.get(p.getReadCardBizType());
  471. if (readCardBizType == ReadCardBizType.SETTLEMENT) {
  472. MdtrtCertType mdtrtCertType = MdtrtCertType.getByLabel(p.getMdtrtCertType());
  473. preSetlmt.setMdtrtCertType(mdtrtCertType.getCode());
  474. if (mdtrtCertType.getCode().equals(MdtrtCertType.SOCIAL_SECURITY_CARD.getCode())) {
  475. String[] out = p.getReadCardResult().split("\\|");
  476. if (!p.getName().trim().equals(out[4].trim())) {
  477. revokeDischarge(p);
  478. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "社保卡姓名与HIS姓名不一致,请确认是否人证相符。");
  479. }
  480. preSetlmt.setMdtrtCertNo(out[2]);
  481. preSetlmt.setCardSn(out[3]);
  482. } else if (mdtrtCertType.getCode().equals(MdtrtCertType.MEDICAL_INSURANCE_ELECTRONIC_VOUCHER.getCode())) {
  483. JSONObject qrinfo = JSONObject.parseObject(p.getReadCardResult());
  484. if (!p.getName().trim().equals(qrinfo.getString("userName").trim())) {
  485. revokeDischarge(p);
  486. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "电子医保凭证姓名与HIS姓名不一致,请确认是否人证相符。");
  487. }
  488. if (!p.getSocialNo().trim().equals(qrinfo.getString("idNo").trim())) {
  489. revokeDischarge(p);
  490. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "电子医保凭证身份证与HIS身份证不一致,请确认是否人证相符。");
  491. }
  492. preSetlmt.setMdtrtCertNo(qrinfo.getString("ecToken"));
  493. }
  494. }
  495. preSetlmt.setPsnSetlway(p.getDbg() ? PsnSetlWay.SETTLE_BY_QUOTA.getCode() : PsnSetlWay.SETTLE_BY_ITEMS.getCode());
  496. preSetlmt.setAcctUsedFlag(p.getAcctUsedFlag());
  497. preSetlmt.setMidSetlFlag(YesOrNo.NO.getCodeStr());
  498. preSetlmt.setInvono(SnowFlakeId.instance().nextId());
  499. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.HOSPITALIZATION_SETTLEMENT, preSetlmt.getInsuplcAdmdvs());
  500. String ref = JSONObject.toJSONString(preSetlmt);
  501. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  502. JSONObject result = exec.executeTrade(input, SiFunction.HOSPITALIZATION_SETTLEMENT);
  503. if (null == result) {
  504. revokeDischarge(p);
  505. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  506. }
  507. Integer infcode = result.getInteger(RESULT_CODE);
  508. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, preSetlmt.getPsnNo()));
  509. if (null == infcode) {
  510. revokeDischarge(p);
  511. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  512. }
  513. if (infcode == 0) {
  514. p.setInsuplcAdmdvs(preSetlmt.getInsuplcAdmdvs());
  515. p.setInsuplcAdmdvsName(queryDao.getInsuplcAdmdvsName(p));
  516. return executeHisSettlement(result.getJSONObject(OUTPUT), p);
  517. }
  518. String message = result.getString(ERROR_MESSAGE);
  519. if (message.contains("服务提供者后端服务响应超时")) {
  520. return timeoutSettlement(p);
  521. }
  522. revokeDischarge(p);
  523. throw new BizException(ExceptionEnum.LOGICAL_ERROR, message);
  524. }
  525. public String timeoutSettlement(ZyPatientInfo p) {
  526. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  527. if (null == siPatInfo) {
  528. throw new BizException(ExceptionEnum.LOGICAL_ERROR, "[t_si_pat_info]没有此患者的就诊信息。");
  529. }
  530. fillBeginTimeAndEndTime(p);
  531. p.setInsuplcAdmdvs(siPatInfo.getInsuplcAdmdvs());
  532. p.setInsuplcAdmdvsName(siPatInfo.getInsuplcAdmdvsName());
  533. JSONObject output = queryService.execute5203(siPatInfo);
  534. return executeHisSettlement(output, p);
  535. }
  536. private String executeHisSettlement(JSONObject output, ZyPatientInfo p) {
  537. dao.deleteSetlDetail(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  538. JSONObject setlinfo = output.getJSONObject("setlinfo");
  539. SiSetlinfo setlinfoEntity = JSONObject.parseObject(setlinfo.toJSONString(), SiSetlinfo.class);
  540. setlinfoEntity.setPatNo(p.getInpatientNo());
  541. setlinfoEntity.setTimes(p.getAdmissTimes());
  542. setlinfoEntity.setLedgerSn(p.getLedgerSn());
  543. setlinfoEntity.setStaffId(TokenUtil.getInstance().getTokenUserId());
  544. setlinfoEntity.setRevoked(YesOrNo.NO.getCode());
  545. setlinfoEntity.setSetlType(ClrType.INPATIENT.getCode());
  546. setlinfoEntity.setInsuplcAdmdvs(p.getInsuplcAdmdvs());
  547. setlinfoEntity.setInsuplcAdmdvsName(p.getInsuplcAdmdvsName());
  548. setlinfoEntity.setBegntime(p.getYbRegisterDate());
  549. setlinfoEntity.setEndtime(p.getDismissDate());
  550. setlinfoEntity.setHiPaymtd(CommonUtil.calcHiPaymtd(setlinfoEntity.getInsuplcAdmdvs(),setlinfoEntity.getMedType(),setlinfoEntity.getInsutype(),setlinfoEntity.getSetlTime()));
  551. setlinfoEntity.setMedinsType(MedInsTypeUtil.getMedInsType(setlinfoEntity));
  552. if (null == setlinfoEntity.getPsnPartAmt()) {
  553. Double psnPay = setlinfo.getDouble("psn_pay");
  554. setlinfoEntity.setPsnPartAmt(psnPay);
  555. }
  556. if (null == setlinfoEntity.getPsnCashPay()) {
  557. Double cashPay = setlinfo.getDouble("cash_payamt");
  558. setlinfoEntity.setPsnCashPay(cashPay);
  559. }
  560. JSONArray setldetail = output.getJSONArray("setldetail");
  561. BigDecimal hospitalPart = BigDecimal.ZERO;
  562. int setlCount = setlinfodao.getSetlCount(setlinfoEntity.getSetlId());
  563. for (int i = 0; i < setldetail.size(); i++) {
  564. SiSetldetail setldetailEntity = JSONObject.parseObject(setldetail.getJSONObject(i).toJSONString(), SiSetldetail.class);
  565. setldetailEntity.setSetlId(setlinfoEntity.getSetlId());
  566. setldetailEntity.setSortNo(i + 1);
  567. setldetailEntity.setPatNo(p.getInpatientNo());
  568. setldetailEntity.setTimes(p.getAdmissTimes());
  569. setldetailEntity.setLedgerSn(p.getLedgerSn());
  570. if (setldetailEntity.getFundPayType().equals("999996") || setldetailEntity.getSetlProcInfo().equals("999996")) {
  571. hospitalPart = hospitalPart.add(setldetailEntity.getFundPayamt());
  572. }
  573. if (setlCount == 0) {
  574. setldetldao.insert(setldetailEntity);
  575. }
  576. }
  577. setlinfoEntity.setHospPartAmt(hospitalPart.doubleValue());
  578. if (setlCount == 0) {
  579. setlinfodao.insert(setlinfoEntity);
  580. }
  581. setlinfodao.updateSiZyInfoSetlId(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(),
  582. setlinfoEntity.getSetlId(), setlinfoEntity.getMedinsSetlId(), setlinfoEntity.getMedinsSetlId());
  583. setlinfodao.updateApplySettled(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), YesOrNo.YES.getCode());
  584. // 跨省异地数据不参与对账,对总账时无需统计进去。
  585. // String hospArea = cfg.getHospArea();
  586. // if (null != hospArea && hospArea.length() > 2) {
  587. // String areaHeader = hospArea.substring(0, 2);
  588. // if (setlinfoEntity.getFundPaySumamt() > 0 && setlinfoEntity.getInsuplcAdmdvs().startsWith(areaHeader)) {
  589. // InstStlLdgChk ldgChk = new InstStlLdgChk();
  590. // ldgChk.setInsutype(setlinfoEntity.getInsutype());
  591. // ldgChk.setClrType(setlinfoEntity.getClrType());
  592. // ldgChk.setSetlOptins(setlinfoEntity.getClrOptins());
  593. // ldgChk.setStmtBegndate(setlinfoEntity.getSetlTime());
  594. // ldgChk.setStmtEnddate(setlinfoEntity.getSetlTime());
  595. // ResultVo<String> totalLedgerCheck = manageService.institutionSettlementLedgerCheck(ldgChk);
  596. // if (totalLedgerCheck.getCode() != ExceptionEnum.SUCCESS.getCode()) {
  597. // InstStlLdgChk detlChk = new InstStlLdgChk();
  598. // detlChk.setSetlOptins(ldgChk.getSetlOptins());
  599. // detlChk.setStmtBegndate(ldgChk.getStmtBegndate());
  600. // detlChk.setStmtEnddate(ldgChk.getStmtEnddate());
  601. // detlChk.setClrType(ldgChk.getClrType());
  602. // detlChk.setRefdSetlFlag(YesOrNo.NO.getCodeStr());
  603. // ResultVo<List<InsSetlDetlChkRslt>> detailLedgerCheck = manageService.institutionSettlementDetailCheck(detlChk);
  604. // if (detailLedgerCheck.getCode() != ExceptionEnum.SUCCESS.getCode()) {
  605. // revokeSettlement(p);
  606. // throw new BizException(ExceptionEnum.LOGICAL_ERROR, detailLedgerCheck.getMessage());
  607. // }
  608. // for (InsSetlDetlChkRslt insSetlDetlChkRslt : detailLedgerCheck.getData()) {
  609. // if (Objects.equals(insSetlDetlChkRslt.getSetlId(), setlinfoEntity.getSetlId())) {
  610. // if (!Objects.equals(insSetlDetlChkRslt.getStmtRslt(), "0")) {
  611. // revokeSettlement(p);
  612. // throw new BizException(ExceptionEnum.LOGICAL_ERROR, insSetlDetlChkRslt.getMemo());
  613. // }
  614. // break;
  615. // }
  616. // }
  617. // }
  618. // }
  619. // }
  620. queryService.saveCumInfo(setlinfoEntity);
  621. if (p.getLedgerSn() == 0) {
  622. return StrUtil.format("出院结算成功。患者总费用:{}。其中基金支付:{};个账支付:{};现金支付:{}",
  623. setlinfoEntity.getMedfeeSumamt(), setlinfoEntity.getFundPaySumamt(), setlinfoEntity.getAcctPay(), setlinfoEntity.getPsnCashPay());
  624. }
  625. MedinsSettleFee settleFee = new MedinsSettleFee();
  626. if (p.getMidSetl()) {
  627. settleFee.setZjdzDatetime(p.getZjdzDatetime());
  628. }
  629. settleFee.setMidSetl(p.getMidSetl());
  630. settleFee.setStaffId(TokenUtil.getInstance().getTokenUserId());
  631. settleFee.setInpatientNo(p.getInpatientNo());
  632. settleFee.setAdmissTimes(p.getAdmissTimes());
  633. settleFee.setBedNo(p.getBedNo());
  634. settleFee.setWardCode(p.getAdmissWard());
  635. settleFee.setDeptCode(p.getAdmissDept());
  636. settleFee.setTotalCost(setlinfo.getString("medfee_sumamt"));
  637. settleFee.setTczf(setlinfo.getString("fund_pay_sumamt"));
  638. settleFee.setHospitalPay(setlinfo.getString("hosp_part_amt"));
  639. settleFee.setGrzhzf(setlinfo.getString("acct_pay"));
  640. settleFee.setDbzf(setlinfo.getString("hifmi_pay"));
  641. settleFee.setXjzf(String.valueOf(setlinfoEntity.getPsnCashPay()));
  642. settleFee.setTable(p.getTable());
  643. return dismissService.executeDischarging(settleFee);
  644. }
  645. public String revokeSettlement(ZyPatientInfo p) {
  646. if (null == p.getStaffId()) {
  647. p.setStaffId(TokenUtil.getInstance().getTokenUserId());
  648. }
  649. if (null == p.getLedgerSn()) {
  650. p.setLedgerSn(dao.selectMaxLedgerSn(p.getInpatientNo(), p.getAdmissTimes()));
  651. }
  652. SiPatInfo siPatInfo = queryDao.selectSiPatInfo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  653. if (null == siPatInfo || StringUtil.isBlank(siPatInfo.getSetlId())) {
  654. return revokeDischarge(p);
  655. }
  656. p.setMdtrtId(siPatInfo.getMdtrtId());
  657. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.REVOKE_HOSPITALIZATION_SETTLEMENT, siPatInfo.getInsuplcAdmdvs());
  658. JSONObject data = new JSONObject();
  659. data.put("mdtrt_id", siPatInfo.getMdtrtId());
  660. data.put("setl_id", siPatInfo.getSetlId());
  661. data.put("psn_no", siPatInfo.getPsnNo());
  662. input.getJSONObject("input").put("data", data);
  663. JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_HOSPITALIZATION_SETTLEMENT);
  664. if (null == result) {
  665. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  666. }
  667. Integer infcode = result.getInteger(RESULT_CODE);
  668. logDao.insert(new SiLog(input, result, p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), infcode, siPatInfo.getPsnNo()));
  669. if (null == infcode) {
  670. throw new BizException(ExceptionEnum.NETWORK_ERROR);
  671. }
  672. if (infcode != 0) {
  673. throw new BizException(ExceptionEnum.LOGICAL_ERROR, result.getString("err_msg"));
  674. }
  675. String rvkDischrgRslt = revokeDischarge(p);
  676. dao.updateRvkSetlMsgid(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), input.getString("msgid"));
  677. setlinfodao.updateApplySettled(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn(), YesOrNo.NO.getCode());
  678. transbackTables(p);
  679. return rvkDischrgRslt;
  680. }
  681. private void transbackTables(ZyPatientInfo p) {
  682. dao.deleteSiSetlFeeDetl(p.getMdtrtId());
  683. dao.deleteZyLedgerFileYb(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  684. dao.deleteZyReceipt(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  685. dao.updateSettleType(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  686. dao.updateChargeStatus(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  687. }
  688. }