package thyyxxk.webserver.controller.medicaladvice.patientinfo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.inpatient.ZyActpatient;
import thyyxxk.webserver.entity.medicaladvice.medicamanage.MzZyReq;
import thyyxxk.webserver.entity.medicaladvice.medicamanage.ZyBedPreMsg;
import thyyxxk.webserver.entity.medicaladvice.medicamanage.patientinfo.ZyBedMi;
import thyyxxk.webserver.entity.medicaladvice.medicamanage.patientinfo.ZyBedMiParam;
import thyyxxk.webserver.service.medicaladvice.patientinfo.AdjustBedService;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;
import java.util.Map;

/**
 * @Description:整理床位
 * @Author:lihong
 * @Date: 2023/5/31
 */
@RestController
@RequestMapping("/medicalAdvice/adjustBed/")
public class AdjustBedController {
    @Autowired
    private AdjustBedService service;


    @PostMapping("preAllocationBed")
    @PassToken
    public ResultVo<String> preAllocationBed(@RequestBody MzZyReq mzZyReq){
        return service.preAllocationBed(mzZyReq);
    }

    @PostMapping("confirmPreBed")
    public ResultVo<String> confirmPreBed(@RequestBody ZyBedPreMsg msg){
        return service.confirmPreBed(msg);
    }

    @PostMapping("queryZyBedPreMsg")
    public ResultVo<IPage<ZyBedPreMsg>> queryZyBedPreMsg(@RequestBody ZyBedPreMsg msg){
        return service.queryZyBedPreMsg(msg);
    }

    @GetMapping("queryPreAdmiss")
    public ResultVo<List<ZyActpatient>> queryPreAdmiss(@RequestParam("ward") String ward) {
        List<ZyActpatient> list = service.queryPreAdmiss(ward);
        if (null == list || list.isEmpty()) {
            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有待接收的患者。");
        }
        return ResultVoUtil.success(list);
    }

    @PostMapping("receivePatient")
    public ResultVo<String> receivePatient(@RequestBody ZyActpatient actpatient) {
        service.receivePatient(actpatient);
        return ResultVoUtil.success("接收成功。");
    }

    @PostMapping("getIdleBedNoList")
    public ResultVo<List<Map>> getIdleBedNoList(@RequestBody ZyBedPreMsg msg){
        return service.getIdleBedNoList(msg);
    }

    @PostMapping("queryZybedMi")
    public ResultVo<Map<String,Object>> queryZybedMi(@RequestBody ZyBedMi param){
        return ResultVoUtil.success(service.queryZybedMi(param));
    }

    @PostMapping("clearBed")
    public ResultVo<String> clearBed(@RequestBody ZyBedMi param){
        return service.clearBed(param);
    }

    @PostMapping("addBed")
    public ResultVo<String> addBed(@RequestBody ZyBedMi param){
        return service.addBed(param);
    }

    @PostMapping("saveBed")
    public ResultVo<String> saveBed(@RequestBody ZyBedMiParam params){
        return service.saveBed(params);
    }
    @PostMapping("queryIsPreBed")
    public ResultVo<String> queryIsPreBed(@RequestBody ZyBedMi param){
        return service.queryIsPreBed(param);
    }

}
