request->get(); $query = User::find()->where([ 'is_delete' => 0 ]); if (!empty($get['name'])) {//搜索姓名 $query->andWhere(['like', 'nickname', $get['name']]); } if (!empty($get['major_number'])) {//手机号 $query->andWhere(['mobile' => $get['major_number']]); } if (!empty($get['gender'])) {//性别 $query->andWhere(['gender' => $get['gender']]); } if (!empty($get['idcard'])) {//身份证 $query->andWhere(['idcard' => $get['idcard']]); } $this->field = [ User::class => [ 'id', 'nickname', 'mobile', 'gender', 'idcard', 'created_at' => function ($model) { return date('Y-m-d H:i:s', $model->created_at); }, 'age' => function ($model) { return $model->idcard ? FuncHelper::getAgeFromIdNo($model->idcard) : ''; }, 'UserPatientHealthInquiry' => function ($m) { $UserPatient = UserPatient::find()->select('id')->where([ 'user_id' => $m->id, 'relation' => 0 ])->column(); return UserPatientHealthInquiry::find()->where([ 'user_patient_id' => $UserPatient, 'is_delete' => 0 ])->one(); }, 'UserInquiry' => function ($i) { return Order::find()->where([ 'user_id' => $i->id, ])->with(['inquiry'])->asArray()->all(); }, 'Prescription' => function ($p) { return Prescription::find()->where([ 'user_id' => $p->id, 'is_deleted' => 0 ])->all(); }, 'register'=>function($r){ return Register::find()->where([ 'user_id'=>$r->id ])->all(); } ] ]; return $this->create($query, $get); } /** * @doc-name 用户端用户详情 * @doc-param int id ID * @doc-return mixed @User{id,nickname-string-昵称,mobile-string-电话,created_at-string-首次访问时间,gender-int-性别,值为1时是男性,值为2时是女性,值为0时是未知性别,idcard-string-身份证,age-int-年龄} 用户信息 * @doc-return mixed @UserPatientHealthInquiry{liver_function-int-肝功能状态0正常1异常,liver_index-string-肝功能异常指标,renal_function-int-肾功能状态0正常1异常,renal_index-string-肾功能异常指标,person_status-int-既往史0无1有,person_history-string-既往史,allergic_status-int-过敏史0无1有,allergic_status-string-过敏史,,allergic_status-int-家族遗传史0无1有,allergic_status-string-家族遗传史} 基本健康信息 * @doc-return mixed @UserInquiry{id-int-订单id,user_id-int-用户id,order_no-string-订单号,total_pay_price-float-支付金额,is_pay-int-知否支付0否1是,@Inquiry{images-string-检查报告或患者照片,is_visit-string-是否就诊0否1是,visit_desc-string-就诊描述,patient_data-string-就诊人基础信息,liver_function-int-肝功能0正常1异常,renal_function-string-肾功能0正常1异常,person_status-int-个人病史0无1有,person_history-string-个人病史,allergic_status-int-过敏史0无1有,allergic_history-int-过敏史0无1有,family_status-int-家庭病史0无1有,family_history-string-家庭病史}} 问诊记录 * @doc-return mixed @Prescription{id-int-id,platform_prescription_no-string-平台处方单号,prescription_no-string-处方单号,order_id-int-订单id,status-int-状态0待审核1已通过2未通过3待使用4已使用5未使用6已失效7已初审,content-string-处方快照,prescription_type-int-1中药处方2西药处方3颗粒药处方,category-int-类别 1自费2医保,doctor_order-string-医嘱,clinical_diagnose-string-临床诊断,,医生签名-string-医生签名,type-int-类型1普通方2常用方,order_type-int-订单类型1处方2医技,total_pay_price-float-支付金额} 处方记录 */ public function actionInfo() { $get = \Yii::$app->request->get(); $this->requestValidate($get, [ ['id', 'required'] ]); $User = User::find()->where([ 'id' => $get['id'], 'is_delete' => 0 ])->with(['userPatient' => function ($u) { $u->where(['relation' => 0]); }])->asArray()->one(); $UserPatientId = $User['userPatient'][0]['id']; if (!$User) throw new Exception('用户不存在'); $UserPatientHealthInquiry = UserPatientHealthInquiry::find()->where([ 'user_patient_id' => $UserPatientId, 'is_delete' => 0 ])->one(); $UserInquiry = Order::find()->where([ 'user_id' => $get['id'], ])->with(['inquiry'])->asArray()->all(); $Prescription = Prescription::find()->where([ 'user_id' => $get['id'], 'is_deleted' => 0 ])->all(); $register=Register::find()->where([ 'user_id'=>$get['id'], ])->all(); return [ 'User' => $User, 'UserPatientHealthInquiry' => $UserPatientHealthInquiry, 'UserInquiry' => $UserInquiry, 'Prescription' => $Prescription, 'register' => $register, ]; } public function actionPatientList(){ $get = \Yii::$app->request->get(); $this->requestValidate($get, [ ['id', 'required'] ]); $user = User::find()->where([ 'id' => $get['id'], 'is_delete' => 0 ])->asArray()->one(); if (!$user) throw new Exception('用户不存在'); $userPatient = UserPatient::find()->select('id,name')->where(['user_id' => $get['id'],'is_delete' => 0])->orderBy('is_default desc,created_at asc')->all(); return $userPatient; } public function actionPatientInfo(){ $get = \Yii::$app->request->get(); $this->requestValidate($get, [ ['patient_id', 'required'] ]); $userPatient = UserPatient::find()->where(['id' => $get['patient_id'],'is_delete' => 0])->one(); if(!$userPatient){ throw new Exception('就诊人不存在'); } $UserPatientHealthInquiry = UserPatientHealthInquiry::find()->where([ 'user_patient_id' => $get['patient_id'], 'is_delete' => 0 ])->one(); return [ 'info' => $userPatient, 'healthInquiry' => $UserPatientHealthInquiry ]; } public function actionPatientPrescriptionList(){ $get = \Yii::$app->request->get(); $this->requestValidate($get, [ ['patient_id', 'required'] ]); $userPatient = UserPatient::find()->where(['id' => $get['patient_id'],'is_delete' => 0])->one(); if(!$userPatient){ throw new Exception('就诊人不存在'); } $prescriptionList = Prescription::find()->select(['id','su_id','clinical_diagnose','prescription_no','created_at'])->where(['up_id' => $get['patient_id'],'is_deleted' => 0,'cancel_status' => 0])->orderBy('created_at desc')->asArray()->all(); foreach($prescriptionList as &$v){ $v['created_at'] = date('Y年m月d日 H:i',$v['created_at']); $v['doctor_name'] = DoctorInfo::find()->where(['su_id' => $v['su_id']])->select('name')->scalar(); } return $prescriptionList; } }