Browse Source

回退门诊病历

xiaochan 1 month ago
parent
commit
871bcb264a

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>13.4.4</version>
+    <version>13.4.7</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 10 - 0
src/main/java/thyyxxk/webserver/controller/outpatient/thmz/MzEmrController.java

@@ -28,6 +28,16 @@ public class MzEmrController {
     @Autowired
     private MzEmrService service;
 
+    @PostMapping("/queryMzEmrTree")
+    public ResultVo<List<MzEmrPatientData>> queryMzEmrTree(@RequestBody MzEmrPatientVo param) {
+        return ResultVoUtil.success(service.queryMzEmrTree(param));
+    }
+
+    @PostMapping("/saveMzEmrModel")
+    public ResultVo<String> saveMzEmrModel(@RequestBody MzEmrPatientData param) {
+        return service.saveMzEmrModel(param);
+    }
+
     @GetMapping("/getMzEmrModel")
     public ResultVo<JSONArray> getMzEmrModel() {
         return ResultVoUtil.success(service.getMzEmrModel());

+ 72 - 0
src/main/java/thyyxxk/webserver/service/outpatient/thmz/MzEmrService.java

@@ -46,6 +46,78 @@ public class MzEmrService {
     private final EmrEditor emr;
     private final UserCache userCache;
     private final DeptCache deptCache;
+    private final EmrPatientDao emrPatientDao;
+
+    /**
+     * @description:查询 1住院 2当前  3历史记录
+     * @author: lihong
+     * @date: 2023/10/18 16:51
+     * @param: type
+     * @return: java.util.Map<java.lang.String, java.util.List < com.alibaba.fastjson.JSONObject>>
+     **/
+    public List<MzEmrPatientData> queryMzEmrTree(MzEmrPatientVo param) {
+        List<MzEmrPatientData> result;
+        QueryWrapper<MzEmrPatientData> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("pat_no", param.getPatientId());
+        String strTemplate = "";
+        List<MzEmrPatientData> list;
+        if (param.getType() == 1) {
+            String patNo = dao.selectPatNo(param.getPatientId());
+            list = emrPatientDao.selectDataByPatNo(patNo);
+            strTemplate = "第{}住院记录";
+        } else if (param.getType() == 2) {
+            queryWrapper.eq("times", param.getTimes());
+            list = dao.selectList(queryWrapper);
+            return list;
+        } else {
+            strTemplate = "第{}就诊记录";
+            queryWrapper.ne("times", param.getTimes());
+            list = dao.selectList(queryWrapper);
+        }
+        result = getTree(list, strTemplate);
+        return result;
+    }
+
+    private List<MzEmrPatientData> getTree(List<MzEmrPatientData> list, String strTemplate) {
+        if (CollUtil.isEmpty(list)) return list;
+        List<MzEmrPatientData> result = new ArrayList<>();
+        Map<Integer, List<MzEmrPatientData>> collect = list.stream().collect(Collectors.groupingBy(MzEmrPatientData::getTimes));
+        int index = 1;
+        for (Integer key : collect.keySet()) {
+            MzEmrPatientData tem = new MzEmrPatientData();
+            tem.setId(index);
+            tem.setName(StrUtil.format(strTemplate, key));
+            tem.setChildren(collect.get(key));
+            result.add(tem);
+        }
+        return result;
+    }
+
+    public ResultVo<String> saveMzEmrModel(MzEmrPatientData param) {
+        AssertUtil.isnotBlank(param.getEmrDocumentId(), "文档id不能为空");
+        AssertUtil.isnotBlank(param.getUserIdCode(), "用户不能为空");
+        JSONObject saveJson = new JSONObject();
+        saveJson.put("document", param.getDocumentData());
+        try {
+            emr.saveDocument(saveJson);
+        } catch (Exception e) {
+            return ResultVoUtil.fail(ExceptionEnum.EMR_SAVE, "病历保存错误,请重试!" + e.getMessage());
+        }
+        QueryWrapper<MzEmrPatientData> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("emr_document_id", param.getEmrDocumentId());
+        MzEmrPatientData mzEmrPatientData = dao.selectOne(queryWrapper);
+        if (mzEmrPatientData == null) {
+            param.setCreateId(param.getUserIdCode());
+            dao.insert(param);
+        } else {
+            param.setModifyId(param.getUserIdCode());
+            param.setModifyDate(new Date());
+            UpdateWrapper<MzEmrPatientData> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.eq("emr_document_id", param.getEmrDocumentId());
+            dao.update(param, updateWrapper);
+        }
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE, "保存成功");
+    }
 
 
     public JSONArray getMzEmrModel() {