|  | @@ -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());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |