package thyyxxk.webserver.controller.inpatient;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.aop.interfaces.NeedYbCode;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
import thyyxxk.webserver.entity.inpatient.ZyActpatient;
import thyyxxk.webserver.entity.projectEntry.DrugReturnForm;
import thyyxxk.webserver.service.inpatient.XiangMuLuRuService;

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

/**
 * <p>
 * 描述： 项目录入
 * </p>
 *
 * @author xc
 * @date 2021-08-02 10:36
 */
@RestController
@RequestMapping("/xmlr")
public class XiangMuLuRuController {
    private final XiangMuLuRuService service;

    @Autowired
    public XiangMuLuRuController(XiangMuLuRuService service) {
        this.service = service;
    }

    @PostMapping("/getHuanZheFeiYong")
    public ResultVo<Page<ZyDetailCharge>> getHuanZheFeiYong(@RequestBody ZyDetailCharge param) {
        return service.getHuanZheFeiYong(param);
    }

    @GetMapping("/getChargeCode")
    public ResultVo<List<GetDropdownBox>> getChargeCode(@RequestParam("pyCode") String pyCode) {
        return service.getChargeCode(pyCode);
    }

    @PostMapping("/xiangMuTuiFei")
    public ResultVo<String> xiangMuTuiFei(@RequestBody ZyDetailCharge param) {
        return service.xiangMuTuiFei(param, true);
    }

    @GetMapping("/getMuBan")
    public ResultVo<IPage<ZyDetailCharge>> getMuBan(@RequestParam("deptCode") String deptCode,
                                                    @RequestParam("currentPage") long currentPage,
                                                    @RequestParam("pageSize") long pageSize,
                                                    @RequestParam("total") long total) {
        return service.getMuBan(deptCode, currentPage, pageSize, total);
    }

    @GetMapping("/getMuBanXinXi")
    public ResultVo<List<ZyDetailCharge>> getMuBanXinXi(@RequestParam("patternName") String patternName,
                                                        @RequestParam("opIdCode") String opIdCode) {
        return service.getMuBanXinXi(patternName, opIdCode);
    }

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

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

    @GetMapping("/queryXiangMu")
    public ResultVo<List<ZyDetailCharge>> queryXiangMu(@RequestParam("pyCode") String pyCode,
                                                       @RequestParam("xiangMuHuoYaoPinFlag") Integer xiangMuHuoYaoPinFlag) {
        return service.queryXiangMu(pyCode, xiangMuHuoYaoPinFlag);
    }


    @PostMapping("/xiangMuFeiYongShangChuan")
    @NeedYbCode
    public ResultVo<String> xiangMuFeiYongShangChuan(@RequestBody ZyDetailCharge param) {
        return service.xiangMuFeiYongShangChuan(param);
    }

    @PostMapping("/shangChuanMuBan")
    public ResultVo<String> shangChuanMuBan(@RequestBody ZyDetailCharge zyDetailCharge) {
        return service.shangChuanMuBan(zyDetailCharge);
    }

    @GetMapping("/yiZhuTuiFeiPiPei")
    public ResultVo<String> yiZhuTuiFeiPiPei(@RequestParam("inpatientNo") String inpatientNo,
                                             @RequestParam("admissTimes") Integer admissTimes,
                                             @RequestParam("deptCode") String deptCode) {
        return service.yiZhuTuiFeiPiPei(inpatientNo, admissTimes, deptCode);
    }

    @GetMapping("/shanChuMuBan")
    public ResultVo<String> shanChuMuBan(@RequestParam("patterName") String patterName,
                                         @RequestParam("opIdCode") String opIdCode) {
        return service.shanChuMuBan(patterName, opIdCode);
    }

    @GetMapping("/getPyCode")
    public ResultVo<ZyDetailCharge> getPyCode(String inputStr) {
        return service.getPyCode(inputStr);
    }

    @GetMapping("/getBingQuDuiYingKeShi")
    public ResultVo<List<GetDropdownBox>> getBingQuDuiYingKeShi(String ward) {
        return service.getBingQuDuiYingKeShi(ward);
    }

    @GetMapping("/cheXiaoTuiFei")
    public ResultVo<String> cheXiaoTuiFei(@RequestParam("inpatientNo") String inpatientNo,
                                          @RequestParam("admissTimes") Integer admissTimes,
                                          @RequestParam("ledger") Integer ledger,
                                          @RequestParam("detailSn") Integer detailSn) {
        return service.cheXiaoTuiFei(inpatientNo, admissTimes, ledger, detailSn);
    }

    @PassToken
    @GetMapping("/weiGuiFeiYongFenXi")
    public ResultVo<ZyActpatient> weiGuiFeiYongFenXi(@RequestParam("inpatientNo") String inpatientNo,
                                                     @RequestParam("execUnit") String execUnit) {
        return service.weiGuiFeiYongFenXi(inpatientNo, execUnit);
    }


    @GetMapping("/huoQuZhenShuKePiPei")
    public ResultVo<List<ZyDetailCharge>> huoQuZhenShuKePiPei(@RequestParam("inpatientNo") String inpatientNo,
                                                              @RequestParam("admissTimes") Integer admissTimes,
                                                              @RequestParam("ledgerSn") Integer ledgerSn,
                                                              @RequestParam("chargeCodeMx") String chargeCodeMx,
                                                              @RequestParam("execUnit") String execUnit,
                                                              @RequestParam("orderNo") String orderNo,
                                                              @RequestParam("startTime") String startTime,
                                                              @RequestParam("endTime") String endTime,
                                                              @RequestParam("riQiPaiXu") String riQiPaiXu) {
        return service.huoQuZhenShuKePiPei(inpatientNo, admissTimes, ledgerSn, chargeCodeMx, execUnit, orderNo, startTime, endTime, riQiPaiXu);
    }

    @PostMapping("/caiFenPiPei")
    public ResultVo<String> caiFenPiPei(@RequestBody ZyDetailCharge zyDetailCharge) {
        return service.caiFenPiPei(zyDetailCharge);
    }

    @PostMapping("/exportExcel")
    public void exportExcel(HttpServletResponse response,
                            @RequestBody @Validated ZyDetailCharge param) {
        service.exportExcel(response, param);
    }

    @PostMapping("/xiuGaiZiFeiBiaoZhi")
    public ResultVo<String> xiuGaiZiFeiBiaoZhi(@RequestBody @Validated ZyDetailCharge param) throws Exception {
        return service.xiuGaiZiFeiBiaoZhi(param);
    }

    @GetMapping("/drugRefundForm")
    public ResultVo<Map<String, Map<String, DrugReturnForm>>> drugRefundForm(@RequestParam("groupNo") String groupNo,
                                                                             @RequestParam("patNo") String patNo,
                                                                             @RequestParam("times") Integer times) {
        return service.drugRefundForm(groupNo, patNo, times);
    }

}

