123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626 |
- package thyyxxk.webserver.service.medicalinsurance;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.Wrapper;
- 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.sidicts.SiFunction;
- import thyyxxk.webserver.constants.YesOrNo;
- import thyyxxk.webserver.constants.sidicts.*;
- import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
- import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
- import thyyxxk.webserver.entity.ResultVo;
- import thyyxxk.webserver.entity.dictionary.PureCodeName;
- import thyyxxk.webserver.entity.medicalinsurance.inpatient.InHspPsnInfo;
- import thyyxxk.webserver.entity.medicalinsurance.outpatient.SpcChrDiseAcct;
- import thyyxxk.webserver.entity.medicalinsurance.query.*;
- import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetldetail;
- import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
- import thyyxxk.webserver.entity.medicalinsurance.setlinfo.TimesList;
- import thyyxxk.webserver.entity.medicalinsurance.setllist.*;
- import thyyxxk.webserver.entity.yibao.ZyActpatient;
- import thyyxxk.webserver.service.wxapi.SendWxInfoService;
- import thyyxxk.webserver.utils.*;
- import java.math.BigDecimal;
- import java.time.LocalDate;
- import java.util.*;
- /**
- * @description: 医保查询服务
- * @author: DingJie
- * @create: 2021-06-23 16:35:23
- **/
- @Slf4j
- @Service
- public class SiQueryService {
- private final ExecService exec;
- private final SiQueryDao dao;
- private final SendWxInfoService wxsrvc;
- private final SiSetlinfoDao setlinfoDao;
- private static final String RESULT_CODE = "infcode";
- private static final String ERROR_MESSAGE = "err_msg";
- private static final String OUTPUT = "output";
- @Autowired
- public SiQueryService(ExecService exec, SiQueryDao dao, SendWxInfoService wxsrvc, SiSetlinfoDao setlinfoDao) {
- this.exec = exec;
- this.dao = dao;
- this.wxsrvc = wxsrvc;
- this.setlinfoDao = setlinfoDao;
- }
- public ResultVo<SiPatInfo> getSiPatInfo(QryPsnBsInfo qryPsnBsInfo) {
- SiPatInfo siPatInfo = dao.selectSiPatInfoForZy(qryPsnBsInfo.getPatNo(), qryPsnBsInfo.getTimes(), qryPsnBsInfo.getLedgerSn());
- if (null == siPatInfo) {
- siPatInfo = new SiPatInfo();
- }
- return ResultVoUtil.success(siPatInfo);
- }
- public ResultVo<PsnBaseInfo> obtainBasicPersonInfo(QryPsnBsInfo qryPsnBsInfo) {
- if (null == qryPsnBsInfo.getOnlyQry() && StringUtil.isBlank(qryPsnBsInfo.getMedType())) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "请选择患者的医疗类别!");
- }
- if (StringUtil.isBlank(qryPsnBsInfo.getSocialNo()) && StringUtil.notBlank(qryPsnBsInfo.getPatNo())
- && qryPsnBsInfo.getPatNo().length() >= 15) {
- qryPsnBsInfo.setSocialNo(qryPsnBsInfo.getPatNo());
- }
- if (StringUtil.isBlank(qryPsnBsInfo.getSocialNo())) {
- QryPsnBsInfo qpbi = dao.selectMzSocialAndName(qryPsnBsInfo.getPatNo());
- if (StringUtil.isBlank(qpbi.getSocialNo())) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的身份证不能为空,请补充!");
- }
- if (null == qryPsnBsInfo.getTimes()) {
- qryPsnBsInfo.setTimes(qpbi.getTimes());
- }
- qryPsnBsInfo.setName(qpbi.getName());
- qryPsnBsInfo.setSocialNo(qpbi.getSocialNo());
- qryPsnBsInfo.setLedgerSn(0);
- }
- if (null != qryPsnBsInfo.getLedgerSn() && qryPsnBsInfo.getLedgerSn() != 0) {
- qryPsnBsInfo.setLedgerSn(dao.selectMaxLedgerSn(qryPsnBsInfo.getPatNo(), qryPsnBsInfo.getTimes()));
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.OBTAIN_BASIC_PERSON_INFO, qryPsnBsInfo.getAdmdvs());
- JSONObject data = new JSONObject();
- if (qryPsnBsInfo.getSocialNo().length() < 15) {
- data.put("mdtrt_cert_type", MdtrtCertType.OTHER.getCode());
- data.put("psn_cert_type", PsnCertType.RESIDENCE_PERMIT_FOR_HMT.getCode());
- } else {
- data.put("mdtrt_cert_type", MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
- data.put("psn_cert_type", "01");
- }
- data.put("mdtrt_cert_no", qryPsnBsInfo.getSocialNo());
- data.put("certno", qryPsnBsInfo.getSocialNo());
- if (StringUtil.notBlank(qryPsnBsInfo.getName())) {
- data.put("psn_name", qryPsnBsInfo.getName());
- }
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.OBTAIN_BASIC_PERSON_INFO);
- 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 baseinfo = output.getJSONObject("baseinfo");
- PsnBaseInfo psnBaseinfo = JSONObject.parseObject(baseinfo.toJSONString(), PsnBaseInfo.class);
- psnBaseinfo.setPatNo(qryPsnBsInfo.getPatNo());
- psnBaseinfo.setTimes(qryPsnBsInfo.getTimes());
- psnBaseinfo.setLedgerSn(qryPsnBsInfo.getLedgerSn());
- psnBaseinfo.setMedType(qryPsnBsInfo.getMedType());
- psnBaseinfo.setGendName(Gend.get(psnBaseinfo.getGend()).getName());
- psnBaseinfo.setPsnCertTypeName(PsnCertType.get(psnBaseinfo.getPsnCertType()).getName());
- Naty naty = Naty.get(psnBaseinfo.getNaty());
- if (null != naty) {
- psnBaseinfo.setNatyName(naty.getName());
- }
- List<IdetInfo> idetInfos = new ArrayList<>();
- JSONArray idet = output.getJSONArray("idetinfo");
- for (int i = 0; i < idet.size(); i++) {
- JSONObject item = idet.getJSONObject(i);
- IdetInfo info = JSONObject.parseObject(item.toJSONString(), IdetInfo.class);
- PsnIdetType psnIdetType = PsnIdetType.get(info.getPsnIdetType());
- if (null != psnIdetType) {
- psnBaseinfo.setPsnIdetType(psnIdetType.getCode());
- info.setPsnIdetTypeName(psnIdetType.getName());
- }
- idetInfos.add(info);
- }
- if (StringUtil.notBlank(psnBaseinfo.getPsnIdetType())) {
- dao.updatePsnIdetType(psnBaseinfo.getPsnIdetType(), psnBaseinfo.getPsnNo());
- }
- psnBaseinfo.setIdetinfo(idetInfos);
- if (new Integer(1).equals(qryPsnBsInfo.getNeedSaving())) {
- dao.updateZyActpatient(psnBaseinfo);
- int saved = dao.selectSiZyInfoCount(qryPsnBsInfo.getPatNo(), qryPsnBsInfo.getTimes(), qryPsnBsInfo.getLedgerSn());
- if (saved == 0) {
- dao.insertSiZyInfoPsnNo(psnBaseinfo);
- } else {
- dao.updateSiZyInfoPsnNo(psnBaseinfo);
- }
- log.info("患者基本信息已更新:{}", psnBaseinfo);
- output.put("times", qryPsnBsInfo.getTimes());
- }
- List<InsuInfo> list = new ArrayList<>();
- JSONArray insuinfo = output.getJSONArray("insuinfo");
- for (int i = 0; i < insuinfo.size(); i++) {
- JSONObject item = insuinfo.getJSONObject(i);
- InsuInfo info = JSONObject.parseObject(item.toJSONString(), InsuInfo.class);
- Insutype insutype = Insutype.get(info.getInsutype());
- if (null != insutype) {
- info.setInsutypeName(insutype.getName());
- }
- PsnType psnType = PsnType.get(info.getPsnType());
- if (null != psnType) {
- info.setPsnTypeName(psnType.getName());
- }
- if (null != info.getPsnInsuStas()) {
- if (info.getPsnInsuStas().equals(YesOrNo.YES.getCodeStr())) {
- info.setPsnInsuStasName("正常参保");
- } else {
- info.setPsnInsuStasName("暂停参保");
- }
- }
- if (null != info.getCvlservFlag()) {
- if (info.getCvlservFlag().equals(YesOrNo.YES.getCodeStr())) {
- info.setCvlservFlagName("是");
- } else {
- info.setCvlservFlagName("否");
- }
- }
- if (null != info.getInsuplcAdmdvs()) {
- String admdvsName = dao.selectRegionName(info.getInsuplcAdmdvs());
- if (null == admdvsName) {
- PureCodeName region = dao.selectAdmdvsNameAndParentName(info.getInsuplcAdmdvs());
- if (null == region) {
- region = dao.selectAdmdvsName(info.getInsuplcAdmdvs());
- if (null == region) {
- region = dao.selectAdmdvsNameAndParentName(info.getInsuplcAdmdvs().substring(0, 4) + "00");
- }
- }
- admdvsName = region.getName();
- }
- info.setInsuplcAdmdvsName(admdvsName);
- }
- list.add(info);
- }
- psnBaseinfo.setInsuinfo(list);
- return ResultVoUtil.success(psnBaseinfo);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<MedInsInfo>> obtainMedicalInstitutionInfo(String type, String fuzzyName) {
- JSONObject input = exec.makeTradeHeader(SiFunction.OBTAIN_MEDICAL_INSTITUTION_INFO);
- JSONObject medinsinfo = new JSONObject();
- medinsinfo.put("fixmedins_type", type);
- medinsinfo.put("fixmedins_name", fuzzyName);
- input.getJSONObject("input").put("medinsinfo", medinsinfo);
- JSONObject result = exec.executeTrade(input, SiFunction.OBTAIN_MEDICAL_INSTITUTION_INFO);
- 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) {
- JSONArray output = result.getJSONObject(OUTPUT).getJSONArray("medinsinfo");
- List<MedInsInfo> list = new ArrayList<>();
- for (int i = 0; i < output.size(); i++) {
- JSONObject item = output.getJSONObject(i);
- MedInsInfo info = JSONObject.parseObject(item.toJSONString(), MedInsInfo.class);
- info.setFixmedinsAdmdvs(info.getFixmedinsCode().substring(1, 7));
- info.setFixmedinsAdmdvsName(dao.selectRegionName(info.getFixmedinsAdmdvs()));
- FixmedinsType fixmedinsType = FixmedinsType.get(info.getFixmedinsType());
- if (null != fixmedinsType) {
- info.setFixmedinsTypeName(fixmedinsType.getName());
- }
- HospLv hospLv = HospLv.get(info.getHospLv());
- if (null != hospLv) {
- info.setHospLvName(hospLv.getName());
- }
- list.add(info);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<MdtrtInfo>> queryVisitInfo(BscQryPrm q) {
- PureCodeName codeName = dao.selectPsnNoByPatNoAndMedType(q.getPatNo(), q.getMedType());
- if (null == codeName) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有找到患者该医疗类别的我院就诊记录。");
- }
- q.setPsnNo(codeName.getName());
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_VISIT_INFO, codeName.getCode());
- String ref = JSONObject.toJSONStringWithDateFormat(q, "yyyy-MM-dd HH:mm:ss");
- input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_VISIT_INFO);
- 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);
- JSONArray mdts = output.getJSONArray("mdtrtinfo");
- List<MdtrtInfo> list = new ArrayList<>();
- for (int i = 0; i < mdts.size(); i++) {
- JSONObject item = mdts.getJSONObject(i);
- MdtrtInfo mdtrtInfo = JSONObject.parseObject(item.toJSONString(), MdtrtInfo.class);
- if (null != mdtrtInfo.getInsuOptins()) {
- mdtrtInfo.setInsuOptinsName(dao.selectRegionName(mdtrtInfo.getInsuOptins()));
- }
- SiEnumReflectUtil.mdtrtInfoReflect(mdtrtInfo);
- list.add(mdtrtInfo);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<DiseInfo>> queryDiagnosisInfo(BscQryPrm q) {
- String admdvs = dao.selectAdmdvsByPsnNo(q.getPsnNo());
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_DIAGNOSIS_INFO, admdvs);
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- data.put("mdtrt_id", q.getMdtrtId());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_DIAGNOSIS_INFO);
- 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);
- List<DiseInfo> list = new ArrayList<>();
- JSONArray diseInfos = output.getJSONArray("diseinfo");
- for (int i = 0; i < diseInfos.size(); i++) {
- JSONObject item = diseInfos.getJSONObject(i);
- DiseInfo diseInfo = JSONObject.parseObject(item.toJSONString(), DiseInfo.class);
- SiEnumReflectUtil.diseInfoReflect(diseInfo);
- list.add(diseInfo);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<SetlInfo> querySettlementInfo(BscQryPrm q) {
- SiPatInfo siPatInfo;
- if (null == q.getMdtrtId()) {
- if (null == q.getLedgerSn()) {
- q.setLedgerSn(0);
- }
- siPatInfo = dao.selectSiPatInfoForZy(q.getPatNo(), q.getTimes(), q.getLedgerSn());
- } else {
- siPatInfo = dao.selectSiPatInfoByMdtrtId(q.getMdtrtId());
- }
- if (null == siPatInfo) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该次就诊尚未结算,无法查询结算信息。");
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_SETTLEMENT_INFO, siPatInfo.getInsuplcAdmdvs());
- JSONObject data = new JSONObject();
- data.put("psn_no", siPatInfo.getPsnNo());
- data.put("setl_id", siPatInfo.getSetlId());
- data.put("mdtrt_id", siPatInfo.getMdtrtId());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SETTLEMENT_INFO);
- 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 obj = output.getJSONObject("setlinfo");
- if (null == obj) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到该次就诊的结算明细。");
- }
- SetlInfo setlInfo = JSONObject.parseObject(obj.toJSONString(), SetlInfo.class);
- ClrType clrType = ClrType.get(setlInfo.getClrType());
- if (null != clrType) {
- setlInfo.setClrTypeName(clrType.getName());
- }
- MedType medType = MedType.get(setlInfo.getMedType());
- if (null != medType) {
- setlInfo.setMedTypeName(medType.getName());
- }
- Insutype insutype = Insutype.get(setlInfo.getInsutype());
- if (null != insutype) {
- setlInfo.setInsutypeName(insutype.getName());
- }
- PsnType psnType = PsnType.get(setlInfo.getPsnType());
- if (null != psnType) {
- setlInfo.setPsnTypeName(psnType.getName());
- }
- JSONArray setldetail = output.getJSONArray("setldetail");
- if (null != setldetail && setldetail.size() > 0) {
- List<SiSetldetail> list = new ArrayList<>();
- for (int i = 0; i < setldetail.size(); i++) {
- SiSetldetail setldtel = JSONObject.parseObject(setldetail.getJSONObject(i).toJSONString(), SiSetldetail.class);
- FundPayType fundPayType = FundPayType.get(setldtel.getFundPayType());
- if (null != fundPayType) {
- setldtel.setFundPayTypeName(fundPayType.getName());
- }
- list.add(setldtel);
- }
- setlInfo.setSetldetail(list);
- }
- return ResultVoUtil.success(setlInfo);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<Map<String, Object>> queryFeeDetails(QryFeeDetl q) {
- SiPatInfo psninfo = dao.selectSiPatInfoByMdtrtId(q.getMdtrtId());
- if (null == psninfo) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的医保登记信息。");
- }
- Map<String, Object> map = new HashMap<>();
- map.put("psninfo", psninfo);
- if (!q.getType().equals("settled")) {
- List<SiSetlFeeDetl> list = dao.selectTempCharge(psninfo.getPatNo(), psninfo.getTimes(), psninfo.getLedgerSn());
- if (null == list || list.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有已经上传的医保费用。");
- }
- map.put("feedtle", list);
- map.put("analyse", analyseFeedtle(list));
- return ResultVoUtil.success(map);
- }
- List<SiSetlFeeDetl> list = dao.selectFeeDetlList(psninfo.getMdtrtId(), psninfo.getPatNo(), psninfo.getTimes(), psninfo.getLedgerSn());
- if (list.size() > 0) {
- map.put("feedtle", list);
- map.put("analyse", analyseFeedtle(list));
- return ResultVoUtil.success(map);
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_FEE_DETAILS, psninfo.getInsuplcAdmdvs());
- JSONObject data = new JSONObject();
- data.put("psn_no", psninfo.getPsnNo());
- data.put("setl_id", psninfo.getSetlId());
- data.put("mdtrt_id", psninfo.getMdtrtId());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_FEE_DETAILS);
- 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) {
- JSONArray output = result.getJSONArray(OUTPUT);
- if (null == output || output.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到费用明细。");
- }
- for (int i = 0; i < output.size(); i++) {
- list.add(JSONObject.parseObject(output.getJSONObject(i).toJSONString(), SiSetlFeeDetl.class));
- if (list.size() == 30) {
- dao.insertSetlFeeDetlBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dao.insertSetlFeeDetlBatch(list);
- }
- list = dao.selectFeeDetlList(psninfo.getMdtrtId(), psninfo.getPatNo(), psninfo.getTimes(), psninfo.getLedgerSn());
- map.put("feedtle", list);
- map.put("analyse", analyseFeedtle(list));
- return ResultVoUtil.success(map);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- private Map<String, String[]> analyseFeedtle(List<SiSetlFeeDetl> fees) {
- Map<String, String[]> map = new HashMap<>();
- map.put("zhj", new String[]{"合计", "0.00", "0.00", "0.00"});
- fees.forEach(itm -> {
- if (StringUtil.isBlank(itm.getChrgitmLvName())) {
- ChrgitmLv chrgitmLv = ChrgitmLv.get(itm.getChrgitmLv());
- if (null == chrgitmLv) {
- chrgitmLv = ChrgitmLv.SELF_PAY;
- }
- itm.setChrgitmLvName(chrgitmLv.getName());
- }
- String[] all = map.get("zhj");
- all[1] = DecimalUtil.add(all[1], itm.getDetItemFeeSumamt());
- all[2] = DecimalUtil.add(all[2], itm.getInscpScpAmt());
- all[3] = DecimalUtil.add(all[3], DecimalUtil.minus(itm.getDetItemFeeSumamt(), itm.getInscpScpAmt()));
- if (map.containsKey(itm.getMedChrgitmType())) {
- String[] dtle = map.get(itm.getMedChrgitmType());
- dtle[1] = DecimalUtil.add(dtle[1], itm.getDetItemFeeSumamt());
- dtle[2] = DecimalUtil.add(dtle[2], itm.getInscpScpAmt());
- dtle[3] = DecimalUtil.add(dtle[3], DecimalUtil.minus(itm.getDetItemFeeSumamt(), itm.getInscpScpAmt()));
- } else {
- String[] dtle = new String[4];
- MedChrgitmType type = MedChrgitmType.get(itm.getMedChrgitmType());
- if (type == null) {
- type = MedChrgitmType.OTH;
- itm.setMedChrgitmType(type.getCode());
- }
- dtle[0] = type.getName();
- dtle[1] = itm.getDetItemFeeSumamt();
- dtle[2] = itm.getInscpScpAmt();
- dtle[3] = DecimalUtil.minus(itm.getDetItemFeeSumamt(), itm.getInscpScpAmt());
- map.put(type.getCode(), dtle);
- }
- });
- return map;
- }
- public ResultVo<List<TrtInfo>> checkPersonTreatment(BscQryPrm q) {
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.CHECK_PERSON_TREATMENT,
- dao.selectAdmdvs(q.getPatNo(), q.getTimes()));
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- data.put("insutype", q.getInsutype());
- data.put("fixmedins_code", SiUtil.INSTITUTION_ID);
- data.put("med_type", q.getMedType());
- data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.CHECK_PERSON_TREATMENT);
- 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) {
- List<TrtInfo> list = new ArrayList<>();
- JSONObject output = result.getJSONObject(OUTPUT);
- JSONArray trtinfo = output.getJSONArray("trtinfo");
- for (int i = 0; i < trtinfo.size(); i++) {
- JSONObject obj = trtinfo.getJSONObject(i);
- TrtInfo item = JSONObject.parseObject(obj.toJSONString(), TrtInfo.class);
- TrtChkType trtChkType = TrtChkType.get(item.getTrtChkType());
- if (null != trtChkType) {
- item.setTrtChkTypeName(trtChkType.getName());
- }
- FundPayType fundPayType = FundPayType.get(item.getFundPayType());
- if (null != fundPayType) {
- item.setFundPayTypeName(fundPayType.getName());
- }
- if (null != item.getTrtEnjymntFlag()) {
- if (item.getTrtEnjymntFlag().equals(YesOrNo.YES.getCodeStr())) {
- item.setTrtEnjymntFlagName("是");
- } else {
- item.setTrtEnjymntFlagName("否");
- }
- }
- list.add(item);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<InHspPsnInfo>> queryInHospitalPatientsInfo(BscQryPrm q) {
- if (StringUtil.notBlank(q.getPatNo())) {
- String psnNo = dao.selectPsnNo(q.getPatNo());
- if (null == psnNo) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【住院号/门诊号:" + q.getPatNo() +
- "】没有找到此患者在我院的医保在院信息,请核实。");
- }
- q.setPsnNo(psnNo);
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_IN_HOSPITAL_PATIENTS_INFO,
- dao.selectAdmdvsByPatNoAndPsnNo(q.getPatNo(), q.getPsnNo()));
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
- data.put("endtime", null == q.getEndtime() ? DateUtil.now() : DateUtil.formatDatetime(q.getEndtime()));
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_IN_HOSPITAL_PATIENTS_INFO);
- 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);
- JSONArray pts = output.getJSONArray("data");
- if (pts.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到医保在院的患者信息。");
- }
- List<InHspPsnInfo> list = new ArrayList<>();
- for (int i = 0; i < pts.size(); i++) {
- JSONObject item = pts.getJSONObject(i);
- InHspPsnInfo inHspPsnInfo = JSONObject.parseObject(item.toJSONString(), InHspPsnInfo.class);
- SiEnumReflectUtil.inHspPsnInfoReflect(inHspPsnInfo);
- list.add(inHspPsnInfo);
- }
- if (list.size() == 1 && null != q.getTimes()) {
- InHspPsnInfo info = list.get(0);
- dao.updateInhospInfo(q.getPatNo(), q.getTimes(), q.getLedgerSn(), info.getMdtrtId(), info.getInsutype());
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<RefMedin>> queryPersonnelTransferHospitalInfo(BscQryPrm q) {
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_TRANSFER_HOSPITAL_INFO,
- dao.selectAdmdvsByPatNoAndPsnNo(q.getPatNo(), q.getPsnNo()));
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
- data.put("endtime", DateUtil.formatDatetime(q.getEndtime()));
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_TRANSFER_HOSPITAL_INFO);
- 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);
- JSONArray array = output.getJSONArray("refmedin");
- if (null == array || array.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到符合条件的转院信息。");
- }
- List<RefMedin> list = new ArrayList<>();
- for (int i = 0; i < array.size(); i++) {
- JSONObject obj = array.getJSONObject(i);
- RefMedin item = JSONObject.parseObject(obj.toJSONString(), RefMedin.class);
- Insutype insutype = Insutype.get(item.getInsutype());
- if (null != insutype) {
- item.setInsutypeName(insutype.getName());
- }
- DclaSouc dclaSouc = DclaSouc.get(item.getDclaSouc());
- if (null != dclaSouc) {
- item.setDclaSoucName(dclaSouc.getName());
- }
- PsnCertType psnCertType = PsnCertType.get(item.getPsnCertType());
- if (null != psnCertType) {
- item.setPsnCertTypeName(psnCertType.getName());
- }
- item.setGendName(Gend.get(item.getGend()).getName());
- if (null != item.getInsuOptins()) {
- item.setInsuOptinsName(dao.selectRegionName(item.getInsuOptins()));
- }
- if (null != item.getOutFlag()) {
- if (item.getOutFlag().equals(YesOrNo.YES.getCodeStr())) {
- item.setOutFlagName("是");
- } else {
- item.setOutFlagName("否");
- }
- }
- if (null != item.getHospAgreReflFlag()) {
- if (item.getHospAgreReflFlag().equals(YesOrNo.YES.getCodeStr())) {
- item.setHospAgreReflFlagName("是");
- } else {
- item.setHospAgreReflFlagName("否");
- }
- }
- list.add(item);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<MedUseRcd>> querySpecialChronicDiseasesMedicalRecord(BscQryPrm q) {
- if (null == q.getPsnNo()) {
- String psnNo = dao.selectPsnNo(q.getPatNo());
- if (null == psnNo) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【住院号/门诊号:" + q.getPatNo() +
- "】未找到此患者的医保参保信息,请核实。");
- }
- q.setPsnNo(psnNo);
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_MEDICAL_RECORD,
- dao.selectAdmdvsByPsnNo(q.getPsnNo()));
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
- data.put("endtime", DateUtil.formatDatetime(q.getEndtime()));
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_MEDICAL_RECORD);
- 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);
- JSONArray array = output.getJSONArray("feedetail");
- if (null == array || array.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到此人的慢特病用药记录。");
- }
- List<MedUseRcd> list = new ArrayList<>();
- for (int i = 0; i < array.size(); i++) {
- JSONObject obj = array.getJSONObject(i);
- MedUseRcd item = JSONObject.parseObject(obj.toJSONString(), MedUseRcd.class);
- list.add(item);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<CumInfo>> queryPersonnelCumulativeInfo(BscQryPrm q) {
- String admdvs = q.getAdmdvs();
- if (StringUtil.isBlank(admdvs)) {
- admdvs = dao.selectAdmdvsByPsnNo(q.getPsnNo());
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO, admdvs);
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- data.put("cum_ym", q.getCumYm());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO);
- 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);
- JSONArray array = output.getJSONArray("cuminfo");
- List<CumInfo> list = new ArrayList<>();
- for (int i = 0; i < array.size(); i++) {
- JSONObject obj = array.getJSONObject(i);
- CumInfo item = JSONObject.parseObject(obj.toJSONString(), CumInfo.class);
- Insutype insutype = Insutype.get(item.getInsutype());
- if (null != insutype) {
- item.setInsutypeName(insutype.getName());
- }
- list.add(item);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<SpcChrDiseAcct>> querySpecialChronicDiseasesAccreditation(BscQryPrm q) {
- if (null == q.getPsnNo()) {
- String psnNo = dao.selectPsnNo(q.getPatNo());
- if (null == psnNo) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【住院号/门诊号:" + q.getPatNo() +
- "】未找到此患者的医保参保信息,请核实。");
- }
- q.setPsnNo(psnNo);
- }
- if (StringUtil.isBlank(q.getAdmdvs())) {
- String admdvs = StringUtil.isBlank(q.getPatNo()) ? dao.selectAdmdvsByPsnNo(q.getPsnNo())
- : dao.selectAdmdvsByPatNo(q.getPatNo());
- q.setAdmdvs(admdvs);
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_ACCREDITATION, q.getAdmdvs());
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_ACCREDITATION);
- 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);
- JSONArray details = output.getJSONArray("feedetail");
- if (null == details || details.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到此患者的慢特病备案信息。");
- }
- List<SpcChrDiseAcct> list = new ArrayList<>();
- Date now = new Date();
- for (int i = 0; i < details.size(); i++) {
- JSONObject detail = details.getJSONObject(i);
- SpcChrDiseAcct spcChrDiseAcct = JSONObject.parseObject(detail.toJSONString(), SpcChrDiseAcct.class);
- if (null != q.getNeedAllRcd() && 1 == q.getNeedAllRcd()) {
- list.add(spcChrDiseAcct);
- } else {
- if (now.before(spcChrDiseAcct.getEnddate())) {
- spcChrDiseAcct.setPatNo(q.getPatNo());
- spcChrDiseAcct.setTimes(q.getTimes());
- list.add(spcChrDiseAcct);
- }
- }
- }
- if (list.size() > 0) {
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的慢特病备案,或慢特病备案已过期!");
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<PsnFixMedin>> queryPersonnelAssignmentInfo(BscQryPrm q) {
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_ASSIGNMENT_INFO,
- dao.selectAdmdvs(q.getPatNo(), q.getTimes()));
- JSONObject data = new JSONObject();
- data.put("psn_no", q.getPsnNo());
- data.put("biz_appy_type", q.getBizAppyType());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_ASSIGNMENT_INFO);
- 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);
- JSONArray array = output.getJSONArray("psnfixmedin");
- if (null == array || array.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到对应的点定信息。");
- }
- List<PsnFixMedin> list = new ArrayList<>();
- for (int i = 0; i < array.size(); i++) {
- JSONObject obj = array.getJSONObject(i);
- PsnFixMedin item = JSONObject.parseObject(obj.toJSONString(), PsnFixMedin.class);
- Insutype insutype = Insutype.get(item.getInsutype());
- if (null != insutype) {
- item.setInsutypeName(insutype.getName());
- }
- list.add(item);
- }
- return ResultVoUtil.success(list);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
- }
- public ResultVo<List<TimesList>> fetchSiTimesList(String patNo, Integer type) {
- List<TimesList> list = dao.fetchSiTimesList(patNo, type);
- if (null == list || list.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "此患者没有有效的结算信息。");
- }
- return ResultVoUtil.success(list);
- }
- public ResultVo<String> queryInsuplcAdmdvsByMdtrtId(String mdtrtId) {
- return ResultVoUtil.success(dao.selectInsuplcAdmdvsByMdtrtId(mdtrtId));
- }
- public ResultVo querySiSetlList(SetlIndex index) {
- if (null == index.getTimes() && StringUtil.isBlank(index.getLabel())) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "结算条目不能为空!");
- }
- if (StringUtil.notBlank(index.getLabel())) {
- String[] arr = index.getLabel().split("_");
- index.setSetlId(arr[0]);
- index.setTimes(Integer.parseInt(arr[1]));
- if (index.getType() == SetlType.INPATIENT.getCode()) {
- index.setLedgerSn(Integer.parseInt(arr[2]));
- } else {
- index.setLedgerSn(0);
- }
- } else {
- index.setLedgerSn(0);
- index.setSetlId(dao.selectSetlId(index.getPatNo(), index.getTimes(), index.getLedgerSn()));
- }
- SiPatInfo siPatInfo = dao.selectSiPatInfo(index.getPatNo(), index.getTimes(), index.getLedgerSn());
- if (null == siPatInfo) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的结算信息!");
- }
- CuminfoInYear cuminfo = getYearCuminfo(siPatInfo.getPsnNo(), siPatInfo.getInsuplcAdmdvs());
- if (cuminfo.getCode() != ExceptionEnum.SUCCESS.getCode()) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, cuminfo.getMessage());
- }
- if (index.getType() == SetlType.INPATIENT.getCode()) {
- InptntSetlmtLst lst = dao.selectZySetlinfo(index.getSetlId(), "zy_inactpatient");
- if (null == lst) {
- lst = dao.selectZySetlinfo(index.getSetlId(), "zy_actpatient");
- if (null == lst) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的结算信息!");
- }
- }
- lst.setInHospdays(DateUtil.daysBetween(lst.getBegntime(), lst.getEndtime()) + 1);
- PsnIdetType psnIdetType = PsnIdetType.get(lst.getPsnIdetType());
- if (null != psnIdetType) {
- lst.setPsnIdetTypeName(psnIdetType.getName());
- }
- Admdvs admdvs = Admdvs.get(lst.getInsuplcAdmdvs());
- if (null == admdvs) {
- lst.setInsuplcAdmdvsName(dao.selectRegionName(lst.getInsuplcAdmdvs()));
- } else {
- lst.setInsuplcAdmdvsName(admdvs.getName());
- }
- lst.setFixmedinsName(SiUtil.INSTITUTION_NAME);
- lst.setGendName(Gend.get(lst.getGend()).getName());
- SiEnumReflectUtil.inptntSetlmtLstReflect(lst);
- ResultVo<List<SiSetlFeeDetl>> chrgrsvo = getChrgitems(lst.getPsnNo(), lst.getSetlId(), lst.getMdtrtId(), lst.getInsuplcAdmdvs());
- if (!chrgrsvo.getCode().equals(ExceptionEnum.SUCCESS.getCode())) {
- return chrgrsvo;
- }
- analyzeZyChrgitm(lst, chrgrsvo.getData());
- lst.setYrAdmtimes(cuminfo.getYearAdmtimesZy());
- lst.setYrAcmltvExpsClted(cuminfo.getYearPeriodfeeSumamtZy());
- lst.setYrMedfeeSumamt(cuminfo.getYearMedfeesumZy());
- lst.setYrPayedBegnLine(cuminfo.getYearPayedBegnlineZy());
- lst.setYrFundPaySumamt(cuminfo.getYearBaseFundPayAmtZy());
- lst.setYrBigAmtFundPay(cuminfo.getYearBigAmtpaysZy());
- lst.setYrBigDssInsPay(cuminfo.getYearBigdssFundPayAmtZy());
- lst.setYrMafPay(cuminfo.getYearMafPayAmtZy());
- lst.setYrPolicySelfPay(cuminfo.getYearPolicySelfPayZy());
- lst.setYrPreSelfPay(cuminfo.getYearPreSelfPayZy());
- lst.setYrBigDssFee(cuminfo.getYearBigDssLegalFee());
- return listPolItemCodePayInfo(lst);
- } else {
- index.setLedgerSn(0);
- OtptntSetlmtLst lst = dao.selectMzSetlifo(index.getPatNo(), index.getTimes());
- if (null == lst) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的结算信息!");
- }
- Admdvs admdvs = Admdvs.get(lst.getInsuplcAdmdvs());
- if (null == admdvs) {
- lst.setInsuplcAdmdvsName(dao.selectRegionName(lst.getInsuplcAdmdvs()));
- } else {
- lst.setInsuplcAdmdvsName(admdvs.getName());
- }
- SiEnumReflectUtil.outptntSetlmtLstReflect(lst);
- List<BrfChrgitm> chrgitms = dao.selectMzBrfChrgitms(index.getPatNo(), index.getTimes());
- analyzeMzChrgitm(lst, chrgitms);
- lst.setYrAdmtimes(cuminfo.getYearAdmtimesMz());
- lst.setYrMedfeeSumamt(cuminfo.getYearMedfeesumMz());
- lst.setYrFundPaySumamt(cuminfo.getYearBaseFundPayAmtMz());
- lst.setYrBigAmtFundPay(cuminfo.getYearBigAmtpaysMz());
- lst.setYrBigDssFundPay(cuminfo.getYearBigdssFundPayAmtMz());
- lst.setYrAcctPay(cuminfo.getYearAcctPayMz());
- lst.setYrMafPay(cuminfo.getYearMafPayAmtMz());
- lst.setFixmedinsName(SiUtil.INSTITUTION_NAME);
- return ResultVoUtil.success(lst);
- }
- }
- private ResultVo<InptntSetlmtLst> listPolItemCodePayInfo(InptntSetlmtLst lst) {
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.LIST_POL_ITEM_CODE_PAY_INFO, lst.getInsuplcAdmdvs());
- JSONObject data = new JSONObject();
- data.put("psn_no", lst.getPsnNo());
- data.put("mdtrt_id", lst.getMdtrtId());
- data.put("setl_id", lst.getSetlId());
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.LIST_POL_ITEM_CODE_PAY_INFO);
- log.info("【操作员:{}】,政策信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- if (null == result.getInteger("code")) {
- String message = result.getString("message");
- if (null == message) {
- message = result.getString(ERROR_MESSAGE);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + message);
- }
- if (result.getIntValue("code") != 0) {
- String message = result.getString("message");
- if (null == message) {
- message = result.getString(ERROR_MESSAGE);
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心出错:" + message);
- }
- JSONArray array = result.getJSONArray("data");
- BigDecimal selfPaySum = new BigDecimal(0);
- BigDecimal fundPaySum = new BigDecimal(0);
- for (int i = 0; i < array.size(); i++) {
- JSONObject itm = array.getJSONObject(i);
- BigDecimal selfPayAmt = BigDecimal.valueOf(itm.getDouble("selfPayAmt"));
- String selfPayProp = itm.getString("selfPayProp");
- BigDecimal fundPayAmt = BigDecimal.valueOf(itm.getDouble("fundPayAmt"));
- String fundPayProp = itm.getString("fundPayProp");
- BigDecimal polItemPaySum = BigDecimal.valueOf(itm.getDouble("polItemPaySum"));
- selfPaySum = selfPaySum.add(selfPayAmt);
- fundPaySum = fundPaySum.add(fundPayAmt);
- PolItemCode polItemCode = PolItemCode.get(itm.getString("polItemCode"));
- if (null == polItemCode) {
- String message = String.format("找到了字典缺失的政策项:%s", itm);
- log.info(message);
- wxsrvc.sendCorpWxMsg("2801", message);
- continue;
- }
- switch (polItemCode) {
- case QZF:
- lst.setSelfPayPsnAmt(selfPayAmt);
- lst.setSelfPayPsnProp(selfPayProp);
- lst.setSelfPayFundAmt(fundPayAmt);
- lst.setSelfPayFundProp(fundPayProp);
- lst.setSelfPaySum(polItemPaySum);
- break;
- case YLXZF:
- lst.setScndPrePayPsnAmt(selfPayAmt);
- lst.setScndPrePayPsnProp(selfPayProp);
- lst.setScndPrePayFundAmt(fundPayAmt);
- lst.setScndPrePayFundProp(fundPayProp);
- lst.setScndPrePaySum(polItemPaySum);
- break;
- case CXEZF:
- lst.setOvrlmtSelfPayPsnAmt(selfPayAmt);
- lst.setOvrlmtSelfPayPsnProp(selfPayProp);
- lst.setOvrlmtSelfPayFundAmt(fundPayAmt);
- lst.setOvrlmtSelfPayFundProp(fundPayProp);
- lst.setOvrlmtSelfPaySum(polItemPaySum);
- break;
- case BCYFQFBZ:
- lst.setBegnlinePsnAmt(selfPayAmt);
- lst.setBegnlinePsnProp(selfPayProp);
- lst.setBegnlineFundAmt(fundPayAmt);
- lst.setBegnlineFundProp(fundPayProp);
- lst.setBegnlineSum(polItemPaySum);
- break;
- case TCYD:
- lst.setFundFrstLvPsnAmt(selfPayAmt);
- lst.setFundFrstLvPsnProp(selfPayProp);
- lst.setFundFrstLvFundAmt(fundPayAmt);
- lst.setFundFrstLvFundProp(fundPayProp);
- lst.setFundFrstLvSum(polItemPaySum);
- break;
- case TCED:
- lst.setFundScndLvPsnAmt(selfPayAmt);
- lst.setFundScndLvPsnProp(selfPayProp);
- lst.setFundScndLvFundAmt(fundPayAmt);
- lst.setFundScndLvFundProp(fundPayProp);
- lst.setFundScndLvSum(polItemPaySum);
- break;
- case DEYD:
- lst.setBigAmtFrstLvPsnAmt(selfPayAmt);
- lst.setBigAmtFrstLvPsnProp(selfPayProp);
- lst.setBigAmtFrstLvFundAmt(fundPayAmt);
- lst.setBigAmtFrstLvFundProp(fundPayProp);
- lst.setBigAmtFrstLvSum(polItemPaySum);
- break;
- }
- }
- lst.setAllPsnAmt(selfPaySum);
- lst.setAllFundAmt(fundPaySum);
- lst.setAllSum(fundPaySum.add(selfPaySum));
- return ResultVoUtil.success(lst);
- }
- private CuminfoInYear getYearCuminfo(String psnNo, String admdvs) {
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO, admdvs);
- JSONObject data = new JSONObject();
- data.put("psn_no", psnNo);
- data.put("cum_ym", "");
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO);
- CuminfoInYear cuminfo = new CuminfoInYear();
- if (null == result) {
- cuminfo.setCode(ExceptionEnum.NETWORK_ERROR.getCode());
- cuminfo.setMessage(ExceptionEnum.NETWORK_ERROR.getMessage());
- return cuminfo;
- }
- if (null == result.getInteger(RESULT_CODE)) {
- cuminfo.setCode(ExceptionEnum.LOGICAL_ERROR.getCode());
- cuminfo.setMessage("医保中心报错:" + result.getString("message"));
- return cuminfo;
- }
- if (result.getIntValue(RESULT_CODE) != 0) {
- cuminfo.setCode(ExceptionEnum.NETWORK_ERROR.getCode());
- cuminfo.setMessage("医保中心出错:" + result.getString("message"));
- return cuminfo;
- }
- cuminfo.setCode(ExceptionEnum.SUCCESS.getCode());
- String year = String.valueOf(LocalDate.now().getYear());
- JSONArray cuminfos = result.getJSONObject(OUTPUT).getJSONArray("cuminfo");
- log.info("累计信息:{}", cuminfos);
- for (int i = 0; i < cuminfos.size(); i++) {
- JSONObject itm = cuminfos.getJSONObject(i);
- if (itm.getString("year").equals(year)) {
- switch (itm.getString("cum_type_code")) {
- // 本年住院次数
- case "C0000_BIZ2101":
- case "C0000_BIZ2102":
- case "C0000_BIZ2106":
- case "C0000_BIZ2107":
- case "C0000_BIZ22":
- case "C0000_BIZ52":
- cuminfo.addYearAdmtimesZy(itm.getDoubleValue("cum"));
- break;
- // 本年门诊次数
- case "C0000_BIZ11":
- case "C0000_BIZ13":
- case "C0000_BIZ14":
- case "C0000_BIZ51":
- case "C0000_BIZ9901":
- case "C0000_BIZ9903":
- case "C0000_BIZ9904":
- cuminfo.addYearAdmtimesMz(itm.getDoubleValue("cum"));
- break;
- // 本年度住院分段计算费用累计
- case "S0000_BIZ2101":
- case "S0000_BIZ2102":
- case "S0000_BIZ2106":
- case "S0000_BIZ2107":
- case "S0000_BIZ22":
- case "S0000_BIZ52":
- cuminfo.addYearPeriodFeeSumZy(itm.getDoubleValue("cum"));
- break;
- // 住院医疗费合计
- case "F0000_BIZ2101":
- case "F0000_BIZ2102":
- case "F0000_BIZ2106":
- case "F0000_BIZ2107":
- case "F0000_BIZ22":
- case "F0000_BIZ52":
- cuminfo.addYearFeesumZy(itm.getDoubleValue("cum"));
- break;
- // 门诊医疗费合计
- case "F0000_BIZ11":
- case "F0000_BIZ13":
- case "F0000_BIZ14":
- case "F0000_BIZ51":
- case "F0000_BIZ9901":
- case "F0000_BIZ9903":
- case "F0000_BIZ9904":
- cuminfo.addYearFeesumMz(itm.getDoubleValue("cum"));
- break;
- // 住院已付起付线
- case "Q0000_BIZ2101":
- case "Q0000_BIZ2102":
- case "Q0000_BIZ2106":
- case "Q0000_BIZ2107":
- case "Q0000_BIZ22":
- case "Q0000_BIZ52":
- cuminfo.addYearPayedbegnlineZy(itm.getDoubleValue("cum"));
- break;
- // 住院统筹支付
- case "D310101_BIZ2101":
- case "D310101_BIZ2102":
- case "D310101_BIZ2106":
- case "D310101_BIZ2107":
- case "D310101_BIZ22":
- case "D310101_BIZ52":
- case "D390101_BIZ2101":
- case "D390101_BIZ2102":
- case "D390101_BIZ2106":
- case "D390101_BIZ2107":
- case "D390101_BIZ22":
- case "D390101_BIZ52":
- cuminfo.addYearFundpaysZy(itm.getDoubleValue("cum"));
- break;
- // 门诊统筹支付
- case "D310101_BIZ11":
- case "D310101_BIZ13":
- case "D310101_BIZ14":
- case "D310101_BIZ51":
- case "D310101_BIZ9901":
- case "D310101_BIZ9903":
- case "D310101_BIZ9904":
- case "D390101_BIZ11":
- case "D390101_BIZ13":
- case "D390101_BIZ14":
- case "D390101_BIZ51":
- case "D390101_BIZ9901":
- case "D390101_BIZ9903":
- case "D390101_BIZ9904":
- cuminfo.addYearFundpaysMz(itm.getDoubleValue("cum"));
- break;
- // 政策自费
- case "Z0000_BIZ2101_LAB101":
- case "Z0000_BIZ2102_LAB101":
- case "Z0000_BIZ22_LAB101":
- case "Z0000_BIZ2106_LAB101":
- case "Z0000_BIZ2107_LAB101":
- case "Z0000_BIZ52_LAB101":
- case "Z0000_BIZ2101_LAB103":
- case "Z0000_BIZ2102_LAB103":
- case "Z0000_BIZ22_LAB103":
- case "Z0000_BIZ2106_LAB103":
- case "Z0000_BIZ2107_LAB103":
- case "Z0000_BIZ52_LAB103":
- cuminfo.addYearPolicySelfpayZy(itm.getDoubleValue("cum"));
- break;
- // 政策自付
- case "Z0000_BIZ2101_LAB102":
- case "Z0000_BIZ2102_LAB102":
- case "Z0000_BIZ22_LAB102":
- case "Z0000_BIZ2106_LAB102":
- case "Z0000_BIZ2107_LAB102":
- case "Z0000_BIZ52_LAB102":
- cuminfo.addYearPreSelfpayZy(itm.getDoubleValue("cum"));
- break;
- // 住院大额基金支付
- case "D330101_BIZ2101":
- case "D330101_BIZ2102":
- case "D330101_BIZ2106":
- case "D330101_BIZ2107":
- case "D330101_BIZ22":
- case "D330101_BIZ52":
- cuminfo.addYearBigAmtpaysZy(itm.getDoubleValue("cum"));
- break;
- // 门诊大额基金支付
- case "D330101_BIZ11":
- case "D330101_BIZ13":
- case "D330101_BIZ14":
- case "D330101_BIZ51":
- case "D330101_BIZ9901":
- case "D330101_BIZ9903":
- case "D330101_BIZ9904":
- cuminfo.addYearBigAmtpaysMz(itm.getDoubleValue("cum"));
- break;
- // 住院大病保险支付
- case "D390201_BIZ2101":
- case "D390201_BIZ2102":
- case "D390201_BIZ2106":
- case "D390201_BIZ2107":
- case "D390201_BIZ22":
- case "D390201_BIZ52":
- cuminfo.addYearBigdssInspaysZy(itm.getDoubleValue("cum"));
- break;
- // 门诊大病保险支付
- case "D390201_BIZ11":
- case "D390201_BIZ13":
- case "D390201_BIZ14":
- case "D390201_BIZ51":
- case "D390201_BIZ9901":
- case "D390201_BIZ9903":
- case "D390201_BIZ9904":
- cuminfo.addYearBigdssInspaysMz(itm.getDoubleValue("cum"));
- break;
- // 住院医疗救助支付
- case "D610101_BIZ2101":
- case "D610101_BIZ2102":
- case "D610101_BIZ2106":
- case "D610101_BIZ2107":
- case "D610101_BIZ22":
- case "D610101_BIZ52":
- cuminfo.addYearMafpaysZy(itm.getDoubleValue("cum"));
- break;
- // 门诊医疗救助支付
- case "D610101_BIZ11":
- case "D610101_BIZ13":
- case "D610101_BIZ14":
- case "D610101_BIZ51":
- case "D610101_BIZ9901":
- case "D610101_BIZ9903":
- case "D610101_BIZ9904":
- cuminfo.addYearMafpaysMz(itm.getDoubleValue("cum"));
- break;
- // 门诊个人账户支付
- case "D310201_BIZ11":
- case "D310201_BIZ13":
- case "D310201_BIZ14":
- case "D310201_BIZ51":
- case "D310201_BIZ9901":
- case "D310201_BIZ9903":
- case "D310201_BIZ9904":
- cuminfo.addYearAcctPayMz(itm.getDoubleValue("cum"));
- break;
- // 大病保险合规费用
- case "TS390201":
- cuminfo.addYearBigdssLegalFee(itm.getDoubleValue("cum"));
- break;
- }
- }
- }
- return cuminfo;
- }
- private ResultVo<List<SiSetlFeeDetl>> getChrgitems(String psnNo, String setlId, String mdtrtId, String admdvs) {
- List<SiSetlFeeDetl> list = dao.selectAllSetlFeeDtle(mdtrtId);
- if (list.size() > 0) {
- return ResultVoUtil.success(list);
- }
- JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_FEE_DETAILS, admdvs);
- JSONObject data = new JSONObject();
- data.put("psn_no", psnNo);
- data.put("setl_id", setlId);
- data.put("mdtrt_id", mdtrtId);
- input.getJSONObject("input").put("data", data);
- JSONObject result = exec.executeTrade(input, SiFunction.QUERY_FEE_DETAILS);
- 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 (0 == result.getInteger(RESULT_CODE)) {
- JSONArray output = result.getJSONArray(OUTPUT);
- if (null == output || output.size() == 0) {
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到费用明细。");
- }
- for (int i = 0; i < output.size(); i++) {
- SiSetlFeeDetl fee = JSONObject.parseObject(output.getJSONObject(i).toJSONString(), SiSetlFeeDetl.class);
- if (StringUtil.isBlank(fee.getSetlId())) {
- fee.setSetlId(setlId);
- }
- list.add(fee);
- if (list.size() == 30) {
- dao.insertSetlFeeDetlBatch(list);
- list.clear();
- }
- }
- if (list.size() > 0) {
- dao.insertSetlFeeDetlBatch(list);
- }
- return ResultVoUtil.success(dao.selectAllSetlFeeDtle(mdtrtId));
- }
- return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, result.getString(ERROR_MESSAGE));
- }
- private void analyzeZyChrgitm(InptntSetlmtLst lst, List<SiSetlFeeDetl> chrgitms) {
- Map<String, BigDecimal> map = new HashMap<>();
- map.put("allfeeSum", new BigDecimal(0));
- map.put("totalFrst", new BigDecimal(0));
- map.put("totalScnd", new BigDecimal(0));
- chrgitms.forEach(itm -> {
- BigDecimal itmfeeSum = new BigDecimal(itm.getDetItemFeeSumamt());
- map.replace("allfeeSum", map.get("allfeeSum").add(itmfeeSum));
- if (itm.getChrgitmLv().equals(ChrgitmLv.FIRST_CLASS.getCode())) {
- map.replace("totalFrst", map.get("totalFrst").add(itmfeeSum));
- } else if (itm.getChrgitmLv().equals(ChrgitmLv.SECOND_CLASS.getCode())) {
- map.replace("totalScnd", map.get("totalScnd").add(itmfeeSum));
- }
- String typeKey = itm.getMedChrgitmType();
- String lvKey = typeKey + "-" + itm.getChrgitmLv();
- if (map.containsKey(typeKey)) {
- map.replace(typeKey, map.get(typeKey).add(itmfeeSum));
- } else {
- map.put(typeKey, itmfeeSum);
- }
- if (map.containsKey(lvKey)) {
- map.replace(lvKey, map.get(lvKey).add(itmfeeSum));
- } else {
- map.put(lvKey, itmfeeSum);
- }
- });
- lst.setAllfeeSum(map.get("allfeeSum"));
- lst.setAllfeeFrst(map.get("totalFrst"));
- lst.setAllfeeScnd(map.get("totalScnd"));
- lst.setWestMedFeeSum(map.get("09"));
- lst.setWestMedFeeFrst(map.get("09-01"));
- lst.setWestMedFeeScnd(map.get("09-02"));
- lst.setHerbalSum(map.get("10"));
- lst.setHerbalFrst(map.get("10-01"));
- lst.setHerbalScnd(map.get("10-02"));
- lst.setChnsPtntSum(map.get("11"));
- lst.setChnsPtntFrst(map.get("11-01"));
- lst.setChnsPtntScnd(map.get("11-02"));
- lst.setClinicSum(map.get("02"));
- lst.setClinicFrst(map.get("02-01"));
- lst.setClinicScnd(map.get("02-02"));
- lst.setTreatSum(map.get("05"));
- lst.setTreatFrst(map.get("05-01"));
- lst.setTreatScnd(map.get("05-02"));
- lst.setSurgerySum(map.get("06"));
- lst.setSurgeryFrst(map.get("06-01"));
- lst.setSurgeryScnd(map.get("06-02"));
- lst.setNursingSum(map.get("07"));
- lst.setNursingFrst(map.get("07-01"));
- lst.setNursingScnd(map.get("07-02"));
- lst.setSntryMtrlsSum(map.get("08"));
- lst.setSntryMtrlsFrst(map.get("08-01"));
- lst.setSntryMtrlsScnd(map.get("08-02"));
- lst.setExamSum(map.get("04"));
- lst.setExamFrst(map.get("04-01"));
- lst.setExamScnd(map.get("04-02"));
- lst.setNrmlTrtmtSum(map.get("12"));
- lst.setNrmlTrtmtFrst(map.get("12-01"));
- lst.setNrmlTrtmtScnd(map.get("12-02"));
- lst.setInspectSum(map.get("03"));
- lst.setInspectFrst(map.get("03-01"));
- lst.setInspectScnd(map.get("03-02"));
- lst.setRegisterSum(map.get("13"));
- lst.setRegisterFrst(map.get("13-01"));
- lst.setRegisterScnd(map.get("13-02"));
- lst.setBedfeeSum(map.get("01"));
- lst.setBedfeeFrst(map.get("01-01"));
- lst.setBedfeeScnd(map.get("01-02"));
- lst.setOthfeeSum(map.get("14"));
- lst.setOthfeeFrst(map.get("14-01"));
- lst.setOthfeeScnd(map.get("14-02"));
- }
- private void analyzeMzChrgitm(OtptntSetlmtLst lst, List<BrfChrgitm> chrgitms) {
- Map<String, BigDecimal> map = new HashMap<>();
- map.put("allfeeSum", BigDecimal.valueOf(0));
- map.put("totalThrd", BigDecimal.valueOf(0));
- map.put("totalScnd", BigDecimal.valueOf(0));
- map.put("othSum", BigDecimal.valueOf(0));
- map.put("othThrd", BigDecimal.valueOf(0));
- map.put("othScnd", BigDecimal.valueOf(0));
- chrgitms.forEach(itm -> {
- map.replace("allfeeSum", map.get("allfeeSum").add(BigDecimal.valueOf(itm.getChargeFee())));
- if (itm.getChrgitmLv().equals(ChrgitmLv.SELF_PAY.getCode())) {
- map.replace("totalThrd", map.get("totalThrd").add(BigDecimal.valueOf(itm.getChargeFee())));
- } else if (itm.getChrgitmLv().equals(ChrgitmLv.SECOND_CLASS.getCode())) {
- map.replace("totalScnd", map.get("totalScnd").add(BigDecimal.valueOf(itm.getChargeFee())));
- }
- String typeKey = itm.getMedChrgitmType();
- if (!typeKey.equals("09") && !typeKey.equals("11")) {
- map.replace("othSum", map.get("othSum").add(BigDecimal.valueOf(itm.getChargeFee())));
- if (itm.getChrgitmLv().equals(ChrgitmLv.SELF_PAY.getCode())) {
- map.replace("othThrd", map.get("othThrd").add(BigDecimal.valueOf(itm.getChargeFee())));
- } else if (itm.getChrgitmLv().equals(ChrgitmLv.SECOND_CLASS.getCode())) {
- map.replace("othScnd", map.get("othScnd").add(BigDecimal.valueOf(itm.getChargeFee())));
- }
- } else {
- String lvKey = typeKey + "-" + itm.getChrgitmLv();
- if (map.containsKey(typeKey)) {
- map.replace(typeKey, map.get(typeKey).add(BigDecimal.valueOf(itm.getChargeFee())));
- } else {
- map.put(typeKey, BigDecimal.valueOf(itm.getChargeFee()));
- }
- if (map.containsKey(lvKey)) {
- map.replace(lvKey, map.get(lvKey).add(BigDecimal.valueOf(itm.getChargeFee())));
- } else {
- map.put(lvKey, BigDecimal.valueOf(itm.getChargeFee()));
- }
- }
- });
- lst.setAllfeeSum(map.get("allfeeSum"));
- lst.setAllfeeThrd(map.get("totalThrd"));
- lst.setAllfeeScnd(map.get("totalScnd"));
- lst.setWestMedFeeSum(map.get("09"));
- lst.setWestMedFeeThrd(map.get("09-03"));
- lst.setWestMedFeeScnd(map.get("09-02"));
- lst.setChnsPtntSum(map.get("11"));
- lst.setChnsPtntThrd(map.get("11-03"));
- lst.setChnsPtntScnd(map.get("11-02"));
- lst.setMedsrvcSum(map.get("othSum"));
- lst.setMedsrvcThrd(map.get("othThrd"));
- lst.setMedsrvcScnd(map.get("othScnd"));
- }
- public ResultVo<List<SiMzMatnDise>> queryMzMatnDises() {
- return ResultVoUtil.success(dao.selectAllMzMatnDises());
- }
- public ResultVo<List<SetlStatisticResult>> selectSetlinfoStatistics(SetlCondition condition) {
- String begntime = condition.getMonth() + "-01 00:00:00.000";
- String endtime = DateUtil.getMonthEndtime(condition.getMonth());
- String insutype = condition.getInsutype();
- if (StringUtil.isBlank(insutype)) {
- insutype = "%%";
- }
- List<BaseSetlStatistics> baseStatistics;
- switch (condition.getAdmdvsType()) {
- case 1:
- baseStatistics = dao.selectBaseSetlStatisticsInProvinceLevel(begntime, endtime, insutype, condition.getSetlType());
- break;
- case 2:
- baseStatistics = dao.selectBaseSetlStatisticsInChangshaCity(begntime, endtime, insutype, condition.getSetlType());
- break;
- case 3:
- baseStatistics = dao.selectBaseSetlStatisticsInProvinceOtherCities(begntime, endtime, insutype, condition.getSetlType());
- break;
- case 4:
- baseStatistics = dao.selectBaseSetlStatisticsOutProvince(begntime, endtime, insutype, condition.getSetlType());
- break;
- case 5:
- baseStatistics = dao.selectBaseSetlStatisticsInChangshaCounty(begntime, endtime, insutype, condition.getSetlType());
- break;
- case 6:
- baseStatistics = dao.selectBaseSetlStatisticsInLiuYangCity(begntime, endtime, insutype, condition.getSetlType());
- break;
- default:
- baseStatistics = dao.selectBaseSetlStatisticsInAllPlaces(begntime, endtime, insutype, condition.getSetlType());
- break;
- }
- if (null == baseStatistics || baseStatistics.isEmpty()) {
- return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
- }
- Map<String, String> regionMap = new HashMap<>();
- Map<String, List<BaseSetlStatistics>> admdvsSetldataMap = new HashMap<>();
- List<BaseSetlStatistics> shangChuanJieSuanDan = new ArrayList<>();
- baseStatistics.forEach(itm -> {
- itm.setInsutypeName(Insutype.getName(itm.getInsutype()));
- if (null != itm.getHospPay()) {
- itm.setFundPaySumamt(DecimalUtil.minus(itm.getFundPaySumamt(), itm.getHospPay()));
- }
- String key;
- if (condition.getAdmdvsType() == 5 || condition.getAdmdvsType() == 6) {
- key = itm.getInsuplcAdmdvs();
- } else {
- key = itm.getInsuplcAdmdvs().substring(0, 4) + "00";
- }
- String admdvsName = regionMap.get(key);
- if (null == admdvsName) {
- PureCodeName region = dao.selectAdmdvsNameAndParentName(key);
- if (null == region) {
- region = dao.selectAdmdvsName(key);
- }
- admdvsName = region.getCode() + region.getName();
- regionMap.put(key, admdvsName);
- }
- if (admdvsSetldataMap.containsKey(admdvsName)) {
- admdvsSetldataMap.get(admdvsName).add(itm);
- } else {
- List<BaseSetlStatistics> tempList = new ArrayList<>();
- tempList.add(itm);
- admdvsSetldataMap.put(admdvsName, tempList);
- }
- shangChuanJieSuanDan.add(itm);
- });
- List<SetlStatisticResult> resultList = new ArrayList<>();
- for (Map.Entry<String, List<BaseSetlStatistics>> entry : admdvsSetldataMap.entrySet()) {
- List<BaseSetlStatistics> admdvsSetldataList = entry.getValue();
- SetlStatisticResult resultItem = new SetlStatisticResult();
- resultItem.setAdmdvsName(entry.getKey());
- resultItem.setInsuplcAdmdvs(entry.getValue().get(0).getInsuplcAdmdvs().substring(0, 4) + "00");
- resultItem.setPsnSumamt(admdvsSetldataList.size());
- if (StringUtil.notBlank(condition.getInsutype())) {
- resultItem.setInsutype(condition.getInsutype());
- resultItem.setInsutypeName(Insutype.getName(condition.getInsutype()));
- resultItem.setChildKey(entry.getKey() + "-" + resultItem.getInsutypeName());
- } else {
- resultItem.setInsutypeName("-");
- resultItem.setChildKey(entry.getKey());
- }
- fillSetlStatisticResult(resultList, admdvsSetldataList, resultItem);
- }
- if (StringUtil.isBlank(condition.getInsutype())) {
- for (SetlStatisticResult resultItem : resultList) {
- Map<String, List<BaseSetlStatistics>> insutypeSetldataMap = new HashMap<>();
- String admdvsName = resultItem.getAdmdvsName();
- List<BaseSetlStatistics> admdvsSetldataList = admdvsSetldataMap.get(admdvsName);
- for (BaseSetlStatistics baseSetlStatistics : admdvsSetldataList) {
- if (insutypeSetldataMap.containsKey(baseSetlStatistics.getInsutypeName())) {
- insutypeSetldataMap.get(baseSetlStatistics.getInsutypeName()).add(baseSetlStatistics);
- } else {
- List<BaseSetlStatistics> tmpList = new ArrayList<>();
- tmpList.add(baseSetlStatistics);
- insutypeSetldataMap.put(baseSetlStatistics.getInsutypeName(), tmpList);
- }
- }
- if (insutypeSetldataMap.size() == 1) {
- resultItem.setInsutype(admdvsSetldataList.get(0).getInsutype());
- resultItem.setInsutypeName(admdvsSetldataList.get(0).getInsutypeName());
- continue;
- }
- List<SetlStatisticResult> children = new ArrayList<>();
- for (Map.Entry<String, List<BaseSetlStatistics>> entry : insutypeSetldataMap.entrySet()) {
- List<BaseSetlStatistics> insutypeSetldataList = entry.getValue();
- SetlStatisticResult result = new SetlStatisticResult();
- result.setAdmdvsName(resultItem.getAdmdvsName());
- result.setInsuplcAdmdvs(resultItem.getInsuplcAdmdvs());
- result.setPsnSumamt(insutypeSetldataList.size());
- result.setInsutype(entry.getValue().get(0).getInsutype());
- result.setInsutypeName(entry.getValue().get(0).getInsutypeName());
- result.setChildKey(resultItem.getAdmdvsName() + "-" + result.getInsutypeName());
- result.setIsChildren(true);
- fillSetlStatisticResult(children, insutypeSetldataList, result);
- }
- resultItem.setChildren(children);
- }
- }
- resultList.get(0).setShangChuanJieSuanDan(shangChuanJieSuanDan);
- return ResultVoUtil.success(resultList);
- }
- private void fillSetlStatisticResult(List<SetlStatisticResult> resultList,
- List<BaseSetlStatistics> admdvsSetldataList,
- SetlStatisticResult resultItem) {
- String medfeeSumamt = "0";
- String baseMedFundpaySumamt = "0";
- String bigDssFundpaySumamt = "0";
- String clvFundpaySumamt = "0";
- String othFundpaySumamt = "0";
- String fundpaySumamt = "0";
- for (BaseSetlStatistics itm : admdvsSetldataList) {
- medfeeSumamt = DecimalUtil.add(medfeeSumamt, itm.getMedfeeSumamt());
- baseMedFundpaySumamt = DecimalUtil.add(baseMedFundpaySumamt, itm.getHifpPay());
- bigDssFundpaySumamt = DecimalUtil.add(bigDssFundpaySumamt, itm.getHifmiPay());
- clvFundpaySumamt = DecimalUtil.add(clvFundpaySumamt, itm.getCvlservPay());
- fundpaySumamt = DecimalUtil.add(fundpaySumamt, itm.getFundPaySumamt());
- String othpay = DecimalUtil.minusLink(itm.getFundPaySumamt(), itm.getHifpPay(),
- itm.getHifmiPay(), itm.getCvlservPay());
- othFundpaySumamt = DecimalUtil.add(othFundpaySumamt, othpay);
- }
- resultItem.setMedfeeSumamt(medfeeSumamt);
- resultItem.setBaseMedFundpaySumamt(baseMedFundpaySumamt);
- resultItem.setBigDssFundpaySumamt(bigDssFundpaySumamt);
- resultItem.setClvFundpaySumamt(clvFundpaySumamt);
- resultItem.setOthFundpaySumamt(othFundpaySumamt);
- resultItem.setFundpaySumamt(fundpaySumamt);
- resultList.add(resultItem);
- }
- public ResultVo<List<SiSetlinfo>> selectSetldetailStatistics(SetlCondition condition) {
- String begntime = condition.getMonth() + "-01 00:00:00.000";
- String endtime = DateUtil.getMonthEndtime(condition.getMonth());
- String insuplcAdmdvs = condition.getInsuplcAdmdvs().substring(0, 4) + "%";
- String insutype = condition.getInsutype();
- if (StringUtil.isBlank(insutype)) {
- insutype = "%%";
- }
- QueryWrapper<SiSetlinfo> wrapper = new QueryWrapper<>();
- wrapper.eq("setl_type", condition.getSetlType());
- wrapper.eq("revoked", YesOrNo.NO.getCode());
- wrapper.like("insutype", insutype);
- wrapper.like("insuplc_admdvs", insuplcAdmdvs);
- wrapper.apply("setl_time>='" + begntime + "'");
- wrapper.apply("setl_time<='" + endtime + "'");
- List<SiSetlinfo> list = setlinfoDao.selectList(wrapper);
- Map<String, String> regionMap = new HashMap<>();
- list.forEach(item -> {
- String admdvsName = regionMap.get(item.getInsuplcAdmdvs());
- if (null == admdvsName) {
- PureCodeName region = dao.selectAdmdvsNameAndParentName(item.getInsuplcAdmdvs());
- if (null == region) {
- region = dao.selectAdmdvsName(item.getInsuplcAdmdvs());
- if (null == region) {
- region = dao.selectAdmdvsNameAndParentName(item.getInsuplcAdmdvs().substring(0, 4) + "00");
- }
- }
- admdvsName = region.getCode() + region.getName();
- regionMap.put(item.getInsuplcAdmdvs(), admdvsName);
- }
- item.setInsuplcAdmdvsName(admdvsName);
- FilterUtil.filterCodeToName(item);
- });
- return ResultVoUtil.success(list);
- }
- public ResultVo<List<ZyActpatient>> weiJieSuanZaiYuanHuanZhe(String patNo,
- String startTime,
- String endTime,
- String name,
- String certno) {
- List<ZyActpatient> actpatients = dao.zaiYuanHuanZheXinXi(patNo, startTime, endTime, StringUtil.isContainChinese(name), certno);
- Map<String, String> insuplcAdmdvs = new HashMap<>();
- for (ZyActpatient actpatient : actpatients) {
- if (StringUtil.isBlank(actpatient.getInsuplcAdmdvsName())) {
- String key = actpatient.getInsuplcAdmdvs().substring(0, 4) + "00";
- if (insuplcAdmdvs.containsKey(key)) {
- actpatient.setInsuplcAdmdvsName(insuplcAdmdvs.get(key));
- } else {
- String insuplcAdmdvsName = dao.selectRegionName(key);
- insuplcAdmdvs.put(key, insuplcAdmdvsName);
- actpatient.setInsuplcAdmdvsName(insuplcAdmdvsName);
- }
- }
- }
- return ResultVoUtil.success(actpatients);
- }
- public ResultVo<String> checkRegisterDate(String patNo, Integer times) {
- Date ledgerAccountDate = dao.selectMaxLedgerAccountDate(patNo, times);
- if (null == ledgerAccountDate) {
- return ResultVoUtil.success();
- }
- Date registerDate = dao.selectRegisterDate(patNo);
- if (null == registerDate) {
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保登记日期不能为空,请联系病房填写。");
- }
- Calendar ledgerCalendar = Calendar.getInstance();
- ledgerCalendar.setTime(ledgerAccountDate);
- Calendar registerCalendar = Calendar.getInstance();
- registerCalendar.setTime(registerDate);
- if (registerCalendar.after(ledgerCalendar)) {
- return ResultVoUtil.success();
- }
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保登记日期不能小于断账日期,请联系病房修改。");
- }
- }
|