package thyyxxk.webserver.controller.zhuyuanyizheng;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.SerializeUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.dao.his.zhuyuanyisheng.JianYanJianChaDao;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
import thyyxxk.webserver.entity.dictionary.CyComboGrid;
import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.*;
import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.vo.JcJyPartOrSample;
import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.vo.ViewInspectionItemDetailsVo;
import thyyxxk.webserver.entity.zhuyuanyisheng.query.ChaXunJianChaHeJianYan;
import thyyxxk.webserver.service.zhuyuanyisheng.JianYanJianChaShenQingService;
import thyyxxk.webserver.utils.ListUtil;
import thyyxxk.webserver.utils.R;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 描述： 检查申请控制器
 * </p>
 *
 * @author xc
 * @date 2022-02-11 09:09
 */
@RequestMapping(path = {"/jianYanJianChaShenQing", "/checkTheCallbacks"})
@RestController
@RequiredArgsConstructor
public class JianYanJianChaController {
    private final JianYanJianChaShenQingService server;
    private final JianYanJianChaDao dao;


    @PostMapping("/huoQuJianChaShenQing")
    public ResultVo<List<YshYjReq>> huoQuJianChaShenQing(@RequestBody @Validated ChaXunJianChaHeJianYan param) {
        return server.huoQuJianChaShenQing(param);
    }

    @GetMapping("/huoQuShengQingXiangQing")
    public ResultVo<Map<String, Object>> huoQuShengQingXiangQing(@RequestParam("reqNo") Integer reqNo) {
        return server.huoQuShengQingXiangQing(reqNo);
    }

    @GetMapping("/getTemplateGrouping")
    public ResultVo<List<JcZdClass>> getTemplateGrouping(@RequestParam("itemType") Integer itemType,
                                                         @RequestParam("templateType") Integer templateType) {
        return server.getTemplateGrouping(itemType, templateType);
    }

    @GetMapping("/getTemplateByCodeAndType")
    public ResultVo<List<Map<String, String>>> getTemplateByCodeAndType(@RequestParam("code") String code,
                                                                        @RequestParam("type") String type) {
        return server.getTemplateByCodeAndType(code, type);
    }


    @GetMapping("/getTemplate")
    public ResultVo<List<JcZdClass>> getTemplate(@RequestParam("itemType") Integer itemType,
                                                 @RequestParam("templateType") Integer templateType) {
        return server.getTemplate(itemType, templateType);
    }

    @GetMapping("/shanShuJianChaMuBan")
    public ResultVo<String> shanShuJianChaMuBan(@RequestParam("code") String code,
                                                @RequestParam("deptCode") String deptCode) {
        return server.shanShuJianChaMuBan(code, deptCode);
    }

    @GetMapping("/huoMuShuoMingMuBan")
    public ResultVo<IPage<YshZdYjTemplate>> huoMuShuoMingMuBan(@RequestParam("name") String name,
                                                               @RequestParam("fenLei") Integer fenLei,
                                                               @RequestParam("total") long total,
                                                               @RequestParam("currentPage") long currentPage) {
        return server.huoMuShuoMingMuBan(name, fenLei, total, currentPage);
    }

    @PostMapping("/shouMingMuBanChaoZuo")
    public ResultVo<String> shouMingMuBanChaoZuo(@RequestBody YshZdYjTemplate param) {
        return server.shouMingMuBanChaoZuo(param);
    }

    @GetMapping("/diagnosisInOurHospital")
    public ResultVo<List<GetDropdownBox>> diagnosisInOurHospital(@RequestParam("name") String name) {
        return server.diagnosisInOurHospital(name);
    }

    @GetMapping("/jianChaJianYanMuBanMing")
    public ResultVo<Boolean> jianChaJianYanMuBanMing(@RequestParam("name") String name,
                                                     @RequestParam("reqType") String reqType) {
        return server.jianChaJianYanMuBanMing(name, reqType);
    }

    @PostMapping("/baoCunJianChaJianYanMuBan")
    public ResultVo<String> baoCunJianChaJianYanMuBan(@RequestBody ZyTcYj param) {
        return server.baoCunJianChaJianYanMuBan(param);
    }

    @PostMapping("/baoCunJianYanJianCha")
    public ResultVo<List<Integer>> baoCunJianYanJianCha(@RequestBody @Validated TianJiaJianChaJianYan param) {
        return server.baoCunJianYanJianCha(param);
    }

    @PostMapping("/huoQuJianYan")
    public ResultVo<List<YshYjReq>> huoQuJianYan(@RequestBody @Validated ChaXunJianChaHeJianYan param) {
        return server.huoQuJianYan(param);
    }

    @GetMapping("/jianYanFenLei")
    public ResultVo<IPage<JcZdClass>> huoQuJianYanMing(@RequestParam("total") long total,
                                                       @RequestParam("currentPage") long currentPage,
                                                       @RequestParam("leiXing") Integer leiXing) {
        return server.huoQuJianYanMing(total, currentPage, leiXing);
    }

    @GetMapping("/biaoBenShuJu")
    public ResultVo<List<GetDropdownBox>> biaoBenShuJu(@RequestParam("name") String name) {
        return server.biaoBenShuJu(name);
    }

    @GetMapping("/viewInspectionItemDetails")
    public ResultVo<ViewInspectionItemDetailsVo> viewInspectionItemDetails(@RequestParam("orderCode") String orderCode,
                                                                           @RequestParam(value = "isCheck", defaultValue = "true") Boolean isCheck) {
        return server.viewInspectionItemDetails(orderCode, isCheck);
    }

    @GetMapping("/shanChuJianChaJianYan")
    public ResultVo<String> shanChuJianChaJianYan(@RequestParam("reqNo") Integer reqNo,
                                                  @RequestParam("patNo") String patNo,
                                                  @RequestParam("times") Integer times) {
        return server.shanChuJianChaJianYan(reqNo, patNo, times);
    }

    @GetMapping("/queryCheckTextResults")
    public ResultVo<Map<String, Object>> queryCheckTextResults(@RequestParam("patNo") String patNo,
                                                               @RequestParam("reqNo") String reqNo) {
        return server.queryCheckTextResults(patNo, reqNo);
    }

    @GetMapping("/getJyJcZdTree")
    @PassToken
    public ResultVo<Map<String, List<JyJcItem>>> getJyJcZdTree() {
        return server.getJyJcZdTree();
    }

    @GetMapping("/getAncillaryInformation")
    public ResultVo<YshYjReq> getAncillaryInformation(@RequestParam("patNo") String patNo,
                                                      @RequestParam("times") Integer times) {
        return server.getAncillaryInformation(patNo, times);
    }

    @PostMapping("/push")
    @PassToken
    public ResultVo<String> checkTheCallbacks(@RequestBody @Validated CheckTheCallbacks param) {
        return server.checkTheCallbacks(param);
    }

    @GetMapping("/getJcIdByPatNo")
    public ResultVo<List<String>> getJcIdByPatNo(@RequestParam("patNo") String patNo) {
        return server.getJcIdByPatNo(patNo);
    }

    @GetMapping("/getExamineDetail")
    public ResultVo<List<JianChaJieGuo>> getExamineDetail(@RequestParam("jcId") String jcId) {
        return server.getExamineDetail(jcId);
    }


    @GetMapping("/getExamineIllustrate")
    public ResultVo<JSONObject> getExamineIllustrate(@RequestParam("orderCode") String orderCode,
                                                     @RequestParam("isCheck") Boolean isCheck) {
        return server.getExamineIllustrate(orderCode, isCheck);
    }

    @PostMapping("/printListReqNo")
    @PassToken
    public ResultVo<Object> printListReqNo(@RequestBody List<Integer> reqNo) {
        return server.printListReqNo(reqNo);
    }

    @GetMapping("/buWeiShuJu")
    public ResultVo<List<GetDropdownBox>> buWeiShuJu(String name) {
        return server.buWeiShuJu(name);
    }

    @GetMapping("/selectBuWeiAll")
    public ResultVo<List<GetDropdownBox>> selectBuWeiAll() {
        return server.selectBuWeiAll();
    }

    @GetMapping("/getJySample")
    public ResultVo<List<JcJyPartOrSample>> getJySample() {
        return R.ok(dao.getJySample());
    }

    @GetMapping("/getJcPartCode")
    public ResultVo<List<JcJyPartOrSample>> getJcPartCode() {
        return R.ok(dao.getJcPartCode());
    }
}
