public function followupStateSummary($request, $response)
 {
     /*{{{*/
     $ownerId = $request->ownerid;
     $owner = DAL::get()->find('FollowupOwner', $ownerId);
     $response->owner = $owner;
     $startTime = $request->starttime;
     $response->startTime = $startTime;
     $endTime = $request->endtime;
     $response->endTime = $endTime;
     $search = $request->search;
     if (isset($search)) {
         $response->search = $search;
         $res = FollowupSchemeClient::getInstance()->getSchemeTask4StateSummary($owner->id, $startTime, $endTime);
         $response->schemeTaskList = $res['schemetasklist'];
         $response->schemeList = $res['schemelist'];
         $response->childCategoryList = $res['childcategorylist'];
         $response->parentCategoryList = $res['parentcategorylist'];
         $bloodFatHistoryList = PatientCaseHistoryClient::getInstance()->getCaseHistory4StateSummary('血脂', $owner->user->id, $startTime, $endTime);
         $response->bloodFatArr = $this->processBloodFatData($bloodFatHistoryList);
         $response->bloodJsonArr = HealthRecordClient::getInstance()->getBloodJsonData4StateSummaryChart($owner->user->id, $startTime, $endTime);
         $response->bloodGlucoseJsonArr = HealthRecordClient::getInstance()->getBloodGlucoseJsonData4StateSummaryChart($owner->user->id, $startTime, $endTime);
         $response->heartRateJson = HealthRecordClient::getInstance()->getAnswerJsonData4StateSummaryChart($owner->user->id, '心率', $startTime, $endTime);
         $response->userMedicineRefList = HealthRecordClient::getInstance()->getValidMedicineProblemUserRefByUserId($owner->user->id);
     }
 }
<?php
$isAbNormalArr = PatientCaseHistoryClient::getInstance()->getAbnormalStatusByEntityIds(array($flow->id));
$questionInfos = array();
foreach($flow->questionNaire->questionNaireTpl->quNaireTplCategoryRefs as $tplCategoryRef)
{
    foreach($tplCategoryRef->questionCategory->questions as $question)
    {
        $questionInfos[$question->id] = $tplCategoryRef->questionCategory->name;
    }
}
$normalCateList = $flow->getNormalAnswerCates();
$i = 0;
foreach($normalCateList as $normalCate) {
    $i++;
?>

    <p ><?=$i?>.<?=$normalCate->name?> &nbsp;&nbsp;<font color="red">正常</font></p>
<?php
}
$answerInfos = array();
$answers = $flow->answers;
foreach($answers as $answer)
{
    $title = '';
    if($answer->isNormal() == false)
    {
        $title = '复查结果中有异常项目:';
    }
    $answerInfos[$questionInfos[$answer->question->id]][] = $answer;
} ?>
<?php 
    public function ajaxGetMoreCaseHistory($request, $response)
    {/*{{{*/
        $response->counter = $request->counter;
		$params = array();
		$params['userId'] = $request->userid;

		$page = $request->getRequest('page', 1);
		$pageSize = 10;		
		$res = PatientCaseHistoryClient::getInstance()->getCaseHistoryList($page, $pageSize ,$params); 
		$response->caseHistoryList = $res['caseHistoryList'];
        $response->itemCategoryArr = PatientCaseHistoryClient::getInstance()->getItemCategoryArrFromCaseHistoryArr($res['caseHistoryList']);
    }/*}}}*/
 private function getAbnormalStatus($flowInfos)
 {
     /*{{{*/
     $entityIds = array();
     foreach ($flowInfos as $flow) {
         $entityIds[] = $flow->id;
     }
     $abnormalStatus = array();
     if (false == empty($entityIds)) {
         $abnormalStatus = PatientCaseHistoryClient::getInstance()->getAbnormalStatusByEntityIds($entityIds);
     }
     return $abnormalStatus;
 }
 public function ajaxShowCustomerInfoRecords4Operation($request, $response)
 {
     /*{{{*/
     $needAudited = FollowupCustomerInfoRecord::NEED_AUDITED_YES;
     $customerInfoRecordArr = DAL::get()->find_all_by_condition('FollowupCustomerInfoRecord', "customerid={$request->customerid} and needaudited ={$needAudited} order by ctime desc");
     $response->arrExtractedStatus = PatientCaseHistoryClient::getInstance()->getExtractedStatusByEntityIds(array_keys($customerInfoRecordArr));
     $response->ticketId = $request->ticketid;
     $response->customerInfoRecordArr = $customerInfoRecordArr;
     $response->labelList = DAL::get()->find_all_by_CategoryName('Label', LabelCategory::$typeArr[LabelCategory::NFS_CUSTOMERINFORECORD]);
 }
 /**
  * @brief 当前流所对应随访患者的病例库
  * @author lhl
  * @version branches/v2.14.23
  * @date 2013-07-25
  */
 public function patientCaseHistoryList($request, $response)
 {
     /*{{{*/
     $doctorPatientRefId = Codec::getInstance()->decodeId($request->refid);
     $ref = DAL::get()->find('DoctorPatientRef', $doctorPatientRefId);
     $response->ref = $ref;
     $user = DAL::get()->find('user', $ref->user->id);
     $params = array();
     $params['userId'] = $user->id;
     $pageParams = 'refid=' . $ref->getEncodeId();
     $page = $request->getRequest('page', 1);
     $pageSize = 10;
     $res = PatientCaseHistoryClient::getInstance()->getCaseHistoryList($page, $pageSize, $params);
     $caseHistoryList = $res['caseHistoryList'];
     $response->caseHistoryList = $caseHistoryList;
     $response->pageLink = '';
     if (false == empty($res['pageInfo'])) {
         $response->pageLink = PageNav::getNavLink(PageNav::getPageNavTemplateForSpace('/flow/patientcasehistorylist?' . $pageParams . '&page='), $res['pageInfo']['nowpage'], $res['pageInfo']['pagesize'], $res['pageInfo']['total']);
     }
 }
    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);
    }/*}}}*/
 private function doPassDiary($request, $response, $rediRectUrl)
 {
     /*{{{*/
     $medicineLogIdList = $request->medicinelog;
     $ticket = DAL::get()->find('NfsTaskTicket', $request->ticketId);
     NfsAuditClient::getInstance()->pass($this->auditor, $ticket->id);
     if ($ticket->hostEntity instanceof HealthDiary) {
         $this->refreshFlow($ticket->hostEntity->id);
     }
     if ($medicineLogIdList !== null) {
         $logList = DAL::get()->find('HealthRecordLog', $medicineLogIdList);
         foreach ($logList as $log) {
             $questionCategory = DAL::get()->find_by_name('QuestionCategory', $log->getItemCategoryName());
             $preparedData = array('diseaseName' => '冠心病', 'hospitalFaculty' => '', 'doctorName' => '', 'caseType' => '治疗', 'questionCategoryId' => $questionCategory->id, 'questionCategoryName' => $log->getItemCategoryName(), 'questionId' => $log->problem->id, 'itemName' => $log->problem->title, 'itemUnit' => $log->unit, 'itemValue' => $log->value, 'itemTextValue' => '', 'occurTime' => $log->ctime);
             //if ($log->getHealthDiary()->isUnaudited()) {
             $caseHistory = PatientCaseHistoryClient::getInstance()->addPatientCaseHistory($log->user, $this->auditor, $log->getHealthDiary(), $preparedData);
             //}
         }
     }
     $payingStatus = $request->payingStatus;
     if (false == isset($payingStatus)) {
         $payingStatus == 'all';
     }
     $params = array('payingStatus' => $payingStatus);
     $stageValue = $request->stageValue;
     if (isset($stageValue) && false == empty($stageValue)) {
         $params['stageValue'] = $stageValue;
     }
     $response->setRedirect($response->router->urlfor($rediRectUrl, $params));
 }
 public function showCaseHistoryList($request, $response)
 {
     /*{{{*/
     $userId = $request->userId;
     //显示范围
     $caseHistoryScope = $request->caseHistoryScope;
     $response->caseHistoryScope = $caseHistoryScope;
     //只显示某一来源的病历,但是会有多种类型的sourceid(附件,量表等)
     $sourceIds = $request->sourceIds;
     $user = DAL::get()->find('user', $userId);
     $response->user = $user;
     $params = array();
     $params['userId'] = $userId;
     $pageParams = 'userId=' . $userId;
     $pageParams .= "&doAction={$request->doAction}";
     if (false == empty($sourceIds)) {
         $params['sourceIds'] = explode(',', $sourceIds);
         $pageParams .= '&sourceIds=' . $sourceIds;
     }
     $page = $request->getRequest('page', 1);
     $pageSize = 15;
     $res = PatientCaseHistoryClient::getInstance()->getCaseHistoryList($page, $pageSize, $params);
     $caseHistoryList = $res['caseHistoryList'];
     $response->caseHistoryList = $caseHistoryList;
     $response->pageLink = '';
     if (false == empty($res['pageInfo'])) {
         $response->pageLink = PageNav::getNavLink(PageNav::getPageNavTemplate('/patientcasehistory/showcasehistorylist?' . $pageParams . '&page='), $res['pageInfo']['nowpage'], $res['pageInfo']['pagesize'], $res['pageInfo']['total']);
     }
     //当前操作
     $response->doAction = $request->doAction;
 }
 public function nextCheckup($request, $response)
 {
     /*{{{*/
     $ticketId = $request->ticketId;
     if (empty($ticketId)) {
         $ticket = NfsAuditClient::getInstance()->getNextTaskTicket($this->auditor, 'User', 'AnswerNaire');
     } else {
         $ticket = DAL::get()->find('NfsTaskTicket', $ticketId);
     }
     if ($ticket->isNull()) {
         die('审核结束');
     }
     $user = $ticket->owner;
     $pageSize = 15;
     $page = $request->page == null ? 1 : $request->page;
     $res = CheckupClient::getInstance()->getAuditCheckupList($page, $pageSize, $user->id);
     $response->pagelink = '';
     if (false == empty($res['pageInfo'])) {
         $response->pagelink = PageNav::getNavLink(PageNav::getPageNavTemplate('/checkup/nextcheckup?ticketId=' . $ticket->id . '&page='), $res['pageInfo']['nowpage'], $res['pageInfo']['pagesize'], $res['pageInfo']['total']);
     }
     $checkupList = $res['list'];
     $response->checkupList = $checkupList;
     $response->user = $user;
     $response->ticket = $ticket;
     $patientSignin = $user->getFollowupPatientSignin();
     $response->patientSignin = $patientSignin;
     $response->auditorId = $this->auditor->id;
     $checkupIds = array_keys($checkupList);
     $arrExtractedStatus = array();
     $abnormalStatus = array();
     if (empty($checkupIds) == false) {
         $arrExtractedStatus = PatientCaseHistoryClient::getInstance()->getExtractedStatusByEntityIds($checkupIds);
         $abnormalStatus = PatientCaseHistoryClient::getInstance()->getAbnormalStatusByEntityIds($checkupIds);
     }
     $response->arrExtractedStatus = $arrExtractedStatus;
     $response->abnormalStatus = $abnormalStatus;
 }