public function addIncidentPost($request, $response)
 {
     $followupCustomerId = $request->followupCustomerId;
     $params = $request->arr;
     $vars = $request->vars;
     $incident = DAL::get()->find_by_title_and_followupcustomerid('Incident', $params['title'], $followupCustomerId);
     if ($incident instanceof Incident) {
         throw new BizException('事件名称已存在!');
     }
     $incidentId = IncidentClient::getInstance()->addIncident($followupCustomerId, $params['title'], $params['firstTime'], $params);
     $incident = DAL::get()->find('Incident', $incidentId);
     $followupCustomer = DAL::get()->find('FollowupCustomer', $followupCustomerId);
     $model = DAL::get()->find_by_title('NfsTaskModel', '症状事件');
     $model = array($model);
     $incident = DAL::get()->find('Incident', $incidentId);
     $user = $followupCustomer->getBindUser();
     $assigner = $this->auditor;
     $deadline = XDateTime::tomorrow();
     $taskDesc = "新建症状事件任务";
     $roleId = 825967283;
     //医助的角色id
     $taskId = TaskClient::getInstance()->addTask($model, $incident, $followupCustomer->space, $user, $assigner, $deadline, $taskDesc, $roleId);
     $this->addIncidentStatePostImp($incident, $vars);
     $preMsg = "{$incidentId} 添加成功";
     $response->setRedirect($response->router->urlfor('incident/incidentsofcustomer', array('followupCustomerId' => $followupCustomerId, 'preMsg' => $preMsg)));
 }
 /**
  * Test remove task
  * 
  * @param array $task
  * @param int $taskId
  * @param string $exception
  * @param bool $result
  * @dataProvider removeProvider
  */
 public function testRemove(array $task, $taskId, $exception, $result)
 {
     if ($exception) {
         $this->expectException($exception);
     }
     if ($task) {
         $this->assertTrue((bool) $this->TaskClient->save($task), 'Can\'t save task for test');
     }
     $this->assertSame($result, $this->TaskClient->remove($taskId));
 }
 public function markAuditFinished($request, $response)
 {
     /*{{{*/
     $ownerId = $request->ownerid;
     $taskIdArr = $request->auditfinished;
     if (!empty($taskIdArr)) {
         TaskClient::getInstance()->markAuditFinished($taskIdArr, $this->auditor);
     }
     $response->setRedirect($response->router->urlfor('followup/patientfollowupinfo', array('ownerid' => $ownerId)));
 }
 public function modifyWorkSheetSubmit($request, $response)
 {
     /*{{{*/
     $workSheetId = $request->worksheetid;
     $contactTime = $request->contacttime;
     $task = DAL::get()->find_by_sourceid('nfstask', $workSheetId);
     if ($contactTime != $task->deadline->toShortString()) {
         TaskClient::getInstance()->changeTaskDeadline4WorkSheet($task->id, $contactTime);
     }
     $healthItemNames = $request->healthitemnames;
     $contactLabelIds = $request->contactlabelids;
     $contactMedicineInfo = $request->contactmedicineinfo;
     $contactOtherInfo = $request->contactotherinfo;
     WorkSheetClient::getInstance()->modifyUnSubmitWorkSheet($workSheetId, $healthItemNames, $contactLabelIds, $contactMedicineInfo, $contactOtherInfo);
     $response->setRedirect($response->router->urlfor('followup/modifyworksheetinfo', array('worksheetid' => $workSheetId)));
 }
 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) {
         $role = DAL::get()->find_by_name("followupAuditorRole", FollowupAuditorRole::NAME_ASSISTANTDOCTOROPERATION);
         $deadline = XDateTime::valueOf($request->nfstasktime);
         TaskClient::getInstance()->addTask(array($model), $doctorPatientPost, $doctorPatientRef->space, $doctorPatientRef->user, $this->auditor, $deadline, $desc, $role->id);
     }
     $response->setRedirect($response->router->urlfor('nfsaudit/managetemporarytask', array('refid' => $doctorPatientRefId)));
 }
 /**
  * Tast if task must be stopped
  * 
  * @param array $task
  * @param int $taskId
  * @param bool $mustStop
  * @dataProvider mustStopProvider
  */
 public function testMustStop(array $task, $taskId, $mustStop)
 {
     $this->TaskClient->save($task);
     $this->assertSame($mustStop, $this->TaskServer->mustStop($taskId));
 }
 public function bindTask4Bloodsugarstep($request, $response)
 {
     /*{{{*/
     $bloodSugarStep = DAL::get()->find('BloodSugarStep', $request->bloodSugarStepId);
     DBC::requireTrue($bloodSugarStep instanceof BloodSugarStep, "不存在该血糖");
     $followupCustomer = $bloodSugarStep->followupCustomer;
     $model = DAL::get()->find_by_title('NfsTaskModel', '血糖任务');
     $model = array($model);
     $user = $followupCustomer->getBindUser();
     $assigner = $this->auditor;
     $deadline = XDateTime::tomorrow();
     $taskDesc = "新建血糖管理任务";
     $roleId = 825967283;
     //医助的角色id
     $taskId = TaskClient::getInstance()->addTask($model, $bloodSugarStep, $followupCustomer->space, $user, $assigner, $deadline, $taskDesc, $roleId);
     $preMsg = $bloodSugarStep->id . "绑定成功";
     $response->setRedirect($response->router->urlfor('bloodsugarstep/bloodsugarstepsofcustomer', array('followupCustomerId' => $followupCustomer->id, 'preMsg' => $preMsg)));
 }
 public function bindTask4HealthItemProject($request, $response)
 {
     /*{{{*/
     $healthItemProject = DAL::get()->find('HealthItemProject', $request->healthItemProjectId);
     DBC::requireTrue($healthItemProject instanceof HealthItemProject, "不存在该项目");
     $followupCustomer = $healthItemProject->followupCustomer;
     $model = DAL::get()->find_by_title('NfsTaskModel', '体重管理');
     $model = array($model);
     $user = $followupCustomer->getBindUser();
     $assigner = $this->auditor;
     $deadline = XDateTime::tomorrow();
     $taskDesc = "新建体重管理任务";
     $roleId = 825967283;
     //医助的角色id
     $taskId = TaskClient::getInstance()->addTask($model, $healthItemProject, $followupCustomer->space, $user, $assigner, $deadline, $taskDesc, $roleId);
     $preMsg = $healthItemProject->id . "绑定成功";
     $response->setRedirect($response->router->urlfor('healthitemproject/healthitemprojectsofcustomer', array('followupCustomerId' => $followupCustomer->id, 'preMsg' => $preMsg)));
 }
 /**
  * Approximate runtime of the command
  * 
  * @param string $command
  * @return int
  */
 public function approximateRuntime($command)
 {
     $tasks = $this->Task->find('list', array('conditions' => array('command' => $command, 'status' => TaskType::FINISHED, 'runtime >' => 0), 'fields' => array('id', 'runtime'), 'limit' => Configure::read('Task.approximateLimit'), 'order' => array('id' => 'DESC')));
     return $tasks ? (int) round(array_sum($tasks) / count($tasks)) : 0;
 }
Example #10
0
<?php

$_auditorsRole = DAL::get()->find_by_name('followupauditorrole', FollowupAuditorRole::NAME_ASSISTANTDOCTOROPERATION);
$_followupAuditorList = FollowupAuditorClient::getInstance()->getAuditorListByRoleId($_auditorsRole->id);
$theFollowupOwner = $theFollowupCustomer->getFollowupOwner();
$_taskModelListOfDangerMgr = TaskClient::getInstance()->getTaskModelListOfDangerMgr();
?>
<div class="mt10 pt5" style="border-top:1px dotted #ccc;">
<div class="f16"><?php 
echo $_no;
?>
 出组处理 
</div>
<div class="content_div">
<input type="button" class="createTask" value="转任务" />
<table class="adminlist" cellspacing="0" cellpadding="0" border="1" style="margin-top:5px;">
    <tr >
        <th class="ltl" width=60 style="text-align:right"><input type="radio" name="_chuzu[chuzu]" value='0' checked/>不转组</th>
        <td>
           <div class="tip">不做出组处理,不改变运营负责人,不创建任务。</div> 
        </td>
    </tr>
    <tr>
        <th class="ltl" style="text-align:right;"><input type="radio" name="_chuzu[chuzu]" value='1'/> 转组</th>
        <td>
        
            <div>
            转组任务备注: <br/>
            <textarea cols="50" rows="2" name="_chuzu[chuzuRemark]"></textarea>
        
            <br/>
 function setCheckupTaskAuditor($request, $response)
 {
     /*{{{*/
     $followupAuditor = DAL::get()->find_by_auditorId('followupauditor', $request->auditorId);
     TaskClient::getInstance()->modifyTaskAuditor($request->taskId, $request->auditorId);
     $preMsg = "成功,taskId=" . $request->taskId . "; auditorId=" . $response->auditorId;
     $referer = $_SERVER['HTTP_REFERER'];
     //$referer .= ('&preMsg='.urlencode($preMsg));
     $response->setRedirect($referer);
 }
 private function _submit_chuzu($customer, $datas, EntityBase $sourceEntity)
 {
     /*{{{*/
     $str = "\n===出组 begin===";
     $followupCustomer = $customer;
     //转组
     if (isset($datas['chuzu']) && $datas['chuzu'] == 1) {
         $chuzuRemark = $datas['chuzuRemark'] ? $datas['chuzuRemark'] : '';
         $taskModelIdOfDangerMgr = $datas['taskModelIdOfDangerMgr'];
         $nextServiceAuditorId = $datas['nextServiceAuditorId'];
         //下一个责任人
         //修改责任人
         $nextServiceAuditor = DAL::get()->find('auditor', $nextServiceAuditorId);
         FollowupClient::getInstance()->markServiceAuditor($followupCustomer, $nextServiceAuditor, $this->auditor);
         $str .= "\n修改责任人为{$nextServiceAuditorId}.";
         //创建危险因素管理任务和出组交接任务
         $modelIds = array($taskModelIdOfDangerMgr, 945482850);
         //危险因素管理的任务modelID
         $models = DAL::get()->find('nfstaskmodel', $modelIds);
         $sourceEntity = $followupCustomer;
         $space = $followupCustomer->space;
         $user = $followupCustomer->getBindUser();
         $assigner = $this->auditor;
         if ($datas['deadline']) {
             $deadline = XDateTime::valueOf($datas['deadline']);
         } else {
             $deadline = XDateTime::today()->addDay(0);
         }
         $taskDesc = "首次工作单转组,危险因素管理任务和出组交接任务;备注:" . $chuzuRemark;
         $role = DAL::get()->find_by_name("followupAuditorRole", FollowupAuditorRole::NAME_ASSISTANTDOCTOROPERATION);
         $taskIds = TaskClient::getInstance()->addTask($models, $sourceEntity, $space, $user, $assigner, $deadline, $taskDesc, $role->id);
         $str .= "\n创建危险因素管理任务和出组交接任务:" . implode(',', $taskIds) . ".";
     } elseif (isset($datas['chuzu']) && $datas['chuzu'] == 2) {
         $followupOwner = $followupCustomer->getFollowupOwner();
         $nfsDisease = $followupOwner->getNfsDisease();
         //获取当前服务
         $curService = null;
         try {
             $curService = FollowupClient::getInstance()->findCurrentFollowupService($followupCustomer->id, $nfsDisease->id);
         } catch (Exception $ex) {
             $str .= "\n不在收费服务期.";
         }
         if ($curService instanceof FollowupServiceDetail) {
             $endserviceid = $curService->id;
             $endtype = FollowupServiceDetail::ENDTYPE_REFUND;
             $endreason = $datas['endreason'] ? $datas['endreason'] : '';
             $deadtime = null;
             FollowupClient::getInstance()->endFollowupService($endserviceid, $endtype, $this->auditor, $followupOwner->id, $endreason, $deadtime);
             $str .= "\n退费 : {$curService->id} : {$endreason} .";
         } else {
             $str .= "\n没有找到当期有效收费服务段,跳过退费.";
         }
         $taskIds = TaskClient::getInstance()->markFinishedTaskOfCustomersWithAuditor(array($followupCustomer->id), $this->auditor);
         $str .= "\n关闭全部医助运营任务:" . implode(',', $taskIds) . ".";
     } else {
         $str .= "\n不出组";
     }
     $str .= "\n===出组 end===";
     return $str;
 }