|
@@ -1,48 +1,29 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.diagbot.client.AiptServiceClient;
|
|
|
-import com.diagbot.client.bean.ConceptBaseVO;
|
|
|
-import com.diagbot.client.bean.ConceptExistVO;
|
|
|
import com.diagbot.client.bean.ResponseData;
|
|
|
import com.diagbot.client.bean.SearchData;
|
|
|
-import com.diagbot.dto.ConceptBaseDTO;
|
|
|
-import com.diagbot.dto.ConceptPushDTO;
|
|
|
import com.diagbot.dto.PushDTO;
|
|
|
import com.diagbot.dto.PushKYJDTO;
|
|
|
-import com.diagbot.dto.QuestionDTO;
|
|
|
-import com.diagbot.dto.QuestionPushDTO;
|
|
|
import com.diagbot.dto.RespDTO;
|
|
|
-import com.diagbot.entity.DeptVital;
|
|
|
-import com.diagbot.entity.QuestionInfo;
|
|
|
-import com.diagbot.enums.ConceptTypeEnum;
|
|
|
import com.diagbot.enums.FeatureTypeEnum;
|
|
|
-import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.enums.LisSourceEnum;
|
|
|
-import com.diagbot.enums.QuestionTypeEnum;
|
|
|
-import com.diagbot.enums.TagTypeEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
-import com.diagbot.util.BeanUtil;
|
|
|
-import com.diagbot.util.EntityUtil;
|
|
|
-import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.RespDTOUtil;
|
|
|
import com.diagbot.vo.LisResult;
|
|
|
import com.diagbot.vo.PushKYJVO;
|
|
|
import com.diagbot.vo.PushVO;
|
|
|
-import com.diagbot.vo.QuestionIds2VO;
|
|
|
-import com.diagbot.vo.QuestionVO;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
+import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -52,9 +33,7 @@ import java.util.stream.Collectors;
|
|
|
@Component
|
|
|
public class PushFacade {
|
|
|
@Autowired
|
|
|
- private QuestionFacade questionFacade;
|
|
|
- @Autowired
|
|
|
- private DeptVitalFacade deptVitalFacade;
|
|
|
+ private DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade;
|
|
|
@Autowired
|
|
|
private TreatmentFacade treatmentFacade;
|
|
|
@Autowired
|
|
@@ -117,112 +96,26 @@ public class PushFacade {
|
|
|
//推理结果返回科室
|
|
|
pushDTO.setDept(data.getDept());
|
|
|
|
|
|
- //症状 概念+标签id
|
|
|
- if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Symptom.getKey()))) {
|
|
|
- List<ConceptPushDTO> symptom = data.getSymptom();
|
|
|
- if (ListUtil.isNotEmpty(symptom)) {
|
|
|
- List<ConceptPushDTO> symptomDTO = addQuestionId(symptom, QuestionTypeEnum.Symptom.getKey());
|
|
|
- pushDTO.setSymptom(symptomDTO);
|
|
|
+ try {
|
|
|
+ Map<String, Object> invokeParams = new HashMap<>();
|
|
|
+ invokeParams.put("pushVO", pushVO);
|
|
|
+ invokeParams.put("pushDTO", pushDTO);
|
|
|
+ invokeParams.put("featureTypeSet", featureTypeSet);
|
|
|
+ invokeParams.put("data", data);
|
|
|
+ pushDTO
|
|
|
+ = dataBeanAggregateQueryFacade.get("setICSSAll", invokeParams, PushDTO.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
|
|
|
+ } finally {
|
|
|
+ if (pushDTO == null) {
|
|
|
+ pushDTO = new PushDTO();
|
|
|
+ pushDTO.setDept(data.getDept());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//其他史 概念+标签id
|
|
|
if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Other.getKey()))) {
|
|
|
}
|
|
|
- //查体标记项
|
|
|
- if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.VitalResult.getKey())) ||
|
|
|
- featureTypeSet.contains(String.valueOf(FeatureTypeEnum.VitalIndex.getKey()))) {
|
|
|
- List<ConceptPushDTO> vitals = data.getVital();
|
|
|
- if (ListUtil.isNotEmpty(vitals)) {
|
|
|
- List<ConceptPushDTO> vitalDTOList = addQuestionId(vitals, QuestionTypeEnum.Vital.getKey());
|
|
|
- pushDTO.setVital(vitalDTOList);
|
|
|
- if (ListUtil.isNotEmpty(vitalDTOList)) {
|
|
|
- List<Long> vitalIds = vitalDTOList
|
|
|
- .stream()
|
|
|
- .map(vital -> vital.getId())
|
|
|
- .filter(vitalId -> vitalId != null)
|
|
|
- .collect(Collectors.toList());
|
|
|
- pushDTO.setVitalIds(vitalIds);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //查体模板
|
|
|
- if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.VitalModule.getKey()))) {
|
|
|
- ConceptPushDTO dept = data.getDept();
|
|
|
- List<QuestionPushDTO> moduleVitalDTO = getVitalModule(dept, pushVO);
|
|
|
- pushDTO.setModuleVital(moduleVitalDTO);
|
|
|
- }
|
|
|
- //化验 标签列表
|
|
|
- if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Lis.getKey()))) {
|
|
|
- List<QuestionPushDTO> labs = data.getLab();
|
|
|
- if (ListUtil.isNotEmpty(labs)) {
|
|
|
- List<QuestionPushDTO> lisDTO = Lists.newLinkedList();
|
|
|
- Map<String, Long> lisMap = new LinkedHashMap<>();
|
|
|
- List<String> mealNameList = labs
|
|
|
- .stream()
|
|
|
- .map(lab -> lab.getName())
|
|
|
- .collect(Collectors.toList());
|
|
|
- Map<String, QuestionDTO> questionDTOMap
|
|
|
- = addLisQuestion(mealNameList, pushVO.getAge(), pushVO.getSex());
|
|
|
- for (String name : mealNameList) {
|
|
|
- QuestionPushDTO questionPushDTO = new QuestionPushDTO();
|
|
|
- QuestionDTO questionDTO = questionDTOMap.get(name);
|
|
|
- if (questionDTO != null) {
|
|
|
- BeanUtil.copyProperties(questionDTO, questionPushDTO);
|
|
|
- } else {
|
|
|
- questionPushDTO.setName(name);
|
|
|
- questionPushDTO.setType(ConceptTypeEnum.Lis.getKey());
|
|
|
- }
|
|
|
- questionPushDTO.setLibType(12);
|
|
|
- if (lisMap.containsKey(name) && lisMap.get(name) != null) {
|
|
|
- questionPushDTO.setConceptId(lisMap.get(name));
|
|
|
- }
|
|
|
- lisDTO.add(questionPushDTO);
|
|
|
- }
|
|
|
-
|
|
|
- /* List<String> uniqueNameList = labs.stream().map(lab -> lab.getName()).collect(Collectors.toList());
|
|
|
- //公表项转套餐项
|
|
|
- Map<String, List<String>> lisMapping = lisMappingFacade.getLisMappingByUniqueName(uniqueNameList);
|
|
|
- List<String> nameList = Lists.newLinkedList();
|
|
|
- Map<String, Long> lisMap = new LinkedHashMap<>();
|
|
|
- List<QuestionPushDTO> lisDTO = Lists.newLinkedList();
|
|
|
- for (QuestionPushDTO lab : labs) {
|
|
|
- if (ListUtil.isNotEmpty(lisMapping.get(lab.getName()))) {
|
|
|
- //匹配出多个套餐项默认取第一个
|
|
|
- String name = lisMapping.get(lab.getName()).get(0);
|
|
|
- if (nameList.contains(name)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- nameList.add(name);
|
|
|
- }
|
|
|
- }
|
|
|
- if (ListUtil.isNotEmpty(nameList)) {
|
|
|
- ConceptExistVO conceptExistVO = new ConceptExistVO();
|
|
|
- conceptExistVO.setNameList(nameList);
|
|
|
- conceptExistVO.setType(ConceptTypeEnum.Lis.getKey());
|
|
|
- RespDTO<Map<String, Long>> respDTO = aiptServiceClient.getConceptMapByNameAndType(conceptExistVO);
|
|
|
- if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
- lisMap = respDTO.data;
|
|
|
- }
|
|
|
- }
|
|
|
- Map<String, QuestionDTO> questionDTOMap = addLisQuestion(nameList, pushVO.getAge(), pushVO.getSex());
|
|
|
- for (String name : nameList) {
|
|
|
- QuestionPushDTO questionPushDTO = new QuestionPushDTO();
|
|
|
- QuestionDTO questionDTO = questionDTOMap.get(name);
|
|
|
- if (questionDTO != null) {
|
|
|
- BeanUtil.copyProperties(questionDTO, questionPushDTO);
|
|
|
- } else {
|
|
|
- questionPushDTO.setName(name);
|
|
|
- questionPushDTO.setType(ConceptTypeEnum.Lis.getKey());
|
|
|
- }
|
|
|
- questionPushDTO.setLibType(12);
|
|
|
- if (lisMap.containsKey(name) && lisMap.get(name) != null) {
|
|
|
- questionPushDTO.setConceptId(lisMap.get(name));
|
|
|
- }
|
|
|
- lisDTO.add(questionPushDTO);
|
|
|
- }*/
|
|
|
- pushDTO.setLab(lisDTO);
|
|
|
- }
|
|
|
- }
|
|
|
//辅检 标签列表
|
|
|
if (featureTypeSet.contains(String.valueOf(FeatureTypeEnum.Pacs.getKey()))) {
|
|
|
pushDTO.setPacs(data.getPacs());
|
|
@@ -277,148 +170,4 @@ public class PushFacade {
|
|
|
pushKYJDTO.setDis(responseData.getDis());
|
|
|
return pushKYJDTO;
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取查体模板
|
|
|
- *
|
|
|
- * @param dept
|
|
|
- * @param pushVO
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<QuestionPushDTO> getVitalModule(ConceptPushDTO dept, PushVO pushVO) {
|
|
|
- List<QuestionPushDTO> vitalDTO = Lists.newLinkedList();
|
|
|
- if (dept.getConceptId() == null) {
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS, "全科信息未维护");
|
|
|
- }
|
|
|
- QueryWrapper<DeptVital> deptVitalQueryWrapper = new QueryWrapper<>();
|
|
|
- deptVitalQueryWrapper
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("dept_id", dept.getConceptId())
|
|
|
- .orderByAsc("order_no");
|
|
|
- List<DeptVital> deptVitalList = deptVitalFacade.list(deptVitalQueryWrapper);
|
|
|
- //科室模板为空时,取全科模板
|
|
|
- if (deptVitalList.size() == 0 && dept.getName().equals("全科") == false) {
|
|
|
- ConceptBaseVO conceptBaseVO = new ConceptBaseVO();
|
|
|
- conceptBaseVO.setName("全科");
|
|
|
- conceptBaseVO.setLibType(ConceptTypeEnum.DEPARTMENT.getKey());
|
|
|
- RespDTO<ConceptBaseDTO> res = aiptServiceClient.existConcept(conceptBaseVO);
|
|
|
- RespDTOUtil.respNGDeal(res, "全科信息未维护");
|
|
|
- BeanUtil.copyProperties(res.data, dept);
|
|
|
- deptVitalQueryWrapper = new QueryWrapper<>();
|
|
|
- deptVitalQueryWrapper
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("dept_id", dept.getConceptId())
|
|
|
- .orderByAsc("order_no");
|
|
|
- deptVitalList = deptVitalFacade.list(deptVitalQueryWrapper);
|
|
|
- }
|
|
|
- //标签列表
|
|
|
- for (DeptVital deptVital : deptVitalList) {
|
|
|
- QuestionVO questionVO = new QuestionVO();
|
|
|
- QuestionPushDTO questionPushDTO = new QuestionPushDTO();
|
|
|
- questionVO.setAge(pushVO.getAge());
|
|
|
- questionVO.setSexType(pushVO.getSex());
|
|
|
- questionVO.setId(deptVital.getVitalId());
|
|
|
- QuestionDTO questionDTO = questionFacade.getById(questionVO);
|
|
|
- if (questionDTO != null && questionDTO.getId() != null) {
|
|
|
- BeanUtil.copyProperties(questionDTO, questionPushDTO);
|
|
|
- questionPushDTO.setLibType(ConceptTypeEnum.Vital.getKey());
|
|
|
- vitalDTO.add(questionPushDTO);
|
|
|
- }
|
|
|
- }
|
|
|
- //增加概念id
|
|
|
- if (ListUtil.isNotEmpty(vitalDTO)) {
|
|
|
- ConceptExistVO conceptExistVO = new ConceptExistVO();
|
|
|
- conceptExistVO.setType(ConceptTypeEnum.Vital.getKey());
|
|
|
- List<String> vitalNames = vitalDTO
|
|
|
- .stream()
|
|
|
- .map(vital -> vital.getTagName())
|
|
|
- .collect(Collectors.toList());
|
|
|
- conceptExistVO.setNameList(vitalNames);
|
|
|
- RespDTO<Map<String, Long>> respDTO = aiptServiceClient.getConceptMapByNameAndType(conceptExistVO);
|
|
|
- if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
- Map<String, Long> vitalMap = respDTO.data;
|
|
|
- for (QuestionPushDTO questionPushDTO : vitalDTO) {
|
|
|
- if (vitalMap.get(questionPushDTO.getTagName()) != null) {
|
|
|
- questionPushDTO.setConceptId(vitalMap.get(questionPushDTO.getTagName()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return vitalDTO;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 概念关联标签,添加标签id ——症状
|
|
|
- *
|
|
|
- * @param concepts
|
|
|
- * @param type
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<ConceptPushDTO> addQuestionId(List<ConceptPushDTO> concepts, Integer type) {
|
|
|
- QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- List<String> nameList = concepts.stream()
|
|
|
- .map(concept -> concept.getName())
|
|
|
- .collect(Collectors.toList());
|
|
|
- questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("type", type)
|
|
|
- .ne("tag_type", TagTypeEnum.T8.getKey());
|
|
|
- //化验填写单匹配name
|
|
|
- if (ListUtil.isNotEmpty(nameList)) {
|
|
|
- if (type.equals(ConceptTypeEnum.Lis.getKey())) {
|
|
|
- questionInfoQueryWrapper.in("name", nameList);
|
|
|
- } else {
|
|
|
- questionInfoQueryWrapper.in("tag_name", nameList);
|
|
|
- }
|
|
|
- }
|
|
|
- List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
|
|
|
- if (ListUtil.isNotEmpty(questionInfoList)) {
|
|
|
- Map<String, QuestionInfo> questionInfoMap
|
|
|
- = EntityUtil.makeEntityMap(questionInfoList, "tagName");
|
|
|
- for (ConceptPushDTO concept : concepts) {
|
|
|
- if (questionInfoMap.containsKey(concept.getName())) {
|
|
|
- concept.setId(questionInfoMap.get(concept.getName()).getId());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return concepts;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取化验填写单
|
|
|
- *
|
|
|
- * @param nameList
|
|
|
- * @param age
|
|
|
- * @param sex
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String, QuestionDTO> addLisQuestion(List<String> nameList, Integer age, Integer sex) {
|
|
|
- Map<String, QuestionDTO> mapDTO = new LinkedHashMap<>();
|
|
|
- if (ListUtil.isEmpty(nameList)) {
|
|
|
- return mapDTO;
|
|
|
- }
|
|
|
- QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
- questionInfoQueryWrapper
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("name", nameList)
|
|
|
- .eq("tag_type", TagTypeEnum.T7.getKey());
|
|
|
- List<QuestionInfo> lisList = questionFacade.list(questionInfoQueryWrapper);
|
|
|
- if (ListUtil.isNotEmpty(lisList)) {
|
|
|
- List<Long> lisIds = lisList
|
|
|
- .stream()
|
|
|
- .map(lis -> lis.getId())
|
|
|
- .collect(Collectors.toList());
|
|
|
- QuestionIds2VO questionIds2VO = new QuestionIds2VO();
|
|
|
- questionIds2VO.setAge(age);
|
|
|
- questionIds2VO.setSexType(sex);
|
|
|
- questionIds2VO.setIds(lisIds);
|
|
|
- Map<Long, Object> questionDTOMap = questionFacade.getByIds(questionIds2VO);
|
|
|
- for (Map.Entry<Long, Object> entry : questionDTOMap.entrySet()) {
|
|
|
- QuestionDTO questionDTO = new QuestionDTO();
|
|
|
- BeanUtil.copyProperties(entry.getValue(), questionDTO);
|
|
|
- mapDTO.put(questionDTO.getName(), questionDTO);
|
|
|
- }
|
|
|
- }
|
|
|
- return mapDTO;
|
|
|
- }
|
|
|
}
|