package com.diagbot.web;


import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
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 com.diagbot.annotation.SysLogger;
import com.diagbot.dto.GetInquiryDetailDTO;
import com.diagbot.dto.HisInquiryDTO;
import com.diagbot.dto.ReadInquiryDTO;
import com.diagbot.dto.RespDTO;
import com.diagbot.dto.SaveInquiryDTO;
import com.diagbot.facade.InquiryInfoFacade;
import com.diagbot.vo.GetInquiryDetailVO;
import com.diagbot.vo.GetLastOtherVO;
import com.diagbot.vo.HisInquirysVO;
import com.diagbot.vo.ReadInquiryVO;
import com.diagbot.vo.SaveInquiryVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author rengb
 * @since 2018-11-23
 */
@RestController
@RequestMapping("/inquiryInfo")
@Api(value = "问诊记录API", tags = { "问诊记录API" })
@SuppressWarnings("unchecked")
public class InquiryInfoController {

    @Autowired
    private InquiryInfoFacade inquiryInfoFacade;

    @ApiOperation(value = "问诊记录保存[by:rengb]")
    @PostMapping("/saveInquiry")
    @SysLogger("saveInquiry")
    @Transactional
    public RespDTO<SaveInquiryDTO> saveInquiry(@Valid @RequestBody SaveInquiryVO saveInquiryVO) {
        return RespDTO.onSuc(inquiryInfoFacade.saveInquiry(saveInquiryVO));
    }

    @ApiOperation(value = "问诊记录回显[by:rengb]")
    @PostMapping("/readInquiry")
    @SysLogger("readInquiry")
    public RespDTO<ReadInquiryDTO> readInquiry(@Valid @RequestBody ReadInquiryVO readInquiryVO) {
        return RespDTO.onSuc(inquiryInfoFacade.readInquiry(readInquiryVO));
    }
    
    @ApiOperation(value = "获取最近一次其他史信息[by:rengb]")
    @PostMapping("/getLastOther")
    @SysLogger("getLastOther")
    public RespDTO<String> getLastOther(@Valid @RequestBody GetLastOtherVO getLastOtherVO) {
        return RespDTO.onSuc(inquiryInfoFacade.getLastOther(getLastOtherVO));
    }

    @ApiOperation(value = "历史病历列表[by:rengb]")
    @PostMapping("/hisInquirys")
    @SysLogger("hisInquirys")
    public RespDTO<List<HisInquiryDTO>> hisInquirys(@Valid @RequestBody HisInquirysVO hisInquirysVO) {
        return RespDTO.onSuc(inquiryInfoFacade.hisInquirys(hisInquirysVO));
    }

    @ApiOperation(value = "病历详情[by:rengb]")
    @PostMapping("/getInquiryDetail")
    @SysLogger("getInquiryDetail")
    public RespDTO<GetInquiryDetailDTO> getInquiryDetail(@Valid @RequestBody GetInquiryDetailVO getInquiryDetailVO) {
        return RespDTO.onSuc(inquiryInfoFacade.getInquiryDetail(getInquiryDetailVO));
    }


}
