SiQueryService.java 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626
  1. package thyyxxk.webserver.service.medicalinsurance;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.conditions.Wrapper;
  5. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  6. import lombok.extern.slf4j.Slf4j;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import thyyxxk.webserver.config.exception.ExceptionEnum;
  10. import thyyxxk.webserver.constants.sidicts.SiFunction;
  11. import thyyxxk.webserver.constants.YesOrNo;
  12. import thyyxxk.webserver.constants.sidicts.*;
  13. import thyyxxk.webserver.dao.his.medicalinsurance.SiQueryDao;
  14. import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
  15. import thyyxxk.webserver.entity.ResultVo;
  16. import thyyxxk.webserver.entity.dictionary.PureCodeName;
  17. import thyyxxk.webserver.entity.medicalinsurance.inpatient.InHspPsnInfo;
  18. import thyyxxk.webserver.entity.medicalinsurance.outpatient.SpcChrDiseAcct;
  19. import thyyxxk.webserver.entity.medicalinsurance.query.*;
  20. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetldetail;
  21. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
  22. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.TimesList;
  23. import thyyxxk.webserver.entity.medicalinsurance.setllist.*;
  24. import thyyxxk.webserver.entity.yibao.ZyActpatient;
  25. import thyyxxk.webserver.service.wxapi.SendWxInfoService;
  26. import thyyxxk.webserver.utils.*;
  27. import java.math.BigDecimal;
  28. import java.time.LocalDate;
  29. import java.util.*;
  30. /**
  31. * @description: 医保查询服务
  32. * @author: DingJie
  33. * @create: 2021-06-23 16:35:23
  34. **/
  35. @Slf4j
  36. @Service
  37. public class SiQueryService {
  38. private final ExecService exec;
  39. private final SiQueryDao dao;
  40. private final SendWxInfoService wxsrvc;
  41. private final SiSetlinfoDao setlinfoDao;
  42. private static final String RESULT_CODE = "infcode";
  43. private static final String ERROR_MESSAGE = "err_msg";
  44. private static final String OUTPUT = "output";
  45. @Autowired
  46. public SiQueryService(ExecService exec, SiQueryDao dao, SendWxInfoService wxsrvc, SiSetlinfoDao setlinfoDao) {
  47. this.exec = exec;
  48. this.dao = dao;
  49. this.wxsrvc = wxsrvc;
  50. this.setlinfoDao = setlinfoDao;
  51. }
  52. public ResultVo<SiPatInfo> getSiPatInfo(QryPsnBsInfo qryPsnBsInfo) {
  53. SiPatInfo siPatInfo = dao.selectSiPatInfoForZy(qryPsnBsInfo.getPatNo(), qryPsnBsInfo.getTimes(), qryPsnBsInfo.getLedgerSn());
  54. if (null == siPatInfo) {
  55. siPatInfo = new SiPatInfo();
  56. }
  57. return ResultVoUtil.success(siPatInfo);
  58. }
  59. public ResultVo<PsnBaseInfo> obtainBasicPersonInfo(QryPsnBsInfo qryPsnBsInfo) {
  60. if (null == qryPsnBsInfo.getOnlyQry() && StringUtil.isBlank(qryPsnBsInfo.getMedType())) {
  61. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "请选择患者的医疗类别!");
  62. }
  63. if (StringUtil.isBlank(qryPsnBsInfo.getSocialNo()) && StringUtil.notBlank(qryPsnBsInfo.getPatNo())
  64. && qryPsnBsInfo.getPatNo().length() >= 15) {
  65. qryPsnBsInfo.setSocialNo(qryPsnBsInfo.getPatNo());
  66. }
  67. if (StringUtil.isBlank(qryPsnBsInfo.getSocialNo())) {
  68. QryPsnBsInfo qpbi = dao.selectMzSocialAndName(qryPsnBsInfo.getPatNo());
  69. if (StringUtil.isBlank(qpbi.getSocialNo())) {
  70. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者的身份证不能为空,请补充!");
  71. }
  72. if (null == qryPsnBsInfo.getTimes()) {
  73. qryPsnBsInfo.setTimes(qpbi.getTimes());
  74. }
  75. qryPsnBsInfo.setName(qpbi.getName());
  76. qryPsnBsInfo.setSocialNo(qpbi.getSocialNo());
  77. qryPsnBsInfo.setLedgerSn(0);
  78. }
  79. if (null != qryPsnBsInfo.getLedgerSn() && qryPsnBsInfo.getLedgerSn() != 0) {
  80. qryPsnBsInfo.setLedgerSn(dao.selectMaxLedgerSn(qryPsnBsInfo.getPatNo(), qryPsnBsInfo.getTimes()));
  81. }
  82. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.OBTAIN_BASIC_PERSON_INFO, qryPsnBsInfo.getAdmdvs());
  83. JSONObject data = new JSONObject();
  84. if (qryPsnBsInfo.getSocialNo().length() < 15) {
  85. data.put("mdtrt_cert_type", MdtrtCertType.OTHER.getCode());
  86. data.put("psn_cert_type", PsnCertType.RESIDENCE_PERMIT_FOR_HMT.getCode());
  87. } else {
  88. data.put("mdtrt_cert_type", MdtrtCertType.RESIDENT_IDENTITY_CARD.getCode());
  89. data.put("psn_cert_type", "01");
  90. }
  91. data.put("mdtrt_cert_no", qryPsnBsInfo.getSocialNo());
  92. data.put("certno", qryPsnBsInfo.getSocialNo());
  93. if (StringUtil.notBlank(qryPsnBsInfo.getName())) {
  94. data.put("psn_name", qryPsnBsInfo.getName());
  95. }
  96. input.getJSONObject("input").put("data", data);
  97. JSONObject result = exec.executeTrade(input, SiFunction.OBTAIN_BASIC_PERSON_INFO);
  98. log.info("【操作员:{}】,人员基本信息获取:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  99. if (null == result) {
  100. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  101. }
  102. if (null == result.getInteger(RESULT_CODE)) {
  103. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  104. }
  105. if (result.getIntValue(RESULT_CODE) == 0) {
  106. JSONObject output = result.getJSONObject(OUTPUT);
  107. JSONObject baseinfo = output.getJSONObject("baseinfo");
  108. PsnBaseInfo psnBaseinfo = JSONObject.parseObject(baseinfo.toJSONString(), PsnBaseInfo.class);
  109. psnBaseinfo.setPatNo(qryPsnBsInfo.getPatNo());
  110. psnBaseinfo.setTimes(qryPsnBsInfo.getTimes());
  111. psnBaseinfo.setLedgerSn(qryPsnBsInfo.getLedgerSn());
  112. psnBaseinfo.setMedType(qryPsnBsInfo.getMedType());
  113. psnBaseinfo.setGendName(Gend.get(psnBaseinfo.getGend()).getName());
  114. psnBaseinfo.setPsnCertTypeName(PsnCertType.get(psnBaseinfo.getPsnCertType()).getName());
  115. Naty naty = Naty.get(psnBaseinfo.getNaty());
  116. if (null != naty) {
  117. psnBaseinfo.setNatyName(naty.getName());
  118. }
  119. List<IdetInfo> idetInfos = new ArrayList<>();
  120. JSONArray idet = output.getJSONArray("idetinfo");
  121. for (int i = 0; i < idet.size(); i++) {
  122. JSONObject item = idet.getJSONObject(i);
  123. IdetInfo info = JSONObject.parseObject(item.toJSONString(), IdetInfo.class);
  124. PsnIdetType psnIdetType = PsnIdetType.get(info.getPsnIdetType());
  125. if (null != psnIdetType) {
  126. psnBaseinfo.setPsnIdetType(psnIdetType.getCode());
  127. info.setPsnIdetTypeName(psnIdetType.getName());
  128. }
  129. idetInfos.add(info);
  130. }
  131. if (StringUtil.notBlank(psnBaseinfo.getPsnIdetType())) {
  132. dao.updatePsnIdetType(psnBaseinfo.getPsnIdetType(), psnBaseinfo.getPsnNo());
  133. }
  134. psnBaseinfo.setIdetinfo(idetInfos);
  135. if (new Integer(1).equals(qryPsnBsInfo.getNeedSaving())) {
  136. dao.updateZyActpatient(psnBaseinfo);
  137. int saved = dao.selectSiZyInfoCount(qryPsnBsInfo.getPatNo(), qryPsnBsInfo.getTimes(), qryPsnBsInfo.getLedgerSn());
  138. if (saved == 0) {
  139. dao.insertSiZyInfoPsnNo(psnBaseinfo);
  140. } else {
  141. dao.updateSiZyInfoPsnNo(psnBaseinfo);
  142. }
  143. log.info("患者基本信息已更新:{}", psnBaseinfo);
  144. output.put("times", qryPsnBsInfo.getTimes());
  145. }
  146. List<InsuInfo> list = new ArrayList<>();
  147. JSONArray insuinfo = output.getJSONArray("insuinfo");
  148. for (int i = 0; i < insuinfo.size(); i++) {
  149. JSONObject item = insuinfo.getJSONObject(i);
  150. InsuInfo info = JSONObject.parseObject(item.toJSONString(), InsuInfo.class);
  151. Insutype insutype = Insutype.get(info.getInsutype());
  152. if (null != insutype) {
  153. info.setInsutypeName(insutype.getName());
  154. }
  155. PsnType psnType = PsnType.get(info.getPsnType());
  156. if (null != psnType) {
  157. info.setPsnTypeName(psnType.getName());
  158. }
  159. if (null != info.getPsnInsuStas()) {
  160. if (info.getPsnInsuStas().equals(YesOrNo.YES.getCodeStr())) {
  161. info.setPsnInsuStasName("正常参保");
  162. } else {
  163. info.setPsnInsuStasName("暂停参保");
  164. }
  165. }
  166. if (null != info.getCvlservFlag()) {
  167. if (info.getCvlservFlag().equals(YesOrNo.YES.getCodeStr())) {
  168. info.setCvlservFlagName("是");
  169. } else {
  170. info.setCvlservFlagName("否");
  171. }
  172. }
  173. if (null != info.getInsuplcAdmdvs()) {
  174. String admdvsName = dao.selectRegionName(info.getInsuplcAdmdvs());
  175. if (null == admdvsName) {
  176. PureCodeName region = dao.selectAdmdvsNameAndParentName(info.getInsuplcAdmdvs());
  177. if (null == region) {
  178. region = dao.selectAdmdvsName(info.getInsuplcAdmdvs());
  179. if (null == region) {
  180. region = dao.selectAdmdvsNameAndParentName(info.getInsuplcAdmdvs().substring(0, 4) + "00");
  181. }
  182. }
  183. admdvsName = region.getName();
  184. }
  185. info.setInsuplcAdmdvsName(admdvsName);
  186. }
  187. list.add(info);
  188. }
  189. psnBaseinfo.setInsuinfo(list);
  190. return ResultVoUtil.success(psnBaseinfo);
  191. }
  192. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  193. }
  194. public ResultVo<List<MedInsInfo>> obtainMedicalInstitutionInfo(String type, String fuzzyName) {
  195. JSONObject input = exec.makeTradeHeader(SiFunction.OBTAIN_MEDICAL_INSTITUTION_INFO);
  196. JSONObject medinsinfo = new JSONObject();
  197. medinsinfo.put("fixmedins_type", type);
  198. medinsinfo.put("fixmedins_name", fuzzyName);
  199. input.getJSONObject("input").put("medinsinfo", medinsinfo);
  200. JSONObject result = exec.executeTrade(input, SiFunction.OBTAIN_MEDICAL_INSTITUTION_INFO);
  201. log.info("【操作员:{}】,获取定点医药机构信息:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  202. if (null == result) {
  203. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  204. }
  205. if (null == result.getInteger(RESULT_CODE)) {
  206. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  207. }
  208. if (result.getIntValue(RESULT_CODE) == 0) {
  209. JSONArray output = result.getJSONObject(OUTPUT).getJSONArray("medinsinfo");
  210. List<MedInsInfo> list = new ArrayList<>();
  211. for (int i = 0; i < output.size(); i++) {
  212. JSONObject item = output.getJSONObject(i);
  213. MedInsInfo info = JSONObject.parseObject(item.toJSONString(), MedInsInfo.class);
  214. info.setFixmedinsAdmdvs(info.getFixmedinsCode().substring(1, 7));
  215. info.setFixmedinsAdmdvsName(dao.selectRegionName(info.getFixmedinsAdmdvs()));
  216. FixmedinsType fixmedinsType = FixmedinsType.get(info.getFixmedinsType());
  217. if (null != fixmedinsType) {
  218. info.setFixmedinsTypeName(fixmedinsType.getName());
  219. }
  220. HospLv hospLv = HospLv.get(info.getHospLv());
  221. if (null != hospLv) {
  222. info.setHospLvName(hospLv.getName());
  223. }
  224. list.add(info);
  225. }
  226. return ResultVoUtil.success(list);
  227. }
  228. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  229. }
  230. public ResultVo<List<MdtrtInfo>> queryVisitInfo(BscQryPrm q) {
  231. PureCodeName codeName = dao.selectPsnNoByPatNoAndMedType(q.getPatNo(), q.getMedType());
  232. if (null == codeName) {
  233. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有找到患者该医疗类别的我院就诊记录。");
  234. }
  235. q.setPsnNo(codeName.getName());
  236. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_VISIT_INFO, codeName.getCode());
  237. String ref = JSONObject.toJSONStringWithDateFormat(q, "yyyy-MM-dd HH:mm:ss");
  238. input.getJSONObject("input").put("data", JSONObject.parseObject(ref));
  239. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_VISIT_INFO);
  240. log.info("【操作员:{}】,查询就诊信息:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  241. if (null == result) {
  242. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  243. }
  244. if (null == result.getInteger(RESULT_CODE)) {
  245. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  246. }
  247. if (result.getIntValue(RESULT_CODE) == 0) {
  248. JSONObject output = result.getJSONObject(OUTPUT);
  249. JSONArray mdts = output.getJSONArray("mdtrtinfo");
  250. List<MdtrtInfo> list = new ArrayList<>();
  251. for (int i = 0; i < mdts.size(); i++) {
  252. JSONObject item = mdts.getJSONObject(i);
  253. MdtrtInfo mdtrtInfo = JSONObject.parseObject(item.toJSONString(), MdtrtInfo.class);
  254. if (null != mdtrtInfo.getInsuOptins()) {
  255. mdtrtInfo.setInsuOptinsName(dao.selectRegionName(mdtrtInfo.getInsuOptins()));
  256. }
  257. SiEnumReflectUtil.mdtrtInfoReflect(mdtrtInfo);
  258. list.add(mdtrtInfo);
  259. }
  260. return ResultVoUtil.success(list);
  261. }
  262. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  263. }
  264. public ResultVo<List<DiseInfo>> queryDiagnosisInfo(BscQryPrm q) {
  265. String admdvs = dao.selectAdmdvsByPsnNo(q.getPsnNo());
  266. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_DIAGNOSIS_INFO, admdvs);
  267. JSONObject data = new JSONObject();
  268. data.put("psn_no", q.getPsnNo());
  269. data.put("mdtrt_id", q.getMdtrtId());
  270. input.getJSONObject("input").put("data", data);
  271. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_DIAGNOSIS_INFO);
  272. log.info("【操作员:{}】,查询诊断信息:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  273. if (null == result) {
  274. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  275. }
  276. if (null == result.getInteger(RESULT_CODE)) {
  277. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  278. }
  279. if (result.getIntValue(RESULT_CODE) == 0) {
  280. JSONObject output = result.getJSONObject(OUTPUT);
  281. List<DiseInfo> list = new ArrayList<>();
  282. JSONArray diseInfos = output.getJSONArray("diseinfo");
  283. for (int i = 0; i < diseInfos.size(); i++) {
  284. JSONObject item = diseInfos.getJSONObject(i);
  285. DiseInfo diseInfo = JSONObject.parseObject(item.toJSONString(), DiseInfo.class);
  286. SiEnumReflectUtil.diseInfoReflect(diseInfo);
  287. list.add(diseInfo);
  288. }
  289. return ResultVoUtil.success(list);
  290. }
  291. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  292. }
  293. public ResultVo<SetlInfo> querySettlementInfo(BscQryPrm q) {
  294. SiPatInfo siPatInfo;
  295. if (null == q.getMdtrtId()) {
  296. if (null == q.getLedgerSn()) {
  297. q.setLedgerSn(0);
  298. }
  299. siPatInfo = dao.selectSiPatInfoForZy(q.getPatNo(), q.getTimes(), q.getLedgerSn());
  300. } else {
  301. siPatInfo = dao.selectSiPatInfoByMdtrtId(q.getMdtrtId());
  302. }
  303. if (null == siPatInfo) {
  304. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该次就诊尚未结算,无法查询结算信息。");
  305. }
  306. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_SETTLEMENT_INFO, siPatInfo.getInsuplcAdmdvs());
  307. JSONObject data = new JSONObject();
  308. data.put("psn_no", siPatInfo.getPsnNo());
  309. data.put("setl_id", siPatInfo.getSetlId());
  310. data.put("mdtrt_id", siPatInfo.getMdtrtId());
  311. input.getJSONObject("input").put("data", data);
  312. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SETTLEMENT_INFO);
  313. log.info("【操作员:{}】,查询结算信息:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  314. if (null == result) {
  315. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  316. }
  317. if (null == result.getInteger(RESULT_CODE)) {
  318. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  319. }
  320. if (result.getIntValue(RESULT_CODE) == 0) {
  321. JSONObject output = result.getJSONObject(OUTPUT);
  322. JSONObject obj = output.getJSONObject("setlinfo");
  323. if (null == obj) {
  324. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到该次就诊的结算明细。");
  325. }
  326. SetlInfo setlInfo = JSONObject.parseObject(obj.toJSONString(), SetlInfo.class);
  327. ClrType clrType = ClrType.get(setlInfo.getClrType());
  328. if (null != clrType) {
  329. setlInfo.setClrTypeName(clrType.getName());
  330. }
  331. MedType medType = MedType.get(setlInfo.getMedType());
  332. if (null != medType) {
  333. setlInfo.setMedTypeName(medType.getName());
  334. }
  335. Insutype insutype = Insutype.get(setlInfo.getInsutype());
  336. if (null != insutype) {
  337. setlInfo.setInsutypeName(insutype.getName());
  338. }
  339. PsnType psnType = PsnType.get(setlInfo.getPsnType());
  340. if (null != psnType) {
  341. setlInfo.setPsnTypeName(psnType.getName());
  342. }
  343. JSONArray setldetail = output.getJSONArray("setldetail");
  344. if (null != setldetail && setldetail.size() > 0) {
  345. List<SiSetldetail> list = new ArrayList<>();
  346. for (int i = 0; i < setldetail.size(); i++) {
  347. SiSetldetail setldtel = JSONObject.parseObject(setldetail.getJSONObject(i).toJSONString(), SiSetldetail.class);
  348. FundPayType fundPayType = FundPayType.get(setldtel.getFundPayType());
  349. if (null != fundPayType) {
  350. setldtel.setFundPayTypeName(fundPayType.getName());
  351. }
  352. list.add(setldtel);
  353. }
  354. setlInfo.setSetldetail(list);
  355. }
  356. return ResultVoUtil.success(setlInfo);
  357. }
  358. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  359. }
  360. public ResultVo<Map<String, Object>> queryFeeDetails(QryFeeDetl q) {
  361. SiPatInfo psninfo = dao.selectSiPatInfoByMdtrtId(q.getMdtrtId());
  362. if (null == psninfo) {
  363. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的医保登记信息。");
  364. }
  365. Map<String, Object> map = new HashMap<>();
  366. map.put("psninfo", psninfo);
  367. if (!q.getType().equals("settled")) {
  368. List<SiSetlFeeDetl> list = dao.selectTempCharge(psninfo.getPatNo(), psninfo.getTimes(), psninfo.getLedgerSn());
  369. if (null == list || list.isEmpty()) {
  370. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有已经上传的医保费用。");
  371. }
  372. map.put("feedtle", list);
  373. map.put("analyse", analyseFeedtle(list));
  374. return ResultVoUtil.success(map);
  375. }
  376. List<SiSetlFeeDetl> list = dao.selectFeeDetlList(psninfo.getMdtrtId(), psninfo.getPatNo(), psninfo.getTimes(), psninfo.getLedgerSn());
  377. if (list.size() > 0) {
  378. map.put("feedtle", list);
  379. map.put("analyse", analyseFeedtle(list));
  380. return ResultVoUtil.success(map);
  381. }
  382. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_FEE_DETAILS, psninfo.getInsuplcAdmdvs());
  383. JSONObject data = new JSONObject();
  384. data.put("psn_no", psninfo.getPsnNo());
  385. data.put("setl_id", psninfo.getSetlId());
  386. data.put("mdtrt_id", psninfo.getMdtrtId());
  387. input.getJSONObject("input").put("data", data);
  388. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_FEE_DETAILS);
  389. log.info("【操作员:{}】,【就诊信息查询】查询费用明细:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  390. if (null == result) {
  391. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  392. }
  393. if (null == result.getInteger(RESULT_CODE)) {
  394. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  395. }
  396. if (result.getIntValue(RESULT_CODE) == 0) {
  397. JSONArray output = result.getJSONArray(OUTPUT);
  398. if (null == output || output.size() == 0) {
  399. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到费用明细。");
  400. }
  401. for (int i = 0; i < output.size(); i++) {
  402. list.add(JSONObject.parseObject(output.getJSONObject(i).toJSONString(), SiSetlFeeDetl.class));
  403. if (list.size() == 30) {
  404. dao.insertSetlFeeDetlBatch(list);
  405. list.clear();
  406. }
  407. }
  408. if (list.size() > 0) {
  409. dao.insertSetlFeeDetlBatch(list);
  410. }
  411. list = dao.selectFeeDetlList(psninfo.getMdtrtId(), psninfo.getPatNo(), psninfo.getTimes(), psninfo.getLedgerSn());
  412. map.put("feedtle", list);
  413. map.put("analyse", analyseFeedtle(list));
  414. return ResultVoUtil.success(map);
  415. }
  416. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  417. }
  418. private Map<String, String[]> analyseFeedtle(List<SiSetlFeeDetl> fees) {
  419. Map<String, String[]> map = new HashMap<>();
  420. map.put("zhj", new String[]{"合计", "0.00", "0.00", "0.00"});
  421. fees.forEach(itm -> {
  422. if (StringUtil.isBlank(itm.getChrgitmLvName())) {
  423. ChrgitmLv chrgitmLv = ChrgitmLv.get(itm.getChrgitmLv());
  424. if (null == chrgitmLv) {
  425. chrgitmLv = ChrgitmLv.SELF_PAY;
  426. }
  427. itm.setChrgitmLvName(chrgitmLv.getName());
  428. }
  429. String[] all = map.get("zhj");
  430. all[1] = DecimalUtil.add(all[1], itm.getDetItemFeeSumamt());
  431. all[2] = DecimalUtil.add(all[2], itm.getInscpScpAmt());
  432. all[3] = DecimalUtil.add(all[3], DecimalUtil.minus(itm.getDetItemFeeSumamt(), itm.getInscpScpAmt()));
  433. if (map.containsKey(itm.getMedChrgitmType())) {
  434. String[] dtle = map.get(itm.getMedChrgitmType());
  435. dtle[1] = DecimalUtil.add(dtle[1], itm.getDetItemFeeSumamt());
  436. dtle[2] = DecimalUtil.add(dtle[2], itm.getInscpScpAmt());
  437. dtle[3] = DecimalUtil.add(dtle[3], DecimalUtil.minus(itm.getDetItemFeeSumamt(), itm.getInscpScpAmt()));
  438. } else {
  439. String[] dtle = new String[4];
  440. MedChrgitmType type = MedChrgitmType.get(itm.getMedChrgitmType());
  441. if (type == null) {
  442. type = MedChrgitmType.OTH;
  443. itm.setMedChrgitmType(type.getCode());
  444. }
  445. dtle[0] = type.getName();
  446. dtle[1] = itm.getDetItemFeeSumamt();
  447. dtle[2] = itm.getInscpScpAmt();
  448. dtle[3] = DecimalUtil.minus(itm.getDetItemFeeSumamt(), itm.getInscpScpAmt());
  449. map.put(type.getCode(), dtle);
  450. }
  451. });
  452. return map;
  453. }
  454. public ResultVo<List<TrtInfo>> checkPersonTreatment(BscQryPrm q) {
  455. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.CHECK_PERSON_TREATMENT,
  456. dao.selectAdmdvs(q.getPatNo(), q.getTimes()));
  457. JSONObject data = new JSONObject();
  458. data.put("psn_no", q.getPsnNo());
  459. data.put("insutype", q.getInsutype());
  460. data.put("fixmedins_code", SiUtil.INSTITUTION_ID);
  461. data.put("med_type", q.getMedType());
  462. data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
  463. input.getJSONObject("input").put("data", data);
  464. JSONObject result = exec.executeTrade(input, SiFunction.CHECK_PERSON_TREATMENT);
  465. log.info("【操作员:{}】,人员待遇享受检查:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  466. if (null == result) {
  467. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  468. }
  469. if (null == result.getInteger(RESULT_CODE)) {
  470. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  471. }
  472. if (result.getIntValue(RESULT_CODE) == 0) {
  473. List<TrtInfo> list = new ArrayList<>();
  474. JSONObject output = result.getJSONObject(OUTPUT);
  475. JSONArray trtinfo = output.getJSONArray("trtinfo");
  476. for (int i = 0; i < trtinfo.size(); i++) {
  477. JSONObject obj = trtinfo.getJSONObject(i);
  478. TrtInfo item = JSONObject.parseObject(obj.toJSONString(), TrtInfo.class);
  479. TrtChkType trtChkType = TrtChkType.get(item.getTrtChkType());
  480. if (null != trtChkType) {
  481. item.setTrtChkTypeName(trtChkType.getName());
  482. }
  483. FundPayType fundPayType = FundPayType.get(item.getFundPayType());
  484. if (null != fundPayType) {
  485. item.setFundPayTypeName(fundPayType.getName());
  486. }
  487. if (null != item.getTrtEnjymntFlag()) {
  488. if (item.getTrtEnjymntFlag().equals(YesOrNo.YES.getCodeStr())) {
  489. item.setTrtEnjymntFlagName("是");
  490. } else {
  491. item.setTrtEnjymntFlagName("否");
  492. }
  493. }
  494. list.add(item);
  495. }
  496. return ResultVoUtil.success(list);
  497. }
  498. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  499. }
  500. public ResultVo<List<InHspPsnInfo>> queryInHospitalPatientsInfo(BscQryPrm q) {
  501. if (StringUtil.notBlank(q.getPatNo())) {
  502. String psnNo = dao.selectPsnNo(q.getPatNo());
  503. if (null == psnNo) {
  504. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【住院号/门诊号:" + q.getPatNo() +
  505. "】没有找到此患者在我院的医保在院信息,请核实。");
  506. }
  507. q.setPsnNo(psnNo);
  508. }
  509. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_IN_HOSPITAL_PATIENTS_INFO,
  510. dao.selectAdmdvsByPatNoAndPsnNo(q.getPatNo(), q.getPsnNo()));
  511. JSONObject data = new JSONObject();
  512. data.put("psn_no", q.getPsnNo());
  513. data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
  514. data.put("endtime", null == q.getEndtime() ? DateUtil.now() : DateUtil.formatDatetime(q.getEndtime()));
  515. input.getJSONObject("input").put("data", data);
  516. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_IN_HOSPITAL_PATIENTS_INFO);
  517. log.info("【操作员:{}】,在院信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  518. if (null == result) {
  519. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  520. }
  521. if (null == result.getInteger(RESULT_CODE)) {
  522. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  523. }
  524. if (result.getIntValue(RESULT_CODE) == 0) {
  525. JSONObject output = result.getJSONObject(OUTPUT);
  526. JSONArray pts = output.getJSONArray("data");
  527. if (pts.size() == 0) {
  528. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到医保在院的患者信息。");
  529. }
  530. List<InHspPsnInfo> list = new ArrayList<>();
  531. for (int i = 0; i < pts.size(); i++) {
  532. JSONObject item = pts.getJSONObject(i);
  533. InHspPsnInfo inHspPsnInfo = JSONObject.parseObject(item.toJSONString(), InHspPsnInfo.class);
  534. SiEnumReflectUtil.inHspPsnInfoReflect(inHspPsnInfo);
  535. list.add(inHspPsnInfo);
  536. }
  537. if (list.size() == 1 && null != q.getTimes()) {
  538. InHspPsnInfo info = list.get(0);
  539. dao.updateInhospInfo(q.getPatNo(), q.getTimes(), q.getLedgerSn(), info.getMdtrtId(), info.getInsutype());
  540. }
  541. return ResultVoUtil.success(list);
  542. }
  543. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  544. }
  545. public ResultVo<List<RefMedin>> queryPersonnelTransferHospitalInfo(BscQryPrm q) {
  546. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_TRANSFER_HOSPITAL_INFO,
  547. dao.selectAdmdvsByPatNoAndPsnNo(q.getPatNo(), q.getPsnNo()));
  548. JSONObject data = new JSONObject();
  549. data.put("psn_no", q.getPsnNo());
  550. data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
  551. data.put("endtime", DateUtil.formatDatetime(q.getEndtime()));
  552. input.getJSONObject("input").put("data", data);
  553. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_TRANSFER_HOSPITAL_INFO);
  554. log.info("【操作员:{}】,转院信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  555. if (null == result) {
  556. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  557. }
  558. if (null == result.getInteger(RESULT_CODE)) {
  559. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  560. }
  561. if (result.getIntValue(RESULT_CODE) == 0) {
  562. JSONObject output = result.getJSONObject(OUTPUT);
  563. JSONArray array = output.getJSONArray("refmedin");
  564. if (null == array || array.size() == 0) {
  565. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到符合条件的转院信息。");
  566. }
  567. List<RefMedin> list = new ArrayList<>();
  568. for (int i = 0; i < array.size(); i++) {
  569. JSONObject obj = array.getJSONObject(i);
  570. RefMedin item = JSONObject.parseObject(obj.toJSONString(), RefMedin.class);
  571. Insutype insutype = Insutype.get(item.getInsutype());
  572. if (null != insutype) {
  573. item.setInsutypeName(insutype.getName());
  574. }
  575. DclaSouc dclaSouc = DclaSouc.get(item.getDclaSouc());
  576. if (null != dclaSouc) {
  577. item.setDclaSoucName(dclaSouc.getName());
  578. }
  579. PsnCertType psnCertType = PsnCertType.get(item.getPsnCertType());
  580. if (null != psnCertType) {
  581. item.setPsnCertTypeName(psnCertType.getName());
  582. }
  583. item.setGendName(Gend.get(item.getGend()).getName());
  584. if (null != item.getInsuOptins()) {
  585. item.setInsuOptinsName(dao.selectRegionName(item.getInsuOptins()));
  586. }
  587. if (null != item.getOutFlag()) {
  588. if (item.getOutFlag().equals(YesOrNo.YES.getCodeStr())) {
  589. item.setOutFlagName("是");
  590. } else {
  591. item.setOutFlagName("否");
  592. }
  593. }
  594. if (null != item.getHospAgreReflFlag()) {
  595. if (item.getHospAgreReflFlag().equals(YesOrNo.YES.getCodeStr())) {
  596. item.setHospAgreReflFlagName("是");
  597. } else {
  598. item.setHospAgreReflFlagName("否");
  599. }
  600. }
  601. list.add(item);
  602. }
  603. return ResultVoUtil.success(list);
  604. }
  605. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  606. }
  607. public ResultVo<List<MedUseRcd>> querySpecialChronicDiseasesMedicalRecord(BscQryPrm q) {
  608. if (null == q.getPsnNo()) {
  609. String psnNo = dao.selectPsnNo(q.getPatNo());
  610. if (null == psnNo) {
  611. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【住院号/门诊号:" + q.getPatNo() +
  612. "】未找到此患者的医保参保信息,请核实。");
  613. }
  614. q.setPsnNo(psnNo);
  615. }
  616. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_MEDICAL_RECORD,
  617. dao.selectAdmdvsByPsnNo(q.getPsnNo()));
  618. JSONObject data = new JSONObject();
  619. data.put("psn_no", q.getPsnNo());
  620. data.put("begntime", DateUtil.formatDatetime(q.getBegntime()));
  621. data.put("endtime", DateUtil.formatDatetime(q.getEndtime()));
  622. input.getJSONObject("input").put("data", data);
  623. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_MEDICAL_RECORD);
  624. log.info("【操作员:{}】,人员慢特病用药记录查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  625. if (null == result) {
  626. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  627. }
  628. if (null == result.getInteger(RESULT_CODE)) {
  629. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  630. }
  631. if (result.getIntValue(RESULT_CODE) == 0) {
  632. JSONObject output = result.getJSONObject(OUTPUT);
  633. JSONArray array = output.getJSONArray("feedetail");
  634. if (null == array || array.size() == 0) {
  635. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到此人的慢特病用药记录。");
  636. }
  637. List<MedUseRcd> list = new ArrayList<>();
  638. for (int i = 0; i < array.size(); i++) {
  639. JSONObject obj = array.getJSONObject(i);
  640. MedUseRcd item = JSONObject.parseObject(obj.toJSONString(), MedUseRcd.class);
  641. list.add(item);
  642. }
  643. return ResultVoUtil.success(list);
  644. }
  645. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  646. }
  647. public ResultVo<List<CumInfo>> queryPersonnelCumulativeInfo(BscQryPrm q) {
  648. String admdvs = q.getAdmdvs();
  649. if (StringUtil.isBlank(admdvs)) {
  650. admdvs = dao.selectAdmdvsByPsnNo(q.getPsnNo());
  651. }
  652. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO, admdvs);
  653. JSONObject data = new JSONObject();
  654. data.put("psn_no", q.getPsnNo());
  655. data.put("cum_ym", q.getCumYm());
  656. input.getJSONObject("input").put("data", data);
  657. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO);
  658. log.info("【操作员:{}】,人员累计信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  659. if (null == result) {
  660. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  661. }
  662. if (null == result.getInteger(RESULT_CODE)) {
  663. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  664. }
  665. if (result.getIntValue(RESULT_CODE) == 0) {
  666. JSONObject output = result.getJSONObject(OUTPUT);
  667. JSONArray array = output.getJSONArray("cuminfo");
  668. List<CumInfo> list = new ArrayList<>();
  669. for (int i = 0; i < array.size(); i++) {
  670. JSONObject obj = array.getJSONObject(i);
  671. CumInfo item = JSONObject.parseObject(obj.toJSONString(), CumInfo.class);
  672. Insutype insutype = Insutype.get(item.getInsutype());
  673. if (null != insutype) {
  674. item.setInsutypeName(insutype.getName());
  675. }
  676. list.add(item);
  677. }
  678. return ResultVoUtil.success(list);
  679. }
  680. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  681. }
  682. public ResultVo<List<SpcChrDiseAcct>> querySpecialChronicDiseasesAccreditation(BscQryPrm q) {
  683. if (null == q.getPsnNo()) {
  684. String psnNo = dao.selectPsnNo(q.getPatNo());
  685. if (null == psnNo) {
  686. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【住院号/门诊号:" + q.getPatNo() +
  687. "】未找到此患者的医保参保信息,请核实。");
  688. }
  689. q.setPsnNo(psnNo);
  690. }
  691. if (StringUtil.isBlank(q.getAdmdvs())) {
  692. String admdvs = StringUtil.isBlank(q.getPatNo()) ? dao.selectAdmdvsByPsnNo(q.getPsnNo())
  693. : dao.selectAdmdvsByPatNo(q.getPatNo());
  694. q.setAdmdvs(admdvs);
  695. }
  696. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_ACCREDITATION, q.getAdmdvs());
  697. JSONObject data = new JSONObject();
  698. data.put("psn_no", q.getPsnNo());
  699. input.getJSONObject("input").put("data", data);
  700. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_SPECIAL_CHRONIC_DISEASES_ACCREDITATION);
  701. log.info("【操作员:{}】,人员慢特病备案查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  702. if (null == result) {
  703. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  704. }
  705. if (null == result.getInteger(RESULT_CODE)) {
  706. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  707. }
  708. if (result.getIntValue(RESULT_CODE) == 0) {
  709. JSONObject output = result.getJSONObject(OUTPUT);
  710. JSONArray details = output.getJSONArray("feedetail");
  711. if (null == details || details.size() == 0) {
  712. return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到此患者的慢特病备案信息。");
  713. }
  714. List<SpcChrDiseAcct> list = new ArrayList<>();
  715. Date now = new Date();
  716. for (int i = 0; i < details.size(); i++) {
  717. JSONObject detail = details.getJSONObject(i);
  718. SpcChrDiseAcct spcChrDiseAcct = JSONObject.parseObject(detail.toJSONString(), SpcChrDiseAcct.class);
  719. if (null != q.getNeedAllRcd() && 1 == q.getNeedAllRcd()) {
  720. list.add(spcChrDiseAcct);
  721. } else {
  722. if (now.before(spcChrDiseAcct.getEnddate())) {
  723. spcChrDiseAcct.setPatNo(q.getPatNo());
  724. spcChrDiseAcct.setTimes(q.getTimes());
  725. list.add(spcChrDiseAcct);
  726. }
  727. }
  728. }
  729. if (list.size() > 0) {
  730. return ResultVoUtil.success(list);
  731. }
  732. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此患者没有有效的慢特病备案,或慢特病备案已过期!");
  733. }
  734. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  735. }
  736. public ResultVo<List<PsnFixMedin>> queryPersonnelAssignmentInfo(BscQryPrm q) {
  737. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_ASSIGNMENT_INFO,
  738. dao.selectAdmdvs(q.getPatNo(), q.getTimes()));
  739. JSONObject data = new JSONObject();
  740. data.put("psn_no", q.getPsnNo());
  741. data.put("biz_appy_type", q.getBizAppyType());
  742. input.getJSONObject("input").put("data", data);
  743. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_ASSIGNMENT_INFO);
  744. log.info("【操作员:{}】,人员定点信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  745. if (null == result) {
  746. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  747. }
  748. if (null == result.getInteger(RESULT_CODE)) {
  749. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  750. }
  751. if (result.getIntValue(RESULT_CODE) == 0) {
  752. JSONObject output = result.getJSONObject(OUTPUT);
  753. JSONArray array = output.getJSONArray("psnfixmedin");
  754. if (null == array || array.size() == 0) {
  755. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到对应的点定信息。");
  756. }
  757. List<PsnFixMedin> list = new ArrayList<>();
  758. for (int i = 0; i < array.size(); i++) {
  759. JSONObject obj = array.getJSONObject(i);
  760. PsnFixMedin item = JSONObject.parseObject(obj.toJSONString(), PsnFixMedin.class);
  761. Insutype insutype = Insutype.get(item.getInsutype());
  762. if (null != insutype) {
  763. item.setInsutypeName(insutype.getName());
  764. }
  765. list.add(item);
  766. }
  767. return ResultVoUtil.success(list);
  768. }
  769. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString(ERROR_MESSAGE));
  770. }
  771. public ResultVo<List<TimesList>> fetchSiTimesList(String patNo, Integer type) {
  772. List<TimesList> list = dao.fetchSiTimesList(patNo, type);
  773. if (null == list || list.isEmpty()) {
  774. return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "此患者没有有效的结算信息。");
  775. }
  776. return ResultVoUtil.success(list);
  777. }
  778. public ResultVo<String> queryInsuplcAdmdvsByMdtrtId(String mdtrtId) {
  779. return ResultVoUtil.success(dao.selectInsuplcAdmdvsByMdtrtId(mdtrtId));
  780. }
  781. public ResultVo querySiSetlList(SetlIndex index) {
  782. if (null == index.getTimes() && StringUtil.isBlank(index.getLabel())) {
  783. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "结算条目不能为空!");
  784. }
  785. if (StringUtil.notBlank(index.getLabel())) {
  786. String[] arr = index.getLabel().split("_");
  787. index.setSetlId(arr[0]);
  788. index.setTimes(Integer.parseInt(arr[1]));
  789. if (index.getType() == SetlType.INPATIENT.getCode()) {
  790. index.setLedgerSn(Integer.parseInt(arr[2]));
  791. } else {
  792. index.setLedgerSn(0);
  793. }
  794. } else {
  795. index.setLedgerSn(0);
  796. index.setSetlId(dao.selectSetlId(index.getPatNo(), index.getTimes(), index.getLedgerSn()));
  797. }
  798. SiPatInfo siPatInfo = dao.selectSiPatInfo(index.getPatNo(), index.getTimes(), index.getLedgerSn());
  799. if (null == siPatInfo) {
  800. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的结算信息!");
  801. }
  802. CuminfoInYear cuminfo = getYearCuminfo(siPatInfo.getPsnNo(), siPatInfo.getInsuplcAdmdvs());
  803. if (cuminfo.getCode() != ExceptionEnum.SUCCESS.getCode()) {
  804. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, cuminfo.getMessage());
  805. }
  806. if (index.getType() == SetlType.INPATIENT.getCode()) {
  807. InptntSetlmtLst lst = dao.selectZySetlinfo(index.getSetlId(), "zy_inactpatient");
  808. if (null == lst) {
  809. lst = dao.selectZySetlinfo(index.getSetlId(), "zy_actpatient");
  810. if (null == lst) {
  811. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的结算信息!");
  812. }
  813. }
  814. lst.setInHospdays(DateUtil.daysBetween(lst.getBegntime(), lst.getEndtime()) + 1);
  815. PsnIdetType psnIdetType = PsnIdetType.get(lst.getPsnIdetType());
  816. if (null != psnIdetType) {
  817. lst.setPsnIdetTypeName(psnIdetType.getName());
  818. }
  819. Admdvs admdvs = Admdvs.get(lst.getInsuplcAdmdvs());
  820. if (null == admdvs) {
  821. lst.setInsuplcAdmdvsName(dao.selectRegionName(lst.getInsuplcAdmdvs()));
  822. } else {
  823. lst.setInsuplcAdmdvsName(admdvs.getName());
  824. }
  825. lst.setFixmedinsName(SiUtil.INSTITUTION_NAME);
  826. lst.setGendName(Gend.get(lst.getGend()).getName());
  827. SiEnumReflectUtil.inptntSetlmtLstReflect(lst);
  828. ResultVo<List<SiSetlFeeDetl>> chrgrsvo = getChrgitems(lst.getPsnNo(), lst.getSetlId(), lst.getMdtrtId(), lst.getInsuplcAdmdvs());
  829. if (!chrgrsvo.getCode().equals(ExceptionEnum.SUCCESS.getCode())) {
  830. return chrgrsvo;
  831. }
  832. analyzeZyChrgitm(lst, chrgrsvo.getData());
  833. lst.setYrAdmtimes(cuminfo.getYearAdmtimesZy());
  834. lst.setYrAcmltvExpsClted(cuminfo.getYearPeriodfeeSumamtZy());
  835. lst.setYrMedfeeSumamt(cuminfo.getYearMedfeesumZy());
  836. lst.setYrPayedBegnLine(cuminfo.getYearPayedBegnlineZy());
  837. lst.setYrFundPaySumamt(cuminfo.getYearBaseFundPayAmtZy());
  838. lst.setYrBigAmtFundPay(cuminfo.getYearBigAmtpaysZy());
  839. lst.setYrBigDssInsPay(cuminfo.getYearBigdssFundPayAmtZy());
  840. lst.setYrMafPay(cuminfo.getYearMafPayAmtZy());
  841. lst.setYrPolicySelfPay(cuminfo.getYearPolicySelfPayZy());
  842. lst.setYrPreSelfPay(cuminfo.getYearPreSelfPayZy());
  843. lst.setYrBigDssFee(cuminfo.getYearBigDssLegalFee());
  844. return listPolItemCodePayInfo(lst);
  845. } else {
  846. index.setLedgerSn(0);
  847. OtptntSetlmtLst lst = dao.selectMzSetlifo(index.getPatNo(), index.getTimes());
  848. if (null == lst) {
  849. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到此患者的结算信息!");
  850. }
  851. Admdvs admdvs = Admdvs.get(lst.getInsuplcAdmdvs());
  852. if (null == admdvs) {
  853. lst.setInsuplcAdmdvsName(dao.selectRegionName(lst.getInsuplcAdmdvs()));
  854. } else {
  855. lst.setInsuplcAdmdvsName(admdvs.getName());
  856. }
  857. SiEnumReflectUtil.outptntSetlmtLstReflect(lst);
  858. List<BrfChrgitm> chrgitms = dao.selectMzBrfChrgitms(index.getPatNo(), index.getTimes());
  859. analyzeMzChrgitm(lst, chrgitms);
  860. lst.setYrAdmtimes(cuminfo.getYearAdmtimesMz());
  861. lst.setYrMedfeeSumamt(cuminfo.getYearMedfeesumMz());
  862. lst.setYrFundPaySumamt(cuminfo.getYearBaseFundPayAmtMz());
  863. lst.setYrBigAmtFundPay(cuminfo.getYearBigAmtpaysMz());
  864. lst.setYrBigDssFundPay(cuminfo.getYearBigdssFundPayAmtMz());
  865. lst.setYrAcctPay(cuminfo.getYearAcctPayMz());
  866. lst.setYrMafPay(cuminfo.getYearMafPayAmtMz());
  867. lst.setFixmedinsName(SiUtil.INSTITUTION_NAME);
  868. return ResultVoUtil.success(lst);
  869. }
  870. }
  871. private ResultVo<InptntSetlmtLst> listPolItemCodePayInfo(InptntSetlmtLst lst) {
  872. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.LIST_POL_ITEM_CODE_PAY_INFO, lst.getInsuplcAdmdvs());
  873. JSONObject data = new JSONObject();
  874. data.put("psn_no", lst.getPsnNo());
  875. data.put("mdtrt_id", lst.getMdtrtId());
  876. data.put("setl_id", lst.getSetlId());
  877. input.getJSONObject("input").put("data", data);
  878. JSONObject result = exec.executeTrade(input, SiFunction.LIST_POL_ITEM_CODE_PAY_INFO);
  879. log.info("【操作员:{}】,政策信息查询:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  880. if (null == result) {
  881. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  882. }
  883. if (null == result.getInteger("code")) {
  884. String message = result.getString("message");
  885. if (null == message) {
  886. message = result.getString(ERROR_MESSAGE);
  887. }
  888. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + message);
  889. }
  890. if (result.getIntValue("code") != 0) {
  891. String message = result.getString("message");
  892. if (null == message) {
  893. message = result.getString(ERROR_MESSAGE);
  894. }
  895. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心出错:" + message);
  896. }
  897. JSONArray array = result.getJSONArray("data");
  898. BigDecimal selfPaySum = new BigDecimal(0);
  899. BigDecimal fundPaySum = new BigDecimal(0);
  900. for (int i = 0; i < array.size(); i++) {
  901. JSONObject itm = array.getJSONObject(i);
  902. BigDecimal selfPayAmt = BigDecimal.valueOf(itm.getDouble("selfPayAmt"));
  903. String selfPayProp = itm.getString("selfPayProp");
  904. BigDecimal fundPayAmt = BigDecimal.valueOf(itm.getDouble("fundPayAmt"));
  905. String fundPayProp = itm.getString("fundPayProp");
  906. BigDecimal polItemPaySum = BigDecimal.valueOf(itm.getDouble("polItemPaySum"));
  907. selfPaySum = selfPaySum.add(selfPayAmt);
  908. fundPaySum = fundPaySum.add(fundPayAmt);
  909. PolItemCode polItemCode = PolItemCode.get(itm.getString("polItemCode"));
  910. if (null == polItemCode) {
  911. String message = String.format("找到了字典缺失的政策项:%s", itm);
  912. log.info(message);
  913. wxsrvc.sendCorpWxMsg("2801", message);
  914. continue;
  915. }
  916. switch (polItemCode) {
  917. case QZF:
  918. lst.setSelfPayPsnAmt(selfPayAmt);
  919. lst.setSelfPayPsnProp(selfPayProp);
  920. lst.setSelfPayFundAmt(fundPayAmt);
  921. lst.setSelfPayFundProp(fundPayProp);
  922. lst.setSelfPaySum(polItemPaySum);
  923. break;
  924. case YLXZF:
  925. lst.setScndPrePayPsnAmt(selfPayAmt);
  926. lst.setScndPrePayPsnProp(selfPayProp);
  927. lst.setScndPrePayFundAmt(fundPayAmt);
  928. lst.setScndPrePayFundProp(fundPayProp);
  929. lst.setScndPrePaySum(polItemPaySum);
  930. break;
  931. case CXEZF:
  932. lst.setOvrlmtSelfPayPsnAmt(selfPayAmt);
  933. lst.setOvrlmtSelfPayPsnProp(selfPayProp);
  934. lst.setOvrlmtSelfPayFundAmt(fundPayAmt);
  935. lst.setOvrlmtSelfPayFundProp(fundPayProp);
  936. lst.setOvrlmtSelfPaySum(polItemPaySum);
  937. break;
  938. case BCYFQFBZ:
  939. lst.setBegnlinePsnAmt(selfPayAmt);
  940. lst.setBegnlinePsnProp(selfPayProp);
  941. lst.setBegnlineFundAmt(fundPayAmt);
  942. lst.setBegnlineFundProp(fundPayProp);
  943. lst.setBegnlineSum(polItemPaySum);
  944. break;
  945. case TCYD:
  946. lst.setFundFrstLvPsnAmt(selfPayAmt);
  947. lst.setFundFrstLvPsnProp(selfPayProp);
  948. lst.setFundFrstLvFundAmt(fundPayAmt);
  949. lst.setFundFrstLvFundProp(fundPayProp);
  950. lst.setFundFrstLvSum(polItemPaySum);
  951. break;
  952. case TCED:
  953. lst.setFundScndLvPsnAmt(selfPayAmt);
  954. lst.setFundScndLvPsnProp(selfPayProp);
  955. lst.setFundScndLvFundAmt(fundPayAmt);
  956. lst.setFundScndLvFundProp(fundPayProp);
  957. lst.setFundScndLvSum(polItemPaySum);
  958. break;
  959. case DEYD:
  960. lst.setBigAmtFrstLvPsnAmt(selfPayAmt);
  961. lst.setBigAmtFrstLvPsnProp(selfPayProp);
  962. lst.setBigAmtFrstLvFundAmt(fundPayAmt);
  963. lst.setBigAmtFrstLvFundProp(fundPayProp);
  964. lst.setBigAmtFrstLvSum(polItemPaySum);
  965. break;
  966. }
  967. }
  968. lst.setAllPsnAmt(selfPaySum);
  969. lst.setAllFundAmt(fundPaySum);
  970. lst.setAllSum(fundPaySum.add(selfPaySum));
  971. return ResultVoUtil.success(lst);
  972. }
  973. private CuminfoInYear getYearCuminfo(String psnNo, String admdvs) {
  974. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO, admdvs);
  975. JSONObject data = new JSONObject();
  976. data.put("psn_no", psnNo);
  977. data.put("cum_ym", "");
  978. input.getJSONObject("input").put("data", data);
  979. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_PERSONNEL_CUMULATIVE_INFO);
  980. CuminfoInYear cuminfo = new CuminfoInYear();
  981. if (null == result) {
  982. cuminfo.setCode(ExceptionEnum.NETWORK_ERROR.getCode());
  983. cuminfo.setMessage(ExceptionEnum.NETWORK_ERROR.getMessage());
  984. return cuminfo;
  985. }
  986. if (null == result.getInteger(RESULT_CODE)) {
  987. cuminfo.setCode(ExceptionEnum.LOGICAL_ERROR.getCode());
  988. cuminfo.setMessage("医保中心报错:" + result.getString("message"));
  989. return cuminfo;
  990. }
  991. if (result.getIntValue(RESULT_CODE) != 0) {
  992. cuminfo.setCode(ExceptionEnum.NETWORK_ERROR.getCode());
  993. cuminfo.setMessage("医保中心出错:" + result.getString("message"));
  994. return cuminfo;
  995. }
  996. cuminfo.setCode(ExceptionEnum.SUCCESS.getCode());
  997. String year = String.valueOf(LocalDate.now().getYear());
  998. JSONArray cuminfos = result.getJSONObject(OUTPUT).getJSONArray("cuminfo");
  999. log.info("累计信息:{}", cuminfos);
  1000. for (int i = 0; i < cuminfos.size(); i++) {
  1001. JSONObject itm = cuminfos.getJSONObject(i);
  1002. if (itm.getString("year").equals(year)) {
  1003. switch (itm.getString("cum_type_code")) {
  1004. // 本年住院次数
  1005. case "C0000_BIZ2101":
  1006. case "C0000_BIZ2102":
  1007. case "C0000_BIZ2106":
  1008. case "C0000_BIZ2107":
  1009. case "C0000_BIZ22":
  1010. case "C0000_BIZ52":
  1011. cuminfo.addYearAdmtimesZy(itm.getDoubleValue("cum"));
  1012. break;
  1013. // 本年门诊次数
  1014. case "C0000_BIZ11":
  1015. case "C0000_BIZ13":
  1016. case "C0000_BIZ14":
  1017. case "C0000_BIZ51":
  1018. case "C0000_BIZ9901":
  1019. case "C0000_BIZ9903":
  1020. case "C0000_BIZ9904":
  1021. cuminfo.addYearAdmtimesMz(itm.getDoubleValue("cum"));
  1022. break;
  1023. // 本年度住院分段计算费用累计
  1024. case "S0000_BIZ2101":
  1025. case "S0000_BIZ2102":
  1026. case "S0000_BIZ2106":
  1027. case "S0000_BIZ2107":
  1028. case "S0000_BIZ22":
  1029. case "S0000_BIZ52":
  1030. cuminfo.addYearPeriodFeeSumZy(itm.getDoubleValue("cum"));
  1031. break;
  1032. // 住院医疗费合计
  1033. case "F0000_BIZ2101":
  1034. case "F0000_BIZ2102":
  1035. case "F0000_BIZ2106":
  1036. case "F0000_BIZ2107":
  1037. case "F0000_BIZ22":
  1038. case "F0000_BIZ52":
  1039. cuminfo.addYearFeesumZy(itm.getDoubleValue("cum"));
  1040. break;
  1041. // 门诊医疗费合计
  1042. case "F0000_BIZ11":
  1043. case "F0000_BIZ13":
  1044. case "F0000_BIZ14":
  1045. case "F0000_BIZ51":
  1046. case "F0000_BIZ9901":
  1047. case "F0000_BIZ9903":
  1048. case "F0000_BIZ9904":
  1049. cuminfo.addYearFeesumMz(itm.getDoubleValue("cum"));
  1050. break;
  1051. // 住院已付起付线
  1052. case "Q0000_BIZ2101":
  1053. case "Q0000_BIZ2102":
  1054. case "Q0000_BIZ2106":
  1055. case "Q0000_BIZ2107":
  1056. case "Q0000_BIZ22":
  1057. case "Q0000_BIZ52":
  1058. cuminfo.addYearPayedbegnlineZy(itm.getDoubleValue("cum"));
  1059. break;
  1060. // 住院统筹支付
  1061. case "D310101_BIZ2101":
  1062. case "D310101_BIZ2102":
  1063. case "D310101_BIZ2106":
  1064. case "D310101_BIZ2107":
  1065. case "D310101_BIZ22":
  1066. case "D310101_BIZ52":
  1067. case "D390101_BIZ2101":
  1068. case "D390101_BIZ2102":
  1069. case "D390101_BIZ2106":
  1070. case "D390101_BIZ2107":
  1071. case "D390101_BIZ22":
  1072. case "D390101_BIZ52":
  1073. cuminfo.addYearFundpaysZy(itm.getDoubleValue("cum"));
  1074. break;
  1075. // 门诊统筹支付
  1076. case "D310101_BIZ11":
  1077. case "D310101_BIZ13":
  1078. case "D310101_BIZ14":
  1079. case "D310101_BIZ51":
  1080. case "D310101_BIZ9901":
  1081. case "D310101_BIZ9903":
  1082. case "D310101_BIZ9904":
  1083. case "D390101_BIZ11":
  1084. case "D390101_BIZ13":
  1085. case "D390101_BIZ14":
  1086. case "D390101_BIZ51":
  1087. case "D390101_BIZ9901":
  1088. case "D390101_BIZ9903":
  1089. case "D390101_BIZ9904":
  1090. cuminfo.addYearFundpaysMz(itm.getDoubleValue("cum"));
  1091. break;
  1092. // 政策自费
  1093. case "Z0000_BIZ2101_LAB101":
  1094. case "Z0000_BIZ2102_LAB101":
  1095. case "Z0000_BIZ22_LAB101":
  1096. case "Z0000_BIZ2106_LAB101":
  1097. case "Z0000_BIZ2107_LAB101":
  1098. case "Z0000_BIZ52_LAB101":
  1099. case "Z0000_BIZ2101_LAB103":
  1100. case "Z0000_BIZ2102_LAB103":
  1101. case "Z0000_BIZ22_LAB103":
  1102. case "Z0000_BIZ2106_LAB103":
  1103. case "Z0000_BIZ2107_LAB103":
  1104. case "Z0000_BIZ52_LAB103":
  1105. cuminfo.addYearPolicySelfpayZy(itm.getDoubleValue("cum"));
  1106. break;
  1107. // 政策自付
  1108. case "Z0000_BIZ2101_LAB102":
  1109. case "Z0000_BIZ2102_LAB102":
  1110. case "Z0000_BIZ22_LAB102":
  1111. case "Z0000_BIZ2106_LAB102":
  1112. case "Z0000_BIZ2107_LAB102":
  1113. case "Z0000_BIZ52_LAB102":
  1114. cuminfo.addYearPreSelfpayZy(itm.getDoubleValue("cum"));
  1115. break;
  1116. // 住院大额基金支付
  1117. case "D330101_BIZ2101":
  1118. case "D330101_BIZ2102":
  1119. case "D330101_BIZ2106":
  1120. case "D330101_BIZ2107":
  1121. case "D330101_BIZ22":
  1122. case "D330101_BIZ52":
  1123. cuminfo.addYearBigAmtpaysZy(itm.getDoubleValue("cum"));
  1124. break;
  1125. // 门诊大额基金支付
  1126. case "D330101_BIZ11":
  1127. case "D330101_BIZ13":
  1128. case "D330101_BIZ14":
  1129. case "D330101_BIZ51":
  1130. case "D330101_BIZ9901":
  1131. case "D330101_BIZ9903":
  1132. case "D330101_BIZ9904":
  1133. cuminfo.addYearBigAmtpaysMz(itm.getDoubleValue("cum"));
  1134. break;
  1135. // 住院大病保险支付
  1136. case "D390201_BIZ2101":
  1137. case "D390201_BIZ2102":
  1138. case "D390201_BIZ2106":
  1139. case "D390201_BIZ2107":
  1140. case "D390201_BIZ22":
  1141. case "D390201_BIZ52":
  1142. cuminfo.addYearBigdssInspaysZy(itm.getDoubleValue("cum"));
  1143. break;
  1144. // 门诊大病保险支付
  1145. case "D390201_BIZ11":
  1146. case "D390201_BIZ13":
  1147. case "D390201_BIZ14":
  1148. case "D390201_BIZ51":
  1149. case "D390201_BIZ9901":
  1150. case "D390201_BIZ9903":
  1151. case "D390201_BIZ9904":
  1152. cuminfo.addYearBigdssInspaysMz(itm.getDoubleValue("cum"));
  1153. break;
  1154. // 住院医疗救助支付
  1155. case "D610101_BIZ2101":
  1156. case "D610101_BIZ2102":
  1157. case "D610101_BIZ2106":
  1158. case "D610101_BIZ2107":
  1159. case "D610101_BIZ22":
  1160. case "D610101_BIZ52":
  1161. cuminfo.addYearMafpaysZy(itm.getDoubleValue("cum"));
  1162. break;
  1163. // 门诊医疗救助支付
  1164. case "D610101_BIZ11":
  1165. case "D610101_BIZ13":
  1166. case "D610101_BIZ14":
  1167. case "D610101_BIZ51":
  1168. case "D610101_BIZ9901":
  1169. case "D610101_BIZ9903":
  1170. case "D610101_BIZ9904":
  1171. cuminfo.addYearMafpaysMz(itm.getDoubleValue("cum"));
  1172. break;
  1173. // 门诊个人账户支付
  1174. case "D310201_BIZ11":
  1175. case "D310201_BIZ13":
  1176. case "D310201_BIZ14":
  1177. case "D310201_BIZ51":
  1178. case "D310201_BIZ9901":
  1179. case "D310201_BIZ9903":
  1180. case "D310201_BIZ9904":
  1181. cuminfo.addYearAcctPayMz(itm.getDoubleValue("cum"));
  1182. break;
  1183. // 大病保险合规费用
  1184. case "TS390201":
  1185. cuminfo.addYearBigdssLegalFee(itm.getDoubleValue("cum"));
  1186. break;
  1187. }
  1188. }
  1189. }
  1190. return cuminfo;
  1191. }
  1192. private ResultVo<List<SiSetlFeeDetl>> getChrgitems(String psnNo, String setlId, String mdtrtId, String admdvs) {
  1193. List<SiSetlFeeDetl> list = dao.selectAllSetlFeeDtle(mdtrtId);
  1194. if (list.size() > 0) {
  1195. return ResultVoUtil.success(list);
  1196. }
  1197. JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.QUERY_FEE_DETAILS, admdvs);
  1198. JSONObject data = new JSONObject();
  1199. data.put("psn_no", psnNo);
  1200. data.put("setl_id", setlId);
  1201. data.put("mdtrt_id", mdtrtId);
  1202. input.getJSONObject("input").put("data", data);
  1203. JSONObject result = exec.executeTrade(input, SiFunction.QUERY_FEE_DETAILS);
  1204. log.info("【操作员:{}】,【结算单查询】查询费用明细:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
  1205. if (null == result) {
  1206. return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
  1207. }
  1208. if (null == result.getInteger(RESULT_CODE)) {
  1209. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
  1210. }
  1211. if (0 == result.getInteger(RESULT_CODE)) {
  1212. JSONArray output = result.getJSONArray(OUTPUT);
  1213. if (null == output || output.size() == 0) {
  1214. return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到费用明细。");
  1215. }
  1216. for (int i = 0; i < output.size(); i++) {
  1217. SiSetlFeeDetl fee = JSONObject.parseObject(output.getJSONObject(i).toJSONString(), SiSetlFeeDetl.class);
  1218. if (StringUtil.isBlank(fee.getSetlId())) {
  1219. fee.setSetlId(setlId);
  1220. }
  1221. list.add(fee);
  1222. if (list.size() == 30) {
  1223. dao.insertSetlFeeDetlBatch(list);
  1224. list.clear();
  1225. }
  1226. }
  1227. if (list.size() > 0) {
  1228. dao.insertSetlFeeDetlBatch(list);
  1229. }
  1230. return ResultVoUtil.success(dao.selectAllSetlFeeDtle(mdtrtId));
  1231. }
  1232. return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, result.getString(ERROR_MESSAGE));
  1233. }
  1234. private void analyzeZyChrgitm(InptntSetlmtLst lst, List<SiSetlFeeDetl> chrgitms) {
  1235. Map<String, BigDecimal> map = new HashMap<>();
  1236. map.put("allfeeSum", new BigDecimal(0));
  1237. map.put("totalFrst", new BigDecimal(0));
  1238. map.put("totalScnd", new BigDecimal(0));
  1239. chrgitms.forEach(itm -> {
  1240. BigDecimal itmfeeSum = new BigDecimal(itm.getDetItemFeeSumamt());
  1241. map.replace("allfeeSum", map.get("allfeeSum").add(itmfeeSum));
  1242. if (itm.getChrgitmLv().equals(ChrgitmLv.FIRST_CLASS.getCode())) {
  1243. map.replace("totalFrst", map.get("totalFrst").add(itmfeeSum));
  1244. } else if (itm.getChrgitmLv().equals(ChrgitmLv.SECOND_CLASS.getCode())) {
  1245. map.replace("totalScnd", map.get("totalScnd").add(itmfeeSum));
  1246. }
  1247. String typeKey = itm.getMedChrgitmType();
  1248. String lvKey = typeKey + "-" + itm.getChrgitmLv();
  1249. if (map.containsKey(typeKey)) {
  1250. map.replace(typeKey, map.get(typeKey).add(itmfeeSum));
  1251. } else {
  1252. map.put(typeKey, itmfeeSum);
  1253. }
  1254. if (map.containsKey(lvKey)) {
  1255. map.replace(lvKey, map.get(lvKey).add(itmfeeSum));
  1256. } else {
  1257. map.put(lvKey, itmfeeSum);
  1258. }
  1259. });
  1260. lst.setAllfeeSum(map.get("allfeeSum"));
  1261. lst.setAllfeeFrst(map.get("totalFrst"));
  1262. lst.setAllfeeScnd(map.get("totalScnd"));
  1263. lst.setWestMedFeeSum(map.get("09"));
  1264. lst.setWestMedFeeFrst(map.get("09-01"));
  1265. lst.setWestMedFeeScnd(map.get("09-02"));
  1266. lst.setHerbalSum(map.get("10"));
  1267. lst.setHerbalFrst(map.get("10-01"));
  1268. lst.setHerbalScnd(map.get("10-02"));
  1269. lst.setChnsPtntSum(map.get("11"));
  1270. lst.setChnsPtntFrst(map.get("11-01"));
  1271. lst.setChnsPtntScnd(map.get("11-02"));
  1272. lst.setClinicSum(map.get("02"));
  1273. lst.setClinicFrst(map.get("02-01"));
  1274. lst.setClinicScnd(map.get("02-02"));
  1275. lst.setTreatSum(map.get("05"));
  1276. lst.setTreatFrst(map.get("05-01"));
  1277. lst.setTreatScnd(map.get("05-02"));
  1278. lst.setSurgerySum(map.get("06"));
  1279. lst.setSurgeryFrst(map.get("06-01"));
  1280. lst.setSurgeryScnd(map.get("06-02"));
  1281. lst.setNursingSum(map.get("07"));
  1282. lst.setNursingFrst(map.get("07-01"));
  1283. lst.setNursingScnd(map.get("07-02"));
  1284. lst.setSntryMtrlsSum(map.get("08"));
  1285. lst.setSntryMtrlsFrst(map.get("08-01"));
  1286. lst.setSntryMtrlsScnd(map.get("08-02"));
  1287. lst.setExamSum(map.get("04"));
  1288. lst.setExamFrst(map.get("04-01"));
  1289. lst.setExamScnd(map.get("04-02"));
  1290. lst.setNrmlTrtmtSum(map.get("12"));
  1291. lst.setNrmlTrtmtFrst(map.get("12-01"));
  1292. lst.setNrmlTrtmtScnd(map.get("12-02"));
  1293. lst.setInspectSum(map.get("03"));
  1294. lst.setInspectFrst(map.get("03-01"));
  1295. lst.setInspectScnd(map.get("03-02"));
  1296. lst.setRegisterSum(map.get("13"));
  1297. lst.setRegisterFrst(map.get("13-01"));
  1298. lst.setRegisterScnd(map.get("13-02"));
  1299. lst.setBedfeeSum(map.get("01"));
  1300. lst.setBedfeeFrst(map.get("01-01"));
  1301. lst.setBedfeeScnd(map.get("01-02"));
  1302. lst.setOthfeeSum(map.get("14"));
  1303. lst.setOthfeeFrst(map.get("14-01"));
  1304. lst.setOthfeeScnd(map.get("14-02"));
  1305. }
  1306. private void analyzeMzChrgitm(OtptntSetlmtLst lst, List<BrfChrgitm> chrgitms) {
  1307. Map<String, BigDecimal> map = new HashMap<>();
  1308. map.put("allfeeSum", BigDecimal.valueOf(0));
  1309. map.put("totalThrd", BigDecimal.valueOf(0));
  1310. map.put("totalScnd", BigDecimal.valueOf(0));
  1311. map.put("othSum", BigDecimal.valueOf(0));
  1312. map.put("othThrd", BigDecimal.valueOf(0));
  1313. map.put("othScnd", BigDecimal.valueOf(0));
  1314. chrgitms.forEach(itm -> {
  1315. map.replace("allfeeSum", map.get("allfeeSum").add(BigDecimal.valueOf(itm.getChargeFee())));
  1316. if (itm.getChrgitmLv().equals(ChrgitmLv.SELF_PAY.getCode())) {
  1317. map.replace("totalThrd", map.get("totalThrd").add(BigDecimal.valueOf(itm.getChargeFee())));
  1318. } else if (itm.getChrgitmLv().equals(ChrgitmLv.SECOND_CLASS.getCode())) {
  1319. map.replace("totalScnd", map.get("totalScnd").add(BigDecimal.valueOf(itm.getChargeFee())));
  1320. }
  1321. String typeKey = itm.getMedChrgitmType();
  1322. if (!typeKey.equals("09") && !typeKey.equals("11")) {
  1323. map.replace("othSum", map.get("othSum").add(BigDecimal.valueOf(itm.getChargeFee())));
  1324. if (itm.getChrgitmLv().equals(ChrgitmLv.SELF_PAY.getCode())) {
  1325. map.replace("othThrd", map.get("othThrd").add(BigDecimal.valueOf(itm.getChargeFee())));
  1326. } else if (itm.getChrgitmLv().equals(ChrgitmLv.SECOND_CLASS.getCode())) {
  1327. map.replace("othScnd", map.get("othScnd").add(BigDecimal.valueOf(itm.getChargeFee())));
  1328. }
  1329. } else {
  1330. String lvKey = typeKey + "-" + itm.getChrgitmLv();
  1331. if (map.containsKey(typeKey)) {
  1332. map.replace(typeKey, map.get(typeKey).add(BigDecimal.valueOf(itm.getChargeFee())));
  1333. } else {
  1334. map.put(typeKey, BigDecimal.valueOf(itm.getChargeFee()));
  1335. }
  1336. if (map.containsKey(lvKey)) {
  1337. map.replace(lvKey, map.get(lvKey).add(BigDecimal.valueOf(itm.getChargeFee())));
  1338. } else {
  1339. map.put(lvKey, BigDecimal.valueOf(itm.getChargeFee()));
  1340. }
  1341. }
  1342. });
  1343. lst.setAllfeeSum(map.get("allfeeSum"));
  1344. lst.setAllfeeThrd(map.get("totalThrd"));
  1345. lst.setAllfeeScnd(map.get("totalScnd"));
  1346. lst.setWestMedFeeSum(map.get("09"));
  1347. lst.setWestMedFeeThrd(map.get("09-03"));
  1348. lst.setWestMedFeeScnd(map.get("09-02"));
  1349. lst.setChnsPtntSum(map.get("11"));
  1350. lst.setChnsPtntThrd(map.get("11-03"));
  1351. lst.setChnsPtntScnd(map.get("11-02"));
  1352. lst.setMedsrvcSum(map.get("othSum"));
  1353. lst.setMedsrvcThrd(map.get("othThrd"));
  1354. lst.setMedsrvcScnd(map.get("othScnd"));
  1355. }
  1356. public ResultVo<List<SiMzMatnDise>> queryMzMatnDises() {
  1357. return ResultVoUtil.success(dao.selectAllMzMatnDises());
  1358. }
  1359. public ResultVo<List<SetlStatisticResult>> selectSetlinfoStatistics(SetlCondition condition) {
  1360. String begntime = condition.getMonth() + "-01 00:00:00.000";
  1361. String endtime = DateUtil.getMonthEndtime(condition.getMonth());
  1362. String insutype = condition.getInsutype();
  1363. if (StringUtil.isBlank(insutype)) {
  1364. insutype = "%%";
  1365. }
  1366. List<BaseSetlStatistics> baseStatistics;
  1367. switch (condition.getAdmdvsType()) {
  1368. case 1:
  1369. baseStatistics = dao.selectBaseSetlStatisticsInProvinceLevel(begntime, endtime, insutype, condition.getSetlType());
  1370. break;
  1371. case 2:
  1372. baseStatistics = dao.selectBaseSetlStatisticsInChangshaCity(begntime, endtime, insutype, condition.getSetlType());
  1373. break;
  1374. case 3:
  1375. baseStatistics = dao.selectBaseSetlStatisticsInProvinceOtherCities(begntime, endtime, insutype, condition.getSetlType());
  1376. break;
  1377. case 4:
  1378. baseStatistics = dao.selectBaseSetlStatisticsOutProvince(begntime, endtime, insutype, condition.getSetlType());
  1379. break;
  1380. case 5:
  1381. baseStatistics = dao.selectBaseSetlStatisticsInChangshaCounty(begntime, endtime, insutype, condition.getSetlType());
  1382. break;
  1383. case 6:
  1384. baseStatistics = dao.selectBaseSetlStatisticsInLiuYangCity(begntime, endtime, insutype, condition.getSetlType());
  1385. break;
  1386. default:
  1387. baseStatistics = dao.selectBaseSetlStatisticsInAllPlaces(begntime, endtime, insutype, condition.getSetlType());
  1388. break;
  1389. }
  1390. if (null == baseStatistics || baseStatistics.isEmpty()) {
  1391. return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
  1392. }
  1393. Map<String, String> regionMap = new HashMap<>();
  1394. Map<String, List<BaseSetlStatistics>> admdvsSetldataMap = new HashMap<>();
  1395. List<BaseSetlStatistics> shangChuanJieSuanDan = new ArrayList<>();
  1396. baseStatistics.forEach(itm -> {
  1397. itm.setInsutypeName(Insutype.getName(itm.getInsutype()));
  1398. if (null != itm.getHospPay()) {
  1399. itm.setFundPaySumamt(DecimalUtil.minus(itm.getFundPaySumamt(), itm.getHospPay()));
  1400. }
  1401. String key;
  1402. if (condition.getAdmdvsType() == 5 || condition.getAdmdvsType() == 6) {
  1403. key = itm.getInsuplcAdmdvs();
  1404. } else {
  1405. key = itm.getInsuplcAdmdvs().substring(0, 4) + "00";
  1406. }
  1407. String admdvsName = regionMap.get(key);
  1408. if (null == admdvsName) {
  1409. PureCodeName region = dao.selectAdmdvsNameAndParentName(key);
  1410. if (null == region) {
  1411. region = dao.selectAdmdvsName(key);
  1412. }
  1413. admdvsName = region.getCode() + region.getName();
  1414. regionMap.put(key, admdvsName);
  1415. }
  1416. if (admdvsSetldataMap.containsKey(admdvsName)) {
  1417. admdvsSetldataMap.get(admdvsName).add(itm);
  1418. } else {
  1419. List<BaseSetlStatistics> tempList = new ArrayList<>();
  1420. tempList.add(itm);
  1421. admdvsSetldataMap.put(admdvsName, tempList);
  1422. }
  1423. shangChuanJieSuanDan.add(itm);
  1424. });
  1425. List<SetlStatisticResult> resultList = new ArrayList<>();
  1426. for (Map.Entry<String, List<BaseSetlStatistics>> entry : admdvsSetldataMap.entrySet()) {
  1427. List<BaseSetlStatistics> admdvsSetldataList = entry.getValue();
  1428. SetlStatisticResult resultItem = new SetlStatisticResult();
  1429. resultItem.setAdmdvsName(entry.getKey());
  1430. resultItem.setInsuplcAdmdvs(entry.getValue().get(0).getInsuplcAdmdvs().substring(0, 4) + "00");
  1431. resultItem.setPsnSumamt(admdvsSetldataList.size());
  1432. if (StringUtil.notBlank(condition.getInsutype())) {
  1433. resultItem.setInsutype(condition.getInsutype());
  1434. resultItem.setInsutypeName(Insutype.getName(condition.getInsutype()));
  1435. resultItem.setChildKey(entry.getKey() + "-" + resultItem.getInsutypeName());
  1436. } else {
  1437. resultItem.setInsutypeName("-");
  1438. resultItem.setChildKey(entry.getKey());
  1439. }
  1440. fillSetlStatisticResult(resultList, admdvsSetldataList, resultItem);
  1441. }
  1442. if (StringUtil.isBlank(condition.getInsutype())) {
  1443. for (SetlStatisticResult resultItem : resultList) {
  1444. Map<String, List<BaseSetlStatistics>> insutypeSetldataMap = new HashMap<>();
  1445. String admdvsName = resultItem.getAdmdvsName();
  1446. List<BaseSetlStatistics> admdvsSetldataList = admdvsSetldataMap.get(admdvsName);
  1447. for (BaseSetlStatistics baseSetlStatistics : admdvsSetldataList) {
  1448. if (insutypeSetldataMap.containsKey(baseSetlStatistics.getInsutypeName())) {
  1449. insutypeSetldataMap.get(baseSetlStatistics.getInsutypeName()).add(baseSetlStatistics);
  1450. } else {
  1451. List<BaseSetlStatistics> tmpList = new ArrayList<>();
  1452. tmpList.add(baseSetlStatistics);
  1453. insutypeSetldataMap.put(baseSetlStatistics.getInsutypeName(), tmpList);
  1454. }
  1455. }
  1456. if (insutypeSetldataMap.size() == 1) {
  1457. resultItem.setInsutype(admdvsSetldataList.get(0).getInsutype());
  1458. resultItem.setInsutypeName(admdvsSetldataList.get(0).getInsutypeName());
  1459. continue;
  1460. }
  1461. List<SetlStatisticResult> children = new ArrayList<>();
  1462. for (Map.Entry<String, List<BaseSetlStatistics>> entry : insutypeSetldataMap.entrySet()) {
  1463. List<BaseSetlStatistics> insutypeSetldataList = entry.getValue();
  1464. SetlStatisticResult result = new SetlStatisticResult();
  1465. result.setAdmdvsName(resultItem.getAdmdvsName());
  1466. result.setInsuplcAdmdvs(resultItem.getInsuplcAdmdvs());
  1467. result.setPsnSumamt(insutypeSetldataList.size());
  1468. result.setInsutype(entry.getValue().get(0).getInsutype());
  1469. result.setInsutypeName(entry.getValue().get(0).getInsutypeName());
  1470. result.setChildKey(resultItem.getAdmdvsName() + "-" + result.getInsutypeName());
  1471. result.setIsChildren(true);
  1472. fillSetlStatisticResult(children, insutypeSetldataList, result);
  1473. }
  1474. resultItem.setChildren(children);
  1475. }
  1476. }
  1477. resultList.get(0).setShangChuanJieSuanDan(shangChuanJieSuanDan);
  1478. return ResultVoUtil.success(resultList);
  1479. }
  1480. private void fillSetlStatisticResult(List<SetlStatisticResult> resultList,
  1481. List<BaseSetlStatistics> admdvsSetldataList,
  1482. SetlStatisticResult resultItem) {
  1483. String medfeeSumamt = "0";
  1484. String baseMedFundpaySumamt = "0";
  1485. String bigDssFundpaySumamt = "0";
  1486. String clvFundpaySumamt = "0";
  1487. String othFundpaySumamt = "0";
  1488. String fundpaySumamt = "0";
  1489. for (BaseSetlStatistics itm : admdvsSetldataList) {
  1490. medfeeSumamt = DecimalUtil.add(medfeeSumamt, itm.getMedfeeSumamt());
  1491. baseMedFundpaySumamt = DecimalUtil.add(baseMedFundpaySumamt, itm.getHifpPay());
  1492. bigDssFundpaySumamt = DecimalUtil.add(bigDssFundpaySumamt, itm.getHifmiPay());
  1493. clvFundpaySumamt = DecimalUtil.add(clvFundpaySumamt, itm.getCvlservPay());
  1494. fundpaySumamt = DecimalUtil.add(fundpaySumamt, itm.getFundPaySumamt());
  1495. String othpay = DecimalUtil.minusLink(itm.getFundPaySumamt(), itm.getHifpPay(),
  1496. itm.getHifmiPay(), itm.getCvlservPay());
  1497. othFundpaySumamt = DecimalUtil.add(othFundpaySumamt, othpay);
  1498. }
  1499. resultItem.setMedfeeSumamt(medfeeSumamt);
  1500. resultItem.setBaseMedFundpaySumamt(baseMedFundpaySumamt);
  1501. resultItem.setBigDssFundpaySumamt(bigDssFundpaySumamt);
  1502. resultItem.setClvFundpaySumamt(clvFundpaySumamt);
  1503. resultItem.setOthFundpaySumamt(othFundpaySumamt);
  1504. resultItem.setFundpaySumamt(fundpaySumamt);
  1505. resultList.add(resultItem);
  1506. }
  1507. public ResultVo<List<SiSetlinfo>> selectSetldetailStatistics(SetlCondition condition) {
  1508. String begntime = condition.getMonth() + "-01 00:00:00.000";
  1509. String endtime = DateUtil.getMonthEndtime(condition.getMonth());
  1510. String insuplcAdmdvs = condition.getInsuplcAdmdvs().substring(0, 4) + "%";
  1511. String insutype = condition.getInsutype();
  1512. if (StringUtil.isBlank(insutype)) {
  1513. insutype = "%%";
  1514. }
  1515. QueryWrapper<SiSetlinfo> wrapper = new QueryWrapper<>();
  1516. wrapper.eq("setl_type", condition.getSetlType());
  1517. wrapper.eq("revoked", YesOrNo.NO.getCode());
  1518. wrapper.like("insutype", insutype);
  1519. wrapper.like("insuplc_admdvs", insuplcAdmdvs);
  1520. wrapper.apply("setl_time>='" + begntime + "'");
  1521. wrapper.apply("setl_time<='" + endtime + "'");
  1522. List<SiSetlinfo> list = setlinfoDao.selectList(wrapper);
  1523. Map<String, String> regionMap = new HashMap<>();
  1524. list.forEach(item -> {
  1525. String admdvsName = regionMap.get(item.getInsuplcAdmdvs());
  1526. if (null == admdvsName) {
  1527. PureCodeName region = dao.selectAdmdvsNameAndParentName(item.getInsuplcAdmdvs());
  1528. if (null == region) {
  1529. region = dao.selectAdmdvsName(item.getInsuplcAdmdvs());
  1530. if (null == region) {
  1531. region = dao.selectAdmdvsNameAndParentName(item.getInsuplcAdmdvs().substring(0, 4) + "00");
  1532. }
  1533. }
  1534. admdvsName = region.getCode() + region.getName();
  1535. regionMap.put(item.getInsuplcAdmdvs(), admdvsName);
  1536. }
  1537. item.setInsuplcAdmdvsName(admdvsName);
  1538. FilterUtil.filterCodeToName(item);
  1539. });
  1540. return ResultVoUtil.success(list);
  1541. }
  1542. public ResultVo<List<ZyActpatient>> weiJieSuanZaiYuanHuanZhe(String patNo,
  1543. String startTime,
  1544. String endTime,
  1545. String name,
  1546. String certno) {
  1547. List<ZyActpatient> actpatients = dao.zaiYuanHuanZheXinXi(patNo, startTime, endTime, StringUtil.isContainChinese(name), certno);
  1548. Map<String, String> insuplcAdmdvs = new HashMap<>();
  1549. for (ZyActpatient actpatient : actpatients) {
  1550. if (StringUtil.isBlank(actpatient.getInsuplcAdmdvsName())) {
  1551. String key = actpatient.getInsuplcAdmdvs().substring(0, 4) + "00";
  1552. if (insuplcAdmdvs.containsKey(key)) {
  1553. actpatient.setInsuplcAdmdvsName(insuplcAdmdvs.get(key));
  1554. } else {
  1555. String insuplcAdmdvsName = dao.selectRegionName(key);
  1556. insuplcAdmdvs.put(key, insuplcAdmdvsName);
  1557. actpatient.setInsuplcAdmdvsName(insuplcAdmdvsName);
  1558. }
  1559. }
  1560. }
  1561. return ResultVoUtil.success(actpatients);
  1562. }
  1563. public ResultVo<String> checkRegisterDate(String patNo, Integer times) {
  1564. Date ledgerAccountDate = dao.selectMaxLedgerAccountDate(patNo, times);
  1565. if (null == ledgerAccountDate) {
  1566. return ResultVoUtil.success();
  1567. }
  1568. Date registerDate = dao.selectRegisterDate(patNo);
  1569. if (null == registerDate) {
  1570. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保登记日期不能为空,请联系病房填写。");
  1571. }
  1572. Calendar ledgerCalendar = Calendar.getInstance();
  1573. ledgerCalendar.setTime(ledgerAccountDate);
  1574. Calendar registerCalendar = Calendar.getInstance();
  1575. registerCalendar.setTime(registerDate);
  1576. if (registerCalendar.after(ledgerCalendar)) {
  1577. return ResultVoUtil.success();
  1578. }
  1579. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保登记日期不能小于断账日期,请联系病房修改。");
  1580. }
  1581. }