51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
namespace platform\modules\v1\controllers;
|
|
|
|
use common\core\BasePlatformController;
|
|
use common\models\oldDb\UserPatient;
|
|
use platform\models\forms\SyncPatientForm;
|
|
use yii\base\Exception;
|
|
|
|
/**
|
|
* @doc-module 互医数据同步
|
|
*/
|
|
class SyncController extends BasePlatformController
|
|
{
|
|
|
|
/**
|
|
* @doc-name 就诊人信息增加/修改同步
|
|
* @doc-return mixed 同步结果
|
|
*/
|
|
public function actionPatient()
|
|
{
|
|
$post = \Yii::$app->request->post();
|
|
|
|
$syncPatientForm = new SyncPatientForm();
|
|
$syncPatientForm->attributes = $post;
|
|
return $syncPatientForm->save();
|
|
}
|
|
|
|
|
|
/**
|
|
* @doc-name 就诊人信息删除同步
|
|
* @doc-return mixed 同步结果
|
|
*/
|
|
public function actionPatientDelete()
|
|
{
|
|
$post = \Yii::$app->request->post();
|
|
|
|
$userPatient = UserPatient::findOne(['user_id'=>$post['user_id'],'id_card'=>$post['id_card'],'is_delete' => 0]);
|
|
if(!$userPatient){
|
|
throw new Exception('就诊人信息错误,无法进行该操作');
|
|
}
|
|
|
|
try {
|
|
UserPatient::updateAll(['is_delete' => 1],['id' => $userPatient->id]);
|
|
} catch (\Throwable $th) {
|
|
throw new Exception('删除失败');
|
|
} catch (\Exception $e) {
|
|
throw new Exception('删除失败');
|
|
}
|
|
return ['删除同步成功'];
|
|
}
|
|
} |