修复就诊人健康信息默认值

This commit is contained in:
2024-11-15 10:13:05 +08:00
parent 858f1726a8
commit e18e2ed4d7

View File

@@ -23,7 +23,7 @@ class PatientController extends BaseAppController
public function actionList()
{
$all = UserPatient::find()->where([
'user_id' => \Yii::$app->user->identity->id,
'user_id' => \Yii::$app->user->identity->id,
'is_delete' => 0
])->orderBy('id desc')->asArray()->all();
return $all;
@@ -52,8 +52,8 @@ class PatientController extends BaseAppController
*/
public function actionSave()
{
$form = new PatientForm();
$form->attributes = \Yii::$app->request->post();
$form = new PatientForm();
$form->attributes = \Yii::$app->request->post();
return $form->save();
}
@@ -63,15 +63,16 @@ class PatientController extends BaseAppController
*/
public function actionChangePatient()
{
$post = \Yii::$app->request->post();
$this->requestValidate($post,[
['up_id','required']
$post = \Yii::$app->request->post();
$this->requestValidate($post, [
['up_id', 'required']
]);
$form = new PatientForm();
$form->attributes = $post;
$form = new PatientForm();
$form->attributes = $post;
return $form->change();
}
/**
* @doc-name 就诊人关系
* @doc-return int key 建
@@ -80,14 +81,14 @@ class PatientController extends BaseAppController
public function actionRelation()
{
return [
['key'=> 0,'text'=>'本人'],
['key'=> 1,'text'=>'丈夫'],
['key'=> 2,'text'=>'妻子'],
['key'=> 3,'text'=>'爸爸'],
['key'=> 4,'text'=>'妈妈'],
['key'=> 5,'text'=>'儿子'],
['key'=> 6,'text'=>'女儿'],
['key'=> 7,'text'=>'其他'],
['key' => 0, 'text' => '本人'],
['key' => 1, 'text' => '丈夫'],
['key' => 2, 'text' => '妻子'],
['key' => 3, 'text' => '爸爸'],
['key' => 4, 'text' => '妈妈'],
['key' => 5, 'text' => '儿子'],
['key' => 6, 'text' => '女儿'],
['key' => 7, 'text' => '其他'],
];
}
@@ -98,28 +99,28 @@ class PatientController extends BaseAppController
*/
public function actionInfo()
{
$post = \Yii::$app->request->post();
$this->requestValidate($post,[
['id','required']
$post = \Yii::$app->request->post();
$this->requestValidate($post, [
['id', 'required']
]);
$patient = UserPatient::find()->where([
'id' => $post['id'],
'user_id' => \Yii::$app->user->identity->id,
$patient = UserPatient::find()->where([
'id' => $post['id'],
'user_id' => \Yii::$app->user->identity->id,
'is_delete' => 0,
])->one();
if(!$patient){
if (!$patient) {
throw new Exception('就诊人不存在');
}
return ArrayHelper::toArray($patient,[
UserPatient::class => [
'id','name','id_card','sex','relation','mobile','is_default',
'avatar'=>function($model){
if (empty($model->avatar)){
return ArrayHelper::toArray($patient, [
UserPatient::class => [
'id', 'name', 'id_card', 'sex', 'relation', 'mobile', 'is_default',
'avatar' => function ($model) {
if (empty($model->avatar)) {
return 'https://hbimg.huabanimg.com/2dbbc9177be8b9912b2a0d881200dd47ccb84d92710aa-IepOs1_fw658';
}
return $model->avatar;
},
'age' => function($model){
'age' => function ($model) {
return FuncHelper::getAgeFromIdNo($model->id_card);
},
]
@@ -133,38 +134,39 @@ class PatientController extends BaseAppController
*/
public function actionEditPatient()
{
$post = \Yii::$app->request->post();
$this->requestValidate($post,[
['up_id','required'],
['avatar','required']
$post = \Yii::$app->request->post();
$this->requestValidate($post, [
['up_id', 'required'],
['avatar', 'required']
]);
$userPatient=UserPatient::find()->where([
'id'=>$post['up_id'],
'user_id'=>\Yii::$app->user->identity->getId(),
$userPatient = UserPatient::find()->where([
'id' => $post['up_id'],
'user_id' => \Yii::$app->user->identity->getId(),
])->one();
if (!$userPatient) throw new \yii\db\Exception('就诊人不存在');
UserPatient::updateAll([
'avatar'=>$post['avatar'],
'avatar' => $post['avatar'],
],
['id'=>$post['up_id'],'user_id'=>\Yii::$app->user->identity->getId()]);
['id' => $post['up_id'], 'user_id' => \Yii::$app->user->identity->getId()]);
return ['编辑成功'];
}
/**
* @doc-name 删除就诊人
* @doc-param int id 就诊人id
*/
public function actionDel()
{
$post = \Yii::$app->request->post();
$this->requestValidate($post,[
['id','required'],
$post = \Yii::$app->request->post();
$this->requestValidate($post, [
['id', 'required'],
]);
$PatientForm=new PatientForm();
$PatientForm->attributes=$post;
return $PatientForm->del();
$PatientForm = new PatientForm();
$PatientForm->attributes = $post;
return $PatientForm->del();
}
/**
@@ -174,18 +176,18 @@ class PatientController extends BaseAppController
*/
public function actionHealthInfo()
{
$post = \Yii::$app->request->post();
$this->requestValidate($post,[
['user_patient_id','required'],
$post = \Yii::$app->request->post();
$this->requestValidate($post, [
['user_patient_id', 'required'],
]);
$HealthForm=new HealthForm();
$HealthForm->attributes=$post;
$HealthForm = new HealthForm();
$HealthForm->attributes = $post;
$info = $HealthForm->info();
$info['family_history'] = explode(',',$info['family_history']);
$info['person_history'] = explode(',',$info['person_history']);
$info['allergic_history'] = explode(',',$info['allergic_history']);
$info['family_history'] = !empty($info['family_history']) ? explode(',', $info['family_history']) : [];
$info['person_history'] = !empty($info['person_history']) ? explode(',', $info['person_history']) : [];
$info['allergic_history'] = !empty($info['allergic_history']) ? explode(',', $info['allergic_history']) : [];
return $info;
}