zhaops 4 лет назад
Родитель
Сommit
a166c53cae

+ 3 - 1
tran-service/src/main/java/com/diagbot/facade/DiseaseDeptFacade.java

@@ -33,8 +33,10 @@ public class DiseaseDeptFacade extends DiseaseDeptServiceImpl {
         QueryWrapper<DiseaseDept> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
                 .eq("status", StatusEnum.Enable.getKey())
-                .eq("hospital_code", diseaseDeptVO.getHospitalCode())
                 .in(ListUtil.isNotEmpty(diseaseDeptVO.getConceptNames()), "concept_dis_name", diseaseDeptVO.getConceptNames());
+        if (StringUtil.isNotBlank(diseaseDeptVO.getHospitalCode())) {
+            queryWrapper.eq("hospital_code", diseaseDeptVO.getHospitalCode());
+        }
         List<DiseaseDept> diseaseDeptList = this.list(queryWrapper);
         //过滤科室为空的数据和诊断分类为空的数据
         diseaseDeptList = diseaseDeptList

+ 1 - 0
triage-service/src/main/java/com/diagbot/dto/SYFDiseaseDeptDTO.java

@@ -23,4 +23,5 @@ public class SYFDiseaseDeptDTO {
     private List<String> diseaseNames;
     //private List<SYFFeatureDTO> features;
     private String suggestion;
+    private List<HospitalDeptDTO> hospitalDepts;
 }

+ 3 - 0
triage-service/src/main/java/com/diagbot/dto/SYFFeatureDTO.java

@@ -4,6 +4,8 @@ import com.diagbot.annotation.CryptField;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @Description:
  * @Author:zhaops
@@ -26,4 +28,5 @@ public class SYFFeatureDTO {
     private String subDeptCode;
     private String url;
     private String suggestion;
+    private List<HospitalDeptDTO> hospitalDepts;
 }

+ 141 - 0
triage-service/src/main/java/com/diagbot/facade/AIV2Facade.java

@@ -7,6 +7,8 @@ import com.diagbot.client.AiptServiceClient;
 import com.diagbot.client.TranServiceClient;
 import com.diagbot.dto.ConceptPushDTO;
 import com.diagbot.dto.DiseaseDeptDTO;
+import com.diagbot.dto.FeatureRateDTO;
+import com.diagbot.dto.HospitalDeptDTO;
 import com.diagbot.dto.PushDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.SYFDTO;
@@ -23,6 +25,7 @@ import com.diagbot.util.RespDTOUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.AIVO;
 import com.diagbot.vo.DiseaseDeptVO;
+import com.diagbot.vo.HospitalDeptVO;
 import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -201,4 +204,142 @@ public class AIV2Facade {
         syfdto.setDiseaseDept(syfDeptDTOList);
         return syfdto;
     }
+
+    /**
+     * 邵逸夫诊断推理
+     *
+     * @param aivo
+     * @param type
+     * @return
+     */
+    public SYFDTO pushDisForNaliV2(AIVO aivo, String type) {
+        if (StringUtil.isBlank(aivo.getHospitalCode())) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入医院编码");
+        }
+        RespDTO<ResponseDataWithExplainV2> res
+                = aiptServiceClient.pushWithExplainV2(assembleFacade.assembleData(aivo, type));
+        RespDTOUtil.respNGDealCover(res, "中间层没有结果返回");
+        SYFDTO syfdto = new SYFDTO();
+
+        List<SYFDiseaseDeptDTO> items = Lists.newLinkedList();
+        List<FeatureRateV2> dis = res.data.getDis();
+        if (ListUtil.isNotEmpty(dis)) {
+            Map<String, List<SYFFeatureDTO>> disFeatureMap = new LinkedHashMap<>();
+            List<SYFFeatureDTO> disDTO = BeanUtil.listCopyTo(dis, SYFFeatureDTO.class);
+
+            //关联邵逸夫医院映射,hospitalCode不传
+            DiseaseDeptVO diseaseDeptVO = new DiseaseDeptVO();
+            List<String> disNames = dis.stream().map(i -> i.getFeatureName()).collect(Collectors.toList());
+            diseaseDeptVO.setConceptNames(disNames);
+            RespDTO<List<DiseaseDeptDTO>> diseaseDeptDTORes
+                    = tranServiceClient.getDiseaseDeptByConceptNames(diseaseDeptVO);
+            RespDTOUtil.respNGDealCover(diseaseDeptDTORes, "诊断科室映射关系未维护");
+            List<DiseaseDeptDTO> diseaseDeptDTOList = diseaseDeptDTORes.data;
+            Map<String, List<DiseaseDeptDTO>> diseaseDeptMap
+                    = EntityUtil.makeEntityListMap(diseaseDeptDTOList, "conceptDisName");
+            //诊断分类
+            for (SYFFeatureDTO featureRateDTO : disDTO) {
+                //关联外部诊断科室
+                if (diseaseDeptMap != null
+                        && ListUtil.isNotEmpty(diseaseDeptMap.get(featureRateDTO.getFeatureName()))) {
+                    List<DiseaseDeptDTO> ddList = diseaseDeptMap.get(featureRateDTO.getFeatureName());
+                    featureRateDTO.setDeptName(ddList.get(0).getDeptName());
+                    featureRateDTO.setSubDeptName(ddList.get(0).getSubDeptName());
+                    featureRateDTO.setDiseaseName(ddList.get(0).getDiseaseName());
+                    featureRateDTO.setSuggestion(ddList.get(0).getSuggestion());
+                    featureRateDTO.setDeptCode(ddList.get(0).getDeptCode());
+                    featureRateDTO.setSubDeptCode(ddList.get(0).getSubDeptCode());
+                    if (StringUtil.isNotBlank(ddList.get(0).getSubDeptName())
+                            && (!ddList.get(0).getDeptName().equals(ddList.get(0).getSubDeptName()))) {
+                        featureRateDTO
+                                .setConcatDept(ddList.get(0).getDeptName() + "-" + ddList.get(0).getSubDeptName());
+                    } else {
+                        featureRateDTO.setConcatDept(ddList.get(0).getDeptName());
+                    }
+                    featureRateDTO.setUrl(ddList.get(0).getUrl());
+                } else {
+                    featureRateDTO.setDiseaseName(featureRateDTO.getFeatureName());
+                }
+                if (StringUtil.isBlank(featureRateDTO.getDesc())) {
+                    featureRateDTO.setDesc("{\"可能诊断\":\"\"}");
+                }
+                Map<String, Object> descMap = FastJsonUtils.getJsonToMap(featureRateDTO.getDesc());
+                for (String disClass : descMap.keySet()) {
+                    List<SYFFeatureDTO> featureRateDTOList = Lists.newLinkedList();
+                    if (disFeatureMap.get(disClass) != null) {
+                        featureRateDTOList = disFeatureMap.get(disClass);
+                    }
+                    featureRateDTOList.add(featureRateDTO);
+                    disFeatureMap.put(disClass, featureRateDTOList);
+                }
+            }
+
+            //仅分析确诊、拟诊、可能诊断,其他类型(如:警惕)不参与分诊推理
+            List<SYFFeatureDTO> featureRateList = Lists.newLinkedList();
+            if (disFeatureMap.containsKey("确诊")) {
+                featureRateList.addAll(disFeatureMap.get("确诊"));
+            } else if (disFeatureMap.containsKey("拟诊")) {
+                featureRateList.addAll(disFeatureMap.get("拟诊"));
+            } else if (disFeatureMap.containsKey("可能诊断")) {
+                featureRateList.addAll(disFeatureMap.get("可能诊断"));
+            }
+
+            if (ListUtil.isEmpty(featureRateList)) {
+                throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "推理结果为空");
+            }
+
+            //过滤科室为空的数据
+            featureRateList = featureRateList
+                    .stream()
+                    .filter(i -> StringUtil.isNotBlank(i.getConcatDept()))
+                    .collect(Collectors.toList());
+
+            //获取对接科室
+            HospitalDeptVO hospitalDeptVO = new HospitalDeptVO();
+            hospitalDeptVO.setHospitalCode(aivo.getHospitalCode());
+            hospitalDeptVO.setConceptNames(items
+                    .stream()
+                    .map(i -> i.getDeptName())
+                    .collect(Collectors.toList()));
+            RespDTO<Map<String, List<HospitalDeptDTO>>> retDeptMap
+                    = tranServiceClient.hospitalDeptByConceptNames(hospitalDeptVO);
+            if (RespDTOUtil.respIsOK(retDeptMap)) {
+                Map<String, List<HospitalDeptDTO>> deptMap = retDeptMap.data;
+                for (SYFFeatureDTO record : featureRateList) {
+                    record.setHospitalDepts(deptMap.get(record.getDeptName()));
+                }
+            }
+
+            List<SYFFeatureDTO> syfFeatureDTOList = featureRateList
+                    .stream()
+                    .filter(i -> StringUtil.isNotBlank(i.getConcatDept()))
+                    .limit(2)
+                    .collect(Collectors.toList());
+            Map<String, List<SYFFeatureDTO>> featureMap
+                    = EntityUtil.makeEntityListMap(syfFeatureDTOList, "concatDept");
+            for (Map.Entry<String, List<SYFFeatureDTO>> entry : featureMap.entrySet()) {
+                SYFDiseaseDeptDTO item = new SYFDiseaseDeptDTO();
+                BeanUtil.copyProperties(entry.getValue().get(0), item);
+                item.setDiseaseNames(entry.getValue()
+                        .stream()
+                        .map(i -> i.getDiseaseName())
+                        .distinct()
+                        .collect(Collectors.toList()));
+                item.setDept(entry.getKey());
+                items.add(item);
+            }
+        }
+        //按大科室分组展示
+        Map<String, List<SYFDiseaseDeptDTO>> itemMap = EntityUtil.makeEntityListMap(items, "deptName");
+        List<SYFDeptDTO> syfDeptDTOList = Lists.newLinkedList();
+        itemMap.entrySet().forEach(item -> {
+            SYFDeptDTO syfDeptDTO = new SYFDeptDTO();
+            syfDeptDTO.setDeptName(item.getKey());
+            syfDeptDTO.setDeptCode(item.getValue().get(0).getDeptCode());
+            syfDeptDTO.setDiseaseDept(item.getValue());
+            syfDeptDTOList.add(syfDeptDTO);
+        });
+        syfdto.setDiseaseDept(syfDeptDTOList);
+        return syfdto;
+    }
 }

+ 16 - 0
triage-service/src/main/java/com/diagbot/web/AIController.java

@@ -98,4 +98,20 @@ public class AIController {
     public RespDTO<SYFDTO> pushDisForSYF(@RequestBody @Valid AIVO aivo) {
         return RespDTO.onSuc(aiv2Facade.pushDisForSYFV2(aivo, "7"));
     }
+
+    /**
+     * 症状推理症状接口
+     *
+     * @param aivo ai输入参数
+     * @return 疾病相关数据
+     */
+    @ApiOperation(value = "知识库标准化-症状推理疾病接口-纳里[by:zhaops]",
+            notes = "age: 年龄(必填)<br>" +
+                    "sex:性别,1:男,2:女(必填)<br>" +
+                    "symptom:症状自然文本描述(必填)")
+    @PostMapping("/pushDisForNaliV2")
+    @SysLogger("pushDisForNaliV2")
+    public RespDTO<SYFDTO> pushDisForNaliV2(@RequestBody @Valid AIVO aivo) {
+        return RespDTO.onSuc(aiv2Facade.pushDisForNaliV2(aivo, "7"));
+    }
 }