package com.ywt.alipaympapi.controller;

import com.alibaba.fastjson.JSON;
import com.ywt.model.ResponseVO;
import com.ywt.request.inpatient.DailyBillDetailsRequest;
import com.ywt.request.inpatient.DailyBillRequest;
import com.ywt.request.inpatient.DepositTradeDetailsRequest;
import com.ywt.request.inpatient.DepositTradeListRequest;
import com.ywt.request.inpatient.DepositTradeRequest;
import com.ywt.request.inpatient.DepositTradeResultRequest;
import com.ywt.request.inpatient.InpatientCheckInRequest;
import com.ywt.request.inpatient.InpatientDeleteRequest;
import com.ywt.request.inpatient.InpatientDetailsRequest;
import com.ywt.request.inpatient.InpatientListRequest;
import com.ywt.request.inpatient.InpatientNoticeRequest;
import com.ywt.request.inpatient.InpatientUpdateRequest;
import com.ywt.request.inpatient.NoticeAuthRequest;
import com.ywt.request.inpatient.SettlementAuthRequest;
import com.ywt.request.inpatient.SettlementDetailsRequest;
import com.ywt.request.inpatient.SettlementExecuteRequest;
import com.ywt.request.inpatient.SettlementListRequest;
import com.ywt.request.inpatient.SettlementQueryRequest;
import com.ywt.response.inpatient.DailyBillDetailsResponseData;
import com.ywt.response.inpatient.DailyBillResponseData;
import com.ywt.response.inpatient.DepositTradeDetailsResponseData;
import com.ywt.response.inpatient.DepositTradeListResponseData;
import com.ywt.response.inpatient.DepositTradeResponseData;
import com.ywt.response.inpatient.DepositTradeResultResponseData;
import com.ywt.response.inpatient.InpatientCheckInResponseData;
import com.ywt.response.inpatient.InpatientDeleteResponseData;
import com.ywt.response.inpatient.InpatientDetailsResponseData;
import com.ywt.response.inpatient.InpatientListResponseData;
import com.ywt.response.inpatient.InpatientNoticeResponseData;
import com.ywt.response.inpatient.InpatientUpdateResponseData;
import com.ywt.response.inpatient.NoticeAuthResponseData;
import com.ywt.response.inpatient.SettlementAuthResponseData;
import com.ywt.response.inpatient.SettlementDetailsResponseData;
import com.ywt.response.inpatient.SettlementExecuteResponseData;
import com.ywt.response.inpatient.SettlementListResponseData;
import com.ywt.response.inpatient.SettlementQueryResponseData;
import com.ywt.alipaympapi.service.InpatientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Desc
 */
@Slf4j
@RestController
public class InpatientController {

    @Autowired
    private InpatientService inpatientService;

    /**
     * 入院登记
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.inpatient.checkIn")
    public ResponseVO<InpatientCheckInResponseData> checkIn(InpatientCheckInRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.checkIn(request));
    }

    /**
     * 修改住院人（就诊人）信息
     * 仅支持修改手机号
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.inpatient.edict")
    public ResponseVO<InpatientUpdateResponseData> inpatientEdict(InpatientUpdateRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.updateInpatient(request));
    }

    /**
     * 住院登记/住院人列表
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.inpatient.list")
    public ResponseVO<List<InpatientListResponseData>> inpatientList(InpatientListRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.inpatientList(request));
    }

    /**
     * 住院登记/住院人详情
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.inpatient.details")
    public ResponseVO<InpatientDetailsResponseData> inpatientDetails(InpatientDetailsRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.inpatientDetails(request));
    }

    /**
     * 删除住院登记数据
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.inpatient.delete")
    public ResponseVO<InpatientDeleteResponseData> deleteInpatient(InpatientDeleteRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.deleteInpatient(request));
    }

    /**
     * 首页日清列表
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.home.dailyBill.list")
    public ResponseVO<List<DailyBillResponseData>> dailyBillList(DailyBillRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.dailyBillList(request));
    }

    /**
     * 日清详情
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.dailyBill.details")
    public ResponseVO<DailyBillDetailsResponseData> dailyBillDetails(DailyBillDetailsRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.dailyBillDetail(request));
    }

    /**
     * 押金缴纳
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.deposit.tradeNoQuery")
    public ResponseVO<DepositTradeResponseData> depositTradeNoQuery(DepositTradeRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.depositTrade(request));
    }

    /**
     * 押金缴纳
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.deposit.tradeResult")
    public ResponseVO<DepositTradeResultResponseData> queryDepositTradeResult(DepositTradeResultRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.queryTradeResult(request));
    }

    /**
     * 押金缴纳记录查询
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.deposit.list")
    public ResponseVO<List<DepositTradeListResponseData>> queryDepositTradeList(DepositTradeListRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.queryTradeList(request));
    }

    /**
     * 押金缴纳详情
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.deposit.details")
    public ResponseVO<DepositTradeDetailsResponseData> queryDepositTradeDetails(DepositTradeDetailsRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.queryTradeDetails(request));
    }

    /**
     * 出院信息结算列表
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.settlement.list")
    public ResponseVO<List<SettlementListResponseData>> settlementList(SettlementListRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.settlementList(request));
    }

    /**
     * 出院结算查询
     * 查询支出明细、医保可报销金额，计算押金总额、实际支付金额、押金余额、应退/补金额
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.settlement.query")
    public ResponseVO<SettlementQueryResponseData> settlementQuery(SettlementQueryRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.informTradeResult(request));
    }

    /**
     * 出院预结算授权 （仅医保支付调用）
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.settlement.auth")
    public ResponseVO<SettlementAuthResponseData> settlementAuth(SettlementAuthRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.settlementAuth(request));
    }

    /**
     * 出院结算
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.settlement.execute")
    public ResponseVO<SettlementExecuteResponseData> settlementExecute(SettlementExecuteRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.settlementExecute(request));
    }

    /**
     * 出院结算详情查询
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.settlement.details")
    public ResponseVO<SettlementDetailsResponseData> settlementDetails(SettlementDetailsRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.settlementDetails(request));
    }

    /**
     * 出入院须知
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.inpatient.notice")
    public ResponseVO<InpatientNoticeResponseData> inpatientNotice(InpatientNoticeRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.inpatientNotice(request));
    }

    /**
     * 押金缴纳消息通知授权
     *
     * @param request
     * @return
     */
    @PostMapping("isvRequest.deposit.noticeAuth")
    public ResponseVO<NoticeAuthResponseData> noticeAuth(NoticeAuthRequest request) {
        log.info("request:{}", JSON.toJSONString(request));
        return ResponseVO.success(inpatientService.noticeAuth(request));
    }

}