liusheng
2025-04-02 ae086bc3ad6f785e6368b84e57a7e199c675779b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
package com.ruoyi.web.controller.smartor;
 
import com.github.pagehelper.ISelect;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.domain.*;
import com.smartor.service.IPatArchiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
 
/**
 * 患者档案Controller
 *
 * @author smartor
 * @date 2023-03-04
 */
@Api(description = "患者档案")
@RestController
@RequestMapping("/smartor/patarchive")
public class PatArchiveController extends BaseController {
    @Autowired
    private IPatArchiveService patArchiveService;
 
    /**
     * 查询患者档案列表
     */
    @ApiOperation("查询患者档案列表")
    //@PreAuthorize("@ss.hasPermi('smartor:patarchive:list')")
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody PatArchive patArchive) {
        startPage();
        List<PatArchive> list = patArchiveService.selectPatArchiveList(patArchive);
        return getDataTable(list);
    }
 
    /**
     * 导出患者档案列表
     */
    @ApiOperation("导出患者档案列表")
    //@PreAuthorize("@ss.hasPermi('smartor:patarchive:export')")
    @Log(title = "患者档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatArchive patArchive) {
        List<PatArchive> list = patArchiveService.selectPatArchiveList(patArchive);
        ExcelUtil<PatArchive> util = new ExcelUtil<PatArchive>(PatArchive.class);
        util.exportExcel(response, list, "患者档案数据");
    }
 
    /**
     * 获取患者档案详细信息
     */
    @ApiOperation("获取患者档案详细信息")
    //@PreAuthorize("@ss.hasPermi('smartor:patarchive:query')")
    @GetMapping(value = "/getInfo/{patid}")
    @ApiImplicitParam(name = "patid", value = "患者id")
    public AjaxResult getInfo(@PathVariable(name = "patid") Long patid) {
        return success(patArchiveService.selectPatArchiveByPatid(patid));
    }
 
//    /**
//     * 新增患者档案
//     */
//    @ApiOperation("新增患者档案")
//    //@PreAuthorize("@ss.hasPermi('smartor:patarchive:add')")
//    @Log(title = "患者档案", businessType = BusinessType.INSERT)
//    @PostMapping("/add")
//    public AjaxResult add(@RequestBody PatArchive patArchive) {
//        return toAjax(patArchiveService.insertPatArchive(patArchive));
//    }
 
    /**
     * 新增患者档案
     */
    @ApiOperation("修改患者档案")
    //@PreAuthorize("@ss.hasPermi('smartor:patarchive:update')")
    @Log(title = "患者档案", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult update(@RequestBody PatArchive patArchive) {
        return toAjax(patArchiveService.update(patArchive));
    }
 
    /**
     * 新增或修改患者档信息
     */
    @ApiOperation("新增或修改患者档信息")
    //@PreAuthorize("@ss.hasPermi('smartor:patarchive:edit')")
    @Log(title = "患者档案", businessType = BusinessType.UPDATE)
    @PostMapping("/saveOrUpdatePatInfo")
    public AjaxResult saveOrUpdatePatInfo(@RequestBody PatArchiveVO patArchiveVO) {
        SysUser user = getLoginUser().getUser();
        patArchiveVO.setOrgid(user.getOrgid());
        return toAjax(patArchiveService.saveOrUpdatePatInfo(patArchiveVO));
    }
 
    /**
     * 删除患者档案
     */
    @ApiOperation("删除患者档案")
    //@PreAuthorize("@ss.hasPermi('smartor:patarchive:remove')")
    @Log(title = "患者档案", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{patids}")
    @ApiImplicitParam(name = "patids", value = "患者id集合", dataType = "long", dataTypeClass = Long.class)
    public AjaxResult remove(@PathVariable Long[] patids) {
        return toAjax(patArchiveService.deletePatArchiveByPatids(patids));
    }
 
 
    /**
     * 导入患者文件处理
     *
     * @param multipartFile
     */
    @ApiOperation("导入患者文件处理")
    @PostMapping("/importFilehandle")
    @ApiImplicitParams({@ApiImplicitParam(name = "tags", value = "标签"), @ApiImplicitParam(name = "multipartFile", value = "上传文件")})
    public AjaxResult importFilehandle(@RequestParam("tags") String tags, @RequestParam("multipartFile") MultipartFile multipartFile) {
        Executor executor = Executors.newFixedThreadPool(3);
        //获取当前登陆人
        LoginUser loginUser = getLoginUser();
        SysUser user = loginUser.getUser();
        PatUpInfoVO patUpInfoVO = patArchiveService.importFilehandle(user, tags, multipartFile);
        return success(patUpInfoVO);
    }
 
    /**
     * 导入患者信息模板
     *
     * @param response
     */
    @ApiOperation("患者信息导入模板")
    @PostMapping("/patImportTemplate")
    public void patImportTemplate(HttpServletResponse response) {
//        ExcelUtil<PatImportInfoVO> util = new ExcelUtil<PatImportInfoVO>(PatImportInfoVO.class);
        ExcelUtil<PatArchive> util = new ExcelUtil<PatArchive>(PatArchive.class);
        util.importTemplateExcel(response, "患者信息导入");
    }
 
    /**
     * 导出患者错误信息
     *
     * @param patArchiveList
     */
    @ApiOperation("导出患者错误信息")
    @PostMapping(value = "/exportErrPatInfo")
    public void exportErrPatInfo(HttpServletResponse response, @RequestBody List<PatImportInfoVO> patArchiveList) {
 
        ExcelUtil<PatImportInfoVO> util = new ExcelUtil<PatImportInfoVO>(PatImportInfoVO.class);
        util.exportExcel(response, patArchiveList, "导出患者错误信息");
    }
 
    /**
     * 查询患者列表
     */
    @ApiOperation("查询患者列表")
    @PostMapping("/patInfoByContion")
    public TableDataInfo patInfoByCondition(@RequestBody PatArchiveReq patArchive) {
//        PageUtils.startPageByPost(patArchive.getPageNum(), patArchive.getPageSize());
        if (CollectionUtils.isEmpty(patArchive.getLeavehospitaldistrictcodes()) || patArchive.getLeavehospitaldistrictcodes().size() == 0) {
            patArchive.setLeavehospitaldistrictcodes(null);
        }
        if (CollectionUtils.isEmpty(patArchive.getLeaveldeptcodes()) || patArchive.getLeaveldeptcodes().size() == 0) {
            patArchive.setLeaveldeptcodes(null);
        }
        List<PatArchive> patArchives = patArchiveService.patInfoByContion(patArchive);
        long count = PageUtils.count(new ISelect() {
            @Override
            public void doSelect() {
                patArchiveService.patInfoByContion(patArchive);
            }
        });
        return getDataTable2(count, patArchives);
    }
 
 
    /**
     * 导出患者列表根据条件
     */
    @ApiOperation("导出患者列表根据条件")
    @PostMapping("/exportPatInfo")
    public void exportPpatInfo(HttpServletResponse response, @RequestBody PatArchiveReq patArchive) {
        startPage();
        List<PatArchive> patArchives = patArchiveService.patInfoByContion(patArchive);
        if (!CollectionUtils.isEmpty(patArchives)) {
            for (int i = 0; i < patArchives.size(); i++) {
                patArchives.get(i).setTag(patArchives.get(i).getTagList().toString());
            }
        }
        ExcelUtil<PatArchive> util = new ExcelUtil<PatArchive>(PatArchive.class);
        util.exportExcel(response, patArchives, "患者档案数据");
    }
 
    /**
     * 获取患者信息
     */
    @ApiOperation("获取患者信息")
    @PostMapping("/getPatientInfo")
    public TableDataInfo getPatientInfo(@RequestBody PatArchiveReq patArchiveReq) {
        PageUtils.startPageByPost(patArchiveReq.getPageNum(), patArchiveReq.getPageSize());
        if (CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) || patArchiveReq.getLeavehospitaldistrictcodes().size() == 0) {
            patArchiveReq.setLeavehospitaldistrictcodes(null);
        }
        if (CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) || patArchiveReq.getLeaveldeptcodes().size() == 0) {
            patArchiveReq.setLeaveldeptcodes(null);
        }
        List<PatArchiveOthreInfo> patientInfo = patArchiveService.getPatientInfo(patArchiveReq);
        long count = PageUtils.count(new ISelect() {
            @Override
            public void doSelect() {
                patArchiveService.getPatientInfo(patArchiveReq);
            }
        });
        return getDataTable2(count, patientInfo);
    }
 
    /**
     * 获取患者信息
     */
    @ApiOperation("获取患者信息")
    @PostMapping("/getPatientInfoQC")
    public TableDataInfo getPatientInfoQC(@RequestBody PatArchiveReq patArchiveReq) {
        PageUtils.startPageByPost(patArchiveReq.getPageNum(), patArchiveReq.getPageSize());
        if (CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) || patArchiveReq.getLeavehospitaldistrictcodes().size() == 0) {
            patArchiveReq.setLeavehospitaldistrictcodes(null);
        }
        if (CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) || patArchiveReq.getLeaveldeptcodes().size() == 0) {
            patArchiveReq.setLeaveldeptcodes(null);
        }
        List<PatArchiveOthreInfo> patientInfo = patArchiveService.getPatientInfoQC(patArchiveReq);
        long count = PageUtils.count(new ISelect() {
            @Override
            public void doSelect() {
                patArchiveService.getPatientInfoQC(patArchiveReq);
            }
        });
        return getDataTable2(count, patientInfo);
    }
 
}