getParams(); // ApplicationValidate::check($params); $token = $this->getToken(); $user = $service->getUser($token); $service->checkApplyRole($user); $info = $service->get_patient_template($params,$user['institution_id']); return $this->success($info); // } catch (\Exception $exception){ // $this->throwError($exception->getMessage(),0001); // } } /* * 获取申请单id */ public function getRemoteStatus(ApplicationService $service) { $params = $this->getParams(); ApplicationValidate::checkId($params); $info = $service->getRemote($params['id']); return $this->success($info); } /** * 同意知情同意书 */ public function step1(ApplicationService $service) { try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $info = $service->get_step1_data($params,$this->getToken()); return $this->success($info); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 暂时保存 */ public function stage(ApplicationService $service) { try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $param = $service->handle_save($params); $return = $service->save_application($param,Config::get('remote_status')['step2']); return $this->success($return); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 上传附件 */ public function upload(){ try{ // 获取表单上传文件 例如上传了001.jpg $file = request()->file('file'); // 移动到框架应用根目录/public/uploads/ 目录下 if($file){ $fildInfo = $file->getInfo(); $name = $fildInfo['name']; $search = '/.php$/'; if(preg_match($search,$name)) { // php文件批量不允许通过 return ''; } $upload = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); if($upload){ return $this->success('/'.$_SERVER["SERVER_NAME"]. '/' . 'uploads'. '/' .$upload->getSaveName()); }else{ // 上传失败获取错误信息 $this->throwError($file->getError(),0011); } } }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 保存继续 */ public function step2(ApplicationService $service) { // try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $param = $service->handle_save($params); $return = $service->save_application($param,Config::get('remote_status')['step3']); return $this->success($return); // }catch(\Exception $e){ // $this->throwError($e->getMessage(),0001); // } } /** * 发起申请 */ public function step3(ApplicationService $service) { // try{ $params = $this->getParams(); ApplicationValidate::checkStep3($params); $doctor = $service->getUser($this->getToken()); $odd_number = $service->getNum(); $update = $service->application_start($params,$doctor,$odd_number); return $this->success($update); // }catch(\Exception $e){ // $this->throwError($e->getMessage(),0001); // } } /** * 同意接收申请 */ public function agree(ApplicationService $service) { try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $doctor = $service->getUser($this->getToken()); $service->checkRole($params['id'],$doctor,'非受邀医生无法接收申请单'); $service->checkStatus($params['id'],Config::get('remote_status')['step4'],'操作失败,只允许接收发起状态的申请单'); // 修改状态为同意申请 $service->updateStatus($params['id'],Config::get('remote_status')['step6'],3,$doctor); $service->save_progress($params['id'],$doctor,'接收了申请',2); $field = ['local_institution_id','req_doctor_id']; $service->insertMessage($params['id'],$doctor,'接受了您的远程申请',$field); return $this->success('ok'); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 驳回申请单 */ public function reject(ApplicationService $service) { $params = $this->getParams(); ApplicationValidate::checkReject($params); $doctor = $service->getUser($this->getToken()); $service->checkRole($params['id'],$doctor,'非受邀医生无法驳回申请单'); $service->checkStatus($params['id'],Config::get('remote_status')['step4'],'操作失败,只允许驳回发起状态的申请单'); // 修改状态为驳回申请 $service->updateStatus($params['id'],Config::get('remote_status')['step5'],5,$doctor); $service->sendSms2RejectApply($params['id'],$params['description']); $service->save_progress($params['id'],$doctor,'驳回了申请,驳回原因'.$params['description'],3); $field = ['local_institution_id','req_doctor_id']; $service->insertMessage($params['id'],$doctor,'驳回了您的远程申请,驳回原因'.$params['description'],$field); return $this->success('ok'); } /** * 取消订单 */ public function cancelOrder(ApplicationService $service) { $params = $this->getParams(); ApplicationValidate::checkCancel($params); $doctor = $service->getUser($this->getToken()); $service->checkApplyRole($doctor); $info = $service->cancelOrder($params['order_id'],$doctor); return $this->success($info); } /** * 完成申请单 */ public function complete(ApplicationService $service) { // try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $service->checkStatus($params['id'],Config::get('remote_status')['step8'],'操作失败,只允许完成审核状态的申请单'); $doctor = $service->getUser($this->getToken()); // 修改状态为完成申请 $service->updateStatus($params['id'],Config::get('remote_status')['step10'],9,$doctor); $service->sendSms2CompleteReport($params['id'],$doctor); $service->save_progress($params['id'],$doctor,'完成了远程申请',5); $field = ['local_institution_id','req_doctor_id']; $service->insertMessage($params['id'],$doctor,'完成了您的远程申请',$field); return $this->success('ok'); // }catch(\Exception $e){ // $this->throwError($e->getMessage(),0001); // } } /** * 撤回申请单 */ public function recall(ApplicationService $service) { try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $service->checkStatus($params['id'],Config::get('remote_status')['step4'],'操作失败,只允许撤回发起状态的申请单'); $doctor = $service->getUser($this->getToken()); // 修改状态为撤回申请 $service->updateStatus($params['id'],Config::get('remote_status')['step11'],4,$doctor); $service->save_progress($params['id'],$doctor,'撤回了远程申请',4); $field = ['remote_institution_id','remote_doctor_id']; $service->insertMessage($params['id'],$doctor,'撤回了远程申请',$field); return $this->success('ok'); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 申请单详情 */ public function details(ApplicationService $service) { try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $info = $service->get_detail($params['id']); return $this->success($info); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } public function applyDetails(ApplicationService $service) { try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $info = $service->get_applyDetail($params['id']); return $this->success($info); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 诊断详情 */ public function report(ApplicationService $service) { $params = $this->getParams(); ApplicationValidate::checkId($params); $info = $service->getReportInfo($params); return $this->success($info); } public function progress(ApplicationService $service) { try{ $params = $this->getParams(); ApplicationValidate::checkId($params); $user = $service->getuser($this->getToken()); $info = $service->getDialog($params['id'],$user); return $this->success($info); }catch(\Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 发起对话 */ public function bbs(ApplicationService $service) { $params = $this->getParams(); ApplicationValidate::checkBbs($params); $doctor = $service->getUser($this->getToken()); $attachment = isset($params['attachment']) ? $params['attachment'] : null; $content = isset($params['content']) ? $params['content'] : null; if($attachment == null && $content == null){ $this->throwError('缺少必要参数,请填写对话内容或附件信息',0001); } // 保存bbs信息 $info = $service->save_bbs($doctor['id'],$params['is_remote'],$params['id'],$content,$attachment,$params['attachment_type'] ?? 1); // 添加message消息 $service->save_bbs_message($params['id'],$doctor['id'],$content,$info['reply'],$params['is_remote']); return $this->success($info); } /** * 对话上传附件 */ public function bbsUpload() { try{ // 获取表单上传文件 例如上传了001.jpg $file = request()->file('file'); // 移动到框架应用根目录/public/uploads/ 目录下 if($file) { $fildInfo = $file->getInfo(); $name = $fildInfo['name']; $search = '/.php$/'; if(preg_match($search,$name)) { // php文件批量不允许通过 return ''; } $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); if ($info) { $type = Config::get('upload'); if($type == 1) { $url = '/' . 'uploads' . '/' . $info->getSaveName(); $success = ['url'=>$url,'type'=>$type,'tokenUrl'=>$url]; return $this->success($success); } $key = 'bbs/' . $info->getFilename(); $source_file = './' . 'uploads' . '/' . $info->getSaveName(); $upload = new uploadToCloud();; $s = $upload->upload($key,$source_file); if(($s['@metadata']['statusCode'] ?? '') == '200') { gc_collect_cycles(); unset($info); unlink($source_file); $success = ['url'=>$key,'type'=>'2','tokenUrl'=>$upload->makeUrl($key)]; return $this->success($success); }else{ return '上传云失败'; } } else { // 上传失败获取错误信息 echo $file->getError(); } }else{ $this->throwError('没有找到上传的文件','3010'); } }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } /** * 申请上传附件 */ public function applyUpload() { try{ // 获取表单上传文件 例如上传了001.jpg $file = request()->file('apply'); // 移动到框架应用根目录/public/uploads/ 目录下 if($file) { $fildInfo = $file->getInfo(); $name = $fildInfo['name']; $search = '/.php$/'; if(preg_match($search,$name)) { // php文件批量不允许通过 return ''; } $info = $file->move(ROOT_PATH . 'public' . DS . 'uploads'); if ($info) { $type = Config::get('upload'); if($type == 1) { $url = '/' . 'uploads' . '/' . $info->getSaveName(); $success = ['url'=>$url,'type'=>$type,'tokenUrl'=>$url]; return $this->success($success); } $key = 'remote/' . $info->getFilename(); $source_file = './' . 'uploads' . '/' . $info->getSaveName(); $upload = new uploadToCloud();; $s = $upload->upload($key,$source_file); if(($s['@metadata']['statusCode'] ?? '') == '200') { gc_collect_cycles(); unset($info); unlink($source_file); $success = ['url'=>$key,'type'=>'2','tokenUrl'=>$upload->makeUrl($key)]; return $this->success($success); }else{ return '上传云失败'; } } else { // 上传失败获取错误信息 echo $file->getError(); } }else{ $this->throwError('没有找到上传的文件','3010'); } }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } }