package thyyxxk.webserver.controller.lis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.lis.LabRpt;
import thyyxxk.webserver.entity.lis.MzYjReq;
import thyyxxk.webserver.service.lis.LisService;
import thyyxxk.webserver.utils.ResultVoUtil;
import thyyxxk.webserver.utils.StringUtil;

import java.util.List;

@RestController
@RequestMapping("/Lis")
public class LisController {

    @Autowired
    private LisService lisService;

    @GetMapping("/getMzYjReqByPatientId")
    public ResultVo<List<MzYjReq>> getMzYjReqByPatientId(@RequestParam("patientId") String patientId, @RequestParam("reqType") String reqType) {
        if (StringUtil.isBlank(patientId)) {
            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "patientId不能为空！");
        }
        if (StringUtil.isBlank(reqType)) {
            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "reqType不能为空！");
        }
        return ResultVoUtil.success(lisService.getMzYjReqByPatientId(patientId, reqType));
    }

    @GetMapping("/getMzJyReqDetail")
    public ResultVo<MzYjReq> getMzJyReqDetail(@RequestParam("reqNo") int reqNo) {

        return ResultVoUtil.success(lisService.getMzJyReqDetail(reqNo));
    }

    @GetMapping("/getLabRpt")
    public ResultVo<List<LabRpt>> getLabRpt(@RequestParam("reportId") String reportId, @RequestParam("patientId") String patientId) {
        if (StringUtil.isBlank(reportId)) {
            return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "reportId不能为空！");
        }
        return ResultVoUtil.success(lisService.getLabRpt(reportId, patientId));
    }
}
