package thyyxxk.webserver.controller.inpatient.casefrontsheet;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.dictionary.SearchDataParam;
import thyyxxk.webserver.service.inpatient.casefrontsheet.CaseFrontSheetSearchService;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/sheetSearch")
public class SheetSearchController {
    private final CaseFrontSheetSearchService service;

    public SheetSearchController(CaseFrontSheetSearchService service) {
        this.service = service;
    }

    @PostMapping("/execute")
    public ResultVo<List<CodeName>> sheetSearch(@Validated @RequestBody SearchDataParam param) {
        return service.sheetSearch(param);
    }

    @GetMapping("/getSsfzSurgeriesByIcd")
    public ResultVo<List<CodeName>> getSsfzSurgeriesByIcd(@RequestParam("bah") String bah,
                                                          @RequestParam("times") int times,
                                                          @RequestParam("icd") String icd) {
        return service.getSsfzSurgeriesByIcd(bah, times, icd);
    }

    @PassToken
    @GetMapping("/fetchStatisticsBySeason")
    public void fetchStatisticsBySeason(HttpServletResponse response, String season) {
        service.fetchStatisticsBySeason(response, season);
    }


}
