Browse Source

bi统计,图谱相关统计指标

kongwz 5 years ago
parent
commit
a153dab133

+ 184 - 0
graphdb/src/main/java/org/diagbot/repository/BiRepository.java

@@ -0,0 +1,184 @@
+package org.diagbot.repository;
+
+import org.diagbot.entity.node.Disease;
+import org.springframework.data.neo4j.annotation.Query;
+import org.springframework.data.neo4j.repository.Neo4jRepository;
+
+import java.util.List;
+import java.util.Map;
+
+public interface BiRepository extends Neo4jRepository<Disease, Long> {
+    List<Disease> findByNameContaining(String token);
+    //查找图谱中诊断依据数量
+    @Query("match(d:Disease)<-[r:确诊|:拟诊]-(c:Condition) return count(distinct d.name) as discount")
+    Long diagnoseCount();
+    //查找图谱中的儿科疾病数量
+    @Query("MATCH (n:Disease)<-[r:确诊|:拟诊]-(c:Condition) where n.maxAge < 200 and n.minAge =0 RETURN count(distinct n.name) as child")
+    Long childCount();
+    //图谱中有内容的量表数量
+    @Query("MATCH (n:Scale) RETURN count(distinct n.name) as scaleCount")
+    Long scaleCount();
+
+
+    // find High Risk Disease
+    @Query("MATCH (d:Disease) WHERE d.name in {0} RETURN d.name as name, d.high_risk as risk")
+    List<Map<String, Object>> findHighRiskDisease(List<String> diseaselist);
+
+    //get high risk
+    @Query("match(d:Disease) where d.name in {0} return d.name as name, d.high_risk as risk")
+    List<Map<String, Object>> getHighRisk(List diagList);
+
+
+    //删除诊断依据
+    //删除关系1
+    @Query("match(d:Disease)<-[r:拟诊|:确诊|:警惕]-(c:Condition)<-[r1]-(k:Condition)<-[r2]-(h:Condition) where d.disId={0} detach delete c,k,h")
+    void deleteRelation1(Long disId);
+    //删除关系2
+    @Query("match(d:Disease)<-[r:拟诊|:确诊|:警惕]-(c:Condition)<-[r1]-(k:Condition) where d.disId={0} detach delete c,k")
+    void deleteRelation2(Long disId);
+    //删除关系3
+    @Query("match(d:Disease)<-[r:拟诊|:确诊|:警惕]-(c:Condition) where d.disId={0} detach delete r")
+    void deleteRelation3(Long disId);
+    //删除排除关系4
+    @Query("match(d:Disease)<-[r:排除]-(l) where d.disId={0} detach delete l")
+    void deleteRelation4(Long disId);
+    //删除排除关系5
+    @Query("match(d:Disease)-[r:表现]->(j)-[r1:属于]->(k) where d.disId={0} detach delete r")
+    void deleteRelation5(Long disId);
+    //删除排除关系6
+    @Query("match(d:Disease)-[r:表现]->(j) where d.disId={0} detach delete r")
+    void deleteRelation6(Long disId);
+    //删除排除关系7
+    @Query("match(d:Disease)-[r:推荐]->(j:LIS) where d.disId={0} detach delete r")
+    void deleteRelation7(Long disId);
+    //删除排除关系8
+    @Query("match(d:Disease)-[r:推荐]->(j:PACS) where d.disId={0} detach delete r")
+    void deleteRelation8(Long disId);
+    //删除排除关系9
+    @Query("match(d:Disease)-[r:鉴别诊断]->(b) where d.disId={0} detach delete r")
+    void deleteRelation9(Long disId);
+    //删除排除关系10
+    @Query("match(c:Condition) where c.name={0} detach delete c")
+    void deleteRelation10(String conditionName);
+    //删除诊断
+    @Query("match(c:Disease) where c.disId={0} detach delete c")
+    void deleteRelation11(Long disId);
+    //更新图谱
+    //存储疾病
+    @Query("merge(d:Disease{name:{0},disId:{1},emergency:{2}})")
+    void mergeDis(String name, Long disId, Integer emergency);
+    //存储确诊,拟诊,警惕
+    @Query( "merge(c:Condition{name:{0},path:{1}})")
+    void mergeCondition(String disName, Integer path);
+    @Query("match(c:Condition{name:{0}}),(d:Disease{disId:{1}})" +
+            " merge(c)-[:确诊]->(d)")
+    void mergeQueNiHigh(String conditionName, Long disId);
+    @Query("match(c:Condition{name:{0}}),(d:Disease{disId:{1}})" +
+            " merge(c)-[:拟诊]->(d)")
+    void mergeNiHigh(String conditionName, Long disId);
+    @Query("match(c:Condition{name:{0}}),(d:Disease{disId:{1}})" +
+            " merge(c)-[:警惕]->(d)")
+    void mergeHigh(String conditionName, Long disId);
+    //任几的condition
+    @Query("merge(c:Condition{name:{0},path:{1},relation:{2}})")
+    void mergeRenCondition(String conditionName, Integer path, String relation);
+    @Query("match(c:Condition{name:{0}}),(s:Condition{name:{1}}) merge(c)-[r:诊断依据]->(s)")
+    void mergeRenCondition(String c1, String c2);
+    //具体code Condition
+    @Query("merge(c:Condition{name:{0},path:1,relation:'任一'})")
+    void mergeNUMCondition(String disName);
+    @Query("match(c:Condition{name:{0}}),(s:Condition{name:{1}}) merge(c)-[r:诊断依据]->(s)")
+    void mergeNUMCondition(String c1, String c2);
+    //开始添加所有的词语
+    //添加症状标准词
+    @Query("merge(d:Symptom{name:{0}})")
+    void mergeStandardSymptom(String name);
+    //疾病表现症状标准词
+    @Query("match(d:Disease{disId:{0}}),(s:Symptom{name:{1}}) merge(d)-[r:表现]->(s)")
+    void mergeRelationStandard(Long disId, String name);
+    //属于症状标准词
+    @Query("match(d:Condition{name:{0}}),(s:Symptom{name:{1}}) merge(d)<-[r:属于]-(s)")
+    void mergeRelationStandardshuyu(String conditionName, String name);
+    //添加体征标准词
+    @Query("merge(d:Vital{name:{0}})")
+    void mergeStandardVital(String name);
+    //疾病表现体征标准词
+    @Query("match(d:Disease{disId:{0}}),(s:Vital{name:{1}}) merge(d)-[r:表现]->(s)")
+    void mergeRelationStandardVital(Long disId, String name);
+    //属于体征标准词
+    @Query("match(d:Condition{name:{0}}),(s:Vital{name:{1}}) merge(d)<-[r:属于]-(s)")
+    void mergeRelationStandardVitalshuyu(String conditionName, String name);
+    //添加病史标准词
+    @Query("merge(d:History{name:{0}})")
+    void mergeStandardHistory(String name);
+    //疾病表现病史标准词
+    @Query("match(d:Disease{disId:{0}}),(s:History{name:{1}}) merge(d)-[r:表现]->(s)")
+    void mergeRelationStandardHistory(Long disId, String name);
+    //属于病史标准词
+    @Query("match(d:Condition{name:{0}}),(s:History{name:{1}}) merge(d)<-[r:属于]-(s)")
+    void mergeRelationStandardHistoryshuyu(String conditionName, String name);
+    //添加诱因标准词
+    @Query("merge(d:Cause{name:{0}})")
+    void mergeStandardCause(String name);
+    //疾病表现诱因标准词
+    @Query("match(d:Disease{disId:{0}}),(s:Cause{name:{1}}) merge(d)-[r:表现]->(s)")
+    void mergeRelationStandardCause(Long disId, String name);
+    //属于诱因标准词
+    @Query("match(d:Condition{name:{0}}),(s:Cause{name:{1}}) merge(d)<-[r:属于]-(s)")
+    void mergeRelationStandardCauseshuyu(String conditionName, String name);
+    //添加病程标准词
+    @Query("merge(d:Prognosis{name:{0}})")
+    void mergeStandardPrognosis(String name);
+    //疾病表现病程标准词
+    @Query("match(d:Disease{disId:{0}}),(s:Prognosis{name:{1}}) merge(d)-[r:表现]->(s)")
+    void mergeRelationStandardPrognosis(Long disId, String name);
+    //属于病程标准词
+    @Query("match(d:Condition{name:{0}}),(s:Prognosis{name:{1}}) merge(d)<-[r:属于]-(s)")
+    void mergeRelationStandardPrognosisshuyu(String conditionName, String name);
+    //添加其他标准词
+    @Query("merge(d:Other{name:{0}})")
+    void mergeStandardOther(String name);
+    //疾病表现其他标准词
+    @Query("match(d:Disease{disId:{0}}),(s:Other{name:{1}}) merge(d)-[r:表现]->(s)")
+    void mergeRelationStandardOther(Long disId, String name);
+    //属于其他标准词
+    @Query("match(d:Condition{name:{0}}),(s:Other{name:{1}}) merge(d)<-[r:属于]-(s)")
+    void mergeRelationStandardOthershuyu(String conditionName, String name);
+    //添加鉴别诊断
+    @Query("merge(d:DifferentDis{name:{0}})")
+    void mergeDifferentDis(String disName);
+    //疾病和鉴别诊断创建关系
+    @Query("match(d:Disease{disId:{0}}),(s:DifferentDis{name:{1}}) merge(d)-[r:鉴别诊断]->(s)")
+    void mergeRelationDifferentDis(Long disId, String name);
+    //创建公表名
+    @Query("merge(l:LIS{name:{0}})")
+    void mergePublicLIS(String lisName);
+    //疾病和鉴别诊断创建关系
+    @Query("match(d:Disease{disId:{0}}),(s:LIS{name:{1}}) merge(d)-[r:推荐]->(s)")
+    void mergeRelationLIS(Long disId, String name);
+    //创建化验结果节点
+    @Query("merge(l:LISResult{name:{0}})")
+    void mergeLISRESULT(String name);
+    //公表名和化验结果创建关系
+    @Query("match(d:LIS{name:{0}}),(s:LISResult{name:{1}}) merge(d)-[r:结果]->(s)")
+    void mergeRelationPublicLIS(String publicLis, String lisResult);
+    //化验结果和对应的codeCondition创建关系
+    @Query("match(d:Condition{name:{0}}),(s:LISResult{name:{1}}) merge(d)<-[r:诊断依据]-(s)")
+    void mergeRelationCondiLisRes(String codeCondition, String lisRes);
+    //创建辅检项目
+    @Query("merge(p:PACS{name:{0}})")
+    void mergePacs(String pacsName);
+    //疾病推荐辅检
+    @Query("match(d:Disease{disId:{0}}),(s:PACS{name:{1}}) merge(d)-[r:推荐]->(s)")
+    void mergeRelationDis2Pacs(Long disId, String name);
+    //创建辅检结果节点
+    @Query("merge(p:PACSResult{name:{0}})")
+    void mergePacsResult(String name);
+    //创建辅检和辅检结果的关系
+    @Query("match(d:PACS{name:{0}}),(s:PACSResult{name:{1}}) merge(d)-[r:结果]->(s)")
+    void mergeRelationPacsResult(String pacs, String pacsResult);
+    //辅检结果和对应的codeCondition创建关系
+    @Query("match(d:Condition{name:{0}}),(s:PACSResult{name:{1}}) merge(d)<-[r:诊断依据]-(s)")
+    void mergeRelationCondiPacsRes(String codeCondition, String pacsRes);
+}
+

+ 2 - 0
graphdb/src/main/java/org/diagbot/service/KnowledgeService.java

@@ -58,5 +58,7 @@ public interface KnowledgeService {
     RespDTO deleteNeoDisease(NeoParamVO singleDisease);
     //批量插入
     RespDTO<Boolean> batchInsertDis();
+    //图谱bi统计
+    Map<String,Long> neoBi();
 
 }

+ 16 - 1
graphdb/src/main/java/org/diagbot/service/impl/KnowledgeServiceImpl.java

@@ -53,7 +53,8 @@ public class    KnowledgeServiceImpl implements KnowledgeService {
     private ScaleRepository scaleRepository;
     @Autowired
     private KnowledgeMapper knowledgeMapper;
-
+    @Autowired
+    private BiRepository biRepository;
     private List<BaseNode> baseNodes;
     private String user = "teamdata";
     private String password = "jiO2rfnYhg";
@@ -2134,6 +2135,19 @@ public class    KnowledgeServiceImpl implements KnowledgeService {
 
         return respDTO;
     }
+
+    @Override
+    public Map<String, Long> neoBi() {
+        Map<String,Long> bi = new HashMap<>();
+        Long disCount = biRepository.diagnoseCount();
+        Long childCount = biRepository.childCount();
+        Long scaleCount = biRepository.scaleCount();
+        bi.put("disCount",disCount);
+        bi.put("childCount",childCount);
+        bi.put("scaleCount",scaleCount);
+        return bi;
+    }
+
     public void updateDate(Connection connection,Long disId){
         String sql = "UPDATE `kl_diagnose` set neo_update='1970-01-01 12:00:00' where id="+disId+";";
     }
@@ -2214,6 +2228,7 @@ public class    KnowledgeServiceImpl implements KnowledgeService {
     }
 
 
+
     public Pageable getPageable(PageVo pageVo) {
         if (pageVo.getSize() > 0) {
             if (pageVo.getSort_key() != null && pageVo.getSort_direct() != null) {

+ 11 - 0
graphdb/src/main/java/org/diagbot/web/KnowledgeController.java

@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -211,4 +212,14 @@ public class KnowledgeController {
         RespDTO respDTO = knowledgeService.batchInsertDis();
         return respDTO;
     }
+
+    /**
+     * 图谱的bi指标统计
+     * @return
+     */
+    @RequestMapping("/neoStatistics")
+    public Map<String,Long> biCount(){
+        Map<String, Long> biCount = knowledgeService.neoBi();
+        return biCount;
+    }
 }