<?php

declare(strict_types=1);

namespace App\Request;

use App\Constants\HttpEnumCode;
use Hyperf\Validation\Request\FormRequest;

class InquiryRequest extends FormRequest
{
    protected array $scenes = [
        'addInquiryOrder' => [ // 创建问诊订单
            'patient_id',
            'family_id',
            'disease_class_id',
            'diagnosis_date',
            'disease_desc',
            'is_allergy_history',// 过敏史
            'allergy_history',
            'is_family_history', // 家族病史
            'family_history',
            'is_pregnant',// 备孕、妊娠、哺乳期
            'pregnant',
            'height',
            'weight',
            'inquiry_type', // 订单类型（1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药）
            'inquiry_mode', // 订单问诊方式（1:图文 2:视频 3:语音 4:电话 5:会员）
            'client_type', // 客户端类型(1:手机 2：电脑)
        ],
        'addInquiryEvaluation' => [ // 新增问诊评价
            'doctor_id',
            'order_inquiry_id',
            'reply_quality',// 回复质量
            'service_attitude', // 服务态度
            'reply_progress',// 回复速度
            'content',
        ],
        'getPatientInquiryOrderList' => [ // 获取患者问诊订单列表
            'inquiry_status',// 问诊订单状态（0:全部 1:待支付 2:待接诊 3:问诊中 4:完成/取消
            'family_id',// 家庭成员id（就诊用户）
        ],
        'getPatientInquiryCase' => [ // 获取患者问诊病例
            'order_inquiry_id',
        ],
    ];

    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'inquiry_type' => 'required|integer|min:1|max:4',
            'inquiry_mode' => 'required|integer|min:1|max:5',
            'patient_id' => 'required',
            'family_id' => 'required',
            'disease_class_id' => 'required',
            'diagnosis_date' => ['sometimes','date'],
            'disease_desc' => 'required',
            'is_allergy_history' => ['sometimes','numeric','min:0','max:1'],
            'is_family_history' => ['sometimes','numeric','min:0','max:1'],
            'is_pregnant' => ['sometimes','numeric','min:0','max:1'],
            'client_type' => 'required|integer|min:1|max:2',

            'doctor_id' => 'required',
            'order_inquiry_id' => 'required',
            'reply_quality' => 'required|integer|min:0|max:5',
            'service_attitude' => 'required|integer|min:0|max:5',
            'reply_progress' => 'required|integer|min:0|max:5',//

            'inquiry_status' => 'required|integer|min:0|max:4',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息.
     */
    public function messages(): array
    {
        return [
            'inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_mode.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'patient_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'disease_class_id.required' => "请您选择疾病",
            'diagnosis_date.date' => HttpEnumCode::getMessage(HttpEnumCode::DATE_FORMAT_ERROR),
            'disease_desc.required' => "请您输入病情主诉",
            'is_allergy_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_allergy_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_allergy_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_family_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_family_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_family_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_pregnant.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_pregnant.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'is_pregnant.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),

            'inquiry_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
            'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
        ];
    }
}
