|
@@ -1,6 +1,7 @@
|
|
package com.diagbot.repository;
|
|
package com.diagbot.repository;
|
|
|
|
|
|
import com.diagbot.entity.node.Indication;
|
|
import com.diagbot.entity.node.Indication;
|
|
|
|
+import com.diagbot.entity.node.IndicationCondition;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.neo4j.annotation.Query;
|
|
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" +
|
|
@Query(value = "match(m)-[r]->(n) \n" +
|
|
"where 1 = 1 \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 {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 {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 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" +
|
|
"id(n) as conditionId,n.name as conditionName,labels(n)[0] as conditionType \n" +
|
|
"order by id(r) desc",
|
|
"order by id(r) desc",
|
|
countQuery = "match(m)-[r]->(n) \n" +
|
|
countQuery = "match(m)-[r]->(n) \n" +
|
|
"where 1 = 1 \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 {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 {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 type(r) contains('禁忌') \n" +
|
|
|
|
+ "and m.状态=1 \n" +
|
|
|
|
+ "and n.状态=1 \n" +
|
|
"return count(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);
|
|
}
|
|
}
|