package thyyxxk.webserver.controller.zhuyuanyizheng;

import com.alibaba.fastjson.JSONArray;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;
import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
import thyyxxk.webserver.entity.login.UserInfo;
import thyyxxk.webserver.service.zhuyuanyisheng.HuiZhenShenQingService;
import thyyxxk.webserver.utils.TokenUtil;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 描述： 会诊申请
 * </p>
 *
 * @author xc
 * @date 2021-05-07 11:00
 */
@RestController
@RequestMapping("/huiZhenShenQing")
public class HuiZhenShenQingController {

    private final HuiZhenShenQingService service;

    public HuiZhenShenQingController(HuiZhenShenQingService service) {
        this.service = service;
    }

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

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

    @PostMapping("/submitHuiZhenShenQing")
    public ResultVo<String> submitHuiZhenShenQing(@RequestBody YshHzRecord param) {
        String tokenUserId = TokenUtil.getInstance().getTokenUserId();
        return service.submitHuiZhenShenQing(param, tokenUserId);
    }

    @PostMapping("/consultationOfDoctors")
    @PassToken
    public ResultVo<String> consultationOfDoctors(@RequestBody YshHzRecord param) {
        String tokenUserId = param.getInputId();
        return service.submitHuiZhenShenQing(param, tokenUserId);
    }

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

    @GetMapping("/shanChuHuiZhenShenQing")
    public ResultVo<Boolean> shanChuHuiZhenShenQing(@RequestParam("inpatientNo") String inpatientNo,
                                                    @RequestParam("admissTimes") int admissTimes,
                                                    @RequestParam("actOrderNo") BigDecimal actOrderNo,
                                                    @RequestParam("reqTimes") int reqTimes) {
        return service.shanChuHuiZhenShenQing(inpatientNo, admissTimes, actOrderNo, reqTimes);
    }

    @GetMapping("/huiZhenYiSheng")
    public ResultVo<List<GetDropdownBox>> huiZhenYiSheng(@RequestParam("deptCode") String deptCode,
                                                         @RequestParam("hzType") String hzType) {
        return service.huiZhenYiSheng(deptCode, hzType);
    }

    @GetMapping("/getConsultingDoctorInfo")
    public ResultVo<List<UserInfo>> getConsultingDoctorInfo(@RequestParam("searchCondition") String searchCondition) {
        return service.getConsultingDoctorInfo(searchCondition);
    }

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

}
