瀏覽代碼

添加建议输血的查询方法

MarkHuang 4 年之前
父節點
當前提交
a9bfb7c34e

+ 3 - 0
src/main/java/com/diagbot/entity/node/TransfusionRemind.java

@@ -24,6 +24,9 @@ public class TransfusionRemind extends BaseNode  {
 	@Property(name = "最大值")
 	private Double maxval;
 
+	@Property(name = "范围")
+	private Integer range=0;
+
 	@Property(name = "指标标签")
 	private String node_label;
 

+ 45 - 0
src/main/java/com/diagbot/entity/node/TransfusionSuggest.java

@@ -0,0 +1,45 @@
+package com.diagbot.entity.node;
+
+import com.diagbot.entity.node.base.BaseNode;
+import lombok.Getter;
+import lombok.Setter;
+import org.neo4j.ogm.annotation.NodeEntity;
+import org.neo4j.ogm.annotation.Property;
+import org.neo4j.ogm.annotation.Relationship;
+
+import java.util.HashSet;
+import java.util.Set;
+
+@Setter
+@Getter
+@NodeEntity(label = "建议输血提醒")
+public class TransfusionSuggest extends BaseNode  {
+
+	@Property(name = "单位")
+	private String unit;
+
+	@Property(name = "最小值")
+	private Double minval;
+
+	@Property(name = "最大值")
+	private Double maxval;
+
+	@Property(name = "范围")
+	private Integer range=0;
+
+	@Property(name = "指标标签")
+	private String node_label;
+
+	@Property(name = "指标名称")
+	private String index_name;
+
+	@Property(name = "输注类型")
+    private String transfusion_type;
+
+	@Relationship(type="建议输血提醒相关医保疾病名称", direction = Relationship.OUTGOING)
+	private Set<YiBaoDiseaseName> diseases = new HashSet<>();
+
+	@Relationship(type="建议输血提醒相关医保手术和操作名称", direction = Relationship.OUTGOING)
+	private Set<YiBaoOperationName> operations = new HashSet<>();
+
+}

+ 4 - 0
src/main/java/com/diagbot/entity/node/YiBaoDiseaseName.java

@@ -47,4 +47,8 @@ public class YiBaoDiseaseName extends BaseNode  {
 
 	@Relationship(type = "化验提醒指标相关医保疾病名称", direction = Relationship.INCOMING)
 	private Set<LisRemind> lisreminds = new HashSet<>();
+
+	@Relationship(type="建议输血提醒相关医保疾病名称", direction = Relationship.INCOMING)
+	private Set<TransfusionSuggest> tfsuggest = new HashSet<>();
+
 }

+ 2 - 0
src/main/java/com/diagbot/entity/node/YiBaoOperationName.java

@@ -58,4 +58,6 @@ public class YiBaoOperationName extends BaseNode  {
 	@Relationship(type = "医保手术和操作名称禁忌禁忌医疗器械及物品", direction = Relationship.OUTGOING)
 	private Set<ConflictDevice> conflictdevices = new HashSet<>();
 
+	@Relationship(type="建议输血提醒相关医保手术和操作名称", direction = Relationship.INCOMING)
+	private Set<TransfusionSuggest> tfsuggest = new HashSet<>();
 }

+ 15 - 1
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -83,6 +83,8 @@ public class NeoFacade {
     SymptomNameRepository symptomNameRepository;
     @Autowired
     TransfusionRemindRepository transfusionRemindRepository;
+    @Autowired
+    TransfusionSuggestRepository transfusionSuggestRepository;
 
     /**
      * 返回药品缓存信息
@@ -298,7 +300,7 @@ public class NeoFacade {
 
 
     /**
-     * 处理其它提醒
+     * 处理其它化验提醒
      */
     public List<OtherTipNeoDTO> getOtherRemind(List<Lis> lislist) {
 
@@ -404,6 +406,18 @@ public class NeoFacade {
         return nodeNeoDTOS;
     }
 
+
+    /**
+     * 处理建议输血
+     */
+    public List<OtherTipTransfusionNeoDTO> getRecommendTransfs(WordCrfDTO wordCrfDTO) {
+        TransfusionSuggestNode transfusionSuggestNode = new TransfusionSuggestNode();
+        List<OtherTipTransfusionNeoDTO> otherTipTransfsNeoDTOS = transfusionSuggestNode.getTransfusionSuggest(wordCrfDTO, transfusionSuggestRepository);
+
+        return otherTipTransfsNeoDTOS;
+    }
+
+
     /**
      * 处理处方开单合理性
      */

+ 2 - 2
src/main/java/com/diagbot/facade/OtherTipFacade.java

@@ -64,8 +64,8 @@ public class OtherTipFacade {
         // // TODO 测试数据结束
         otherTipProcess.processLis(otherTipNeoDTOList, wordCrfDTO, res);
 
-        // 其他提示——输血
-        List<OtherTipTransfusionNeoDTO> otherTipTransfusionNeoDTOList = new ArrayList<>();
+        // 其他提示——建议输血
+        List<OtherTipTransfusionNeoDTO> otherTipTransfusionNeoDTOList = neoFacade.getRecommendTransfs(wordCrfDTO);
         // TODO 测试数据开始
         // // 化验 + 诊断
         // OtherTipTransfusionNeoDTO otherTipTransfusionNeoDTO = new OtherTipTransfusionNeoDTO();

+ 160 - 0
src/main/java/com/diagbot/repository/TransfusionSuggestNode.java

@@ -0,0 +1,160 @@
+package com.diagbot.repository;
+
+
+import com.diagbot.dto.OtherTipTransfusionNeoDTO;
+import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.entity.node.TransfusionSuggest;
+import com.diagbot.biz.push.entity.Item;
+import com.diagbot.biz.push.entity.Lis;
+import com.diagbot.entity.node.YiBaoDiseaseName;
+import com.diagbot.entity.node.YiBaoOperationName;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class TransfusionSuggestNode {
+
+	public List<OtherTipTransfusionNeoDTO> findSuggest(List<TransfusionSuggest> transfusionSuggests, WordCrfDTO wordCrfDTO) {
+
+		List<OtherTipTransfusionNeoDTO> ottfNeoDTOs = new ArrayList<>();
+
+		OtherTipTransfusionNeoDTO otherTipTfNeoDTO = new OtherTipTransfusionNeoDTO();
+
+		Item item;
+		List<String> diseases = new ArrayList<>();
+		List<String> surgery = new ArrayList<>();
+		Map<String, Lis> lismap = new HashMap<>();
+		String disname, surgname, lisname;
+		Lis lisresult;
+
+		for (Item dg : wordCrfDTO.getDiag()) {
+			diseases.add(dg.getUniqueName());
+		}
+
+		for (Item op : wordCrfDTO.getOperation()) {
+			surgery.add(op.getUniqueName());
+		}
+
+		for (Lis lisitem : wordCrfDTO.getLis()) {
+			lismap.put(lisitem.getUniqueName(), lisitem);
+		}
+
+		for (TransfusionSuggest tf : transfusionSuggests) {
+
+			lisname = "";
+			disname = "";
+			surgname = "";
+			lisresult = null;
+			Double val;
+
+			if (tf.getNode_label().equals(Constants.lisname)) {
+				lisname = tf.getIndex_name();
+				lisresult = lismap.get(lisname);
+				if (lisresult!=null) {
+					val = lisresult.getValue();
+					if (tf.getRange() == 0) {
+						if (null==tf.getMinval() && null==tf.getMaxval()) {
+							lisresult = null;
+						}
+						else if (null==tf.getMinval() && val > tf.getMaxval()) {
+							lisresult = null;
+						}
+						else if(null==tf.getMaxval() && val < tf.getMinval()) {
+							lisresult = null;
+						}
+						else if (null!=tf.getMinval() && null!=tf.getMaxval() &&
+								(val > tf.getMaxval() || val < tf.getMinval())) {
+							lisresult = null;
+						}
+					} else if (tf.getRange() == 1) {
+						if (null==tf.getMinval() && null==tf.getMaxval()) {
+							lisresult = null;
+						}
+						else if (null!=tf.getMaxval() && val < tf.getMaxval()) {
+							lisresult = null;
+						}
+						else if (null!=tf.getMinval() && val > tf.getMinval()){
+							lisresult = null;
+						}
+					}
+				}
+				else {
+					lisname = "";
+					lisresult = null;
+				}
+			}
+
+			if (tf.getDiseases().size()>0) {
+				List<YiBaoDiseaseName> ybdisease = new ArrayList(tf.getDiseases());
+				if (diseases.contains(ybdisease.get(0).getName())) {
+					disname = ybdisease.get(0).getName();
+				}
+			}
+
+			if (tf.getOperations().size()>0) {
+				List<YiBaoOperationName> yboperation = new ArrayList(tf.getOperations());
+				if (surgery.contains(yboperation.get(0).getName())) {
+					surgname = yboperation.get(0).getName();
+				}
+			}
+
+
+			if (StringUtil.isNotBlank(lisname) || StringUtil.isNotBlank(disname) || StringUtil.isNotBlank(surgname)) {
+
+				if (StringUtil.isNotBlank(lisname) && null!=lisresult) {
+					otherTipTfNeoDTO.getLisList().add(lisresult);
+				}
+
+				if (StringUtil.isNotBlank(surgname)) {
+					item = new Item();
+					item.setName(surgname);
+					item.setUniqueName(surgname);
+
+					otherTipTfNeoDTO.getOperation().add(item);
+				}
+
+				if (StringUtil.isNotBlank(disname)) {
+					item = new Item();
+					item.setName(disname);
+					item.setUniqueName(disname);
+
+					otherTipTfNeoDTO.getDiag().add(item);
+				}
+
+				ottfNeoDTOs.add(otherTipTfNeoDTO);
+			}
+		}
+
+
+
+		return ottfNeoDTOs;
+	}
+
+
+	/**
+	 * 获取建议输血提醒列表
+	 */
+	public List<OtherTipTransfusionNeoDTO> getTransfusionSuggest(WordCrfDTO wordCrfDTO, TransfusionSuggestRepository transfusionSugRepository) {
+
+		List<OtherTipTransfusionNeoDTO> tfNeoDTOs = new ArrayList<>();
+		List<OtherTipTransfusionNeoDTO> ottfDTOs;
+
+
+		List<TransfusionSuggest> tslist;
+
+		tslist = transfusionSugRepository.findByNameContaining("");
+
+		if (ListUtil.isNotEmpty(tslist)) {
+			ottfDTOs = findSuggest(tslist, wordCrfDTO);
+
+			tfNeoDTOs.addAll(ottfDTOs);
+		}
+
+		return tfNeoDTOs;
+	}
+}
+

+ 24 - 0
src/main/java/com/diagbot/repository/TransfusionSuggestRepository.java

@@ -0,0 +1,24 @@
+package com.diagbot.repository;
+
+import com.diagbot.entity.node.TransfusionSuggest;
+import org.springframework.data.neo4j.annotation.Query;
+import org.springframework.data.neo4j.repository.Neo4jRepository;
+import org.springframework.data.repository.query.Param;
+
+import java.util.List;
+
+
+public interface TransfusionSuggestRepository extends Neo4jRepository<TransfusionSuggest, Long> {
+
+    List<TransfusionSuggest> findByNameIs(String name);
+
+    List<TransfusionSuggest> findByNameContaining(String name);
+
+    @Query("MATCH (n:建议输血提醒) where n.输注类型 contains {name} return distinct(n.输注类型)")
+    List<String> findTransfusionByName(@Param("name") String name);
+
+    @Query("MATCH (n:建议输血提醒指标) where n.输注类型 contains {name} return n")
+    List<TransfusionSuggest> findByTransfusionName(@Param("name") String name);
+
+}
+