Browse Source

检验检查状态通知

lighter 9 months ago
parent
commit
8b355abe5c

+ 70 - 0
src/main/java/thyyxxk/webserver/controller/api/medicallaboratory/MedicalLaboratoryController.java

@@ -1,10 +1,80 @@
 package thyyxxk.webserver.controller.api.medicallaboratory;
 
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.controller.api.medicallaboratory.model.State;
+import thyyxxk.webserver.dao.his.api.MedicalLaboratoryDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.util.Date;
 
 @RestController
 @RequestMapping("/medicalLaboratory")
 public class MedicalLaboratoryController {
+    private final MedicalLaboratoryDao dao;
+
+    @Autowired
+    public MedicalLaboratoryController(MedicalLaboratoryDao dao) {
+        this.dao = dao;
+    }
 
+    @PassToken
+    @PostMapping("/notify")
+    public ResultVo<String> notify(@RequestBody MedicalLaboratoryState body) {
+        if (null == body.getReqTime()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请时间不能为空。");
+        }
+        if (null == body.getReportState()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报告状态不能为空。");
+        }
+        if (null == body.getCategory()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请类别不能为空。");
+        }
+        if (null == body.getPatType()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者类别不能为空。");
+        }
+        if (StringUtil.isBlank(body.getPatNo())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者门诊id/住院号不能为空。");
+        }
+        if (StringUtil.isBlank(body.getPatName())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者姓名不能为空。");
+        }
+        if (StringUtil.isBlank(body.getDeptName())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请科室名称不能为空。");
+        }
+        if (StringUtil.isBlank(body.getDoctorName())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请医生姓名不能为空。");
+        }
+        if (StringUtil.isBlank(body.getReportTitle())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报告标题不能为空。");
+        }
+        if (body.getReportState() == State.PROCESSING) {
+            if (null == body.getTestTime()) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "检查/检验时间不能为空。");
+            }
+        }
+        if (body.getReportState() == State.PUBLISHED) {
+            if (StringUtil.isBlank(body.getReportId())) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报告状态为[发布]时,报告id不能为空。");
+            }
+            if (null == body.getPublishTime()) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "报告状态为[发布]时,发布时间不能为空。");
+            }
+        }
+        MedicalLaboratoryState existOne = dao.selectById(body.getReqNo());
+        if (null == existOne) {
+            body.setCreateTime(new Date());
+            dao.insert(body);
+            return ResultVoUtil.success(body.getReqNo());
+        }
+        dao.updateById(body);
+        return ResultVoUtil.success(body.getReqNo());
+    }
 }

+ 3 - 0
src/main/java/thyyxxk/webserver/controller/api/medicallaboratory/MedicalLaboratoryState.java

@@ -1,5 +1,7 @@
 package thyyxxk.webserver.controller.api.medicallaboratory;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
 import thyyxxk.webserver.controller.api.medicallaboratory.model.Category;
 import thyyxxk.webserver.controller.api.medicallaboratory.model.PatientType;
@@ -13,6 +15,7 @@ public class MedicalLaboratoryState {
 	/**
 	 * 医院申请号
 	 */
+	@TableId(type = IdType.INPUT)
 	private String reqNo;
 
 	/**

+ 9 - 0
src/main/java/thyyxxk/webserver/dao/his/api/MedicalLaboratoryDao.java

@@ -0,0 +1,9 @@
+package thyyxxk.webserver.dao.his.api;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import thyyxxk.webserver.controller.api.medicallaboratory.MedicalLaboratoryState;
+
+@Mapper
+public interface MedicalLaboratoryDao extends BaseMapper<MedicalLaboratoryState> {
+}