165 lines
6.8 KiB
PHP
165 lines
6.8 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Request;
|
||
|
||
use App\Constants\HttpEnumCode;
|
||
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
||
use Hyperf\Validation\Request\FormRequest;
|
||
use Hyperf\Validation\Rule;
|
||
|
||
class PatientFamilyRequest extends FormRequest
|
||
{
|
||
/**
|
||
* @Inject
|
||
* @var ValidatorFactoryInterface
|
||
*/
|
||
protected ValidatorFactoryInterface $validationFactory;
|
||
|
||
protected array $scenes = [
|
||
'addFamily' => [ // 新增家庭成员
|
||
'relation',
|
||
'is_default',
|
||
'card_name',
|
||
'mobile',
|
||
'type',
|
||
'id_number',
|
||
'province_id',
|
||
'city_id',
|
||
'county_id',
|
||
'height',
|
||
'weight',
|
||
'marital_status',
|
||
],
|
||
'editFamily' => [ // 修改家庭成员
|
||
'relation',
|
||
'is_default',
|
||
'card_name',
|
||
'type',
|
||
'id_number',
|
||
'province_id',
|
||
'city_id',
|
||
'county_id',
|
||
'height',
|
||
'weight',
|
||
'marital_status',
|
||
],
|
||
'editFamilyPersonal' => [ // 修改家庭成员-个人情况
|
||
'is_allergy_history',// 过敏史
|
||
'allergy_history',
|
||
'is_family_history', // 家族病史
|
||
'family_history',
|
||
'is_pregnant',// 备孕、妊娠、哺乳期
|
||
'pregnant',
|
||
'is_operation', // 是否存在手术(0:否 1:是)
|
||
'operation',
|
||
'drink_wine_status', // 饮酒状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒酒)
|
||
'smoke_status',// 吸烟状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒烟)
|
||
'chemical_compound_status', // 化合物状态(1:从不 2:偶尔 3:经常 4:每天)
|
||
'chemical_compound_describe',
|
||
],
|
||
'addFamilyPersonal' => [ // 新增家庭成员-个人情况
|
||
'family_id',
|
||
'is_allergy_history',// 过敏史
|
||
'allergy_history',
|
||
'is_family_history', // 家族病史
|
||
'family_history',
|
||
'is_pregnant',// 备孕、妊娠、哺乳期
|
||
'pregnant',
|
||
'is_operation', // 是否存在手术(0:否 1:是)
|
||
'operation',
|
||
'drink_wine_status', // 饮酒状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒酒)
|
||
'smoke_status',// 吸烟状态(1:从不 2:偶尔 3:经常 4:每天 5:已戒烟)
|
||
'chemical_compound_status', // 化合物状态(1:从不 2:偶尔 3:经常 4:每天)
|
||
'chemical_compound_describe',
|
||
],
|
||
'editFamilyHealth' => [ // 修改家庭成员-健康情况
|
||
'disease_class_id',
|
||
'diagnosis_date',// 确诊日期
|
||
'diagnosis_hospital',//确诊医院
|
||
'is_take_medicine', // 正在服药(0:否 1:是)
|
||
'drugs_name', // 正在服药名称
|
||
],
|
||
'addFamilyHealth' => [ // 新增家庭成员-健康情况
|
||
'family_id',
|
||
'disease_class_id',
|
||
'diagnosis_date',// 确诊日期
|
||
'diagnosis_hospital',//确诊医院
|
||
'is_take_medicine', // 正在服药(0:否 1:是)
|
||
'drugs_name', // 正在服药名称
|
||
],
|
||
];
|
||
|
||
/**
|
||
* 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 [
|
||
'card_name' => 'required',
|
||
'type' => ['required',Rule::in(['1', '2', '3', '4'])],
|
||
'id_number' => "required",
|
||
'mobile' => ['sometimes','regex:/^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/'],
|
||
'relation' => ['sometimes',Rule::in([1,2,3,4,5,6,null])],
|
||
'city_id' => 'required_with:province_id',
|
||
'province_id' => 'required_with:city_id',
|
||
'is_default' => ['sometimes',Rule::in([0,1,null])],
|
||
'height' => ['sometimes','numeric'], // 身高
|
||
'weight' => ['sometimes','numeric'], // 体重
|
||
'marital_status' => ['sometimes',Rule::in([0,1,2,null])], // 婚姻状况(0:未婚 1:已婚 2:离异 null:未选择)
|
||
'is_allergy_history' => ['sometimes',Rule::in([0,1,null])],
|
||
'is_pregnant' => ['sometimes',Rule::in([0,1,null])],
|
||
'is_family_history' => ['sometimes',Rule::in([0,1,null])],
|
||
'is_operation' => ['sometimes',Rule::in([0,1,null])],
|
||
'drink_wine_status' => ['sometimes',Rule::in([1,2,3,4,5,null])],
|
||
'smoke_status' => ['sometimes',Rule::in([1,2,3,4,5,null])],
|
||
'chemical_compound_status' => ['sometimes',Rule::in([1,2,3,4,null])],
|
||
'is_take_medicine' => ['sometimes',Rule::in([0,1,null])],
|
||
'family_id' => "required",
|
||
'diagnosis_date' => ['sometimes','date'],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* 获取已定义验证规则的错误消息.
|
||
*/
|
||
public function messages(): array
|
||
{
|
||
return [
|
||
'name.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'type.required' => "请选择证件类型",
|
||
'type.in' => "证件类型错误",
|
||
'id_number.required' => "请选择证件号",
|
||
// 'mobile.required' => "手机号不能为空",
|
||
'mobile.regex' => "手机号格式错误",
|
||
'relation.in' => "患者关系错误",
|
||
'city_id.required_with' => "请选择城市",
|
||
'province_id.required_with' => "请选择省份",
|
||
'is_default.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'height.numeric' => "身高错误",
|
||
'weight.numeric' => "体重错误",
|
||
'blood_type.in' => "血型错误",
|
||
'marital_status.in' => "婚姻状况错误",
|
||
'is_allergy_history.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'is_family_history.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'is_pregnant.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'is_operation.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'drink_wine_status.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'smoke_status.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'chemical_compound_status.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
// 'disease_class_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||
'diagnosis_date.date' => "日期格式错误",
|
||
];
|
||
}
|
||
}
|