package thyyxxk.webserver.controller.zhuyuanyizheng;

import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.criticalValue.CriticalValue;
import thyyxxk.webserver.entity.criticalValue.request.CriticalValueFromTest;
import thyyxxk.webserver.service.zhuyuanyisheng.PatientCriticalValuesService;

import java.util.List;

@RestController
@RequestMapping("/criticalValue")
public class CriticalValuesController {

    private final PatientCriticalValuesService service;


    public CriticalValuesController(PatientCriticalValuesService service) {
        this.service = service;
    }

    @GetMapping("/acceptCriticalValues")
    @PassToken
    public ResultVo<String> acceptCriticalValues(@RequestParam("message") String message) {
        return service.acceptCriticalValues(message);
    }

    @PassToken
    @PostMapping("/criticalValueAssembly")
    public ResultVo<String> criticalValueAssembly(@RequestBody CriticalValueFromTest request) {
        return service.checkTheCriticalValue(request);
    }

    @GetMapping("/getCriticalValues")
    public ResultVo<List<CriticalValue>> getCriticalValues(@RequestParam("patNo") String patNo,
                                                           @RequestParam(value = "id", required = false) Integer id) {
        return service.getCriticalValues(patNo, id);
    }

    @GetMapping("/getExportCriticalValues")
    public ResultVo<List<CriticalValue>> getExportCriticalValues(@RequestParam("label") String label) {
        return service.getExportCriticalValues(label);
    }

    @GetMapping("/handleZyCriticalValue")
    public ResultVo<String> handleZyCriticalValue(@RequestParam("id") Integer id) {
        return service.handleZyCriticalValue(id);
    }
}
