public function newList($request, $response) {/*{{{*/ $response->controller = 'Index'; $response->object = 'flow'; $this->initialize($request, $response); $this->forceSpaceModuleCheck('Case', $response); //threads总数和flow总数 $threadsCount = ThreadClient::getInstance()->getUnSpacePostThreadsCount($this->_newSpace->id, $this->_newUser->id, array('isBrowser'=>$this->_newUser->isNull())); $flowsCount = FlowClient::getInstance()->getFlowListCount($this->_newSpace->id, array('p_type'=>'all', 'isBrowser'=>$this->_newUser->isNull())); $response->flowCount = $threadsCount + $flowsCount; $options = array(); $options['filterUserId'] = $this->_newUser->id; $options['spaceId'] = $this->_newSpace->id; $nowPage = intval($request->getRequest('p', 1)); $nowPage = $nowPage > 0 ? $nowPage : 1; $pageSize = 25; $freeFlowCount = FlowClient::getInstance()->getFreeFlowCntBySpace($this->_newSpace, $needCache = false); $chargeFlowCount = FlowClient::getInstance()->getPaiedFlowCntBySpace($this->_newSpace, $needCache = false); $response->chargeFlowCount = $chargeFlowCount; $threadOptions = array(); $threadOptions['nowPage'] = $nowPage; $threadOptions['pageSize'] = $pageSize; if (false == $this->_newUser->isNull()) { $threadOptions['excludeuser'] = $this->_newUser->id; } $unPostThreadList = ThreadClient::getInstance()->getUnSpacePostThreads($this->_newSpace->id, $this->_newUser->id, $threadOptions); $myThreadIds = array(); if (false == $this->_newUser->isNull()) { $myThreadIds = ThreadClient::getInstance()->getMyThreadInSpace($this->_newSpace->id, $this->_newUser->id); } $nowPageThreadCount = count($unPostThreadList); if ($nowPageThreadCount < $pageSize) { if ($nowPageThreadCount > 0) { $options['from'] = 0; $options['pageSize'] = $pageSize - $nowPageThreadCount; } else { $options['from'] = (($nowPage-1) * $pageSize == $threadsCount - count($myThreadIds)) ? 0 : (($nowPage - 1) * $pageSize - $threadsCount + count($myThreadIds)) ; $options['pageSize'] = $pageSize; } $res = FlowClient::getInstance()->getAllFlows($options); $flowList = $unPostThreadList + $res['refs']; } else { $flowList = $unPostThreadList; } $userSelfFlowCnt = 0; if(false == $this->_newUser->isNull()) { $userSelfFlowCnt = FlowClient::getInstance()->getAllFlowCnt(array('spaceId' => $this->_newSpace->id, 'userId' => $this->_newUser->id)); } $pageInfo = Pager::calcPageInfo(($freeFlowCount + $chargeFlowCount + $threadsCount - $userSelfFlowCnt), $nowPage, $pageSize); $response->pagelink = PageNav::getNavLink(PageNav::getPageNavTemplate("?&p="), $pageInfo['nowpage'], $pageInfo['pagesize'], $pageInfo['total']); $userSelf = array(); //当前患者的流 if($nowPage == 1 && $this->_newUser->isNull() == false && $this->_newUser->id != $this->_newSpace->user->id) { $userSelf = ThreadClient::getInstance()->getMyThreadAndFlowInSpace($this->_newSpace->id, $this->_newUser->id); if(false == empty($userSelf)) { $response->lastPostList = DoctorPatientPostClient::getInstance()->getLastPosts4Flows(array_keys($userSelf)); } } //取intention $intentionList = array(); if(false == $this->_newUser->isNull()) { $intentionList = IntentionClient::getInstance()->queryThreadIntentions($this->_newUser->id, '', '', $this->_newSpace->id); } $response->out = array_merge($intentionList, $userSelf , $flowList); $response->flowList = $response->out; $this->getCommonData($request, $response, $userSelf + $flowList); }/*}}}*/
private function addPost2Flow($user, $ref, $postContent, $option) {/*{{{*/ // 如果还有继续能回复post的就打开post回复开关 if ($ref->isClosePost()) { DoctorPatientPostClient::getInstance()->switchPatientPostCan($this->user->id, $ref->id); } if ($postContent || (isset($option['attachmentIds']) && false == empty($option['attachmentIds']))) { $post = DoctorPatientPostClient::getInstance()->addPost($ref->id, $this->user->id, $postContent, $option); if (false == $post->isNull()) { //系统日志 try{ FlowClient::getInstance()->addLog($ref,$this->user, DoctorPatientLog::TYPE_SYSTEM_LOG, 'FlowController::createPost', $post); }catch(Exception $ex) {} //管理员给患者的提示信息失效 NfsClient::getInstance()->disablePatientNotice($ref->id); } return $post->id; } return 0; }/*}}}*/
public function spaceReplyCase($spaceId, $patientId, $content, $deviceType, $options = array(), $caseId = '', $caseType = '', $os=MobileApi::ANDROID) {/*{{{*/ $space = DAL::get()->find('space', $spaceId); $user = $space->user; if ($user->isNull()) { $this->setErrorCode(107); return 0; } $userId = $user->id; $content = str_replace("<", "<", $content); $content = str_replace(">", ">", $content); $content = str_replace(""", "\"", $content); $content = str_replace("'", "'", $content); $content = strip_tags($content, "<a>"); if (MobileApi::IOS == $os) { $content = $this->convertMarkBack($content, $space); } //兼容老版本spaceid和patientid if($caseId && $caseType) { if($caseType == 'thread') { // $thread = DAL::get()->find_by_id_and_status('thread', $caseId, Thread::STATUS_VALID); $thread = $this->getTheRightThread($caseId); } else { $thread = DAL::get()->find('doctorpatientref', $caseId); } } else { //先取proposal再取flow $thread = DAL::get()->find_by_spaceid_and_patientid_and_status_and_servicedef('proposal', $spaceId, $patientId, Proposal::STATUS_NORMAL, ServiceDef::TYPE_FLOW); if($thread->isNull()) { $thread = DAL::get()->find_by_spaceid_and_patientid('doctorPatientRef', $spaceId, $patientId); } } if($thread->isNull()) { $this->setErrorCode(142); return 0; } $attachmentIds = ''; if(isset($options['attachmentIds'])) { $attachmentIds = $options['attachmentIds']; } $postContent = array('content'=>$content, 'attachmentIds'=>$attachmentIds); if($thread instanceof Proposal) { ProposalClient::getInstance()->firstReply($thread, $space, $content); ScoreClient::getInstance()->reply($user, $thread); } else if($thread instanceof DoctorPatientRef) { if ($thread->isClosePost()) { DoctorPatientPostClient::getInstance()->switchPatientPostCan($thread->space->user->id, $thread->id); } //每次回复都会传remove参数,只有当判断选项时,才让option里面的remove参数恒有值 jz if($thread->replyLimitationIsApproaching()) { $option['removeReplyLimitation'] = isset($options['removeReplyLimitation']) ? $options['removeReplyLimitation'] : 0; } if(isset($option['removeReplyLimitation']) && $option['removeReplyLimitation']) { if($thread->space->isChargeOpened()) { //$option['removeReplyLimitation'] = 0; //当是收费咨询的时候,取消remove参数。因为传0或者1都会在addPost再次改变次数 unset($option['removeReplyLimitation']); FlowClient::getInstance()->addFreeServcieCardBySystem($thread); } } $attachmentIds = explode(',', $attachmentIds); $option['attachmentIds'] = $attachmentIds; $post = DoctorPatientPostClient::getInstance()->addPost($thread->id, $userId, $content, $option); DBC::requireFalse($post->isNull(), '系统繁忙,请稍后重试'); if (false == $post->isNull()) { ScoreClient::getInstance()->replyForFlow($user, $thread); } //系统日志 try{ FlowClient::getInstance()->addLog($thread,$user, DoctorPatientLog::TYPE_SYSTEM_LOG, 'CaseDataBucket::spaceReplyCase', $post); }catch(Exception $ex) {} //加入默认患友会 if($user->id == $thread->space->user->id && $thread->space->isPatientOpened() && $thread->isReGroupMember() == false) { FlowClient::getInstance()->addUserToDefaultReGroup($thread->id, $user->id); } } }/*}}}*/
public function ajaxModifyDoctorReplyQuality($request, $response) { /*{{{*/ $doctorPatientRefId = $request->refId; $inspector = $this->curInspector; $doctorMarkId = DoctorPatientPostClient::getInstance()->modifyDoctorReplyQuality($doctorPatientRefId, $inspector, $request->replyQuality); echo $doctorMarkId; return self::DIRECT_OUTPUT; }
public function agentAddFollowupPost($request, $response) { /*{{{*/ $ownerId = $request->ownerid; if (empty($ownerId)) { die('随访患者报到信息不存在!'); } $owner = DAL::get()->find('FollowupOwner', $ownerId); if ($owner->isNull()) { die('随访患者报到信息不存在!'); } $doctorPatientRef = DAL::get()->find_by_patientid_and_spaceid('DoctorPatientRef', $owner->patient->id, $owner->space->id); $relateEntity = $doctorPatientRef; if ($doctorPatientRef->isNull() || $owner->isOpenFollowup() == false) { die('医患流不存在或者未开通随访!'); } $option = array(); $attachmentIds = $request->attachmentIds != null ? $request->attachmentIds : ''; $attachmentArr = $attachmentIds == '' ? array() : explode(',', $attachmentIds); $option['attachmentIds'] = $attachmentArr; $option['agentAuditorId'] = $this->auditor->id; //患者代理 $postContent = $request->getRequest('content'); if (($postContent == '点击此处跟大夫对话!' || $postContent == '') && $attachmentIds != '') { $postContent = '有新资料上传'; } $labelIds = $request->labelIds ? $request->labelIds : array(); if (empty($labelIds)) { $post = DoctorPatientPostClient::getInstance()->addPost($doctorPatientRef->id, $owner->user->id, $postContent, $option); //系统日志 try { FlowClient::getInstance()->addLog($doctorPatientRef, $owner->user, DoctorPatientLog::TYPE_SYSTEM_LOG, 'FollowupController::agentAddFollowupPost', $post); } catch (Exception $ex) { } } else { $post = FollowupPostClient::getInstance()->addFollowupPost($owner->id, $this->auditor->id, $postContent, $attachmentArr, $request->labelIds); } DBC::requireFalse($post->isNull(), '系统繁忙,请稍后重试'); $response->setRedirect($response->router->urlfor('nfsaudit/blankpage', array())); }
/** * @brief 管理员打开/关闭流 * @author lhl * @version branches/v2.14.23 * @date 2013-07-25 */ public function switchPatientPostCan($request, $response) { /*{{{*/ DoctorPatientPostClient::getInstance()->switchPatientPostCan($this->space->user->id, $request->refid); $ref = DAL::get()->find('doctorPatientRef', $request->refid); $response->setRedirect($ref->url); }
public function ajaxDelPicture($request, $response) { DoctorPatientPostClient::getInstance()->deletePicturePost($request->picturePostId, $this->curInspector->user); $response->callback = $request->callback; return true; }
public function updatePost($request, $response) {/*{{{*/ $ref = DAL::get()->find('DoctorPatientRef', $request->refid); $editPostType = $request->editposttype; if('Post' == $editPostType) { $editPost = DAL::get()->find('Post', $request->editpostid); } else { $editPost = DAL::get()->find('DoctorPatientPost', $request->editpostid); } $relateEntity = $ref; if($ref->isNull() || in_array($this->_newUser->id, array($ref->user->id, $ref->space->user->id)) == false) { header('Location: '.$this->_newSpace->url); return; } // 如果还有继续能回复post的就打开post回复开关 if ($ref->isClosePost()) { DoctorPatientPostClient::getInstance()->switchPatientPostCan($this->_newUser->id, $ref->id); } $option = array(); $attachmentIds = ($request->attachmentIds != null) ? $request->attachmentIds : ''; $attachmentArr = explode(',', $attachmentIds); $option['attachmentIds'] = $attachmentArr; if($ref->space->user->id == $this->_newUser->id) { $content = $ref->space->name."大夫和您有新对话<a href='".$ref->url."' target='_blank'>点击查看详情</a>"; $title = $ref->space->name."大夫和您有新对话"; StationLetterClient::getInstance()->sendMsg(Message::AdminUserId, $ref->user->id, $title, $content); } if($editPost->isSpaceReply()) { $postContent = $request->getUnSafeData('content'); } else { $postContent = $request->content; } if(($postContent == '点击此处跟大夫对话!' || $postContent == '') && $attachmentIds <> '') { $postContent = '有新资料上传'; } $post = new NullEntity(); if('Post' == $editPostType) { $post = PostClient::getInstance()->update4Flow($this->_newUser, $request->editpostid, array('content'=>$postContent, 'attachmentIds'=>$attachmentArr)); } else { $post = DoctorPatientPostClient::getInstance()->updateDoctorPatientPost($editPost->id, array('content'=>$postContent, 'attachmentIds'=>$attachmentArr)); } if(false == $post->isNull() && $ref->user->id == $this->_newUser->id) { //管理员给患者的提示信息失效 PatientSigninClient::getInstance()->disablePatientNotice($ref->id); } DBC::requireFalse($post->isNull(), '系统繁忙,请稍后重试'); $response->setRedirect($ref->url."#reply"); }/*}}}*/
public function healthdiary($request, $response) {/*{{{*/ $user = $this->user; $signin = $this->user->getFollowupPatientSignin(); if($signin->isNull() || ($signin->isNull() == false && false == $signin->isOpenFollowup() && $signin->isSuspendedFollowup() == false)) { $response->setRedirect("http://".URL_PREFIX."passport.haodf.com"); } $response->signin = $signin; //默认不弹出 $nofirst = $request->getRequest('nofirst', 0); $isDisplay = $request->getRequest('isDisplay', 0); $success = $request->getRequest('success',0); if($signin->isNull() && $signin->isSuspendedFollowup()) { $isDisplay = 0; } $response->isDisplay = $isDisplay; $response->saveresult = $success; $response->lastSpacePosts = DoctorPatientPostClient::getInstance()->getLastSpacePostForPayedUser($signin->space->id,30); $response->signin = $signin; // 患教课堂部分 $this->_patientsTech($request, $response); $response->ref = DAL::get()->find_by_spaceid_and_patientid('DoctorPatientRef', $signin->space->id, $signin->patient->id); $ticketId = $request->ticketId; if(empty($ticketId) == false) { $checkupTicket = DAL::get()->find('checkupticket', $ticketId); } else { // 先出临时任务,出定期临时,再出复查任务,只显示正在进行中的任务 $checkupTickets = CheckupClient::getInstance()->getUserWaitingTickets($this->user->id); $checkupTicket = new NullEntity(); $followupCnt = 0; $cycleTemporaryCnt = 1000; $temporaryCnt = 2000; $customizeCnt = 3000; $sortTicketList = array(); foreach ($checkupTickets as $t) { if ($t->task->isFollowupTask()) { $sortTicketList[$followupCnt++] = $t; } else if ($t->task->isTemporaryTask()) { $sortTicketList[$temporaryCnt++] = $t; } else if ($t->task->isCycleTemporaryTask()) { $sortTicketList[$cycleTemporaryCnt++] = $t; } else if ($t->task->isCustomizeTask()){ $sortTicketList[$customizeCnt++] = $t; } } if ($temporaryCnt - 2000 > 0) { $checkupTicket = $sortTicketList[$temporaryCnt - 1]; } else if ($cycleTemporaryCnt - 1000 > 0) { $checkupTicket = $sortTicketList[$cycleTemporaryCnt - 1]; } else if ($followupCnt - 0 > 0) { $checkupTicket = $sortTicketList[$followupCnt - 1]; } else if ($customizeCnt - 3000 > 0){ $checkupTicket = $sortTicketList[$customizeCnt - 1]; } } $response->checkupTicket = $checkupTicket; $healthProblemList = DAL::get()->find_all_userAllHealth('HealthRecordProblem', $user->id); $response->healthProblemList = $healthProblemList; $lastDiaryList = HealthDiaryClient::getInstance()->getLastDiarys($user->id, 2); $response->lastDiaryList = $lastDiaryList; $diaryIds = array_keys($lastDiaryList); $abnormalStatus = array(); if(empty($diaryIds) == false) { $abnormalStatus = PatientCaseHistoryClient::getInstance()->getAbnormalStatusByEntityIds($diaryIds); } $response->abnormalStatus = $abnormalStatus; //吃药 $userCurrentMedicineSchemeList = MedicineClient::getInstance()->getUserCurrentMedicineScheme($user->id); $response->userCurrentMedicineSchemeList = $userCurrentMedicineSchemeList; $medicineId_dotime_answer = $this->medicineId_dotime_answer(MedicineClient::getInstance()->getLastSomeDaysCurrentMedicineAnswerList($user->id, 5)); $response->medicineId_dotime_answer = $medicineId_dotime_answer; // 获取复查任务 显示下次复查时间,只查复查的 $checkupTicketList = CheckupClient::getInstance()->getUserLastFollowupTickets($user->id); $nextTask = new NullEntity(); $nextTaskTime = new NullEntity(); foreach ($checkupTicketList as $ticket) { $nt = CheckupClient::getInstance()->getNextTask($ticket->id); $ntt = CheckupClient::getInstance()->getNextTaskTime($ticket->id); if ($nt->isNull() == false) { if ($nextTask->isNull() || XDateTime::dayDiff($ntt, $nextTaskTime) > 0) { $nextTask = $nt; $nextTaskTime = $ntt; } } } $response->nextTask = $nextTask; $response->nextTaskTime = $nextTaskTime; $response->noFirst = $nofirst; //医生助理其他批注 $response->unReadAnnotationList = DAL::get()->find_all_byUserId_hosttype_read('NfsAnnotation', $user->id, array('HealthDiary','DoctorPatientPost'), NfsAnnotation::IS_USER_READ_NO); }/*}}}*/
public function addFlowPost($request, $response) {/*{{{*/ $arr = array(); $arr['username'] = $request->username; $arr['password'] = $request->password; $arr['content'] = $request->getRequest('content'); $flowId = $request->flowId; $partnerName = $request->partnerName; $urlSuffix = ''; if(false == empty($partnerName)) { $urlSuffix = '4'.$partnerName; } $flow = DAL::get()->find('DoctorPatientRef', $flowId); if($this->isOwner($this->_newUser, $flow)) { DoctorPatientPostClient::getInstance()->addPost($flowId, $this->_newUser->id, $arr['content'], array()); $response->setRedirect("/thread/detail".$urlSuffix.".htm?flowid=".$flowId); } elseif ($arr['username'] == $thread->user->name && $thread->user->password == $thread->user->encryptPassword($arr['password'])) { UserClient::getInstance()->login($arr['username'] , $arr['password'] , false, null, $this->partnerDomain); DoctorPatientPostClient::getInstance()->addPost($flowId, $flow->user->id, $arr['content']); $response->setRedirect("/thread/detail".$urlSuffix.".htm?id=".$threadId); } else { $msg = "用户名或密码不正确..."; $response->setRedirect('/thread/finish'.$urlSuffix.'.htm?msg='.$msg); } }/*}}}*/
public function updatePost($request, $response) {/*{{{*/ $editPostId = $request->postid; $refId = $request->refid; $postContent = $request->content; DoctorPatientPostClient::getInstance()->updateDoctorPatientPost($editPostId, array('content'=>$postContent)); $response->setRedirect('/suifang/taskdetail?refId='.$refId); }/*}}}*/
public function createPost($request, $response) {/*{{{*/ $ref = DAL::get()->find('DoctorPatientRef', $request->refid); if ($ref->isNull() || ($this->user->id != $ref->user->id)) { header('Location: '.$response->touchUrl); return; } // 如果还有继续能回复post的就打开post回复开关 if ($ref->isClosePost()) { DoctorPatientPostClient::getInstance()->switchPatientPostCan($this->user->id, $ref->id); } $option = array(); $attachmentIds = ($request->attachIds != null) ? $request->attachIds : ''; $attachmentArr = explode(',', $attachmentIds); $option['attachmentIds'] = $attachmentArr; $delAttIds = array(); $paList = DAL::get()->find('PatientAttachment', $attachmentArr); foreach($paList as $index => $pa) { if($pa->isNull() || $pa->isDeleted()) { $delAttIds[] = $pa->id; } } foreach ($attachmentArr as $attKey => $attachment) { if ($attachment == "" || in_array($attachment, $delAttIds)) { unset($attachmentArr[$attKey]); } } //$postContent = XString::convertUTF8ToGBK($request->content); $postContent = $request->content; if(($postContent == '点击此处跟大夫对话!' || $postContent == '请填写咨询内容...' || $postContent == '') && false == empty($attachmentArr)) { $postContent = '有新资料上传'; } if (isset($_SESSION['flowMemory'][$ref->id])) { unset($_SESSION['flowMemory'][$ref->id]); } if ($postContent || false == empty($attachmentArr)) { $post = DoctorPatientPostClient::getInstance()->addPost($ref->id, $this->user->id, $postContent, $option); if (false == $post->isNull()) { //系统日志 try{ FlowClient::getInstance()->addLog($ref,$this->user, DoctorPatientLog::TYPE_SYSTEM_LOG, 'FlowController::createPost', $post); }catch(Exception $ex) {} //管理员给患者的提示信息失效 NfsClient::getInstance()->disablePatientNotice($ref->id); } } $url = $ref->getTouchUrl($this->touchDomain); $response->setRedirect($url); }/*}}}*/
private function getFlowLastPostList($flowIds) { /*{{{*/ $lastPostList = array(); if (false == empty($flowIds)) { $lastPostList = DoctorPatientPostClient::getInstance()->getLastPosts4Flows($flowIds); } return $lastPostList; }
/** * deleteDoctorPatientPost 删除流最后一条医生post * * @param mixed $flowId * @param mixed $postId * @access public * @return void */ public function deleteDoctorPatientPost($flowId, $postId) {/*{{{*/ $ref = DAL::get()->find('DoctorPatientRef', $flowId); //$post = DAL::get()->find('DoctorPatientPost', $postId); if($ref->isNull()) { $this->setErrorCode(328); return 0; } FlowClient::getInstance()->deletePostBySpace($postId, $ref); $post = DAL::get()->find('DoctorPatientPost', $postId); if($post->isHavePicture()) { $ids = array_keys($post->picturePosts); if(false == empty($ids)) { foreach($ids as $id) { DoctorPatientPostClient::getInstance()->deletePicturePost($id, $ref->space->user); } } } $this->content = array('id'=>$postId); }/*}}}*/
private function _yiwenjiejue_add_post($customer, $auditor, $content, $labelIds, $options) { /*{{{*/ $owner = $customer->getFollowupOwner(); if ($owner->isNull()) { return new NullEntity(); } $doctorPatientRef = DAL::get()->find_by_patientid_and_spaceid('DoctorPatientRef', $owner->patient->id, $owner->space->id); if ($doctorPatientRef->isNull()) { return new NullEntity(); } if (empty($content)) { return new NullEntity(); } if (false == $owner->isOpenFollowup()) { return new NullEntity(); } if (empty($labelIds)) { $post = DoctorPatientPostClient::getInstance()->addPost($doctorPatientRef->id, $owner->user->id, $content, $options); if (false == $post->isNull()) { try { FlowClient::getInstance()->addLog($doctorPatientRef, $owner->user, DoctorPatientLog::TYPE_SYSTEM_LOG, 'WorkNoteController::_yiwenjiejue_add_post', $post); } catch (Exception $ex) { } } } else { $post = FollowupPostClient::getInstance()->addFollowupPost($owner->id, $auditor->id, $content, array(), $labelIds); } }
public function addTemporaryTask($request, $response) { /*{{{*/ /* // 跟进任务时间要晚于今天 if (XDateTime::dayDiff(XDateTime::today(), XDateTime::valueOf($request->nfstasktime)) < 1) { echo '跟进任务日期要晚于今天'; exit; } */ $doctorPatientRefId = $request->doctorPatientRefId; $doctorPatientRef = DAL::get()->find('DoctorPatientRef', $doctorPatientRefId); $qids = $request->var; $questions = array(); $categories = array(); $tpls = array(); foreach ($qids as $qid) { $question = DAL::get()->find('nfsquestion', $qid); if ($question->isNull()) { $category = DAL::get()->find('questioncategory', $qid); if ($category->isScale()) { $questionArr = $category->questions; $firstQuestion = array_shift($questionArr); $firstQuestionId = $firstQuestion->id; $scaleTplId = NfsClient::getInstance()->createQuestionNaireTpl(array($category), $category->name, QuestionNaireTpl::TYPE_LINK, $firstQuestionId); $scaleTpl = DAL::get()->find('questionnairetpl', $scaleTplId); $tpls[] = $scaleTpl; continue; } $categories[$category->id] = $category; $tmpQuestions = $category->getQuestions(); foreach ($tmpQuestions as $tmpQuestion) { $questions[$tmpQuestion->id] = $tmpQuestion; } } else { $questions[$question->id] = $question; } } $questionCates = array(); $questionStr = ""; foreach ($questions as $question) { $hasInclude = false; foreach ($categories as $category) { $questionCates[$category->id] = $category; if ($category->hasInclude($question->category)) { $hasInclude = true; } } if ($hasInclude == false) { $questionCates[$question->category->id] = $question->category; } $questionStr .= $question->category->name . "-" . $question->title . " "; } $checkupName = $request->checkupname; if (empty($questionCates) == false) { $questionTplId = NfsClient::getInstance()->createQuestionNaireTpl($questionCates, $checkupName, QuestionNaireTpl::TYPE_CHECK, 0, QuestionNaireTpl::IS_SHOW_BUTTON_NO); $questionTpl = DAL::get()->find('QuestionNaireTpl', $questionTplId); $tpls[] = $questionTpl; $questionNaire = NfsClient::getInstance()->createQuNaire($doctorPatientRef->space, $questionTpl, $questions); } $description = $request->shuoming == null ? '' : $request->shuoming; $checkupDateTime = XDateTime::valueOf($request->checkuptime); $isCycleTemporaryTask = $request->iscycletemporarytask != null ? true : false; $cycleDay = $request->cycleday; $nfsDisease = DAL::get()->find('nfsDisease', $request->nfsdiseaseid); if ($nfsDisease->isNull()) { echo "随访的疾病不存在,请核实。。。"; exit; } if ($isCycleTemporaryTask == true) { CheckupClient::getInstance()->addUserCycleTemporaryTask($nfsDisease, $doctorPatientRef->user->id, $doctorPatientRef->space->id, $checkupDateTime, $checkupName, $tpls, $cycleDay, $description); } else { CheckupClient::getInstance()->addUserTemporaryTask($nfsDisease, $doctorPatientRef->user->id, $doctorPatientRef->space->id, $checkupDateTime, $checkupName, $tpls, $description); } //添加电话任务 $doctorPatientPost = DoctorPatientPostClient::getInstance()->getOnePostByRefId($doctorPatientRef->id); /* //电话咨询任务的模板 $model = DAL::get()->find_by_title('nfsTaskModel', '临时复查跟踪任务'); $desc = "复查名称:".$checkupName."\n复查日期:".$checkupDateTime."\n说明:".$description."\n复查项:".$questionStr; if($doctorPatientPost->isNull() == false && $model->isNull() == false) { $deadline = XDateTime::valueOf($request->nfstasktime); TaskClient::getInstance()->addTask(array($model), $doctorPatientPost, $doctorPatientRef->space, $doctorPatientRef->user, $this->auditor, $this->auditor, $deadline, $desc); } */ $response->setRedirect($response->router->urlfor('checkup/managetemporarytask', array('refid' => $doctorPatientRefId))); }