Explorar o código

推理-症状、查体、化验、辅检、诊断

zhaops %!s(int64=4) %!d(string=hai) anos
pai
achega
3ec1c59027

+ 5 - 0
src/main/java/com/diagbot/client/CdssCoreClient.java

@@ -2,8 +2,10 @@ package com.diagbot.client;
 
 import com.diagbot.client.hystrix.CdssCoreHystrix;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.PushCoreDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.vo.IndicationPushVO;
+import com.diagbot.vo.PushVO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -20,6 +22,9 @@ public interface CdssCoreClient {
 
     @PostMapping("/core/indication")
     RespDTO<IndicationDTO> indication(@Valid @RequestBody IndicationPushVO indicationPushVO);
+
+    @PostMapping("/core/push")
+    RespDTO<PushCoreDTO> push(@RequestBody @Valid PushVO pushVo);
 }
 
 

+ 8 - 0
src/main/java/com/diagbot/client/hystrix/CdssCoreHystrix.java

@@ -2,8 +2,10 @@ package com.diagbot.client.hystrix;
 
 import com.diagbot.client.CdssCoreClient;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.PushCoreDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.vo.IndicationPushVO;
+import com.diagbot.vo.PushVO;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -24,4 +26,10 @@ public class CdssCoreHystrix implements CdssCoreClient {
         log.error("【hystrix】调用{}异常", "indication");
         return null;
     }
+
+    @Override
+    public RespDTO<PushCoreDTO> push(@RequestBody @Valid PushVO pushVo) {
+        log.error("【hystrix】调用{}异常", "push");
+        return null;
+    }
 }

+ 21 - 0
src/main/java/com/diagbot/dto/PushBaseCoreDTO.java

@@ -0,0 +1,21 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/8/6 9:59
+ */
+@Getter
+@Setter
+public class PushBaseCoreDTO {
+    //条目名称
+    private String name;
+
+    //his条目名称
+    private List<String> hisNameList;
+}

+ 27 - 0
src/main/java/com/diagbot/dto/PushCoreDTO.java

@@ -0,0 +1,27 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 推理出参
+ * @author: gaodm
+ * @time: 2020/8/6 9:54
+ */
+@Getter
+@Setter
+public class PushCoreDTO {
+    //症状
+    private List<PushBaseCoreDTO> symptom;
+    //体格检查
+    private List<PushBaseCoreDTO> vital;
+    //检验
+    private List<PushBaseCoreDTO> lis;
+    //检查
+    private List<PushBaseCoreDTO> pacs;
+    //诊断
+    private Map<String, List<PushBaseCoreDTO>> dis;
+}

+ 34 - 0
src/main/java/com/diagbot/facade/DiseaseConfigFacade.java

@@ -243,6 +243,40 @@ public class DiseaseConfigFacade {
         return retMap;
     }
 
+    /**
+     * 获取映射关系
+     * Map<uniqueName,Map<hisName,id>>
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    public Map<String,Map<String,Long>> getUniqueNameConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Long>> retMap = new HashMap<>();
+        QueryWrapper<DiseaseConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<DiseaseConfig> records = diseaseConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        Map<String, List<DiseaseConfig>> uniqueNameMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<DiseaseConfig>> entry : uniqueNameMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "hisName", "id"));
+            }
+        }
+        return retMap;
+    }
+
     /**
      * 数据导出
      *

+ 34 - 0
src/main/java/com/diagbot/facade/DrugConfigFacade.java

@@ -242,6 +242,40 @@ public class DrugConfigFacade {
         return retMap;
     }
 
+    /**
+     * 获取映射关系
+     * Map<uniqueName,Map<hisName,id>>
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    public Map<String,Map<String,Long>> getUniqueNameConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Long>> retMap = new HashMap<>();
+        QueryWrapper<DrugConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<DrugConfig> records = drugConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        Map<String, List<DrugConfig>> uniqueNameMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<DrugConfig>> entry : uniqueNameMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "hisName", "id"));
+            }
+        }
+        return retMap;
+    }
+
     /**
      * 数据导出
      *

+ 42 - 0
src/main/java/com/diagbot/facade/LisConfigFacade.java

@@ -283,6 +283,48 @@ public class LisConfigFacade{
         return retMap;
     }
 
+
+    /**
+     * 获取映射关系
+     * Map<uniqueName,Map<hisName,id>>
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    public Map<String,Map<String,Long>> getUniqueNameConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Long>> retMap = new HashMap<>();
+        QueryWrapper<LisConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<LisConfig> records = lisConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        records.forEach(lisConfig -> {
+            if (lisConfig.getHisDetailName() == null) {
+                lisConfig.setHisDetailName("");
+            }
+        });
+
+        Map<String, List<LisConfig>> uniqueNameMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<LisConfig>> entry : uniqueNameMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "hisName", "id"));
+            }
+        }
+        return retMap;
+    }
+
+
     /**
      * 数据导出
      *

+ 34 - 0
src/main/java/com/diagbot/facade/OperationConfigFacade.java

@@ -242,6 +242,40 @@ public class OperationConfigFacade {
         return retMap;
     }
 
+    /**
+     * 获取映射关系
+     * Map<uniqueName,Map<hisName,id>>
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    public Map<String,Map<String,Long>> getUniqueNameConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Long>> retMap = new HashMap<>();
+        QueryWrapper<OperationConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<OperationConfig> records = operationConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        Map<String, List<OperationConfig>> uniqueNameMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<OperationConfig>> entry : uniqueNameMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "hisName", "id"));
+            }
+        }
+        return retMap;
+    }
+
     /**
      * 数据导出
      *

+ 34 - 0
src/main/java/com/diagbot/facade/PacsConfigFacade.java

@@ -242,6 +242,40 @@ public class PacsConfigFacade {
         return retMap;
     }
 
+    /**
+     * 获取映射关系
+     * Map<uniqueName,Map<hisName,id>>
+     *
+     * @param hospitalId
+     * @param hisNames
+     * @param uniqueNames
+     * @return
+     */
+    public Map<String,Map<String,Long>> getUniqueNameConfigMap(Long hospitalId, List<String> hisNames, List<String> uniqueNames) {
+        Map<String, Map<String, Long>> retMap = new HashMap<>();
+        QueryWrapper<PacsConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq("hospital_id", hospitalId);
+        if (ListUtil.isNotEmpty(hisNames)) {
+            queryWrapper.in("his_name", hisNames);
+        }
+        if (ListUtil.isNotEmpty(uniqueNames)) {
+            queryWrapper.in("unique_name", uniqueNames);
+        }
+        List<PacsConfig> records = pacsConfigService.list(queryWrapper);
+        if (ListUtil.isEmpty(records)) {
+            return retMap;
+        }
+
+        Map<String, List<PacsConfig>> uniqueNameMap = EntityUtil.makeEntityListMap(records, "uniqueName");
+        for (Map.Entry<String, List<PacsConfig>> entry : uniqueNameMap.entrySet()) {
+            if (ListUtil.isNotEmpty(entry.getValue())) {
+                retMap.put(entry.getKey(), EntityUtil.makeMapWithKeyValue(entry.getValue(), "hisName", "id"));
+            }
+        }
+        return retMap;
+    }
+
     /**
      * 数据导出
      *

+ 80 - 2
src/main/java/com/diagbot/facade/PushFacade.java

@@ -2,15 +2,24 @@ package com.diagbot.facade;
 
 import com.diagbot.client.CdssCoreClient;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.PushBaseCoreDTO;
+import com.diagbot.dto.PushCoreDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.util.BeanUtil;
+import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
 import com.diagbot.vo.IndicationPushVO;
 import com.diagbot.vo.PushVO;
 import com.diagbot.vo.SearchData;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * @Description:
  * @Author:zhaops
@@ -22,17 +31,86 @@ public class PushFacade {
     private AssembleFacade assembleFacade;
     @Autowired
     private CdssCoreClient cdssCoreClient;
+    @Autowired
+    private LisConfigFacade lisConfigFacade;
+    @Autowired
+    private PacsConfigFacade pacsConfigFacade;
+    @Autowired
+    private DiseaseConfigFacade diseaseConfigFacade;
+
 
     /**
-     * 基础推理
+     * 基础推理-症状、查体、化验、辅检、诊断
      *
      * @param pushVO
      */
-    public void push(PushVO pushVO) {
+    public PushCoreDTO push(PushVO pushVO) {
         SearchData searchData = new SearchData();
         BeanUtil.copyProperties(pushVO, searchData);
         searchData = assembleFacade.assembleData(searchData);
         BeanUtil.copyProperties(searchData, pushVO);
+        RespDTO<PushCoreDTO> resp = cdssCoreClient.push(pushVO);
+        RespDTOUtil.respNGDealCover(resp, "远程调用推理接口失败");
+        PushCoreDTO data = resp.data;
+        //TODO 外部名称映射
+        if (ListUtil.isNotEmpty(data.getLis())) {
+            List<PushBaseCoreDTO> retLis = data.getLis();
+            List<String> uniqueNameList = retLis.stream()
+                    .map(i -> i.getName())
+                    .collect(Collectors.toList());
+            Map<String, Map<String, Long>> uniqueNameMap
+                    = lisConfigFacade.getUniqueNameConfigMap(pushVO.getHospitalId(), null, uniqueNameList);
+            if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
+                retLis.forEach(item -> {
+                    if (uniqueNameMap.get(item.getName()) != null) {
+                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                    }
+                });
+                data.setLis(retLis);
+            }
+        }
+        if (ListUtil.isNotEmpty(data.getPacs())) {
+            List<PushBaseCoreDTO> retPacs = data.getPacs();
+            List<String> uniqueNameList = retPacs.stream()
+                    .map(i -> i.getName())
+                    .collect(Collectors.toList());
+            Map<String, Map<String, Long>> uniqueNameMap
+                    = pacsConfigFacade.getUniqueNameConfigMap(pushVO.getHospitalId(), null, uniqueNameList);
+            if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
+                retPacs.forEach(item -> {
+                    if (uniqueNameMap.get(item.getName()) != null) {
+                        item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                    }
+                });
+                data.setPacs(retPacs);
+            }
+        }
+        if (data.getDis() != null && data.getDis().size() > 0) {
+            Map<String, List<PushBaseCoreDTO>> retMap = data.getDis();
+            List<String> uniqueNameList = Lists.newLinkedList();
+            for (Map.Entry<String, List<PushBaseCoreDTO>> entry : retMap.entrySet()) {
+                if (ListUtil.isNotEmpty(entry.getValue())) {
+                    uniqueNameList.addAll(entry.getValue().stream()
+                            .map(i -> i.getName())
+                            .collect(Collectors.toList()));
+                }
+            }
+            if (ListUtil.isNotEmpty(uniqueNameList)) {
+                Map<String, Map<String, Long>> uniqueNameMap
+                        = diseaseConfigFacade.getUniqueNameConfigMap(pushVO.getHospitalId(), null, uniqueNameList);
+                for (Map.Entry<String, List<PushBaseCoreDTO>> entry : retMap.entrySet()) {
+                    if (uniqueNameMap != null && uniqueNameMap.size() > 0) {
+                        entry.getValue().forEach(item -> {
+                            if (uniqueNameMap.get(item.getName()) != null) {
+                                item.setHisNameList(new ArrayList<>(uniqueNameMap.get(item.getName()).keySet()));
+                            }
+                        });
+                    }
+                }
+                data.setDis(retMap);
+            }
+        }
+        return data;
     }
 
     /**

+ 10 - 0
src/main/java/com/diagbot/web/PushController.java

@@ -2,9 +2,11 @@ package com.diagbot.web;
 
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.PushCoreDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.PushFacade;
 import com.diagbot.vo.IndicationPushVO;
+import com.diagbot.vo.PushVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +30,14 @@ public class PushController {
     @Autowired
     private PushFacade pushFacade;
 
+    @ApiOperation(value = "基础推理[by:zhaops]", notes = "")
+    @PostMapping("/push")
+    @SysLogger("push")
+    public RespDTO<PushCoreDTO> push(@RequestBody @Valid PushVO pushVO) {
+        PushCoreDTO data = pushFacade.push(pushVO);
+        return RespDTO.onSuc(data);
+    }
+
     @ApiOperation(value = "开单合理项推理[by:zhaops]", notes = "")
     @PostMapping("/indicationPush")
     @SysLogger("indicationPush")