Browse Source

开单合理性维护

zhaops 4 năm trước cách đây
mục cha
commit
515499507d

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

@@ -13,6 +13,7 @@ import org.springframework.data.neo4j.annotation.QueryResult;
 @Getter
 @QueryResult
 public class Indication {
+    private String ruleName;
     private Long conceptId;
     private Long relationId;
     private Long conditionId;
@@ -21,4 +22,5 @@ public class Indication {
     private String conditionName;
     private String conceptLabel;
     private String conditionLabel;
+    private Integer  relationStatus;
 }

+ 20 - 0
src/main/java/com/diagbot/entity/node/IndicationCondition.java

@@ -0,0 +1,20 @@
+package com.diagbot.entity.node;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.data.neo4j.annotation.QueryResult;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/11/18 16:09
+ */
+@Getter
+@Setter
+@QueryResult
+public class IndicationCondition {
+    private Long id;
+    private String name;
+    private Long status;
+    private String conditionLabel;
+}

+ 46 - 1
src/main/java/com/diagbot/facade/IndicationManFacade.java

@@ -1,14 +1,21 @@
 package com.diagbot.facade;
 
 import com.diagbot.entity.node.Indication;
+import com.diagbot.entity.node.IndicationCondition;
 import com.diagbot.repository.IndicationRepository;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.ConditionIndexVO;
 import com.diagbot.vo.IndicationPageVO;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @Description:
  * @Author:zhaops
@@ -27,7 +34,45 @@ public class IndicationManFacade {
      */
     public Page<Indication> getPage(IndicationPageVO indicationPageVO) {
         Pageable pageable = PageRequest.of(indicationPageVO.getNumber(), indicationPageVO.getSize());
-        Page<Indication> page = indicationRepository.getPage(indicationPageVO.getLabels(), indicationPageVO.getConceptName(), indicationPageVO.getConditionName(), pageable);
+        Page<Indication> page = indicationRepository.getPage(indicationPageVO.getLabels(),
+                indicationPageVO.getConceptName(),
+                indicationPageVO.getConditionName(),
+                indicationPageVO.getRelationStatus(),
+                pageable);
         return page;
     }
+
+    /**
+     * 条件明细检索
+     *
+     * @param conditionIndexVO
+     * @return
+     */
+    public List<IndicationCondition> conditionIndex(ConditionIndexVO conditionIndexVO) {
+        List<String> relationTypes = indicationRepository.getRelationTypes(conditionIndexVO.getConceptLabel());
+        List<String> conditionLabels = Lists.newArrayList();
+        //条件明细筛选范围
+        if (ListUtil.isNotEmpty(relationTypes)) {
+            for (String relationType : relationTypes) {
+                String[] splitArr = relationType.split("禁忌");
+                if (splitArr != null && splitArr.length > 1) {
+                    conditionLabels.add(splitArr[splitArr.length - 1]);
+                }
+            }
+        }
+        //排除项
+        List<IndicationCondition> notInConditions
+                = indicationRepository.getNotInConditions(conditionIndexVO.getConceptName(), conditionIndexVO.getConceptLabel());
+        List<Long> notInIds = Lists.newArrayList();
+        if (ListUtil.isNotEmpty(notInConditions) && conditionIndexVO.getRuleType().equals("文本类型")) {
+            notInIds = notInConditions.stream().map(i -> i.getId()).distinct().collect(Collectors.toList());
+        }
+        List<IndicationCondition> conditions = indicationRepository.conditionIndex(conditionLabels,
+                notInIds,
+                conditionIndexVO.getConditionName(),
+                conditionIndexVO.getConditionName(),
+                100);
+
+        return conditions;
+    }
 }

+ 55 - 5
src/main/java/com/diagbot/repository/IndicationRepository.java

@@ -1,6 +1,7 @@
 package com.diagbot.repository;
 
 import com.diagbot.entity.node.Indication;
+import com.diagbot.entity.node.IndicationCondition;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.neo4j.annotation.Query;
@@ -18,20 +19,69 @@ public interface IndicationRepository extends Neo4jRepository<Indication,Long> {
 
     @Query(value = "match(m)-[r]->(n) \n" +
             "where 1 = 1 \n" +
-            "and (case {labels} is not null and length({labels})>0 when true then labels(m)[0] in {labels} else 1 = 1 end ) \n" +
+            "and (case {labels} is not null and size({labels})>0 when true then labels(m)[0] in {labels} else 1 = 1 end ) \n" +
             "and (case {conceptName} is not null and {conceptName} <> '' when true then m.name contains {conceptName} else 1 = 1 end ) \n" +
             "and (case {conditionName} is not null and {conditionName} <> '' when true then n.name contains {conditionName} else 1 = 1 end ) \n" +
+            "and (case {relationStatus} is not null and {relationStatus} <> '' when true then r.状态 = {relationStatus} else 1 = 1 end ) \n" +
             "and type(r) contains('禁忌') \n" +
-            "return id(m) as conceptId,m.name as conceptName,labels(m)[0] as conceptType,\n" +
-            "id(r) as relationId,type(r) as relationName,\n" +
+            "and m.状态=1 \n" +
+            "and n.状态=1 \n" +
+            "return n.name + '开单' + m.name as ruleName, \n" +
+            "id(m) as conceptId,m.name as conceptName,labels(m)[0] as conceptType,\n" +
+            "id(r) as relationId,type(r) as relationName,r.状态 as relationStatus, \n" +
             "id(n) as conditionId,n.name as conditionName,labels(n)[0] as conditionType  \n" +
             "order by id(r) desc",
             countQuery = "match(m)-[r]->(n) \n" +
                     "where 1 = 1 \n" +
-                    "and (case {labels} is not null and length({labels})>0 when true then labels(m)[0] in {labels} else 1 = 1 end ) \n" +
+                    "and (case {labels} is not null and size({labels})>0 when true then labels(m)[0] in {labels} else 1 = 1 end ) \n" +
                     "and (case {conceptName} is not null and {conceptName} <> '' when true then m.name contains {conceptName} else 1 = 1 end ) \n" +
                     "and (case {conditionName} is not null and {conditionName} <> '' when true then n.name contains {conditionName} else 1 = 1 end ) \n" +
+                    "and (case {relationStatus} is not null and {relationStatus} <> '' when true then r.状态 = {relationStatus} else 1 = 1 end ) \n" +
                     "and type(r) contains('禁忌') \n" +
+                    "and m.状态=1 \n" +
+                    "and n.状态=1 \n" +
                     "return count(n)")
-    Page<Indication> getPage(@Param("labels") List<String> labels, @Param("conceptName") String conceptName, @Param("conditionName") String conditionName, Pageable pageable);
+    Page<Indication> getPage(@Param("labels") List<String> labels,
+                             @Param("conceptName") String conceptName,
+                             @Param("conditionName") String conditionName,
+                             @Param("relationStatus") String relationStatus,
+                             Pageable pageable);
+
+    @Query("match (m)-[r]->(n) " +
+            "where type(r) contains '禁忌' " +
+            "and labels(m)[0] = $conceptLabel " +
+            "return distinct type(r)")
+    List<String> getRelationTypes(@Param("conceptLabel") String conceptLabel);
+
+    @Query("MATCH (n) \n" +
+            "WHERE (toLower(n.`name`) = toLower($name) OR toLower(n.`拼音编码`) = toLower($pycode))  \n" +
+            "AND labels(n)[0] in {labels}  \n" +
+            "AND (case {notInIds} is not null and size({notInIds})>0 when true then not(id(n) in {notInIds}) else 1 = 1 end ) \n" +
+            "RETURN ID(n) as id, n.name as name,n.状态 as status,labels(n)[0] as conditionLabel \n" +
+            "union \n" +
+            "MATCH (n) \n " +
+            "WHERE (toLower(n.`name`) starts with toLower($name) OR toLower(n.`拼音编码`) starts with toLower($pycode)) \n " +
+            "AND labels(n)[0] in {labels}  \n" +
+            "AND (case {notInIds} is not null and size({notInIds})>0 when true then not(id(n) in {notInIds}) else 1 = 1 end ) \n" +
+            "WITH n SKIP 0 LIMIT $size \n" +
+            "RETURN ID(n) as id, n.name as name,n.状态 as status,labels(n)[0] as conditionLabel  \n" +
+            "union \n" +
+            "MATCH (n) \n" +
+            "WHERE (toLower(n.`name`) CONTAINS toLower($name) OR toLower(n.`拼音编码`) CONTAINS toLower($pycode))  \n" +
+            "AND labels(n)[0] in {labels}  \n" +
+            "AND (case {notInIds} is not null and size({notInIds})>0 when true then not(id(n) in {notInIds}) else 1 = 1 end ) \n" +
+            "WITH n SKIP 0 LIMIT $size \n" +
+            "RETURN ID(n) as id, n.name as name,n.状态 as status,labels(n)[0] as conditionLabel \n")
+    List<IndicationCondition> conditionIndex(@Param("labels") List<String> labels,
+                                             @Param("notInIds") List<Long> notInIds,
+                                             @Param("name") String name,
+                                             @Param("pycode") String pycode,
+                                             @Param("size") Integer size);
+
+    @Query("MATCH(m)-[r]->(n) \n" +
+            "where m.name={conceptName} \n" +
+            "and {conceptLabel} in labels(m) \n" +
+            "and type(r) contains '禁忌' \n" +
+            "return ID(n) as id, n.name as name,n.状态 as status,labels(n)[0] as conditionLabel \n")
+    List<IndicationCondition> getNotInConditions(@Param("conceptName") String conceptName, @Param("conceptLabel") String conceptLabel);
 }

+ 24 - 0
src/main/java/com/diagbot/vo/ConditionIndexVO.java

@@ -0,0 +1,24 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/11/18 14:39
+ */
+@Getter
+@Setter
+public class ConditionIndexVO {
+    @NotBlank(message = "请选择开单项类型")
+    private String conceptLabel;
+    @NotBlank(message = "请选择开单项")
+    private String conceptName;
+    @NotBlank(message = "请选择规则类型:文本类型、数值类型")
+    private String ruleType;
+    @NotBlank(message = "请输入条件明细")
+    private String conditionName;
+}

+ 2 - 1
src/main/java/com/diagbot/vo/IndicationPageVO.java

@@ -18,4 +18,5 @@ public class IndicationPageVO {
     private List<String> labels;
     private String conceptName;
     private String conditionName;
-}
+    private String relationStatus;
+}

+ 17 - 1
src/main/java/com/diagbot/web/IndicationManController.java

@@ -2,7 +2,9 @@ package com.diagbot.web;
 
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.node.Indication;
+import com.diagbot.entity.node.IndicationCondition;
 import com.diagbot.facade.IndicationManFacade;
+import com.diagbot.vo.ConditionIndexVO;
 import com.diagbot.vo.IndicationPageVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * @Description:
  * @Author:zhaops
@@ -31,10 +35,22 @@ public class IndicationManController {
                     "size:每页条目数<br>" +
                     "labels:术语类型(多选)<br>" +
                     "conceptName:术语名称(模糊匹配)<br>" +
-                    "conditionName:条件明细(模糊匹配)<br>")
+                    "conditionName:条件明细(模糊匹配)<br>" +
+                    "relationStatus:启用禁用标志(0-禁用,1-启用)<br>")
     @PostMapping("/getPage")
     public RespDTO<Indication> getPage(@RequestBody IndicationPageVO indicationPageVO) {
         Page<Indication> data = indicationManFacade.getPage(indicationPageVO);
         return RespDTO.onSuc(data);
     }
+
+    @ApiOperation(value = "条件明细检索[zhaops]",
+            notes = "conceptLabel:开单类型<br>" +
+                    "conceptName:开单项<br>" +
+                    "ruleType:规则类型:文本类型、数值类型<br>" +
+                    "conditionName:条件明细(模糊匹配)<br>")
+    @PostMapping("/conditionIndex")
+    public RespDTO<IndicationCondition> conditionIndex(@RequestBody ConditionIndexVO conditionIndexVO) {
+        List<IndicationCondition> data = indicationManFacade.conditionIndex(conditionIndexVO);
+        return RespDTO.onSuc(data);
+    }
 }