Browse Source

门诊电子病历优化完成

xiaochan 1 month ago
parent
commit
d7d07ccdd0

+ 1 - 1
pom.xml

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

+ 23 - 2
src/main/java/thyyxxk/webserver/controller/outpatient/thmz/MzEmrController.java

@@ -2,6 +2,7 @@ package thyyxxk.webserver.controller.outpatient.thmz;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -11,7 +12,10 @@ import thyyxxk.webserver.entity.outpatient.thmz.MzEmrPatientVo;
 import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddDirReq;
 import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddFileReq;
 import thyyxxk.webserver.entity.outpatient.thmz.req.MzSaveFileReq;
+import thyyxxk.webserver.entity.outpatient.thmz.vo.MzVisitListVo;
+import thyyxxk.webserver.service.externalhttp.emr.EmrEditor;
 import thyyxxk.webserver.service.outpatient.thmz.MzEmrService;
+import thyyxxk.webserver.utils.R;
 import thyyxxk.webserver.utils.ResultVoUtil;
 
 import javax.validation.Valid;
@@ -25,9 +29,10 @@ import java.util.List;
 @Slf4j
 @RestController
 @RequestMapping("/mzEmr")
+@RequiredArgsConstructor
 public class MzEmrController {
-    @Autowired
-    private MzEmrService service;
+    private final MzEmrService service;
+    private final EmrEditor emr;
 
     @PostMapping("/queryMzEmrTree")
     public ResultVo<List<MzEmrPatientData>> queryMzEmrTree(@RequestBody MzEmrPatientVo param) {
@@ -108,4 +113,20 @@ public class MzEmrController {
         return service.endOfVisit(patientNo, times);
     }
 
+    @GetMapping("/getMzVisitListVo")
+    public ResultVo<List<MzVisitListVo>> getMzVisitListVo(@RequestParam("patNo") String patNo) {
+        return service.getMzVisitListVo(patNo);
+    }
+
+    @GetMapping("/getTemplate")
+    public ResultVo<JSONObject> getTemplate(@RequestParam("categoryCode") String categoryCode,
+                                            @RequestParam("categoryId") String categoryId) {
+        return R.ok(emr.getTemplate(categoryCode, categoryId));
+    }
+
+    @PostMapping("/addFileV2")
+    public ResultVo<String> addFileV2(@RequestBody @Valid MzEmrService.AddFileV2 params) {
+        return service.addFileV2(params);
+    }
+
 }

+ 11 - 0
src/main/java/thyyxxk/webserver/dao/his/outpatient/thmz/MzEmrDao.java

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.outpatient.thmz.MzEmrPatientData;
 import thyyxxk.webserver.entity.outpatient.thmz.MzEmrPatientVo;
+import thyyxxk.webserver.entity.outpatient.thmz.vo.MzVisitListVo;
 import thyyxxk.webserver.service.outpatient.thmz.MzEmrService;
 
 import java.util.List;
@@ -54,4 +55,14 @@ public interface MzEmrDao extends BaseMapper<MzEmrPatientData> {
             "WHERE a.emr_document_id = #{documentId}")
     MzEmrService.UpdateFileData getSaveData(String documentId);
 
+    @Select("select patient_id,\n" +
+            "       visit_dept,\n" +
+            "       visit_dept_name = (select name from zd_unit_code where code = visit_dept),\n" +
+            "       visit_date,\n" +
+            "       times\n" +
+            "from mz_visit_list\n" +
+            "where patient_id = #{patientId}\n" +
+            "order by visit_date\n")
+    List<MzVisitListVo> getMzVisitListVo(@Param("patientId") String patientId);
+
 }

+ 19 - 0
src/main/java/thyyxxk/webserver/entity/outpatient/thmz/vo/MzVisitListVo.java

@@ -0,0 +1,19 @@
+package thyyxxk.webserver.entity.outpatient.thmz.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+@Data
+public class MzVisitListVo {
+    private String patientId;
+    private Integer times;
+    private String visitDept;
+    private String visitDeptName;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm")
+    private Date visitDate;
+}

+ 7 - 0
src/main/java/thyyxxk/webserver/service/externalhttp/emr/EmrEditor.java

@@ -3,6 +3,7 @@ package thyyxxk.webserver.service.externalhttp.emr;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.dtflys.forest.annotation.*;
+import springfox.documentation.spring.web.json.Json;
 import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrServer;
 
 @BaseRequest(baseURL = "${emrUrl}", interceptor = EmrServer.EmrInterceptor.class)
@@ -67,4 +68,10 @@ public interface EmrEditor {
 
     @Post("/document/data/fill")
     JSONObject dataFill(@JSONBody Object jsonObject);
+
+    @Get("/template/{categoryCode}?categoryId={categoryId}")
+    JSONObject getTemplate(@Var("categoryCode") String categoryCode, @Var("categoryId") String categoryId);
+
+    @Get("/category/{categoryId}")
+    JSONObject getCategoryInfo(@Var("categoryId") String categoryId);
 }

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

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.outpatient.thmz.MzEmrDao;
@@ -24,12 +25,14 @@ import thyyxxk.webserver.entity.outpatient.thmz.MzEmrPatientVo;
 import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddDirReq;
 import thyyxxk.webserver.entity.outpatient.thmz.req.MzEmrAddFileReq;
 import thyyxxk.webserver.entity.outpatient.thmz.req.MzSaveFileReq;
+import thyyxxk.webserver.entity.outpatient.thmz.vo.MzVisitListVo;
 import thyyxxk.webserver.service.externalhttp.emr.EmrEditor;
 import thyyxxk.webserver.service.hutoolcache.DeptCache;
 import thyyxxk.webserver.service.hutoolcache.UserCache;
 import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrServer;
 import thyyxxk.webserver.utils.*;
 
+import javax.validation.constraints.NotBlank;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -41,6 +44,7 @@ import java.util.stream.Collectors;
  * @Author:lihong
  * @Date: 2023/10/18
  */
+@Slf4j
 @Service
 @RequiredArgsConstructor
 public class MzEmrService {
@@ -325,5 +329,64 @@ public class MzEmrService {
         return R.fail(ExceptionEnum.LOGICAL_ERROR, "操作失败,可能原因就诊医生不是您,或者已经完成了结束就诊了。");
     }
 
+    public ResultVo<List<MzVisitListVo>> getMzVisitListVo(String patNo) {
+        return R.ok(dao.getMzVisitListVo(patNo));
+    }
+
+    @Data
+    public static class AddFileV2 {
+
+        @NotBlank(message = "门诊号不能为空")
+        private String patNo;
+        private Integer times;
+
+        @NotBlank(message = "病历编码不能为空")
+        private String categoryCode;
+
+        @NotBlank(message = "病历Id不能为空")
+        private String categoryId;
+    }
+
+
+    public ResultVo<String> addFileV2(AddFileV2 params) {
+        JSONObject categoryInfo = emr.getCategoryInfo(params.getCategoryId());
+        if (categoryInfo.getInteger("valid") == 0) {
+            return R.fail(ExceptionEnum.LOGICAL_ERROR, "该病历模板已失效,请重新选择。");
+        }
+        String name = categoryInfo.getString("name");
+        JSONObject template = emr.getTemplate(params.getCategoryCode(), params.getCategoryId());
+        String id = SnowFlakeId.instance().nextId();
+        template.put("_id", id);
+        String userId = TokenUtil.getInstance().getTokenUserId();
+        JSONObject properties = template.getJSONObject("properties");
+        properties.put("creator", userId);
+        properties.put("createTime", DateUtil.now());
+
+        String categoryCode = properties.getString("categoryCode");
+        JSONObject addFileDocument = new JSONObject() {{
+            put("document", template);
+        }};
+        try {
+            emr.saveDocument(addFileDocument);
+        } catch (Exception e) {
+            return ResultVoUtil.fail(ExceptionEnum.EMR_SAVE, "病历保存错误,请重试!" + e.getMessage());
+        }
+        MzEmrPatientData insert = MzEmrPatientData.builder()
+                .emrCategoryCode(categoryCode)
+                .name(name)
+                .emrName(name)
+                .createId(userId)
+                .parent(null)
+                .patNo(params.getPatNo())
+                .times(params.getTimes())
+                .emrDocumentId(id)
+                .build();
+        dao.insert(insert);
+        return R.ok();
+    }
+
+    public ResultVo<JSONObject> getUserConfig() {
+
+    }
 
 }