package com.docus.server.message.controller;

import com.docus.server.message.busservice.FsBusinessService;
import com.docus.server.message.busservice.NkBusinessService;
import com.docus.server.message.controller.vo.PushInfoVo;
import com.docus.server.message.dto.Message;
import com.docus.server.message.dto.MessageResponse;
import com.docus.server.message.dto.Msg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author WYBDEV
 */
@Api("佛山三院医院")
@RestController
@Slf4j
@RequestMapping("/emr_medical_record/font")
public class FssyHospitalController {

    @Autowired
    private FsBusinessService fsBusinessService;

    @PostMapping("/pushInfo")
    @ResponseBody
    @ApiOperation("佛山三院电子病例提交消息接收")
    public Msg wsRecordSubmit(PushInfoVo pushInfoVo) {
        log.info("佛山三院电子病例提交消息接收：{}", pushInfoVo);
        if (pushInfoVo == null) {
            return Msg.pushFail("参数不得为空");
        }
        if (StringUtils.isBlank(pushInfoVo.getDataType() + "")) {
            return Msg.pushFail("提交类型不得为空");
        }
        if (StringUtils.isBlank(pushInfoVo.getInpNo())) {
            return Msg.pushFail("住院号不得为空");
        }
        if (StringUtils.isBlank(pushInfoVo.getVisitId())) {
            return Msg.pushFail("住院次数不得为空");
        }
        if (StringUtils.isBlank(pushInfoVo.getSubmitCode())) {
            return Msg.pushFail("提交时间不得为空");
        }
        if(pushInfoVo.getDataType()==1){
            if (fsBusinessService.pushInfoEmr(pushInfoVo)) {
                return Msg.fail("成功");
            }
        }
        if(pushInfoVo.getDataType()==2){
            if (fsBusinessService.pushInfoNurs(pushInfoVo)) {
                return Msg.fail("成功");
            }
        }
        return Msg.pushFail("失败");
    }


}
