123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691 |
- 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.clinicinfo.*;
- 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<String> uploadCatalogueContrast(CatalogueContrast prm) {
- JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_CATALOGUE_CONTRAST);
- JSONArray data = new JSONArray();
- setListType(prm);
- List<String> 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<String> 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<String> 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<String> institutionSettlementLedgerCheck(InstStlLdgChk instStlLdgChk) {
- String startdate = DateUtil.getDayStartTime(instStlLdgChk.getStmtBegndate());
- String enddate = DateUtil.getDayEndTime(instStlLdgChk.getStmtEnddate());
- List<InstSetlLdgChkBrf> 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 = redis.getRegionName(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<List<InsSetlDetlChkRslt>> institutionSettlementDetailCheck(InsSetlDetlChk insSetlDetlChk) {
- 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.getHospPay()) {
- fundpaysum = DecimalUtil.minus(fundpaysum, brf.getHospPay());
- brf.setFundPaySumamt(DecimalUtil.minus(brf.getFundPaySumamt(), brf.getHospPay()));
- }
- }
- insSetlDetlChk.setMedfeeSumamt(medfeesum);
- insSetlDetlChk.setCashPayamt(psnCashPay);
- insSetlDetlChk.setFundPaySumamt(fundpaysum);
- insSetlDetlChk.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(insSetlDetlChk.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<String> uplRes = upldServcie.uploadFile(JSONObject.parseObject(fsUploadIn), filename);
- ZipUtil.deleteFile(zipFile);
- if (uplRes.getCode().equals(ExceptionEnum.SUCCESS.getCode())) {
- insSetlDetlChk.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");
- 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<String> queue = SiUtil.readTxtFile(filePath);
- if (null == queue || queue.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "未能成功获取到对账结果。");
- }
- List<InsSetlDetlChkRslt> 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<Map<String, Object>> selectSetlinfos(SlctSetlPrm prm) {
- QueryWrapper<SiSetlinfo> 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<SiSetlinfo> list = setlinfoDao.selectList(wrapper);
- if (null == list || list.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到符合条件的数据。");
- }
- Map<String, Object> map = new HashMap<>(Capacity.TWO);
- Map<String, String> optinsMap = new HashMap<>();
- List<PureCodeName> optinList = new ArrayList<>();
- list.forEach(item -> {
- Admdvs admdvs = Admdvs.get(item.getClrOptins());
- if (null == admdvs) {
- item.setClrOptinsName(redis.getRegionName(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<String, String> entry : optinsMap.entrySet()) {
- optinList.add(new PureCodeName(entry.getKey(), entry.getValue()));
- }
- map.put("optins", optinList);
- return ResultVoUtil.success(map);
- }
- public ResultVo<String> 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> fsiDiagnoseDtos = dao.selectFsiDiagnoseDtos(patNo, times);
- fsiEncounterDtos.setFsiDiagnoseDtos(fsiDiagnoseDtos);
- String setlId = dao.selectSetlId(patNo, times);
- List<FsiOrderDtos> tempFsiOrderDtos = dao.selectFsiOrderDtos(patNo, times, setlId);
- Map<String, Integer> distinctOrderMap = new HashMap<>();
- List<FsiOrderDtos> 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<String> 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<String> deptInfoBatchUpload(List<DeptInfo> 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<String> 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<String> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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<JSONObject> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<JSONObject> 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<String> uploadFrontSheet(String patNo, int times) {
- Baseinfo baseinfo = dao.selectFrontSheetBaseInfo(patNo, times);
- baseinfo.setCtd(CaseClassification.getWjwCodeByHisCode(baseinfo.getCtd()));
- List<Diseinfo> 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<Icuinfo> 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<Oprninfo> 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<String> uploadActOrder(String patNo, int times) {
- List<ActOrder> 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, "医嘱记录上传成功。");
- }
- public ResultVo<String> uploadClinicRecord(String patNo, int times) {
- ClinicRegistration clinicRegistration = dao.selectClinicRegistration(patNo, times);
- List<ClinicDiseinfo> diseinfos = dao.selectClinicDiseinfo(patNo, times);
- List<ClinicRxinfo> rxinfos = dao.selectClinicRxinfo(patNo, times);
- JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_CLINIC_RECORD);
- String rgstinfo = JSONObject.toJSONStringWithDateFormat(clinicRegistration, "yyyy-MM-dd HH:mm:ss");
- input.getJSONObject("input").put("rgstinfo", JSONObject.parseObject(rgstinfo));
- input.getJSONObject("input").put("caseinfo", new JSONArray());
- String diseinfo = JSONArray.toJSONString(diseinfos);
- input.getJSONObject("input").put("diseinfo", JSONArray.parseArray(diseinfo));
- String rxinfo = JSONArray.toJSONStringWithDateFormat(rxinfos, "yyyy-MM-dd HH:mm:ss");
- input.getJSONObject("input").put("rxinfo", JSONArray.parseArray(rxinfo));
- JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_CLINIC_RECORD);
- log.info("【操作员:{}】,门急诊诊疗记录上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return SiUtil.makeReturnWithoutOutput(result, "门急诊诊疗记录上传成功。");
- }
- public ResultVo<String> uploadEmergencyRecord(String patNo, int times) {
- List<EmergencyOprninfo> oprninfos = dao.selectEmergencyOprninfos(patNo, times);
- List<EmergencyRescueinfo> rescueinfos = new ArrayList<>();
- String oprninfo = JSONArray.toJSONString(oprninfos);
- String rescueinfo = JSONArray.toJSONString(rescueinfos);
- JSONObject input = exec.makeTradeHeader(SiFunction.UPLOAD_EMERGENCY_RECORD);
- input.getJSONObject("input").put("oprninfo", JSONArray.parseArray(oprninfo));
- input.getJSONObject("input").put("rescinfo", JSONArray.parseArray(rescueinfo));
- JSONObject result = exec.executeTrade(input, SiFunction.UPLOAD_EMERGENCY_RECORD);
- log.info("【操作员:{}】,急诊留观手术及抢救信息上传:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- return SiUtil.makeReturnWithoutOutput(result, "急诊留观手术及抢救信息上传成功。");
- }
- }
|