|
|
@@ -3,11 +3,11 @@ package thyyxxk.webserver.service.zhuyuanyisheng.emr;
|
|
|
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.dynamic.datasource.annotation.DS;
|
|
|
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 org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
@@ -34,7 +34,6 @@ import thyyxxk.webserver.websocket.WebSocketServer;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import javax.websocket.Session;
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Service
|
|
|
@@ -46,6 +45,9 @@ public class EmrServer {
|
|
|
private final PublicServer publicServer;
|
|
|
private final LoginDao loginDao;
|
|
|
private final RedisLikeService redisLikeService;
|
|
|
+ private static final Map<String, JSONObject> TEMPLATE_DATA = new LinkedHashMap<>();
|
|
|
+ private static final Map<String, String> GROUP_MAP = new HashMap<>();
|
|
|
+ private final String HOSPITAL_WIDE_FOLDER = "3b1655a006ff11edbc820dada413ba28";
|
|
|
|
|
|
public EmrServer(EmrPatientDao dao, EmrEditor emr, PublicServer publicServer, LoginDao loginDao, RedisLikeService redisLikeService) {
|
|
|
this.dao = dao;
|
|
|
@@ -62,10 +64,42 @@ public class EmrServer {
|
|
|
* @param times 住院次数
|
|
|
* @return 数据
|
|
|
*/
|
|
|
- public ResultVo<List<EmrPatientData>> getPatientDataTree(String patNo, Integer times) {
|
|
|
- return ResultVoUtil.success(dao.getPatientData(patNo, times));
|
|
|
+ public ResultVo<List<JSONObject>> getPatientDataTree(String patNo, Integer times) {
|
|
|
+ Map<String, JSONObject> temp = JSON.parseObject(JSON.toJSONString(TEMPLATE_DATA),
|
|
|
+ new TypeReference<LinkedHashMap<String, JSONObject>>() {
|
|
|
+ });
|
|
|
+
|
|
|
+ List<EmrPatientData> list = dao.getPatientData(patNo, times);
|
|
|
+ List<JSONObject> tree = new ArrayList<>(list.size());
|
|
|
+
|
|
|
+ if (ListUtil.isBlank(list)) {
|
|
|
+ return ResultVoUtil.success(tree);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TEMPLATE_DATA.isEmpty()) {
|
|
|
+ tree();
|
|
|
+ }
|
|
|
+
|
|
|
+ list.forEach(item -> {
|
|
|
+ JSONObject js = temp.get(item.getParent());
|
|
|
+
|
|
|
+ if (js == null) {
|
|
|
+ js = temp.get(HOSPITAL_WIDE_FOLDER);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (js.getJSONArray("children") == null) {
|
|
|
+ js.put("children", new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ js.getJSONArray("children").add(item);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ tree.addAll(temp.values());
|
|
|
+ return ResultVoUtil.success(tree);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public ResultVo<Map<String, List<JSONObject>>> getEmrTree(String type) {
|
|
|
Map<String, List<JSONObject>> map = new HashMap<>(Capacity.TWO);
|
|
|
if ("all".equals(type)) {
|
|
|
@@ -217,6 +251,7 @@ public class EmrServer {
|
|
|
if (isUpdated) {
|
|
|
dao.updateCreatedTemplate(param);
|
|
|
} else {
|
|
|
+ param.setParent(GROUP_MAP.get(param.getEmrCategoryCode()));
|
|
|
dao.emrInsertForTheFirstTime(param);
|
|
|
}
|
|
|
return ResultVoUtil.success(extractedData);
|
|
|
@@ -433,7 +468,13 @@ public class EmrServer {
|
|
|
|
|
|
for (int i = 0; i < operation.size(); i++) {
|
|
|
JSONObject item = operation.getJSONObject(i);
|
|
|
- JSONArray list = item.getJSONObject("手术名称").getJSONArray("value");
|
|
|
+ JSONArray list = null;
|
|
|
+ try {
|
|
|
+ list = item.getJSONObject("手术名称").getJSONArray("value");
|
|
|
+ } catch (Exception e) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
if (list == null) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -752,4 +793,36 @@ public class EmrServer {
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @PostConstruct
|
|
|
+ public void tree() {
|
|
|
+ JSONArray data = emr.getEmrTree();
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ JSONObject item = data.getJSONObject(i);
|
|
|
+
|
|
|
+ if (item.getString("_id").equals(HOSPITAL_WIDE_FOLDER)) {
|
|
|
+ item.put("name", "其他病历");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("group-category".equals(item.getString("type"))) {
|
|
|
+ TEMPLATE_DATA.put(item.getString("_id"), item);
|
|
|
+ }
|
|
|
+
|
|
|
+ GROUP_MAP.put(item.getString("code"), item.getString("parent"));
|
|
|
+ }
|
|
|
+ log.info("获取所有的父节点:{}", JSON.toJSONString(TEMPLATE_DATA));
|
|
|
+// 重置父级节点(groupMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void 重置父级节点() {
|
|
|
+ List<EmrPatientData> patData = dao.查询历史数据();
|
|
|
+ patData.forEach(item -> {
|
|
|
+ if (GROUP_MAP.containsKey(item.getEmrCategoryCode())) {
|
|
|
+ String value = GROUP_MAP.get(item.getEmrCategoryCode());
|
|
|
+ dao.更新节点(value, item.getId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|