package thyyxxk.webserver.controller.zhuyuanyizheng;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.zhuyuanyisheng.contagiousdisease.CrbMainCard;
import thyyxxk.webserver.service.zhuyuanyisheng.ContagiousDiseaseService;

import java.util.List;

@RestController
@RequestMapping("/contagiousDisease")
public class ContagiousDiseaseController {

    private final ContagiousDiseaseService service;

    @Autowired
    public ContagiousDiseaseController(ContagiousDiseaseService service) {
        this.service = service;
    }

    @GetMapping("/getContagiousDiseaseByPatNo")
    public ResultVo<List<CrbMainCard>> getContagiousDiseaseByPatNo(@RequestParam("patNo") String patNo) {
        return service.getContagiousDiseaseByPatNo(patNo);
    }

    @PostMapping("/confirmCrb")
    public ResultVo<String> confirmCrb(@RequestBody CrbMainCard param) {
        return service.confirmCrb(param);
    }

    @PostMapping("/updateCrb")
    public ResultVo<String> updateCrb(@RequestBody CrbMainCard param) {
        return service.updateCrb(param);
    }

    @GetMapping("/delCrb")
    public ResultVo<String> delCrb(@RequestParam("patNo") String patNo,
                                   @RequestParam("times") Integer times,
                                   @RequestParam("cardNo") String cardNo) {
        return service.delCrb(patNo, times, cardNo);
    }

    @PostMapping("/infectiousDiseasesAreRequired")
    public ResultVo<JSONObject> infectiousDiseasesAreRequired(@RequestBody ContagiousDiseaseService.PatientDiagnosisIsCrb p) {
        return service.infectiousDiseasesAreRequired(p);
    }

}
