|
@@ -1,18 +1,23 @@
|
|
|
package thyyxxk.webserver.service.zhuyuanyisheng.emr;
|
|
|
|
|
|
+import cn.hutool.core.codec.Base64;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.alibaba.fastjson.TypeReference;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.dtflys.forest.http.ForestRequest;
|
|
|
+import com.dtflys.forest.interceptor.Interceptor;
|
|
|
+import com.dtflys.forest.reflection.ForestMethod;
|
|
|
+import lombok.Getter;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.ListUtils;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
-import org.yaml.snakeyaml.events.Event;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
import thyyxxk.webserver.constants.EmrType;
|
|
@@ -39,8 +44,8 @@ import thyyxxk.webserver.service.externalhttp.emr.EmrEditor;
|
|
|
import thyyxxk.webserver.service.redislike.RedisLikeService;
|
|
|
import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collector;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -51,7 +56,6 @@ public class EmrServer {
|
|
|
private final EmrEditor emr;
|
|
|
private final EmrFolderDao folderDao;
|
|
|
private final RedisServer redisServer;
|
|
|
-
|
|
|
private final PublicServer publicServer;
|
|
|
private final LoginDao loginDao;
|
|
|
private final RedisLikeService redisLikeService;
|
|
@@ -60,7 +64,33 @@ public class EmrServer {
|
|
|
private static final Map<String, String> GROUP_MAP = new HashMap<>();
|
|
|
private final String HOSPITAL_WIDE_FOLDER = "3b1655a006ff11edbc820dada413ba28";
|
|
|
|
|
|
- public EmrServer(EmrPatientDao dao, EmrEditor emr, EmrFolderDao folderDao, RedisServer redisServer, PublicServer publicServer, LoginDao loginDao, RedisLikeService redisLikeService, WebSocketService socketService) {
|
|
|
+ private static String emrToken = null;
|
|
|
+
|
|
|
+ public static class EmrInterceptor implements Interceptor<String> {
|
|
|
+ @Override
|
|
|
+ public void onInvokeMethod(ForestRequest request, ForestMethod method, Object[] args) {
|
|
|
+ request.addHeader("emr-token", emrToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ @Scheduled(cron = "* * */12 * * ?")
|
|
|
+ public void token() {
|
|
|
+ String result = HttpRequest.post("http://172.16.32.125:8001/emr/runtime/api/v1/oauth/token")
|
|
|
+ .header("Authorization", "Basic " + Base64.encode("user:dc71ccfec05b799ad52360c48d504019"))
|
|
|
+ .form("grant_type", "client_credentials").execute().body();
|
|
|
+ JSONObject data = JSONObject.parseObject(result);
|
|
|
+ emrToken = data.getString("access_token");
|
|
|
+ }
|
|
|
+
|
|
|
+ public EmrServer(EmrPatientDao dao,
|
|
|
+ EmrEditor emr,
|
|
|
+ EmrFolderDao folderDao,
|
|
|
+ RedisServer redisServer,
|
|
|
+ PublicServer publicServer,
|
|
|
+ LoginDao loginDao,
|
|
|
+ RedisLikeService redisLikeService,
|
|
|
+ WebSocketService socketService) {
|
|
|
this.dao = dao;
|
|
|
this.emr = emr;
|
|
|
this.folderDao = folderDao;
|
|
@@ -919,5 +949,9 @@ public class EmrServer {
|
|
|
return ResultVoUtil.success(dao.getOpRecordList(patNo, times));
|
|
|
}
|
|
|
|
|
|
+ public String getEmrToken() {
|
|
|
+ return emrToken;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|