<?php

namespace App\Controller;

use App\Amqp\Producer\PrescriptionDistributePhProducer;
use App\Constants\HttpEnumCode;
use App\Model\OrderPrescriptionIcd;
use App\Model\OrderPrescriptionProduct;
use App\Request\DoctorAuthRequest;
use App\Request\UserDoctorRequest;
use App\Services\DoctorAuthService;
use App\Services\DoctorInquiryService;
use App\Services\ImService;
use App\Services\UserDoctorService;
use Extend\TencentIm\Account;
use Hyperf\Amqp\Producer;
use Hyperf\DbConnection\Db;
use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;

class UserDoctorController extends AbstractController
{
    /**
     * 获取医生专长列表
     * 身份认证
     * @return ResponseInterface
     */
    public function getAuthDoctorExpertise(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getAuthDoctorExpertise();
        return $this->response->json($data);
    }

    /**
     * 获取医生问诊配置
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getInquiryConfig(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('getInquiryConfig')->validateResolved();

        $DoctorInquiryService = new DoctorInquiryService();
        $data = $DoctorInquiryService->getInquiryConfig();
        return $this->response->json($data);
    }

    /**
     * 医生问诊开关
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function putInquiryOpen(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('putInquiryOpen')->validateResolved();

        $DoctorInquiryService = new DoctorInquiryService();
        $data = $DoctorInquiryService->putInquiryOpen();
        return $this->response->json($data);
    }

    /**
     * 修改医生问诊配置
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function putInquiryConfig(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('putInquiryConfig')->validateResolved();

        $DoctorInquiryService = new DoctorInquiryService();
        $data = $DoctorInquiryService->putInquiryConfig();
        return $this->response->json($data);
    }

    /**
     * 获取医生银行卡
     * @return ResponseInterface
     */
    public function getDoctorBankCard(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorBankCard();
        return $this->response->json($data);
    }

    /**
     * 获取医生银行卡详情信息
     * @return ResponseInterface
     */
    public function getDoctorBankCardInfo(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorBankCardInfo();
        return $this->response->json($data);
    }

    /**
     * 新增绑定医生银行卡
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function addDoctorBankCard(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('addDoctorBankCard')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->addDoctorBankCard();
        return $this->response->json($data);
    }

    /**
     * 更换医生银行卡
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function putDoctorBankCard(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('putDoctorBankCard')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->putDoctorBankCard();
        return $this->response->json($data);
    }

    /**
     * 获取处方列表
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getPrescriptionList(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('getPrescriptionList')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getPrescriptionList();
        return $this->response->json($data);
    }

    /**
     * 获取医生个人中心数据
     * @return ResponseInterface
     */
    public function getDoctorCenter(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorCenter();
        return $this->response->json($data);
    }

    /**
     * 获取常用语列表
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getDoctorWords(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('getDoctorWords')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorWords();
        return $this->response->json($data);
    }

    /**
     * 新增常用语列表
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function addDoctorWords(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('addDoctorWords')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->addDoctorWords();
        return $this->response->json($data);
    }

    /**
     * 删除常用语
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function deleteDoctorWords(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->deleteDoctorWords();
        return $this->response->json($data);
    }

    /**
     * 获取医生评价
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getDoctorEvaluationList(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('getDoctorEvaluationList')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorEvaluationList();
        return $this->response->json($data);
    }

    /**
     * 获取医生信息
     * @return ResponseInterface
     */
    public function getDoctorCenterInfo(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorCenterInfo();
        return $this->response->json($data);
    }

    /**
     * 获取医生证书信息
     * @return ResponseInterface
     */
    public function getDoctorCret(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorCret();
        return $this->response->json($data);
    }

    /**
     * 获取处方详情
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getPrescriptionInfo(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('getPrescriptionInfo')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getPrescriptionInfo();
        return $this->response->json($data);
    }

    /**
     * 修改处方
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function putPrescription(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('putPrescription')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->putPrescription();
        return $this->response->json($data);
    }

    /**
     * 新增处方
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function addPrescription(): ResponseInterface
    {
        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('addPrescription')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->addPrescription();
        return $this->response->json($data);
    }

    /**
     * 获取医生名片
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     * @throws ClientExceptionInterface
     * @throws DecodingExceptionInterface
     * @throws RedirectionExceptionInterface
     * @throws ServerExceptionInterface
     * @throws TransportExceptionInterface
     */
    public function getDoctorInfoCard(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorInfoCard();
        return $this->response->json($data);
    }

    /**
     * 获取医生问诊消息列表
     * @return ResponseInterface
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getDoctorMessageList(): ResponseInterface
    {
//        $data['order_inquiry_id'] = 1;
//        $data['patient_name'] = "测试用户3";
//        $data['patient_sex'] = 1;
//        $data['patient_age'] = 19;
//        $data['inquiry_status'] = 1;
//        $data['message_send_time'] = 10000;
//        $data['message_seq'] = 101;
//        $data['message_type'] = "TIMTextElem";
//        $data['last_message_content']['Text'] = "测试消息3";
//
//        $imService = new ImService();
//        $imService->addRecentContactRecordCache("491925054779883520",2,"3",$data);


        $request = $this->container->get(UserDoctorRequest::class);
        $request->scene('getDoctorMessageList')->validateResolved();

        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorMessageList();
        return $this->response->json($data);
    }

    /**
     * 获取医生问诊消息用户属性
     * @return ResponseInterface
     */
    public function getDoctorMessageAttrList(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->getDoctorMessageAttrList();
        return $this->response->json($data);
    }

    /**
     * 新增医生接诊
     * @return ResponseInterface
     */
    public function addDoctorInquiry(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->addDoctorInquiry();
        return $this->response->json($data);
    }

    /**
     * 结束问诊
     * @return ResponseInterface
     */
    public function putDoctorFinishInquiry(): ResponseInterface
    {
        $UserDoctorService = new UserDoctorService();
        $data = $UserDoctorService->putDoctorFinishInquiry();
        return $this->response->json($data);
    }
}