DrgWebApi.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package thyyxxk.webserver.http.drg;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.dtflys.forest.Forest;
  6. import lombok.RequiredArgsConstructor;
  7. import lombok.extern.slf4j.Slf4j;
  8. import org.springframework.stereotype.Service;
  9. import thyyxxk.webserver.config.envionment.ApiUrl;
  10. import thyyxxk.webserver.config.envionment.SystemConfig;
  11. import thyyxxk.webserver.config.exception.ExceptionEnum;
  12. import thyyxxk.webserver.entity.ResultVo;
  13. import thyyxxk.webserver.utils.ResultVoUtil;
  14. @Service
  15. @RequiredArgsConstructor
  16. @Slf4j
  17. public class DrgWebApi {
  18. private final ApiUrl apiUrl;
  19. private final SystemConfig config;
  20. public JSONObject drgQuality(JSONObject obj) {
  21. if (StrUtil.isBlank(apiUrl.getDrgWebApi())) {
  22. return new JSONObject();
  23. }
  24. return Forest.post(apiUrl.getDrgWebApi() + "/drg_web/drgGroupThird/V2/setListDrg.action")
  25. .connectTimeout(3000)
  26. .readTimeout(6000)
  27. .contentTypeJson()
  28. .addBody(obj)
  29. .execute(JSONObject.class);
  30. }
  31. public JSONObject etlClient(JSONObject obj) {
  32. if (StrUtil.isBlank(apiUrl.getDrgWebApi())) {
  33. return new JSONObject();
  34. }
  35. return Forest.post(apiUrl.getDrgWebApi() + "/etlClient/callHisData.action")
  36. .connectTimeout(3000)
  37. .readTimeout(6000)
  38. .contentTypeJson()
  39. .addBody(obj)
  40. .execute(JSONObject.class);
  41. }
  42. public JSONObject getDrgCaseQualityControlGroup(JSONObject obj) {
  43. if (StrUtil.isBlank(apiUrl.getDrgWebApi())) {
  44. JSONObject jsonObject = new JSONObject();
  45. jsonObject.put("code", 404);
  46. return jsonObject;
  47. }
  48. return Forest.post(apiUrl.getDrgWebApi() + "/drg_web/drgGroupThird/getAllDrgResults.action")
  49. .connectTimeout(3000)
  50. .readTimeout(6000)
  51. .contentTypeJson()
  52. .addBody(obj)
  53. .execute(JSONObject.class);
  54. }
  55. public ResultVo<JSONArray> powersiPreDischarge(String visitId) {
  56. if (StrUtil.isBlank(apiUrl.getDrgWebApi())) {
  57. return ResultVoUtil.success();
  58. }
  59. String url = apiUrl.getDrgWebApi() + "/drg_web/api/json/call.action";
  60. JSONObject params = new JSONObject();
  61. params.put("function_id", "apiHnsService1001");
  62. params.put("hospital_id", config.getInstitutionId());
  63. params.put("scene_type", "6");
  64. params.put("visit_id", visitId);
  65. JSONObject response;
  66. try {
  67. response = Forest.post(url)
  68. .contentTypeJson()
  69. .addBody(params)
  70. .execute(JSONObject.class);
  71. } catch (Exception e) {
  72. return ResultVoUtil.success();
  73. }
  74. log.info("创智出院预审:【{}】,【{}】", visitId, response);
  75. if (null == response) {
  76. return ResultVoUtil.success();
  77. }
  78. Integer retcode = response.getInteger("return_code");
  79. if (null != retcode && retcode == 1) {
  80. JSONArray retdata = response.getJSONArray("return_data");
  81. if (null == retdata || retdata.isEmpty()) {
  82. return ResultVoUtil.success();
  83. }
  84. return ResultVoUtil.fail(ExceptionEnum.PRE_DISCHARGE_ERROR, retdata);
  85. }
  86. return ResultVoUtil.success();
  87. }
  88. public ResultVo<String> frontsheetQualityCheck(JSONObject jsonParams) {
  89. if (StrUtil.isBlank(apiUrl.getDrgWebApi())) {
  90. return ResultVoUtil.success();
  91. }
  92. String url = apiUrl.getDrgWebApi() + "/drg_web/drgGroupThird/V2/groupAndQuality.action";
  93. String result = Forest.post(url)
  94. .contentTypeJson()
  95. .addBody(jsonParams)
  96. .execute(String.class);
  97. result = apiUrl.getDrgWebApi() + result;
  98. String url2 = apiUrl.getDrgWebApi() + "/drg_web/drgGroupThird/V2/drgGroupAndQuality.action";
  99. String result2 = Forest.post(url2)
  100. .contentTypeJson()
  101. .addBody(jsonParams)
  102. .execute(String.class);
  103. log.info("病案质控:\n参数:{}\n结果:{}", jsonParams, result2);
  104. return ResultVoUtil.success(result);
  105. }
  106. public ResultVo<String> getDrgIntelligentGrouping(JSONObject data) {
  107. if (StrUtil.isBlank(apiUrl.getDrgWebApi())) {
  108. return ResultVoUtil.success();
  109. }
  110. String url = apiUrl.getDrgWebApi() + "/drg_web/localHelp/drg_dagns/list.action";
  111. String res = Forest.post(url)
  112. .contentTypeJson()
  113. .addBody(data)
  114. .execute(String.class);
  115. return ResultVoUtil.success(apiUrl.getDrgWebApi() + res);
  116. }
  117. }