Bläddra i källkod

Merge remote-tracking branch 'origin/dev/icss' into dev/icss

wangyu 6 år sedan
förälder
incheckning
c123ef7ce4

+ 88 - 95
icss-service/src/main/java/com/diagbot/facade/PushFacade.java

@@ -170,37 +170,32 @@ public class PushFacade {
     public PushDTO pushInner(PushVO pushVO, Integer mode) {
         PushDTO pushDTO = new PushDTO();
         SearchData Data = assembleData(pushVO);
-        //        ResponseData data = pushAI(searchData);
         ResponseData data = pushAipt(Data);
 
+        //大数据返回内容
+        List<FeatureRate> dis = data.getDis();
+
         String featureType = pushVO.getFeatureType();
         String[] featureTypes = featureType.split(",|,");
         Set<String> featureTypeSet = new HashSet(Arrays.asList(featureTypes));
 
-        List<FeatureRate> symptom = data.getSymptom();
-        List<FeatureRate> dis = data.getDis();
-        List<FeatureRate> pacs = data.getPacs();
-        List<FeatureRate> labs = data.getLabs();
-        List<FeatureRate> other = data.getHistory();
-        Map<String, JSONObject> treat = data.getTreat();
-
-        Map<String, Object> symptomMap = list2Map(symptom);
-        Map<String, Object> labMap = list2Map(labs);
-        Map<String, Object> pacsMap = list2Map(pacs);
-        Map<String, Object> otherMap = list2Map(other);
-
         //症状 标签列表
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Symptom.getKey()))) {
-            //文本模式不推症状,仅结构化模式推症状
-            //if (mode.equals(InputModeEnum.Structured.getKey())) {
-            List<QuestionDTO> symptomDTO = getTagListByMap(symptomMap, pushVO, QuestionTypeEnum.Symptom.getKey());
-            pushDTO.setSymptom(symptomDTO);
-            //}
+            List<FeatureRate> symptom = data.getSymptom();
+            if (ListUtil.isNotEmpty(symptom)) {
+                List<String> nameList = symptom.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<QuestionDTO> symptomDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Symptom.getKey());
+                pushDTO.setSymptom(symptomDTO);
+            }
         }
         //其他史 标签列表
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Other.getKey()))) {
-            List<QuestionDTO> otherDTO = getTagListByMap(otherMap, pushVO, QuestionTypeEnum.Other.getKey());
-            pushDTO.setOther(otherDTO);
+            List<FeatureRate> other = data.getHistory();
+            if (ListUtil.isNotEmpty(other)) {
+                List<String> nameList = other.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<QuestionDTO> otherDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Other.getKey());
+                pushDTO.setOther(otherDTO);
+            }
         }
         //查体 返回模板(标签列表)
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Vital.getKey()))) {
@@ -215,73 +210,87 @@ public class PushFacade {
         }
         //化验  标签列表
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Lis.getKey()))) {
-            //公表项转套餐项
-            Map<String, List<String>> lisMapping = lisMappingFacade.getLisMappingByUniqueName();
-            Map<String, Object> mealLabMap = new LinkedHashMap<>();
-            for (Map.Entry<String, Object> entry : labMap.entrySet()) {
-                if (ListUtil.isNotEmpty(lisMapping.get(entry.getKey()))) {
-                    //匹配出多个套餐项默认取第一个
-                    mealLabMap.put(lisMapping.get(entry.getKey()).get(0), null);
+            List<FeatureRate> labs = data.getLabs();
+            if (ListUtil.isNotEmpty(labs)) {
+                //公表项转套餐项
+                Map<String, List<String>> lisMapping = lisMappingFacade.getLisMappingByUniqueName();
+                List<String> nameList = Lists.newLinkedList();
+                for (FeatureRate featureRate : labs) {
+                    if (ListUtil.isNotEmpty(lisMapping.get(featureRate.getFeatureName()))) {
+                        //匹配出多个套餐项默认取第一个
+                        String name = lisMapping.get(featureRate.getFeatureName()).get(0);
+                        if (nameList.contains(name)) {
+                            continue;
+                        }
+                        nameList.add(name);
+                    }
                 }
+                List<QuestionDTO> labDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Lis.getKey());
+                pushDTO.setLab(labDTO);
             }
-            List<QuestionDTO> labDTO = getTagListByMap(mealLabMap, pushVO, QuestionTypeEnum.Lis.getKey());
-            pushDTO.setLab(labDTO);
         }
 
         //辅检  标签列表
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Pacs.getKey()))) {
-            List<QuestionDTO> pacsDTO = getTagListByMap(pacsMap, pushVO, QuestionTypeEnum.Pacs.getKey());
-            pushDTO.setPacs(pacsDTO);
+            List<FeatureRate> pacs = data.getPacs();
+            if (ListUtil.isNotEmpty(pacs)) {
+                List<String> nameList = pacs.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                List<QuestionDTO> pacsDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Pacs.getKey());
+                pushDTO.setPacs(pacsDTO);
+            }
         }
         //诊断 返回分类+标签列表
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Disease.getKey()))) {
-            Map<String, List<QuestionDTO>> disMapDTO = new LinkedHashMap<>();
-            Map<String, List<FeatureRate>> disFeatureMap = new LinkedHashMap<>();
-            //警惕
-            List<String> diseaseNameList = dis.stream().map(disease -> disease.getFeatureName()).collect(Collectors.toList());
-            Map<String, String> highRiskMap = new HashMap<>();
-            highRiskMap.put("disease", String.join(",", diseaseNameList));
-            SearchData searchData = new SearchData();
-            searchData.setDiag(String.join(",", diseaseNameList));
-            Response<GdbResponse> graphRes = bigDataServiceClient.highRiskPageData(searchData);
-            if (graphRes != null) {
-                Map<String, String> graphResult = graphRes.getData().getResult();
-                if (graphResult.size() > 0) {
-                    Map<String, Object> disMap = new LinkedHashMap<>();
-                    for (Map.Entry<String, String> entry : graphResult.entrySet()) {
-                        if (entry.getValue().equals("1")) {
-                            disMap.put(entry.getKey(), "");
+            if (ListUtil.isNotEmpty(dis)) {
+                List<String> nameList = dis.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                Map<String, List<QuestionDTO>> disMapDTO = new LinkedHashMap<>();
+                Map<String, List<FeatureRate>> disFeatureMap = new LinkedHashMap<>();
+                //警惕
+                Map<String, String> highRiskMap = new HashMap<>();
+                highRiskMap.put("disease", String.join(",", nameList));
+                SearchData searchData = new SearchData();
+                searchData.setDiag(String.join(",", nameList));
+                Response<GdbResponse> graphRes = bigDataServiceClient.highRiskPageData(searchData);
+                if (graphRes != null) {
+                    Map<String, String> graphResult = graphRes.getData().getResult();
+                    if (graphResult.size() > 0) {
+                        List<String> hrNameList = Lists.newLinkedList();
+                        for (Map.Entry<String, String> entry : graphResult.entrySet()) {
+                            if (entry.getValue().equals("1")) {
+                                hrNameList.add(entry.getKey());
+                            }
                         }
+                        List<QuestionDTO> disDTO = getTagList(hrNameList, pushVO, QuestionTypeEnum.Disease.getKey());
+                        disMapDTO.put("警惕", disDTO);
                     }
-                    List<QuestionDTO> disDTO = getTagListByMap(disMap, pushVO, QuestionTypeEnum.Disease.getKey());
-                    disMapDTO.put("警惕", disDTO);
                 }
-            }
 
-            //诊断分类
-            for (FeatureRate featureRate : dis) {
-                if (StringUtil.isBlank(featureRate.getDesc())) {
-                    featureRate.setDesc("{\"可能诊断\":\"\"}");
-                }
-                Map<String, Object> descMap = FastJsonUtils.getJsonToMap(featureRate.getDesc());
-                for (String disClass : descMap.keySet()) {
-                    List<FeatureRate> featureRateList = Lists.newLinkedList();
-                    if (disFeatureMap.get(disClass) != null) {
-                        featureRateList = disFeatureMap.get(disClass);
+                //诊断分类
+                for (FeatureRate featureRate : dis) {
+                    if (StringUtil.isBlank(featureRate.getDesc())) {
+                        featureRate.setDesc("{\"可能诊断\":\"\"}");
+                    }
+                    Map<String, Object> descMap = FastJsonUtils.getJsonToMap(featureRate.getDesc());
+                    for (String disClass : descMap.keySet()) {
+                        List<FeatureRate> featureRateList = Lists.newLinkedList();
+                        if (disFeatureMap.get(disClass) != null) {
+                            featureRateList = disFeatureMap.get(disClass);
+                        }
+                        featureRateList.add(featureRate);
+                        disFeatureMap.put(disClass, featureRateList);
                     }
-                    featureRateList.add(featureRate);
-                    disFeatureMap.put(disClass, featureRateList);
                 }
+                for (Map.Entry<String, List<FeatureRate>> entry : disFeatureMap.entrySet()) {
+                    List<String> nameListByDisClass = entry.getValue().stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
+                    List<QuestionDTO> disDTO = getTagList(nameListByDisClass, pushVO, QuestionTypeEnum.Disease.getKey());
+                    disMapDTO.put(entry.getKey(), disDTO);
+                }
+                pushDTO.setDis(disMapDTO);
             }
-            for (Map.Entry<String, List<FeatureRate>> entry : disFeatureMap.entrySet()) {
-                Map<String, Object> disMap = list2Map(entry.getValue());
-                List<QuestionDTO> disDTO = getTagListByMap(disMap, pushVO, QuestionTypeEnum.Disease.getKey());
-                disMapDTO.put(entry.getKey(), disDTO);
-            }
-            pushDTO.setDis(disMapDTO);
         }
         //治疗方案
         if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Drug.getKey()))) {
+            Map<String, JSONObject> treat = data.getTreat();
             if (pushVO.getDiseaseId() == null) {
                 throw new CommonException(CommonErrorCode.PARAM_ERROR, "请输入诊断id");
             }
@@ -295,36 +304,35 @@ public class PushFacade {
     /**
      * 获取返回结果标签
      *
-     * @param map
+     * @param nameList
      * @param pushVO
      * @param type
      * @return
      */
-    public List<QuestionDTO> getTagListByMap(Map<String, Object> map, PushVO pushVO, Integer type) {
+    public List<QuestionDTO> getTagList(List<String> nameList, PushVO pushVO, Integer type) {
         List<QuestionDTO> questionDTOList = Lists.newLinkedList();
         QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper();
         questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
-                in("tag_name", map.keySet()).
+                in("tag_name", nameList).
                 eq("type", type);
         List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
         Map<String, QuestionInfo> questionMap = EntityUtil.makeEntityMap(questionInfoList, "tagName");
-        for (Map.Entry<String, Object> entry : map.entrySet()) {
+        for (String name : nameList) {
             QuestionDTO questionDTO = new QuestionDTO();
-            if (questionMap.get(entry.getKey()) != null) {
+            if (questionMap.get(name) != null) {
                 QuestionVO questionVO = new QuestionVO();
                 questionVO.setAge(pushVO.getAge());
                 questionVO.setSexType(pushVO.getSex());
-                questionVO.setId(questionMap.get(entry.getKey()).getId());
+                questionVO.setId(questionMap.get(name).getId());
                 questionDTO = questionFacade.getById(questionVO);
-                if (questionDTO == null || (!questionDTO.getSubType().equals(0))) {
+                if (questionDTO == null || questionDTO.getId() == null) {
                     questionDTO = new QuestionDTO();
-                    questionDTO.setTagName(entry.getKey());
-                    questionDTO.setName(entry.getKey());
+                    questionDTO.setTagName(name);
+                    questionDTO.setName(name);
                 }
-
             } else {
-                questionDTO.setTagName(entry.getKey());
-                questionDTO.setName(entry.getKey());
+                questionDTO.setTagName(name);
+                questionDTO.setName(name);
             }
             questionDTOList.add(questionDTO);
         }
@@ -368,21 +376,6 @@ public class PushFacade {
         return pushKYJDTO;
     }
 
-    /**
-     * 将list 转换成 map
-     *
-     * @param list
-     * @return
-     */
-    public Map<String, Object> list2Map(List<FeatureRate> list) {
-        Map<String, Object> map = new LinkedHashMap<>();
-        for (FeatureRate featureRate : list) {
-            map.put(featureRate.getFeatureName(), null);
-        }
-        return map;
-    }
-
-
     /**
      * 快易检结果预处理
      *

+ 12 - 1
icssman-service/src/main/java/com/diagbot/facade/DeptVitalFacade.java

@@ -59,6 +59,10 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
      * @return
      */
     public Boolean saveDeptVitals(DeptVitalVO deptVitalVO) {
+        DeptInfo deptInfo = deptInfoFacade.getById(deptVitalVO.getDeptId());
+        if (deptInfo == null) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS, "科室不存在");
+        }
         //先删除该科室原有模板
         UpdateWrapper<DeptVital> deptVitalUpdateWrapper = new UpdateWrapper<>();
         deptVitalUpdateWrapper.eq("dept_id", deptVitalVO.getDeptId()).
@@ -91,6 +95,7 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
             DeptVital deptVital = new DeptVital();
             deptVital.setDeptId(deptVitalVO.getDeptId());
             deptVital.setVitalId(dvDetailVO.getVitalId());
+            deptVital.setRemark(dvDetailVO.getRemark());
             deptVital.setOrderNo(dvDetailVO.getOrderNo());
             deptVital.setCreator(userId);
             deptVital.setGmtCreate(now);
@@ -166,7 +171,13 @@ public class DeptVitalFacade extends DeptVitalServiceImpl {
                 .collect(Collectors.toList());
         if (vitalIds.size() > 0) {
             List<QuestionInfo> vitalList = Lists.newArrayList(questionFacade.listByIds(vitalIds));
-            List<QuestionShortDTO> vitals = BeanUtil.listCopyTo(vitalList, QuestionShortDTO.class);
+            Map<Long, QuestionInfo> vitalMap = EntityUtil.makeEntityMap(vitalList, "id");
+            List<QuestionShortDTO> vitals = Lists.newArrayList();
+            for (Long vitalId : vitalIds) {
+                QuestionShortDTO vital = new QuestionShortDTO();
+                BeanUtil.copyProperties(vitalMap.get(vitalId), vital);
+                vitals.add(vital);
+            }
             deptVitalDTO.setVitals(vitals);
         }
 

+ 6 - 1
icssman-service/src/main/java/com/diagbot/vo/DVDetailVO.java

@@ -3,14 +3,19 @@ package com.diagbot.vo;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotNull;
+
 /**
- * @Description:
+ * @Description:查体模板明细
  * @Author:zhaops
  * @time: 2019/1/3 16:45
  */
 @Getter
 @Setter
 public class DVDetailVO {
+    @NotNull(message = "请输入查体标签id")
     private Long vitalId;
+    @NotNull(message = "请输入查体标签排序")
     private Integer orderNo;
+    private String remark;
 }

+ 6 - 2
icssman-service/src/main/java/com/diagbot/web/DeptVitalController.java

@@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
+import javax.validation.Valid;
 import java.util.List;
 
 /**
@@ -41,11 +42,14 @@ public class DeptVitalController {
 
     @ApiOperation(value = "保存查体模板[by:zhaops]",
             notes = "deptId:科室ID,必填<br>" +
-                    "vitalIds:查体标签ids,必填<br>")
+                    "dvDetailVOList:查体标签明细,必填<br>" +
+                    "vitalId:查体标签id,必填<br>" +
+                    "orderNo:查体标签排序,必填<br>" +
+                    "remark:查体标签备注(格式:deptName-tagName),必填<br>")
     @PostMapping("/saveDeptVitals")
     @SysLogger("saveDeptVitals")
     @Transactional
-    public RespDTO<Boolean> saveDeptVitals(@RequestBody DeptVitalVO deptVitalVO) {
+    public RespDTO<Boolean> saveDeptVitals(@RequestBody @Valid DeptVitalVO deptVitalVO) {
         Boolean data = deptVitalFacade.saveDeptVitals(deptVitalVO);
         return RespDTO.onSuc(data);
     }

+ 1 - 1
icssman-service/src/main/resources/mapper/DeptVitalMapper.xml

@@ -40,7 +40,7 @@
           <if test="deptVitalPageVO.deptName!=null and deptVitalPageVO.deptName!=''">
               AND a.name like CONCAT("%",#{deptVitalPageVO.deptName},"%")
           </if>
-        order by gmt_modified desc
+        order by b.gmt_modified desc
     </select>
 
 </mapper>