Merge remote-tracking branch 'origin/dev_2.1.0' into dev_2.1.0
commit
51374ae721
@ -1,33 +0,0 @@
|
|||||||
package com.supervision.neo4j.config;
|
|
||||||
|
|
||||||
import org.neo4j.driver.AuthTokens;
|
|
||||||
import org.neo4j.driver.Driver;
|
|
||||||
import org.neo4j.driver.GraphDatabase;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class Neo4jConfig {
|
|
||||||
|
|
||||||
@Value("${spring.data.neo4j.uri}")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Value("${spring.data.neo4j.username}")
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@Value("${spring.data.neo4j.password}")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public Driver driver() {
|
|
||||||
// 创建驱动器实例
|
|
||||||
return GraphDatabase.driver(uri, AuthTokens.basic(username, password));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.supervision.neo4j.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import com.supervision.neo4j.service.GraphService;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("graph")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class GraphController {
|
|
||||||
|
|
||||||
|
|
||||||
private final GraphService graphService;
|
|
||||||
|
|
||||||
@GetMapping("createGraph")
|
|
||||||
public void createGraph(String processId) {
|
|
||||||
graphService.createGraph(processId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("queryGraph")
|
|
||||||
public Object queryGraph(String processId){
|
|
||||||
return graphService.queryGraph(processId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("deleteNode")
|
|
||||||
public void deleteNode() {
|
|
||||||
graphService.deleteNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.*;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@NodeEntity("辅助检查")
|
|
||||||
@Data
|
|
||||||
public class AncillaryNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("辅助检查名称")
|
|
||||||
private String ancillaryName;
|
|
||||||
|
|
||||||
@Relationship("诊断依据")
|
|
||||||
private Set<DiseaseNode> diseaseNodeSet;
|
|
||||||
|
|
||||||
public AncillaryNode(String ancillaryName) {
|
|
||||||
this.ancillaryName = ancillaryName;
|
|
||||||
this.diseaseNodeSet = new HashSet<>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
|
||||||
import org.neo4j.ogm.annotation.Id;
|
|
||||||
import org.neo4j.ogm.annotation.NodeEntity;
|
|
||||||
import org.neo4j.ogm.annotation.Property;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NodeEntity("疾病分类名称")
|
|
||||||
public class DiseaseNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("疾病名称")
|
|
||||||
private String diseaseName;
|
|
||||||
|
|
||||||
public DiseaseNode(String diseaseName) {
|
|
||||||
this.diseaseName = diseaseName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.*;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@NodeEntity("处置计划")
|
|
||||||
@Data
|
|
||||||
public class DisposalMethodNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("处置计划类型")
|
|
||||||
private String disposalMethod;
|
|
||||||
|
|
||||||
@Relationship("处置措施")
|
|
||||||
private Set<TreatmentPlanNode> treatmentPlanNodeSet;
|
|
||||||
|
|
||||||
public DisposalMethodNode(String disposalMethod) {
|
|
||||||
this.disposalMethod = disposalMethod;
|
|
||||||
treatmentPlanNodeSet = new HashSet<>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
|
||||||
import org.neo4j.ogm.annotation.Id;
|
|
||||||
import org.neo4j.ogm.annotation.NodeEntity;
|
|
||||||
import org.neo4j.ogm.annotation.Property;
|
|
||||||
|
|
||||||
|
|
||||||
@NodeEntity("药品")
|
|
||||||
@Data
|
|
||||||
public class DrugNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("药品名称")
|
|
||||||
private String drugName;
|
|
||||||
|
|
||||||
public DrugNode(String drugName) {
|
|
||||||
this.drugName = drugName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
|
||||||
import org.neo4j.ogm.annotation.Id;
|
|
||||||
import org.neo4j.ogm.annotation.NodeEntity;
|
|
||||||
import org.neo4j.ogm.annotation.Property;
|
|
||||||
|
|
||||||
@NodeEntity("知识库")
|
|
||||||
@Data
|
|
||||||
public class KnowledgeBaseNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("知识库")
|
|
||||||
private String diseaseName;
|
|
||||||
|
|
||||||
public KnowledgeBaseNode(String diseaseName) {
|
|
||||||
this.diseaseName = diseaseName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.*;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NodeEntity("体格检查结果")
|
|
||||||
public class PhysicalNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
|
|
||||||
@Property("检查工具")
|
|
||||||
private String toolName;
|
|
||||||
|
|
||||||
@Relationship("所属工具")
|
|
||||||
private Set<PhysicalToolNode> physicalToolNodeSet;
|
|
||||||
|
|
||||||
@Relationship("诊断依据")
|
|
||||||
private Set<DiseaseNode> diseaseNodeSet;
|
|
||||||
|
|
||||||
public PhysicalNode(String toolName) {
|
|
||||||
this.toolName = toolName;
|
|
||||||
this.physicalToolNodeSet = new HashSet<>();
|
|
||||||
this.diseaseNodeSet = new HashSet<>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
|
||||||
import org.neo4j.ogm.annotation.Id;
|
|
||||||
import org.neo4j.ogm.annotation.NodeEntity;
|
|
||||||
import org.neo4j.ogm.annotation.Property;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NodeEntity("体格检查工具")
|
|
||||||
public class PhysicalToolNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("体格检查工具名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public PhysicalToolNode(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.*;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NodeEntity("问诊实例")
|
|
||||||
public class ProcessNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("实例号")
|
|
||||||
private String processNo;
|
|
||||||
|
|
||||||
@Relationship(type = "问诊")
|
|
||||||
private Set<KnowledgeBaseNode> knowledgeBaseNodeSet;
|
|
||||||
|
|
||||||
@Relationship(type = "诊断")
|
|
||||||
private Set<PhysicalNode> physicalNodeSet;
|
|
||||||
|
|
||||||
@Relationship(type = "诊断")
|
|
||||||
private Set<AncillaryNode> ancillaryNodeSet;
|
|
||||||
|
|
||||||
@Relationship(type = "处置计划")
|
|
||||||
private DisposalMethodNode disposalMethodNode;
|
|
||||||
|
|
||||||
@Relationship(type = "排除诊断")
|
|
||||||
private Set<DiseaseNode> excludeDiagnosisNodeSet;
|
|
||||||
|
|
||||||
@Relationship(type = "最终诊断")
|
|
||||||
private Set<DiseaseNode> finalDiagnosisNodeSet;
|
|
||||||
|
|
||||||
public ProcessNode(String processNo) {
|
|
||||||
this.processNo = processNo;
|
|
||||||
knowledgeBaseNodeSet = new HashSet<>();
|
|
||||||
physicalNodeSet = new HashSet<>();
|
|
||||||
ancillaryNodeSet = new HashSet<>();
|
|
||||||
excludeDiagnosisNodeSet = new HashSet<>();
|
|
||||||
finalDiagnosisNodeSet = new HashSet<>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.supervision.neo4j.node;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import org.neo4j.ogm.annotation.*;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NodeEntity("处置措施")
|
|
||||||
public class TreatmentPlanNode {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Property("处置计划")
|
|
||||||
private String treatmentPlanName;
|
|
||||||
|
|
||||||
@Relationship("所属药品")
|
|
||||||
private Set<DrugNode> drugNodeSet;
|
|
||||||
|
|
||||||
public TreatmentPlanNode(String treatmentPlanName) {
|
|
||||||
this.treatmentPlanName = treatmentPlanName;
|
|
||||||
drugNodeSet = new HashSet<>();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package com.supervision.neo4j.repo;
|
|
||||||
|
|
||||||
import com.supervision.neo4j.node.AncillaryNode;
|
|
||||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface AncillaryRepository extends Neo4jRepository<AncillaryNode, Long> {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package com.supervision.neo4j.repo;
|
|
||||||
|
|
||||||
import com.supervision.neo4j.node.DiseaseNode;
|
|
||||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface DiseaseRepository extends Neo4jRepository<DiseaseNode, Long> {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.supervision.neo4j.repo;
|
|
||||||
|
|
||||||
import com.supervision.neo4j.node.KnowledgeBaseNode;
|
|
||||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface KnowledgeRepository extends Neo4jRepository<KnowledgeBaseNode, Long> {
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package com.supervision.neo4j.repo;
|
|
||||||
|
|
||||||
import com.supervision.neo4j.node.PhysicalNode;
|
|
||||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface PhysicalRepository extends Neo4jRepository<PhysicalNode, Long> {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.supervision.neo4j.repo;
|
|
||||||
|
|
||||||
import com.supervision.neo4j.node.PhysicalToolNode;
|
|
||||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface PhysicalToolRepository extends Neo4jRepository<PhysicalToolNode, Long> {
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.supervision.neo4j.repo;
|
|
||||||
|
|
||||||
import com.supervision.neo4j.node.ProcessNode;
|
|
||||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface ProcessRepository extends Neo4jRepository<ProcessNode, Long> {
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.supervision.neo4j.repo;
|
|
||||||
|
|
||||||
import com.supervision.neo4j.node.TreatmentPlanNode;
|
|
||||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
@Repository
|
|
||||||
public interface TreatmentPlanRepository extends Neo4jRepository<TreatmentPlanNode, Long> {
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package com.supervision.neo4j.service;
|
|
||||||
|
|
||||||
public interface GraphService {
|
|
||||||
|
|
||||||
void createGraph(String processId);
|
|
||||||
|
|
||||||
void deleteNode();
|
|
||||||
|
|
||||||
Object queryGraph(String process);
|
|
||||||
}
|
|
@ -1,275 +0,0 @@
|
|||||||
package com.supervision.neo4j.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.supervision.exception.BusinessException;
|
|
||||||
import com.supervision.model.Process;
|
|
||||||
import com.supervision.model.*;
|
|
||||||
import com.supervision.neo4j.node.*;
|
|
||||||
import com.supervision.neo4j.repo.*;
|
|
||||||
import com.supervision.neo4j.service.GraphService;
|
|
||||||
import com.supervision.service.*;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.neo4j.driver.Driver;
|
|
||||||
import org.neo4j.driver.Record;
|
|
||||||
import org.neo4j.driver.Result;
|
|
||||||
import org.neo4j.driver.Session;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class GraphServiceImpl implements GraphService {
|
|
||||||
|
|
||||||
private final DiseaseService diseaseService;
|
|
||||||
|
|
||||||
private final MedicalRecService medicalRecService;
|
|
||||||
|
|
||||||
private final ProcessMedicalService processMedicalService;
|
|
||||||
|
|
||||||
private final ConfigPhysicalToolService configPhysicalToolService;
|
|
||||||
|
|
||||||
private final ConfigPhysicalLocationService configPhysicalLocationService;
|
|
||||||
|
|
||||||
private final ConfigAncillaryItemService configAncillaryItemService;
|
|
||||||
|
|
||||||
private final DiagnosisAncillaryRecordService diagnosisAncillaryRecordService;
|
|
||||||
|
|
||||||
private final DiagnosisPhysicalRecordService diagnosisPhysicalRecordService;
|
|
||||||
|
|
||||||
private final DiagnosisPrimaryRelationService relationService;
|
|
||||||
|
|
||||||
private final DiagnosisPrimaryService diagnosisPrimaryService;
|
|
||||||
|
|
||||||
private final DiseasePhysicalService diseasePhysicalService;
|
|
||||||
|
|
||||||
private final DiseaseAncillaryService diseaseAncillaryService;
|
|
||||||
|
|
||||||
private final ProcessService processService;
|
|
||||||
|
|
||||||
private final TreatmentPlanRecordService treatmentPlanRecordService;
|
|
||||||
|
|
||||||
private final ConfigTreatmentPlanService configTreatmentPlanService;
|
|
||||||
|
|
||||||
private final ConfigDrugService configDrugService;
|
|
||||||
|
|
||||||
private final DiseaseRepository diseaseRepository;
|
|
||||||
|
|
||||||
private final AncillaryRepository ancillaryRepository;
|
|
||||||
|
|
||||||
private final PhysicalRepository physicalRepository;
|
|
||||||
|
|
||||||
private final ProcessRepository processRepository;
|
|
||||||
|
|
||||||
private final KnowledgeRepository knowledgeRepository;
|
|
||||||
|
|
||||||
private final PhysicalToolRepository physicalToolRepository;
|
|
||||||
|
|
||||||
private final TreatmentPlanRepository treatmentPlanRepository;
|
|
||||||
|
|
||||||
private final Driver driver;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void createGraph(String processId) {
|
|
||||||
Process process = Optional.ofNullable(processService.getById(processId)).orElseThrow(() -> new BusinessException("未找到流程"));
|
|
||||||
ProcessNode processNode = new ProcessNode("问诊实例" + process.getProcessNo());
|
|
||||||
// 生成知识库的关联关系
|
|
||||||
createKnowledge(processId, process, processNode);
|
|
||||||
// 找到process关联的所有初步诊断
|
|
||||||
Map<String, DiseaseNode> diseaseNodeMap = new HashMap<>();
|
|
||||||
List<DiagnosisPrimary> diagnosisPrimaryList = diagnosisPrimaryService.lambdaQuery().eq(DiagnosisPrimary::getProcessId, processId).list();
|
|
||||||
if (CollUtil.isNotEmpty(diagnosisPrimaryList)) {
|
|
||||||
Set<String> diseaseIdSet = diagnosisPrimaryList.stream().map(DiagnosisPrimary::getPrimaryDiagnosisId).collect(Collectors.toSet());
|
|
||||||
List<Disease> diseases = diseaseService.listByIds(diseaseIdSet);
|
|
||||||
for (Disease disease : diseases) {
|
|
||||||
DiseaseNode diseaseNode = new DiseaseNode(disease.getDiseaseNameAlias());
|
|
||||||
diseaseRepository.save(diseaseNode);
|
|
||||||
diseaseNodeMap.put(disease.getId(), diseaseNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// 体格检查结果
|
|
||||||
createPhysical(processId, processNode, diseaseNodeMap);
|
|
||||||
// 辅助检查结果
|
|
||||||
createAncillary(processId, processNode, diseaseNodeMap);
|
|
||||||
// 生成处置项
|
|
||||||
createTreatment(processId, processNode);
|
|
||||||
for (DiagnosisPrimary diagnosisPrimary : diagnosisPrimaryList) {
|
|
||||||
// 生成最终诊断和排除诊断
|
|
||||||
if (ObjectUtil.isNotEmpty(diagnosisPrimary.getExcludeFlag())) {
|
|
||||||
if (1 == diagnosisPrimary.getExcludeFlag()) {
|
|
||||||
Optional.ofNullable(diseaseNodeMap.get(diagnosisPrimary.getPrimaryDiagnosisId())).ifPresent(diseaseNode -> {
|
|
||||||
processNode.getFinalDiagnosisNodeSet().add(diseaseNode);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (0 == diagnosisPrimary.getExcludeFlag()) {
|
|
||||||
Optional.ofNullable(diseaseNodeMap.get(diagnosisPrimary.getPrimaryDiagnosisId())).ifPresent(diseaseNode -> {
|
|
||||||
processNode.getExcludeDiagnosisNodeSet().add(diseaseNode);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
processRepository.save(processNode);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createTreatment(String processId, ProcessNode processNode) {
|
|
||||||
|
|
||||||
|
|
||||||
List<TreatmentPlanRecord> treatmentPlanRecordList = treatmentPlanRecordService.lambdaQuery().eq(TreatmentPlanRecord::getProcessId, processId).list();
|
|
||||||
// 生成处置计划
|
|
||||||
treatmentPlanRecordList.stream().findAny().ifPresent(record -> {
|
|
||||||
if (ObjectUtil.isNotEmpty(record.getDisposalMethod())) {
|
|
||||||
DisposalMethodNode disposalMethodNode = new DisposalMethodNode(1 == record.getDisposalMethod() ? "住院治疗" : "门诊治疗");
|
|
||||||
processNode.setDisposalMethodNode(disposalMethodNode);
|
|
||||||
// 首先生成非药品的
|
|
||||||
treatmentPlanRecordList.stream().filter(e -> StrUtil.isNotBlank(e.getTreatmentPlanId())).forEach(e -> {
|
|
||||||
Optional.ofNullable(configTreatmentPlanService.getById(e.getTreatmentPlanId())).ifPresent(relation -> {
|
|
||||||
TreatmentPlanNode treatmentPlanNode = new TreatmentPlanNode(relation.getDisposalPlan() + "," + relation.getFirstMeasures());
|
|
||||||
disposalMethodNode.getTreatmentPlanNodeSet().add(treatmentPlanNode);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// 生成药品的
|
|
||||||
List<TreatmentPlanRecord> drugRecordList = treatmentPlanRecordList.stream().filter(e -> StrUtil.isBlank(e.getTreatmentPlanId()) && StrUtil.isNotBlank(e.getDrugId())).collect(Collectors.toList());
|
|
||||||
if (CollUtil.isNotEmpty(drugRecordList)) {
|
|
||||||
TreatmentPlanNode treatmentPlanNode = new TreatmentPlanNode("药品");
|
|
||||||
disposalMethodNode.getTreatmentPlanNodeSet().add(treatmentPlanNode);
|
|
||||||
for (TreatmentPlanRecord drugRecord : drugRecordList) {
|
|
||||||
Optional.ofNullable(configDrugService.getById(drugRecord.getDrugId())).ifPresent(configDrug -> {
|
|
||||||
DrugNode drugNode = new DrugNode(configDrug.getDrugName());
|
|
||||||
treatmentPlanNode.getDrugNodeSet().add(drugNode);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 辅助检查
|
|
||||||
*
|
|
||||||
* @param processId 实例ID
|
|
||||||
* @param processNode 实例节点
|
|
||||||
* @param diseaseMap 疾病集合
|
|
||||||
*/
|
|
||||||
private void createAncillary(String processId, ProcessNode processNode, Map<String, DiseaseNode> diseaseMap) {
|
|
||||||
List<DiagnosisAncillaryRecord> diagnosisAncillaryRecordList = diagnosisAncillaryRecordService.lambdaQuery().eq(DiagnosisAncillaryRecord::getProcessId, processId).list();
|
|
||||||
for (DiagnosisAncillaryRecord diagnosisAncillaryRecord : diagnosisAncillaryRecordList) {
|
|
||||||
Optional.ofNullable(configAncillaryItemService.getById(diagnosisAncillaryRecord.getAncillaryId())).ifPresent(ancillaryItem -> {
|
|
||||||
Optional.ofNullable(diseaseAncillaryService.getById(diagnosisAncillaryRecord.getAncillaryId())).ifPresent(diseaseAncillary -> {
|
|
||||||
// 根据预期诊断结果判断
|
|
||||||
String expectedDiagnosisResult = (ObjectUtil.isNotNull(diseaseAncillary.getExpectedDiagnosisResult()) && 1 == diseaseAncillary.getExpectedDiagnosisResult()) ? "异常" : "正常";
|
|
||||||
AncillaryNode ancillaryNode = new AncillaryNode(ancillaryItem.getItemName() + ":" + expectedDiagnosisResult);
|
|
||||||
// 诊断依据
|
|
||||||
Optional<DiagnosisPrimaryRelation> relationOptional = relationService.lambdaQuery().eq(DiagnosisPrimaryRelation::getRelationId, diagnosisAncillaryRecord.getId()).oneOpt();
|
|
||||||
if (relationOptional.isPresent()) {
|
|
||||||
DiagnosisPrimaryRelation primaryRelation = relationOptional.get();
|
|
||||||
Optional<DiagnosisPrimary> primaryOptional = Optional.ofNullable(diagnosisPrimaryService.getById(primaryRelation.getPrimaryId()));
|
|
||||||
primaryOptional.flatMap(diagnosisPrimary -> Optional.ofNullable(diseaseMap.get(diagnosisPrimary.getPrimaryDiagnosisId()))).ifPresent(diseaseNode -> {
|
|
||||||
ancillaryNode.getDiseaseNodeSet().add(diseaseNode);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
processNode.getAncillaryNodeSet().add(ancillaryNode);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createPhysical(String processId, ProcessNode processNode, Map<String, DiseaseNode> diseaseMap) {
|
|
||||||
List<DiagnosisPhysicalRecord> physicalRecordList = diagnosisPhysicalRecordService.lambdaQuery().eq(DiagnosisPhysicalRecord::getProcessId, processId).list();
|
|
||||||
|
|
||||||
for (DiagnosisPhysicalRecord diagnosisPhysicalRecord : physicalRecordList) {
|
|
||||||
Optional.ofNullable(diseasePhysicalService.getById(diagnosisPhysicalRecord.getPhysicalId())).ifPresent(diseasePhysical -> {
|
|
||||||
// 构建工具
|
|
||||||
if (StrUtil.isNotBlank(diagnosisPhysicalRecord.getToolId())) {
|
|
||||||
Optional.ofNullable(configPhysicalToolService.getById(diagnosisPhysicalRecord.getToolId())).ifPresent(tool -> {
|
|
||||||
PhysicalNode physicalNode = new PhysicalNode(tool.getToolName());
|
|
||||||
// 构建所属位置
|
|
||||||
if (StrUtil.isNotBlank(diagnosisPhysicalRecord.getLocationId())) {
|
|
||||||
Optional<ConfigPhysicalLocation> locationOptional = Optional.ofNullable(configPhysicalLocationService.getById(diagnosisPhysicalRecord.getLocationId()));
|
|
||||||
locationOptional.ifPresent(configPhysicalTool -> {
|
|
||||||
// 根据是否有异常值,如果有异常结果,认为是异常
|
|
||||||
String expectedDiagnosisResult = ObjectUtil.isNotEmpty(diseasePhysical.getResult()) ? "正常" : "异常";
|
|
||||||
PhysicalToolNode physicalToolNode = new PhysicalToolNode(configPhysicalTool.getLocationName() + ":" + expectedDiagnosisResult);
|
|
||||||
physicalNode.getPhysicalToolNodeSet().add(physicalToolNode);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 找到关联的初步诊断
|
|
||||||
List<DiagnosisPrimaryRelation> diagnosisPrimaryRelationList = relationService.lambdaQuery().eq(DiagnosisPrimaryRelation::getRelationId, diagnosisPhysicalRecord.getId()).list();
|
|
||||||
for (DiagnosisPrimaryRelation primaryRelation : diagnosisPrimaryRelationList) {
|
|
||||||
Optional<DiagnosisPrimary> primaryOptional = Optional.ofNullable(diagnosisPrimaryService.getById(primaryRelation.getPrimaryId()));
|
|
||||||
primaryOptional.flatMap(diagnosisPrimary -> Optional.ofNullable(diseaseMap.get(diagnosisPrimary.getPrimaryDiagnosisId()))).ifPresent(diseaseNode -> physicalNode.getDiseaseNodeSet().add(diseaseNode));
|
|
||||||
}
|
|
||||||
processNode.getPhysicalNodeSet().add(physicalNode);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createKnowledge(String processId, Process process, ProcessNode processNode) {
|
|
||||||
// 查询主诉作为知识库
|
|
||||||
Optional<MedicalRec> medicalRecOptional = Optional.ofNullable(medicalRecService.getById(process.getMedicalRecId()));
|
|
||||||
if (medicalRecOptional.isPresent()) {
|
|
||||||
MedicalRec medicalRec = medicalRecOptional.get();
|
|
||||||
KnowledgeBaseNode knowledgeBaseNode = new KnowledgeBaseNode(medicalRec.getSymptoms());
|
|
||||||
processNode.getKnowledgeBaseNodeSet().add(knowledgeBaseNode);
|
|
||||||
}
|
|
||||||
// 个人史作为知识库
|
|
||||||
Optional<ProcessMedical> processMedicalOptional = processMedicalService.lambdaQuery().eq(ProcessMedical::getProcessId, processId).oneOpt();
|
|
||||||
if (processMedicalOptional.isPresent()) {
|
|
||||||
ProcessMedical processMedical = processMedicalOptional.get();
|
|
||||||
if (ObjectUtil.isNotEmpty(processMedical.getFamilyHistoryFlag()) && 1 == processMedical.getFamilyHistoryFlag()
|
|
||||||
&& StrUtil.isNotBlank(processMedical.getFamilyHistory())) {
|
|
||||||
KnowledgeBaseNode knowledgeBaseNode = new KnowledgeBaseNode("家族史:" + processMedical.getFamilyHistory());
|
|
||||||
processNode.getKnowledgeBaseNodeSet().add(knowledgeBaseNode);
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isNotEmpty(processMedical.getAllergyHistoryFlag()) && 1 == processMedical.getAllergyHistoryFlag()
|
|
||||||
&& StrUtil.isNotBlank(processMedical.getAllergyHistory())) {
|
|
||||||
KnowledgeBaseNode knowledgeBaseNode = new KnowledgeBaseNode("过敏史:" + processMedical.getPersonalHistory());
|
|
||||||
processNode.getKnowledgeBaseNodeSet().add(knowledgeBaseNode);
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isNotEmpty(processMedical.getPreviousHistoryFlag()) && 1 == processMedical.getPreviousHistoryFlag()
|
|
||||||
&& StrUtil.isNotBlank(processMedical.getPreviousHistory())) {
|
|
||||||
KnowledgeBaseNode knowledgeBaseNode = new KnowledgeBaseNode("既往史:" + processMedical.getPreviousHistory());
|
|
||||||
processNode.getKnowledgeBaseNodeSet().add(knowledgeBaseNode);
|
|
||||||
}
|
|
||||||
if (ObjectUtil.isNotEmpty(processMedical.getOperationHistoryFlag()) && 1 == processMedical.getOperationHistoryFlag()
|
|
||||||
&& StrUtil.isNotBlank(processMedical.getOperationHistory())) {
|
|
||||||
KnowledgeBaseNode knowledgeBaseNode = new KnowledgeBaseNode("手术史:" + processMedical.getOperationHistory());
|
|
||||||
processNode.getKnowledgeBaseNodeSet().add(knowledgeBaseNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteNode() {
|
|
||||||
diseaseRepository.deleteAll();
|
|
||||||
ancillaryRepository.deleteAll();
|
|
||||||
physicalRepository.deleteAll();
|
|
||||||
processRepository.deleteAll();
|
|
||||||
knowledgeRepository.deleteAll();
|
|
||||||
physicalToolRepository.deleteAll();
|
|
||||||
treatmentPlanRepository.deleteAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object queryGraph(String processId) {
|
|
||||||
try (Session session = driver.session()) {
|
|
||||||
Result result = session.run("MATCH (n) RETURN n LIMIT 25");
|
|
||||||
List<Record> list = result.list();
|
|
||||||
return JSONUtil.toJsonStr(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: test
|
active: dev
|
||||||
application:
|
application:
|
||||||
name: virtual-patient-web
|
name: virtual-patient-web
|
Loading…
Reference in New Issue