From 785a1f2124c7999b233a54e6ce8e6bc75e72c36a Mon Sep 17 00:00:00 2001 From: liu <liujiatong112@163.com> Date: Fri, 8 Mar 2024 16:42:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9F=A5=E8=AF=86=E5=9B=BE?= =?UTF-8?q?=E8=B0=B1=E7=9A=84=E7=9F=A5=E8=AF=86=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/GraphNebulaController.java | 4 +- .../java/com/supervision/enums/TagEnum.java | 55 ++++++++++++------- .../service/GraphNebulaService.java | 5 ++ .../service/impl/GraphNebulaServiceImpl.java | 31 ++++++++--- .../com/supervision/vo/GraphLegendVO.java | 15 +++++ .../main/java/com/supervision/vo/GraphVO.java | 10 ++++ .../java/com/supervision/vo/TreeNodeVO.java | 6 ++ .../com/supervision/pojo/vo/ChartNodeVO.java | 6 ++ .../impl/AskDiagnosisResultServiceImpl.java | 5 ++ 9 files changed, 110 insertions(+), 27 deletions(-) create mode 100644 virtual-patient-graph/src/main/java/com/supervision/vo/GraphLegendVO.java diff --git a/virtual-patient-graph/src/main/java/com/supervision/controller/GraphNebulaController.java b/virtual-patient-graph/src/main/java/com/supervision/controller/GraphNebulaController.java index 3a6d40fc..21c5e0d4 100644 --- a/virtual-patient-graph/src/main/java/com/supervision/controller/GraphNebulaController.java +++ b/virtual-patient-graph/src/main/java/com/supervision/controller/GraphNebulaController.java @@ -28,7 +28,9 @@ public class GraphNebulaController { @ApiOperation("查询图谱") @GetMapping("queryGraph") public GraphVO queryGraph(String processId, Integer level) { - return graphNebulaService.queryGraph(processId, level); + GraphVO graphVO = graphNebulaService.queryGraph(processId, level); + graphNebulaService.buildLegend(graphVO); + return graphVO; } diff --git a/virtual-patient-graph/src/main/java/com/supervision/enums/TagEnum.java b/virtual-patient-graph/src/main/java/com/supervision/enums/TagEnum.java index 17252ca7..09d3ccf6 100644 --- a/virtual-patient-graph/src/main/java/com/supervision/enums/TagEnum.java +++ b/virtual-patient-graph/src/main/java/com/supervision/enums/TagEnum.java @@ -1,41 +1,41 @@ package com.supervision.enums; public enum TagEnum { - medical_rec("病例", 1, "#2F7CFF"), + medical_rec("病例", 1, "#2F7CFF", "病历", null), - process_medical("电子病历", 2, "#55CBAD"), + process_medical("电子病历", 2, "#55CBAD", "电子病历", medical_rec), - self_desc("主诉", 3, "#55CBAD"), + self_desc("主诉", 3, "#55CBAD", "电子病历", process_medical), - previous_history("既往病史", 3, "#55CBAD"), + previous_history("既往病史", 3, "#55CBAD", "电子病历", process_medical), - illness_history("现病史", 3, "#55CBAD"), + illness_history("现病史", 3, "#55CBAD", "电子病历", process_medical), - personal_history("个人史", 3, "#55CBAD"), + personal_history("个人史", 3, "#55CBAD", "电子病历", process_medical), - allergy_history("过敏史", 3, "#55CBAD"), + allergy_history("过敏史", 3, "#55CBAD", "电子病历", process_medical), - family_history("家族史", 3, "#55CBAD"), + family_history("家族史", 3, "#55CBAD", "电子病历", process_medical), - marriage_child_history("婚育史", 3, "#55CBAD"), + marriage_child_history("婚育史", 3, "#55CBAD", "电子病历", process_medical), - operation_history("手术史", 3, "#55CBAD"), + operation_history("手术史", 3, "#55CBAD", "电子病历", process_medical), - symptoms("症状", 2, "#55CBAD"), + symptoms("症状", 2, "#55CBAD", "电子病历", process_medical), - patient("患者信息", 2, "#55CBAD"), + patient("患者信息", 2, "#55CBAD", "电子病历", process_medical), - physical("体格检查", 2, "#8D8BFF"), + physical("体格检查", 2, "#8D8BFF", "体格检查", medical_rec), - physical_result("体格检查结果", 3, "#8D8BFF"), + physical_result("体格检查结果", 3, "#8D8BFF", "体格检查", physical), - ancillary("辅助检查", 2, "#4E8CFF"), + ancillary("辅助检查", 2, "#4E8CFF", "辅助检查", medical_rec), - ancillary_result("辅助检查结果", 3, "#4E8CFF"), + ancillary_result("辅助检查结果", 3, "#4E8CFF", "辅助检查", ancillary), - treatment_plan("处置计划", 2, "#2BCCFF"), + treatment_plan("处置计划", 2, "#2BCCFF", "处置计划", medical_rec), - diagnosis("诊断", 2, "#FF6667"); + diagnosis("诊断", 2, "#FF6667", "诊断结果", medical_rec); private final String type; @@ -43,10 +43,19 @@ public enum TagEnum { private final String colour; - TagEnum(String type, Integer level, String colour) { + /** + * 图例名称 + */ + private final String legendType; + + private final TagEnum parentTag; + + TagEnum(String type, Integer level, String colour, String legendType, TagEnum parentTag) { this.type = type; this.level = level; this.colour = colour; + this.legendType = legendType; + this.parentTag = parentTag; } @@ -61,4 +70,12 @@ public enum TagEnum { public String getColour() { return colour; } + + public String getLegendType() { + return legendType; + } + + public TagEnum getParentTag() { + return parentTag; + } } diff --git a/virtual-patient-graph/src/main/java/com/supervision/service/GraphNebulaService.java b/virtual-patient-graph/src/main/java/com/supervision/service/GraphNebulaService.java index 60113101..944d53ed 100644 --- a/virtual-patient-graph/src/main/java/com/supervision/service/GraphNebulaService.java +++ b/virtual-patient-graph/src/main/java/com/supervision/service/GraphNebulaService.java @@ -11,6 +11,11 @@ public interface GraphNebulaService { GraphVO queryGraph(String processId, Integer level); + /** + * 构建图例 + */ + void buildLegend(GraphVO graphVO); + List<TreeNodeVO> queryTreeGraph(String processId, Integer level); } diff --git a/virtual-patient-graph/src/main/java/com/supervision/service/impl/GraphNebulaServiceImpl.java b/virtual-patient-graph/src/main/java/com/supervision/service/impl/GraphNebulaServiceImpl.java index 5912a412..4e8c2c94 100644 --- a/virtual-patient-graph/src/main/java/com/supervision/service/impl/GraphNebulaServiceImpl.java +++ b/virtual-patient-graph/src/main/java/com/supervision/service/impl/GraphNebulaServiceImpl.java @@ -16,10 +16,7 @@ import com.supervision.exception.BusinessException; import com.supervision.model.Process; import com.supervision.model.*; import com.supervision.service.*; -import com.supervision.vo.EdgeVO; -import com.supervision.vo.GraphVO; -import com.supervision.vo.NodeVO; -import com.supervision.vo.TreeNodeVO; +import com.supervision.vo.*; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nebula.contrib.ngbatis.models.data.NgEdge; @@ -141,7 +138,7 @@ public class GraphNebulaServiceImpl implements GraphNebulaService { previousHistoryVertex.setNodeValue(processMedical.getPreviousHistory()); previousHistoryDao.insert(previousHistoryVertex); // 保存节点之间的关系 - processMedicalDao.insertEdge(processMedicalVertex, new SinglePropertyEdge("个人史"), previousHistoryVertex); + processMedicalDao.insertEdge(processMedicalVertex, new SinglePropertyEdge("既往史"), previousHistoryVertex); } // 创建家族史节点 if (ObjectUtil.isNotEmpty(processMedical.getFamilyHistoryFlag()) && 1 == processMedical.getFamilyHistoryFlag() && StrUtil.isNotBlank(processMedical.getFamilyHistory())) { @@ -333,6 +330,24 @@ public class GraphNebulaServiceImpl implements GraphNebulaService { return new GraphVO(nodeList, edgeList); } + @Override + public void buildLegend(GraphVO graphVO) { + // 构建图例 + Map<String, String> legendMap = Arrays.stream(TagEnum.values()).collect(Collectors.toMap(TagEnum::getColour, TagEnum::getLegendType, (k1, k2) -> k1)); + Map<String, List<NodeVO>> nodeGroupByColourMap = graphVO.getNodes().stream().collect(Collectors.groupingBy(NodeVO::getNodeColour)); + List<GraphLegendVO> graphLegendList = new ArrayList<>(); + for (Map.Entry<String, List<NodeVO>> entry : nodeGroupByColourMap.entrySet()) { + String colour = entry.getKey(); + GraphLegendVO graphLegendVO = new GraphLegendVO(); + graphLegendVO.setColour(colour); + graphLegendVO.setLegendType(legendMap.get(colour)); + graphLegendVO.setId(entry.getValue().stream().map(NodeVO::getId).collect(Collectors.toSet())); + graphLegendList.add(graphLegendVO); + } + graphVO.setLegendList(graphLegendList); + + } + @Override public List<TreeNodeVO> queryTreeGraph(String processId, Integer level) { GraphVO graphVO = queryGraph(processId, level); @@ -374,15 +389,17 @@ public class GraphNebulaServiceImpl implements GraphNebulaService { } private void recursionBuildTree(TreeNodeVO preNode, Map<String, TreeNodeVO> treeNodeMap, List<EdgeVO> edgeList) { + // 通过preNode的节点类型,找到这个节点下面应该挂的节点 + Set<String> childNodeTypeSet = Arrays.stream(TagEnum.values()).filter(e -> preNode.getNodeType().equals(Optional.ofNullable(e.getParentTag()).orElse(TagEnum.medical_rec).name())).map(TagEnum::name).collect(Collectors.toSet()); + // 通过preNode的ID找到所有的子节点 List<TreeNodeVO> childNode = new ArrayList<>(); for (EdgeVO edgeVO : edgeList) { if (StrUtil.equals(edgeVO.getSource(), preNode.getId())) { TreeNodeVO treeNodeVO = treeNodeMap.get(edgeVO.getTarget()); - if (ObjectUtil.isNotEmpty(treeNodeVO)) { + if (ObjectUtil.isNotEmpty(treeNodeVO) && childNodeTypeSet.contains(treeNodeVO.getNodeType())) { childNode.add(treeNodeVO); } - ; } } preNode.setChildren(childNode); diff --git a/virtual-patient-graph/src/main/java/com/supervision/vo/GraphLegendVO.java b/virtual-patient-graph/src/main/java/com/supervision/vo/GraphLegendVO.java new file mode 100644 index 00000000..abb5c5e8 --- /dev/null +++ b/virtual-patient-graph/src/main/java/com/supervision/vo/GraphLegendVO.java @@ -0,0 +1,15 @@ +package com.supervision.vo; + +import lombok.Data; + +import java.util.Set; + +@Data +public class GraphLegendVO { + + private String colour; + + private String legendType; + + private Set<String> id; +} diff --git a/virtual-patient-graph/src/main/java/com/supervision/vo/GraphVO.java b/virtual-patient-graph/src/main/java/com/supervision/vo/GraphVO.java index fa0ca2cb..87faa1f6 100644 --- a/virtual-patient-graph/src/main/java/com/supervision/vo/GraphVO.java +++ b/virtual-patient-graph/src/main/java/com/supervision/vo/GraphVO.java @@ -19,4 +19,14 @@ public class GraphVO { @ApiModelProperty("关系") private List<EdgeVO> edges; + + @ApiModelProperty("图例的List") + private List<GraphLegendVO> legendList; + + private String graphTree; + + public GraphVO(List<NodeVO> nodes, List<EdgeVO> edges) { + this.nodes = nodes; + this.edges = edges; + } } diff --git a/virtual-patient-graph/src/main/java/com/supervision/vo/TreeNodeVO.java b/virtual-patient-graph/src/main/java/com/supervision/vo/TreeNodeVO.java index 522db22d..9150cc3d 100644 --- a/virtual-patient-graph/src/main/java/com/supervision/vo/TreeNodeVO.java +++ b/virtual-patient-graph/src/main/java/com/supervision/vo/TreeNodeVO.java @@ -16,16 +16,22 @@ public class TreeNodeVO { private String id; @ApiModelProperty("图谱ID") private String graphId; + @ApiModelProperty("节点值") private String nodeValue; + @ApiModelProperty("节点颜色") private String nodeColour; + @ApiModelProperty("节点级别") private Integer nodeLevel; + @ApiModelProperty("节点类型") private String nodeType; + @ApiModelProperty("节点描述") private String nodeDesc; + @ApiModelProperty("节点的属性列表") private Map<String, Object> params = new LinkedHashMap<>(); diff --git a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/ChartNodeVO.java b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/ChartNodeVO.java index 7f85894e..f4304339 100644 --- a/virtual-patient-web/src/main/java/com/supervision/pojo/vo/ChartNodeVO.java +++ b/virtual-patient-web/src/main/java/com/supervision/pojo/vo/ChartNodeVO.java @@ -20,6 +20,12 @@ public class ChartNodeVO { @ApiModelProperty("评分级别( (0-60) 不合格 [60,75)合格 [75,85)良好 [85,100]优秀,") private String scoreLevel; + /** + * 总数=其他三项之和 + */ + @ApiModelProperty("总数") + private Integer total; + /** * 用户命中的数量 */ diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java index c29ebe48..e6980dea 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskDiagnosisResultServiceImpl.java @@ -412,6 +412,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService ChartNodeVO chartNodeVO = new ChartNodeVO(); chartNodeVO.setNodePer(clinicalThinking); chartNodeVO.setScoreLevel(chartNodeVO.computeScoreLevel()); + chartNodeVO.setTotal(NumberUtil.add(askChart.getTotal(), physicalChart.getTotal(), ancillaryChart.getTotal(), treatmentPlanChart.getTotal()).intValue()); chartNodeVO.setCorrect(NumberUtil.add(askChart.getCorrect(), physicalChart.getCorrect(), ancillaryChart.getCorrect(), treatmentPlanChart.getCorrect()).intValue()); chartNodeVO.setUnCorrect(NumberUtil.add(askChart.getUnCorrect(), physicalChart.getUnCorrect(), ancillaryChart.getUnCorrect(), treatmentPlanChart.getUnCorrect()).intValue()); chartNodeVO.setStandard(NumberUtil.add(askChart.getStandard(), physicalChart.getStandard(), ancillaryChart.getStandard(), treatmentPlanChart.getStandard()).intValue()); @@ -471,6 +472,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService chartNodeVO.setCorrect(hitPlanCount); chartNodeVO.setUnCorrect(medicalCount - hitPlanCount); chartNodeVO.setStandard(medicalCount); + chartNodeVO.setTotal(NumberUtil.add(chartNodeVO.getUnCorrect(), chartNodeVO.getStandard(), chartNodeVO.getCorrect()).intValue()); return chartNodeVO; @@ -502,6 +504,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService chartNodeVO.setCorrect(userHitCount); chartNodeVO.setUnCorrect(medicalCount - userHitCount); chartNodeVO.setStandard(medicalCount); + chartNodeVO.setTotal(NumberUtil.add(chartNodeVO.getUnCorrect(), chartNodeVO.getStandard(), chartNodeVO.getCorrect()).intValue()); return chartNodeVO; } @@ -534,6 +537,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService chartNodeVO.setCorrect(userHitCount); chartNodeVO.setUnCorrect(medicalCount - userHitCount); chartNodeVO.setStandard(medicalCount); + chartNodeVO.setTotal(NumberUtil.add(chartNodeVO.getUnCorrect(), chartNodeVO.getStandard(), chartNodeVO.getCorrect()).intValue()); return chartNodeVO; } @@ -580,6 +584,7 @@ public class AskDiagnosisResultServiceImpl implements AskDiagnosisResultService chartNodeVO.setCorrect(userHitQuestionCount); chartNodeVO.setStandard(Integer.parseInt(String.valueOf(medicalQuestionCount))); chartNodeVO.setUnCorrect(NumberUtil.sub(chartNodeVO.getStandard(), chartNodeVO.getCorrect()).intValue()); + chartNodeVO.setTotal(NumberUtil.add(chartNodeVO.getUnCorrect(), chartNodeVO.getStandard(), chartNodeVO.getCorrect()).intValue()); return chartNodeVO; }