package thyyxxk.webserver.service.medicalinsurance; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import thyyxxk.webserver.config.exception.ExceptionEnum; import thyyxxk.webserver.constants.Capacity; import thyyxxk.webserver.constants.YesOrNo; import thyyxxk.webserver.constants.frntsheet.CaseClassification; import thyyxxk.webserver.constants.sidicts.*; import thyyxxk.webserver.dao.his.medicalinsurance.SiLogDao; import thyyxxk.webserver.dao.his.medicalinsurance.SiManageDao; import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao; import thyyxxk.webserver.entity.ResultVo; import thyyxxk.webserver.entity.dictionary.PureCodeName; import thyyxxk.webserver.entity.medicalinsurance.log.SiLog; import thyyxxk.webserver.entity.medicalinsurance.manage.*; import thyyxxk.webserver.entity.medicalinsurance.manage.deptmanage.DeptInfo; import thyyxxk.webserver.entity.medicalinsurance.manage.deptmanage.DeptInfoQuery; import thyyxxk.webserver.entity.medicalinsurance.manage.deptmanage.MedStaffQuery; import thyyxxk.webserver.entity.medicalinsurance.manage.detailanalyse.*; import thyyxxk.webserver.entity.medicalinsurance.manage.examination.BilgItemInfo; import thyyxxk.webserver.entity.medicalinsurance.manage.frontsheet.Baseinfo; import thyyxxk.webserver.entity.medicalinsurance.manage.frontsheet.Diseinfo; import thyyxxk.webserver.entity.medicalinsurance.manage.frontsheet.Icuinfo; import thyyxxk.webserver.entity.medicalinsurance.manage.frontsheet.Oprninfo; import thyyxxk.webserver.entity.medicalinsurance.manage.goods.*; import thyyxxk.webserver.entity.medicalinsurance.manage.orderinfo.ActOrder; import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo; import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SlctSetlPrm; import thyyxxk.webserver.service.redislike.RedisLikeService; import thyyxxk.webserver.utils.*; import java.io.IOException; import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; /** * @description: 医保管理服务,包涵项目对照等 * @author: DingJie * @create: 2021/6/2914:44 */ @Service @Slf4j public class SiManageService { private static final String RESULT_CODE = "infcode"; private static final String ERROR_MESSAGE = "err_msg"; private static final String OUTPUT = "output"; private final ExecService exec; private final SiUploadService upldServcie; private final SiDownloadService dldService; private final SiManageDao dao; private final SiSetlinfoDao setlinfoDao; private final SiLogDao logDao; private final RedisLikeService redis; @Autowired public SiManageService(ExecService exec, SiUploadService upldServcie, SiDownloadService dldService, SiManageDao dao, SiSetlinfoDao setlinfoDao, SiLogDao logDao, RedisLikeService redis) { this.exec = exec; this.upldServcie = upldServcie; this.dldService = dldService; this.dao = dao; this.setlinfoDao = setlinfoDao; this.logDao = logDao; this.redis = redis; } public ResultVo uploadCatalogueContrast(CatalogueContrast prm) { JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_CATALOGUE_CONTRAST); JSONArray data = new JSONArray(); setListType(prm); List codes = new ArrayList<>(); prm.getList().forEach(item -> { codes.add(item.getCode()); JSONObject catalogue = new JSONObject(); catalogue.put("fixmedins_hilist_id", item.getCode()); catalogue.put("fixmedins_hilist_name", item.getName()); catalogue.put("list_type", prm.getListType()); catalogue.put("med_list_codg", item.getNationalCode()); catalogue.put("begndate", DateUtil.formatDatetime(prm.getBeginDate())); catalogue.put("enddate", DateUtil.formatDatetime(prm.getEndDate())); data.add(catalogue); }); input.getJSONObject("input").put("data", data); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_CATALOGUE_CONTRAST); log.info("【操作员:{}】,上传目录对照:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); if (null == result) { return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR); } Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, null, null, null, infcode, null)); if (null == infcode) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (infcode == 0) { dao.updateUploadedFlag(prm.getTable(), YesOrNo.YES.getCode(), codes); return ResultVoUtil.success("上传目录对照成功。"); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } public ResultVo revokeCatalogueContrast(CatalogueContrast prm) { setListType(prm); JSONObject input = exec.makeTradeHeader(SiFunction.REVOKE_CATALOGUE_CONTRAST); JSONObject data = new JSONObject(); data.put("fixmedins_code", SiUtil.INSTITUTION_ID); data.put("fixmedins_hilist_id", prm.getChargeCode()); data.put("list_type", prm.getListType()); data.put("med_list_codg", prm.getNationalCode()); input.getJSONObject("input").put("data", data); JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_CATALOGUE_CONTRAST); log.info("【操作员:{}】,撤销目录:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); if (null == result) { return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR); } Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, null, null, null, infcode, null)); if (null == infcode) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (infcode == 0) { dao.updateUploadedFlag2(prm.getTable(), prm.getChargeCode()); return ResultVoUtil.success("撤销目录对照成功。"); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } private void setListType(CatalogueContrast prm) { String table = "yp_zd_dict"; switch (prm.getType()) { case 1: prm.setListType(ListType.WEST_PATENT.getCode()); break; case 2: prm.setListType(ListType.HERBAL.getCode()); break; case 3: prm.setListType(ListType.SERVICE.getCode()); table = "zd_charge_item"; break; case 4: prm.setListType(ListType.SUPPLY.getCode()); table = "zd_charge_item"; break; } prm.setTable(table); } public ResultVo autoRecoveryTrade(AtoRcvTrd atoRcvTrd) { Integer recoveryTradePermission = dao.recoveryTradePermission(TokenUtil.getTokenUserId()); if (null == recoveryTradePermission || recoveryTradePermission == 0) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有冲正交易的权限!"); } JSONObject input = exec.makeTradeHeader(SiFunction.AUTO_RECOVERY_TRADE); String ref = JSONObject.toJSONString(atoRcvTrd); input.getJSONObject("input").put("data", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.AUTO_RECOVERY_TRADE); log.info("【操作员:{}】,冲正交易:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, null, null, null, infcode, atoRcvTrd.getPsnNo())); return SiUtil.makeReturnWithoutOutput(result, "冲正成功。"); } public ResultVo institutionSettlementLedgerCheck(InstStlLdgChk instStlLdgChk) { String startdate = DateUtil.getDayStartTime(instStlLdgChk.getStmtBegndate()); String enddate = DateUtil.getDayEndTime(instStlLdgChk.getStmtEnddate()); List brfs = dao.selectSetlChkBrfsWithInsutype(instStlLdgChk.getClrType(), instStlLdgChk.getInsutype(), instStlLdgChk.getSetlOptins(), startdate, enddate); BigDecimal medfeesum = new BigDecimal("0"); BigDecimal acctpaysum = new BigDecimal("0"); BigDecimal fundpaysum = new BigDecimal("0"); for (InstSetlLdgChkBrf brf : brfs) { medfeesum = DecimalUtil.add(medfeesum, brf.getMedfeeSumamt()); acctpaysum = DecimalUtil.add(acctpaysum, brf.getAcctPay()); fundpaysum = DecimalUtil.add(fundpaysum, brf.getFundPaySumamt()); if (null != brf.getHospPay()) { fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay()); } } instStlLdgChk.setMedfeeSumamt(medfeesum); instStlLdgChk.setAcctPay(acctpaysum); instStlLdgChk.setFundPaySumamt(fundpaysum); instStlLdgChk.setFixmedinsSetlCnt(brfs.size()); JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_LEDGER_CHECK); String ref = JSONObject.toJSONStringWithDateFormat(instStlLdgChk, "yyyy-MM-dd"); input.getJSONObject("input").put("data", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.INSTITUTION_SETTLEMENT_LEDGER_CHECK); log.info("【操作员:{}】,医药机构费用结算对总账:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); if (null == result) { return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR); } if (null == result.getInteger(RESULT_CODE)) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (result.getIntValue(RESULT_CODE) == 0) { JSONObject output = result.getJSONObject(OUTPUT); JSONObject info = output.getJSONObject("stmtinfo"); String setlOptins = info.getString("setl_optins"); Admdvs admdvs = Admdvs.get(setlOptins); String optins; if (null == admdvs) { optins = dao.selectRegion(setlOptins); } else { optins = admdvs.getName(); } String rslt; if (info.getString("stmt_rslt").equals(StmtRslt.CORRECT.getCode())) { rslt = StmtRslt.CORRECT.getName(); } else { rslt = StmtRslt.WRONG.getName(); } String dscr = info.getString("stmt_rslt_dscr"); if (StringUtil.isBlank(dscr)) { dscr = "结算笔数:" + brfs.size() + ",医疗费总额:" + medfeesum + ",基金支付总额:" + fundpaysum; } String data = "【清算机构:" + optins + "】对账结果:" + rslt + "。对账结果说明:" + dscr; if (rslt.equals(StmtRslt.CORRECT.getName())) { return ResultVoUtil.success(data); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, data); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } public ResultVo> institutionSettlementDetailCheck(InsSetlDetlChk prm) { String snowId = SnowFlakeId.instance().nextId(); String filename = snowId + ".txt"; StringBuilder fsIn = new StringBuilder(); String startdate = DateUtil.getDayStartTime(prm.getStmtBegndate()); String enddate = DateUtil.getDayEndTime(prm.getStmtEnddate()); List brfs = dao.selectSetlChkBrfs(prm.getClrType(), prm.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.getHospPay()) { fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay()); brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPay())); } } prm.setMedfeeSumamt(medfeesum); prm.setCashPayamt(psnCashPay); prm.setFundPaySumamt(fundpaysum); prm.setFixmedinsSetlCnt(brfs.size()); for (InstSetlLdgChkBrf item : brfs) { 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(prm.getRefdSetlFlag()).append("\n"); } try { Files.write(Paths.get(filename), fsIn.toString().getBytes()); String zipFile = ZipUtil.zip(filename); ZipUtil.deleteFile(filename); String fsUploadIn = "{\"filename\": \"" + filename + ".zip\", \"fixmedins_code\": \"" + SiUtil.INSTITUTION_ID + "\", \"in\": " + Arrays.toString(ZipUtil.zipFileToBytes(zipFile)) + "}"; ResultVo uplRes = upldServcie.uploadFile(JSONObject.parseObject(fsUploadIn), filename); ZipUtil.deleteFile(zipFile); if (uplRes.getCode().equals(ExceptionEnum.SUCCESS.getCode())) { prm.setFileQuryNo(uplRes.getData()); } } catch (IOException e) { log.error("医药机构费用结算对明细账出错", e); } JSONObject input = exec.makeTradeHeader(SiFunction.INSTITUTION_SETTLEMENT_DETAIL_CHECK); String ref = JSONObject.toJSONStringWithDateFormat(prm, "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); if (null == result) { return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR); } if (null == result.getInteger(RESULT_CODE)) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (result.getIntValue(RESULT_CODE) == 0) { JSONObject output = result.getJSONObject(OUTPUT); JSONObject fileinfo = output.getJSONObject("fileinfo"); String filePath = dldService.downloadFile(fileinfo.getString("file_qury_no"), fileinfo.getString("filename")); Queue queue = SiUtil.readTxtFile(filePath); if (null == queue || queue.size() == 0) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "未能成功获取到对账结果。"); } List list = new ArrayList<>(); while (queue.size() > 0) { String item = queue.poll(); String[] arr = item.split("\t"); InsSetlDetlChkRslt rslt = new InsSetlDetlChkRslt(arr); list.add(rslt); } return ResultVoUtil.success(list); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } public ResultVo> selectSetlinfos(SlctSetlPrm prm) { QueryWrapper wrapper = new QueryWrapper<>(); if (StringUtil.notBlank(prm.getInsutype())) { wrapper.eq("insutype", prm.getInsutype()); } String begndate = DateUtil.formatDatetime(prm.getStmtBegndate(), "yyyy-MM-dd") + " 00:00:00"; String enddate = DateUtil.formatDatetime(prm.getStmtEnddate(), "yyyy-MM-dd") + " 23:59:59"; wrapper.eq("setl_type", prm.getClrType()); wrapper.eq("revoked", YesOrNo.NO.getCode()); wrapper.apply("fund_pay_sumamt!=0"); wrapper.apply("setl_time>='" + begndate + "'"); wrapper.apply("setl_time<='" + enddate + "'"); wrapper.apply("(insuplc_admdvs='439900' or insuplc_admdvs like '4301%') "); List list = setlinfoDao.selectList(wrapper); if (null == list || list.isEmpty()) { return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到符合条件的数据。"); } Map map = new HashMap<>(Capacity.TWO); Map optinsMap = new HashMap<>(); List optinList = new ArrayList<>(); list.forEach(item -> { Admdvs admdvs = Admdvs.get(item.getClrOptins()); if (null == admdvs) { item.setClrOptinsName(dao.selectRegion(item.getClrOptins())); } else { item.setClrOptinsName(admdvs.getName()); } if (!optinsMap.containsKey(item.getClrOptins())) { optinsMap.put(item.getClrOptins(), item.getClrOptinsName()); } FilterUtil.filterCodeToName(item); }); map.put("list", list); for (Map.Entry entry : optinsMap.entrySet()) { optinList.add(new PureCodeName(entry.getKey(), entry.getValue())); } map.put("optins", optinList); return ResultVoUtil.success(map); } public ResultVo detailAnalyse(String patNo, int times, int ledger, int type) { SiFunction function = type == 1 ? SiFunction.ITEMIZED_REVIEW_ANALYSIS_SERVICES_BEFORE : SiFunction.ITEMIZED_REVIEW_ANALYSIS_SERVICES_MIDDLE; String logpart = type == 1 ? "明细审核事前分析" : "明细审核事中分析"; JSONObject input = exec.makeTradeHeader(function); MainPart mainPart = new MainPart(); mainPart.setSyscode("csthyy"); mainPart.setTaskId(SnowFlakeId.instance().nextId()); mainPart.setTrigScen("1"); PatientDtos patientDtos = dao.selectPatientDto(patNo, times); FsiEncounterDtos fsiEncounterDtos = dao.selectFsiEncounterDto(patNo, times); fsiEncounterDtos.setAdmDeptName(redis.getDeptName(fsiEncounterDtos.getAdmDeptCodg())); fsiEncounterDtos.setDscgDeptCodg(fsiEncounterDtos.getAdmDeptCodg()); fsiEncounterDtos.setDscgDeptName(fsiEncounterDtos.getAdmDeptName()); List fsiDiagnoseDtos = dao.selectFsiDiagnoseDtos(patNo, times); fsiEncounterDtos.setFsiDiagnoseDtos(fsiDiagnoseDtos); String setlId = dao.selectSetlId(patNo, times); List tempFsiOrderDtos = dao.selectFsiOrderDtos(patNo, times, setlId); Map distinctOrderMap = new HashMap<>(); List fsiOrderDtos = new ArrayList<>(); tempFsiOrderDtos.forEach(item -> { if (!distinctOrderMap.containsKey(item.getRxId())) { distinctOrderMap.put(item.getRxId(), 1); item.setDrordDrProfttl(DrordDrProfttl.getCodeByHisCode(item.getDrordDrProfttl())); fsiOrderDtos.add(item); } }); fsiEncounterDtos.setFsiOrderDtos(fsiOrderDtos); patientDtos.setFsiEncounterDtos(fsiEncounterDtos); FsiHisDataDto fsiHisDataDto = new FsiHisDataDto(); mainPart.setPatientDtos(patientDtos); // mainPart.setFsiHisDataDto(fsiHisDataDto); String ref = JSONObject.toJSONStringWithDateFormat(mainPart, "yyyy-MM-dd HH:mm:ss"); input.getJSONObject("input").put("data", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, function); log.info("【操作员:{}】,{}:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), logpart, input, result); Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, patNo, times, ledger, infcode, "psn_no")); return SiUtil.makeReturnWithoutOutput(result, "分析结果。"); } public ResultVo deptInfoUpload(DeptInfo deptInfo) { JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_DEPARTMENT_INFO); String ref = JSONObject.toJSONStringWithDateFormat(deptInfo, "yyyy-MM-dd HH:mm:ss"); input.getJSONObject("input").put("deptinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_DEPARTMENT_INFO); log.info("【操作员:{}】,科室信息上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, null, null, null, infcode, null)); return SiUtil.makeReturnWithoutOutput(result, "科室信息上传成功。"); } public ResultVo deptInfoBatchUpload(List deptInfos) { JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_DEPARTMENT_INFO_IN_BATCH); String ref = JSONArray.toJSONStringWithDateFormat(deptInfos, "yyyy-MM-dd HH:mm:ss"); input.getJSONObject("input").put("deptinfo", JSONArray.parseArray(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_DEPARTMENT_INFO_IN_BATCH); log.info("【操作员:{}】,科室信息批量上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, null, null, null, infcode, null)); return SiUtil.makeReturnWithoutOutput(result, "科室信息批量上传成功。"); } public ResultVo deptInfoModify(DeptInfo deptInfo) { JSONObject input = exec.makeTradeHeader(SiFunction.MODIFY_DEPARTMENT_INFO); String ref = JSONObject.toJSONStringWithDateFormat(deptInfo, "yyyy-MM-dd HH:mm:ss"); input.getJSONObject("input").put("deptinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.MODIFY_DEPARTMENT_INFO); log.info("【操作员:{}】,科室信息变更:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, null, null, null, infcode, null)); return SiUtil.makeReturnWithoutOutput(result, "科室信息变更成功。"); } public ResultVo deptInfoDelete(DeptInfo deptInfo) { JSONObject input = exec.makeTradeHeader(SiFunction.REVOKE_DEPARTMENT_INFO); JSONObject data = new JSONObject(); data.put("hosp_dept_codg", deptInfo.getHospDeptCodg()); data.put("hosp_dept_name", deptInfo.getHospDeptName()); data.put("begntime", DateUtil.formatDatetime(deptInfo.getBegntime(), "yyyy-MM-dd")); input.getJSONObject("input").put("data", data); JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_DEPARTMENT_INFO); log.info("【操作员:{}】,科室信息撤销:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); logDao.insert(new SiLog(input, result, null, null, null, infcode, null)); return SiUtil.makeReturnWithoutOutput(result, "科室信息撤销成功。"); } public ResultVo queryDeptInfo(DeptInfoQuery query) { JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_DEPARTMENT_INFO); query.setInfno(SiFunction.QUERY_DEPARTMENT_INFO.getCode()); query.setMsgid(input.getString("msgid")); query.setInfTime(input.getString("inf_time")); query.setFixmedinsCode(SiUtil.INSTITUTION_ID); query.setFixmedinsName(SiUtil.INSTITUTION_NAME); query.setSignNo(input.getString("sign_no")); query.setInfver(SiUtil.API_VERSION); String ref = JSONObject.toJSONString(query); input.getJSONObject("input").put("data", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.QUERY_DEPARTMENT_INFO); log.info("【操作员:{}】,科室信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); if (null == infcode) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (infcode == 0) { return ResultVoUtil.success(result.getJSONObject(OUTPUT)); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } // 接口存在问题 public ResultVo queryMedStaffInfo(MedStaffQuery query) { String ref = JSONObject.toJSONString(query); JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_MEDICAL_STAFF_INFO); input.getJSONObject("input").put("data", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.QUERY_MEDICAL_STAFF_INFO); log.info("【操作员:{}】,医执人员信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); if (null == infcode) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (infcode == 0) { return ResultVoUtil.success(result.getJSONObject(OUTPUT)); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } public ResultVo queryExaminationExInfo(BilgItemInfo bilgItemInfo) { String ref = JSONObject.toJSONString(bilgItemInfo); JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_MUTUAL_ACCREDIT_INFO); input.getJSONObject("input").put("bilgiteminfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.QUERY_MUTUAL_ACCREDIT_INFO); log.info("【操作员:{}】,项目互认信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); if (null == infcode) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (infcode == 0) { return ResultVoUtil.success(result.getJSONObject(OUTPUT)); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } public ResultVo queryExaminationDetail(String psnNo, String reportNo) { JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_DIAGNOSIS_REPORT_DETAIL); JSONObject rptdetailinfo = new JSONObject(); rptdetailinfo.put("psn_no", psnNo); rptdetailinfo.put("rpotc_no", reportNo); rptdetailinfo.put("fixmedins_code", SiUtil.INSTITUTION_ID); input.getJSONObject("input").put("rptdetailinfo", rptdetailinfo); JSONObject result = exec.executeTrade(input, SiFunction.QUERY_DIAGNOSIS_REPORT_DETAIL); log.info("【操作员:{}】,报告明细信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); if (null == infcode) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (infcode == 0) { return ResultVoUtil.success(result.getJSONObject(OUTPUT)); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } public ResultVo uploadInvinfo(InvinfoUpload invinfo) { String ref = JSONObject.toJSONStringWithDateFormat(invinfo, "yyyy-MM-dd"); JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_INVENTORY); input.getJSONObject("input").put("invinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_INVENTORY); log.info("【操作员:{}】,商品盘存上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "商品盘存上传成功。"); } public ResultVo modifyInvinfo(InvinfoModify invinfo) { String ref = JSONObject.toJSONStringWithDateFormat(invinfo, "yyyy-MM-dd HH:mm:ss"); JSONObject input = exec.makeTradeHeader(SiFunction.CHANGE_COMMODITY_INVENTORY); input.getJSONObject("input").put("invinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.CHANGE_COMMODITY_INVENTORY); log.info("【操作员:{}】,商品盘存修改:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "商品盘存修改成功。"); } public ResultVo purchaseGoods(PurcinfoBought purcinfo) { String ref = JSONObject.toJSONString(purcinfo); JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_PURCHASE); input.getJSONObject("input").put("purcinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_PURCHASE); log.info("【操作员:{}】,商品采购上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "商品采购上传成功。"); } public ResultVo returnGoods(PurcinfoBought purcinfo) { String ref = JSONObject.toJSONString(purcinfo); JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_PURCHASE_RETURN); input.getJSONObject("input").put("purcinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_PURCHASE_RETURN); log.info("【操作员:{}】,商品采购退货:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "商品采购退货成功。"); } public ResultVo saleGoods(SelinfoSold selinfo) { String ref = JSONObject.toJSONString(selinfo); JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_SALES); input.getJSONObject("input").put("selinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_SALES); log.info("【操作员:{}】,商品销售上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "商品销售上传成功。"); } public ResultVo returnSales(SelinfoReturn selinfo) { String ref = JSONObject.toJSONString(selinfo); JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_COMMODITY_SALES_RETURN); input.getJSONObject("input").put("selinfo", JSONObject.parseObject(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_COMMODITY_SALES_RETURN); log.info("【操作员:{}】,商品销售退货:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "商品销售退货成功。"); } public ResultVo deleteGoods(String fixmedinsBchno, int type) { JSONObject input = exec.makeTradeHeader(SiFunction.DELETE_COMMODITY_INFO); JSONObject data = new JSONObject(); data.put("fixmedins_bchno", fixmedinsBchno); data.put("inv_data_type", type); // 1-盘存信息;2-库存变更信息;3-采购信息;4-销售信息 input.getJSONObject("input").put("data", data); JSONObject result = exec.executeTrade(input, SiFunction.DELETE_COMMODITY_INFO); log.info("【操作员:{}】,商品删除:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "商品删除成功。"); } public ResultVo modifySetllistState(String psnNo, String setlId, int type) { JSONObject input = exec.makeTradeHeader(SiFunction.MODIFY_SI_SETTLE_STATE); JSONObject data = new JSONObject(); data.put("psn_no", psnNo); data.put("setl_id", setlId); data.put("stas_type", type); // 0未提交,1已提交 input.getJSONObject("input").put("data", data); JSONObject result = exec.executeTrade(input, SiFunction.MODIFY_SI_SETTLE_STATE); log.info("【操作员:{}】,结算清单状态修改:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "结算清单状态修改成功。"); } public ResultVo querySetllistInfo(String psnNo, String setlId) { JSONObject input = exec.makeTradeHeader(SiFunction.QUERY_SI_SETTLE_INFO); JSONObject data = new JSONObject(); data.put("psn_no", psnNo); data.put("setl_id", setlId); input.getJSONObject("input").put("data", data); JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SI_SETTLE_INFO); log.info("【操作员:{}】,结算清单信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); Integer infcode = result.getInteger(RESULT_CODE); if (null == infcode) { return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message")); } if (infcode == 0) { return ResultVoUtil.success(result.getJSONObject(OUTPUT)); } return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE)); } public ResultVo uploadFrontSheet(String patNo, int times) { Baseinfo baseinfo = dao.selectFrontSheetBaseInfo(patNo, times); baseinfo.setCtd(CaseClassification.getWjwCodeByHisCode(baseinfo.getCtd())); List diseinfos = dao.selectYbDisdiags(patNo, times); if (null == diseinfos || diseinfos.isEmpty()) { diseinfos = dao.selectFrontSheetDiseInfo(patNo, times); } JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_FRONT_SHEET_INFO); String base = JSONObject.toJSONStringWithDateFormat(baseinfo, "yyyy-MM-dd"); String dise = JSONArray.toJSONString(diseinfos); List icuinfos = new ArrayList<>(); Icuinfo icuinfo = new Icuinfo(); icuinfo.setValiFlag("0"); icuinfo.setIptMedcasHmpgSn(diseinfos.get(0).getIptMedcasHmpgSn()); icuinfo.setMdtrtSn(diseinfos.get(0).getMdtrtSn()); icuinfos.add(icuinfo); String icu = JSONArray.toJSONString(icuinfos); List oprninfos = new ArrayList<>(); Oprninfo oprninfo = new Oprninfo(); oprninfo.setValiFlag("0"); oprninfo.setIptMedcasHmpgSn(diseinfos.get(0).getIptMedcasHmpgSn()); oprninfo.setMdtrtSn(diseinfos.get(0).getMdtrtSn()); oprninfos.add(oprninfo); String oprn = JSONArray.toJSONString(oprninfos); input.getJSONObject("input").put("baseinfo", JSONObject.parseObject(base)); input.getJSONObject("input").put("diseinfo", JSONArray.parseArray(dise)); input.getJSONObject("input").put("oprninfo", JSONArray.parseArray(oprn)); input.getJSONObject("input").put("icuinfo", JSONArray.parseArray(icu)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_FRONT_SHEET_INFO); log.info("【操作员:{}】,病案首页信息上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "病案首页信息上传成功。"); } public ResultVo uploadActOrder(String patNo, int times) { List actOrders = dao.selectActOrders(patNo, times); JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_ACT_ORDER); String ref = JSONArray.toJSONStringWithDateFormat(actOrders, "yyyy-MM-dd HH:mm:ss"); input.getJSONObject("input").put("data", JSONArray.parseArray(ref)); JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_ACT_ORDER); log.info("【操作员:{}】,医嘱记录上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result); return SiUtil.makeReturnWithoutOutput(result, "医嘱记录上传成功。"); } }