Kaynağa Gözat

feat(电子病例): 诊断管理

matianxiang 3 ay önce
ebeveyn
işleme
7a732da081

+ 38 - 0
eitc-patient-base/src/main/java/com/eitc/patient/domain/DiagnosisManage.java

@@ -0,0 +1,38 @@
1
+package com.eitc.patient.domain;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableField;
4
+import com.baomidou.mybatisplus.annotation.TableName;
5
+import com.eitc.common.core.domain.EitcBaseEntity;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+
11
+import javax.validation.constraints.NotBlank;
12
+import javax.validation.constraints.Size;
13
+
14
+/**
15
+ * DiagnosisManage
16
+ *
17
+ * @author mtx
18
+ * @date: 2024/05/17 14:41
19
+ */
20
+@EqualsAndHashCode(callSuper = true)
21
+@Data
22
+@ApiModel("诊断管理表")
23
+@TableName("erm_diagnosis_manage")
24
+public class DiagnosisManage extends EitcBaseEntity {
25
+
26
+    @TableField(value = "diagnosis_code")
27
+    @ApiModelProperty(value = "诊断编码", name = "diagnosisCode")
28
+    @NotBlank(message = "诊断编码不能为空")
29
+    @Size(max = 50, message = "诊断编码长度不能超过50个字符")
30
+    private String diagnosisCode;
31
+
32
+    @TableField(value = "diagnosis_name")
33
+    @ApiModelProperty(value = "诊断名称", name = "diagnosisName")
34
+    @NotBlank(message = "诊断名称不能为空")
35
+    @Size(max = 50, message = "诊断名称长度不能超过50个字符")
36
+    private String diagnosisName;
37
+
38
+}

+ 30 - 0
eitc-patient-base/src/main/java/com/eitc/patient/excel/DiagnosisManageTemplateExcel.java

@@ -0,0 +1,30 @@
1
+package com.eitc.patient.excel;
2
+
3
+import com.eitc.common.annotation.Excel;
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+/**
9
+ * DiagnosisManageTemplateExcel
10
+ *
11
+ * @author mtx
12
+ * @date: 2024/05/20 15:34
13
+ */
14
+@Data
15
+@ApiModel("诊断管理模板导入")
16
+public class DiagnosisManageTemplateExcel {
17
+
18
+    @Excel(name = "诊断编码", type = Excel.Type.ALL)
19
+    @ApiModelProperty(value = "诊断编码", name = "diagnosisCode")
20
+    private String diagnosisCode;
21
+
22
+    @Excel(name = "诊断名称", type = Excel.Type.ALL)
23
+    @ApiModelProperty(value = "诊断名称", name = "diagnosisName")
24
+    private String diagnosisName;
25
+
26
+    @Excel(name = "返回信息", type = Excel.Type.EXPORT)
27
+    @ApiModelProperty(value = "返回信息", name = "msg")
28
+    private String msg;
29
+
30
+}

+ 16 - 0
eitc-patient-base/src/main/java/com/eitc/patient/mapper/DiagnosisManageMapper.java

@@ -0,0 +1,16 @@
1
+package com.eitc.patient.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.eitc.patient.domain.DiagnosisManage;
5
+import com.eitc.patient.domain.DiagnosisType;
6
+import org.apache.ibatis.annotations.Mapper;
7
+
8
+/**
9
+ * DiagnosisManageMapper
10
+ *
11
+ * @author mtx
12
+ * @date: 2024/05/17 15:31
13
+ */
14
+@Mapper
15
+public interface DiagnosisManageMapper extends BaseMapper<DiagnosisManage> {
16
+}

+ 26 - 0
eitc-patient-base/src/main/java/com/eitc/patient/service/IDiagnosisManageService.java

@@ -0,0 +1,26 @@
1
+package com.eitc.patient.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.eitc.patient.domain.DiagnosisManage;
5
+import com.eitc.patient.excel.DiagnosisManageTemplateExcel;
6
+import org.springframework.stereotype.Service;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * IDiagnosisManageService
12
+ *
13
+ * @author mtx
14
+ * @date: 2024/05/17 15:36
15
+ */
16
+@Service
17
+public interface IDiagnosisManageService extends IService<DiagnosisManage> {
18
+
19
+    /**
20
+     * 导入模板数据
21
+     *
22
+     * @param list 待导入的诊断管理模板Excel列表
23
+     * @return 导入失败的诊断管理模板Excel列表,包含错误信息
24
+     */
25
+    List<DiagnosisManageTemplateExcel> importTemplate(List<DiagnosisManageTemplateExcel> list);
26
+}

+ 94 - 0
eitc-patient-base/src/main/java/com/eitc/patient/service/impl/DiagnosisManageServiceImpl.java

@@ -0,0 +1,94 @@
1
+package com.eitc.patient.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
4
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.eitc.common.utils.bean.BeanUtils;
6
+import com.eitc.patient.domain.DiagnosisManage;
7
+import com.eitc.patient.excel.DiagnosisManageTemplateExcel;
8
+import com.eitc.patient.mapper.DiagnosisManageMapper;
9
+import com.eitc.patient.service.IDiagnosisManageService;
10
+import org.apache.commons.lang3.StringUtils;
11
+import org.springframework.stereotype.Service;
12
+import org.springframework.transaction.annotation.Transactional;
13
+
14
+import javax.annotation.Resource;
15
+import java.util.ArrayList;
16
+import java.util.List;
17
+import java.util.stream.Collectors;
18
+
19
+/**
20
+ * DiagnosisManageServiceImpl
21
+ *
22
+ * @author mtx
23
+ * @date: 2024/05/17 15:39
24
+ */
25
+@Service
26
+public class DiagnosisManageServiceImpl extends ServiceImpl<DiagnosisManageMapper, DiagnosisManage> implements IDiagnosisManageService {
27
+
28
+    @Resource
29
+    private IDiagnosisManageService diagnosisManageService;
30
+
31
+    /**
32
+     * 导入模板数据
33
+     *
34
+     * @param list 待导入的诊断管理模板Excel列表
35
+     * @return 导入失败的诊断管理模板Excel列表,包含错误信息
36
+     */
37
+    @Override
38
+    @Transactional(rollbackFor = {Exception.class})
39
+    public List<DiagnosisManageTemplateExcel> importTemplate(List<DiagnosisManageTemplateExcel> list) {
40
+        // 用于存储导入成功的诊断管理对象
41
+        List<DiagnosisManage> successList = new ArrayList<>();
42
+        // 用于存储导入失败的诊断管理模板Excel对象,保留错误信息
43
+        List<DiagnosisManageTemplateExcel> errorList = new ArrayList<>();
44
+
45
+        // 封装已存在的诊断管理
46
+        List<DiagnosisManage> manageList = diagnosisManageService.list();
47
+        List<String> diagnosisCodeList = new ArrayList<>();
48
+        List<String> diagnosisNameList = new ArrayList<>();
49
+        if (CollectionUtils.isNotEmpty(manageList)) {
50
+            diagnosisCodeList.addAll(manageList.stream().map(DiagnosisManage::getDiagnosisCode).collect(Collectors.toList()));
51
+            diagnosisNameList.addAll(manageList.stream().map(DiagnosisManage::getDiagnosisName).collect(Collectors.toList()));
52
+        }
53
+
54
+        // 校验数据是否正确
55
+        for (DiagnosisManageTemplateExcel excel : list) {
56
+            DiagnosisManage diagnosisManage = new DiagnosisManage();
57
+            // 检查诊断编码是否为空
58
+            if (StringUtils.isEmpty(excel.getDiagnosisCode())) {
59
+                excel.setMsg("诊断编码不能为空");
60
+                errorList.add(excel);
61
+                continue;
62
+            }
63
+            // 检查诊断编码是否存在
64
+            if (diagnosisCodeList.contains(excel.getDiagnosisCode())) {
65
+                excel.setMsg("诊断编码已存在");
66
+                errorList.add(excel);
67
+                continue;
68
+            }
69
+            // 检查诊断名称是否为空
70
+            if (StringUtils.isEmpty(excel.getDiagnosisName())) {
71
+                excel.setMsg("诊断名称不能为空");
72
+                errorList.add(excel);
73
+                continue;
74
+            }
75
+            // 检查诊断名称是否存在
76
+            if (diagnosisNameList.contains(excel.getDiagnosisName())) {
77
+                excel.setMsg("诊断名称已存在");
78
+                errorList.add(excel);
79
+                continue;
80
+            }
81
+            // 将Excel对象的属性复制到诊断管理对象
82
+            BeanUtils.copyProperties(excel, diagnosisManage);
83
+            // 将校验成功的诊断管理对象添加到成功列表
84
+            successList.add(diagnosisManage);
85
+        }
86
+        // 如果有成功导入的数据,则批量保存
87
+        if (CollectionUtils.isNotEmpty(successList)) {
88
+            this.saveBatch(successList);
89
+        }
90
+        // 返回导入失败的列表,外部可用于显示错误信息
91
+        return errorList;
92
+    }
93
+
94
+}

+ 1 - 1
eitc-patient-base/src/main/resources/mapper/patient/BusinessDictDataMapper.xml

@@ -2,5 +2,5 @@
2 2
 <!DOCTYPE mapper
3 3
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 4
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
-<mapper namespace="com.eitc.patient.mapper.DiagnosisTypeMapper">
5
+<mapper namespace="com.eitc.patient.mapper.BusinessDictDataMapper">
6 6
 </mapper>

+ 170 - 0
eitc-patient-pc/src/main/java/com/eitc/patient/controller/DiagnosisManageController.java

@@ -0,0 +1,170 @@
1
+package com.eitc.patient.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
5
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
6
+import com.eitc.common.annotation.Log;
7
+import com.eitc.common.core.controller.BaseController;
8
+import com.eitc.common.core.domain.AjaxResult;
9
+import com.eitc.common.enums.BusinessType;
10
+import com.eitc.common.utils.poi.ExcelUtil;
11
+import com.eitc.patient.domain.DiagnosisManage;
12
+import com.eitc.patient.excel.DiagnosisManageTemplateExcel;
13
+import com.eitc.patient.service.IDiagnosisManageService;
14
+import io.swagger.annotations.Api;
15
+import io.swagger.annotations.ApiOperation;
16
+import io.swagger.annotations.ApiParam;
17
+import org.apache.commons.lang3.StringUtils;
18
+import org.springframework.web.bind.annotation.DeleteMapping;
19
+import org.springframework.web.bind.annotation.GetMapping;
20
+import org.springframework.web.bind.annotation.PostMapping;
21
+import org.springframework.web.bind.annotation.PutMapping;
22
+import org.springframework.web.bind.annotation.RequestBody;
23
+import org.springframework.web.bind.annotation.RequestMapping;
24
+import org.springframework.web.bind.annotation.RequestParam;
25
+import org.springframework.web.bind.annotation.RestController;
26
+import org.springframework.web.multipart.MultipartFile;
27
+
28
+import javax.annotation.Resource;
29
+import javax.servlet.http.HttpServletResponse;
30
+import javax.validation.Valid;
31
+import java.io.IOException;
32
+import java.util.List;
33
+
34
+/**
35
+ * DiagnosisManageController
36
+ *
37
+ * @author mtx
38
+ * @date: 2024/05/17 15:51
39
+ */
40
+@Api(tags = "诊断管理")
41
+@RestController
42
+@RequestMapping("/diagnosis-manage")
43
+public class DiagnosisManageController extends BaseController {
44
+
45
+    @Resource
46
+    private IDiagnosisManageService diagnosisManageService;
47
+
48
+    /**
49
+     * 查询诊断管理
50
+     */
51
+    @GetMapping("/list")
52
+    @ApiOperation("查询诊断管理")
53
+    public AjaxResult list(@ApiParam(name = "diagnosisParam", value = "搜索条件")
54
+                           @RequestParam(name = "diagnosisParam", required = false) String diagnosisParam) {
55
+        LambdaQueryWrapper<DiagnosisManage> wrapper = Wrappers.lambdaQuery();
56
+        if (StringUtils.isNotBlank(diagnosisParam)) {
57
+            wrapper.like(DiagnosisManage::getDiagnosisName, diagnosisParam).or()
58
+                    .like(DiagnosisManage::getDiagnosisCode, diagnosisParam);
59
+        }
60
+
61
+        return success(diagnosisManageService.list(wrapper));
62
+    }
63
+
64
+    /**
65
+     * 获取诊断管理详细信息
66
+     */
67
+    @GetMapping(value = "/detail")
68
+    @ApiOperation("获取诊断管理详细信息")
69
+    public AjaxResult detail(String id) {
70
+        return success(diagnosisManageService.getById(id));
71
+    }
72
+
73
+    /**
74
+     * 新增诊断管理
75
+     */
76
+    @Log(title = "新增诊断管理", businessType = BusinessType.INSERT)
77
+    @PostMapping
78
+    @ApiOperation("新增诊断管理")
79
+    public AjaxResult add(@Valid @RequestBody DiagnosisManage diagnosisManage) {
80
+        checkSaveDiagnosisManage(diagnosisManage);
81
+        return toAjax(diagnosisManageService.save(diagnosisManage));
82
+    }
83
+
84
+    /**
85
+     * 修改诊断管理
86
+     */
87
+    @Log(title = "修改诊断管理", businessType = BusinessType.UPDATE)
88
+    @PutMapping
89
+    @ApiOperation("修改诊断管理")
90
+    public AjaxResult edit(@Valid @RequestBody DiagnosisManage diagnosisManage) {
91
+        checkSaveDiagnosisManage(diagnosisManage);
92
+        return toAjax(diagnosisManageService.updateById(diagnosisManage));
93
+    }
94
+
95
+    /**
96
+     * 导入诊断分类模板
97
+     *
98
+     * @param file 文件
99
+     */
100
+    @Log(title = "导入诊断分类模板", businessType = BusinessType.INSERT)
101
+    @PostMapping("/importTemplate")
102
+    @ApiOperation("导入诊断分类模板")
103
+    public void importTemplate(@RequestParam("file") @ApiParam(name = "file", value = "上传文件") MultipartFile file, HttpServletResponse response) throws IOException {
104
+        // 1.解析excel
105
+        ExcelUtil<DiagnosisManageTemplateExcel> util = new ExcelUtil<>(DiagnosisManageTemplateExcel.class);
106
+        List<DiagnosisManageTemplateExcel> list = util.importExcel(file.getInputStream());
107
+        // 2.如果解析数据为空则返回错误信息
108
+        if (CollectionUtils.isEmpty(list)) {
109
+            throw new RuntimeException("上传数据为空,请填写");
110
+        }
111
+        // 解析模板
112
+        List<DiagnosisManageTemplateExcel> diagnosisManageTemplateExcels = diagnosisManageService.importTemplate(list);
113
+        // 导出错误模板
114
+        if (CollectionUtils.isNotEmpty(diagnosisManageTemplateExcels)) {
115
+            util.exportExcel(response, diagnosisManageTemplateExcels, "模板错误");
116
+        }
117
+    }
118
+
119
+    /**
120
+     * 删除诊断管理
121
+     */
122
+    @Log(title = "删除诊断管理", businessType = BusinessType.DELETE)
123
+    @DeleteMapping("/remove")
124
+    @ApiOperation("删除诊断管理")
125
+    public AjaxResult remove(String id) {
126
+        checkDelDiagnosisManage(id);
127
+        return toAjax(diagnosisManageService.removeById(id));
128
+    }
129
+
130
+    /**
131
+     * 检查诊断管理对象的诊断编码和诊断名称是否重复
132
+     * 此方法通过查询数据库中是否存在相同的诊断编码或诊断名称来确保数据的唯一性
133
+     * 如果发现重复,将抛出IllegalArgumentException异常
134
+     *
135
+     * @param diagnosisManage 待检查的诊断管理对象
136
+     * @throws IllegalArgumentException 如果诊断编码或诊断名称重复,则抛出此异常
137
+     */
138
+    private void checkSaveDiagnosisManage(DiagnosisManage diagnosisManage) {
139
+        // 查询数据库中是否有与提供的诊断编码相同的记录
140
+        long diagnosisCodeCount = diagnosisManageService.count(Wrappers.<DiagnosisManage>lambdaQuery()
141
+                .ne(StringUtils.isNotBlank(diagnosisManage.getId()), DiagnosisManage::getId, diagnosisManage.getId())
142
+                .eq(DiagnosisManage::getDiagnosisCode, diagnosisManage.getDiagnosisCode()));
143
+        // 如果诊断编码重复,则抛出异常
144
+        if (diagnosisCodeCount > 0) {
145
+            throw new IllegalArgumentException("诊断编码重复");
146
+        }
147
+        // 查询数据库中是否有与提供的诊断名称相同的记录
148
+        long diagnosisNameCount = diagnosisManageService.count(Wrappers.<DiagnosisManage>lambdaQuery()
149
+                .ne(StringUtils.isNotBlank(diagnosisManage.getId()), DiagnosisManage::getId, diagnosisManage.getId())
150
+                .eq(DiagnosisManage::getDiagnosisName, diagnosisManage.getDiagnosisName()));
151
+        // 如果诊断名称重复,则抛出异常
152
+        if (diagnosisNameCount > 0) {
153
+            throw new IllegalArgumentException("诊断名称重复");
154
+        }
155
+    }
156
+
157
+    /**
158
+     * 检查并处理删除诊断管理信息前的准备工作
159
+     *
160
+     * @param id 待删除的诊断管理信息的ID
161
+     * @throws IllegalArgumentException 如果id为空,则抛出此异常
162
+     */
163
+    private void checkDelDiagnosisManage(String id) {
164
+        // 检查ID是否为空,如果为空则抛出异常,提示id不能为空
165
+        if (StringUtils.isEmpty(id)) {
166
+            throw new IllegalArgumentException("id不能为空");
167
+        }
168
+    }
169
+
170
+}