/**
  * getOrderList 取订单列表 
  * 
  * @param mixed $userId 
  * @param mixed $status 
  * @param mixed $pageId 
  * @param mixed $pageSize 
  * @access public
  * @return void
  */
 public function getOrderList($userId, $status, $pageId, $pageSize)
 {/*{{{*/
     $pageSize = MainDataBucket::_initFetchCount($pageSize);
     $pageId = MainDataBucket::_initPageId($pageId, $pageSize);
     $status = empty($status) ? 0 : $status;
     $space = DAL::get()->find('space', $userId);
     if($space->isNull())
     {
         $this->setErrorCode(328);
         return 0;
     }
     $params['wap'] = true; 
     if($status == self::STATUS_NEED_ILLNESS)
     {
         $params['confirmstarttimeDesc'] = true;
     }
     $telOwner = DAL::get()->find_by_relatedObject('telowner', $space->user);
     $status = $this->getOrderSearchStatus($status);
     if($status != TelOrder::SEARCH_FINISHED_CLOSE)
     {
         $params['noLimit'] = true;
     }
     $res = TelOrderClient::getInstance()->getList($status, $pageId, $pageSize, $telOwner->id, $params);
     $telOrderList = TelOrder::getNoPendingOrderList($res['list'], $status);
     $pageList = $res['pageInfo'];
     $this->pageInfo = array("nowpage" => $pageList['nowpage'], 'pages' =>$pageList['pages'] , 
         'total'=>$pageList['total'], 'pagesize' => $pageList['pagesize']);
     $this->content = $this->getOrderMsg($telOrderList, $status);
 }/*}}}*/
    /**
     * getBookingOrderList  医生查看自己的加号历史列表
     * @exampleUrl http://dev.mobile-api.haodf.com/doctorapi/bookingorder_getbookingorderhistorylist?userId=105133781&type=1&xdebug=1 
     * @param mixed $userId 
     * @param mixed $type 
     * @param mixed $pageId 
     * @param mixed $pageSize 
     * @access public
     * @return void
     */
    public function getBookingOrderHistoryList($userId, $type, $pageId, $pageSize)
    {/*{{{*/
        $pageSize = MainDataBucket::_initFetchCount($pageSize);
        $pageId = MainDataBucket::_initPageId($pageId, $pageSize);
        $code = $this->_check($userId);
        if($code)
        {
            $this->setErrorCode($code);
            return 0;
        }

        $type = (empty($type)) ? self::STATUS_SUCCESS : $type;
        //已就诊,过期,拒绝,医生取消,患者取消,患者爽约,就诊失败
        $status = isset(self::$typeArray[$type]) ? self::$typeArray[$type] : self::STATUS_SUCCESS;
        $res = BookingClient::getInstance()->getSpaceOrderList($userId, $status, $pageId, $pageSize);
        $pageList = $res['pageInfo'];
        $this->pageInfo = array("nowpage" => $pageList['nowpage'], 'pages' =>$pageList['pages'] , 
            'total'=>$pageList['total'], 'pagesize' => $pageList['pagesize']);

        $results = array(); 
        foreach($res['list'] as $bookingOrder)
        {
            $order = array();
            $time = XDateTime::valueOf($bookingOrder->schedule)->toShortString();
            $order['id'] = $bookingOrder->id;
            $order['userName'] = $bookingOrder->user->name;
            $patient = $bookingOrder->patient;
            $order += $this->getBookingOrderPatientMessage($patient);
            $disease = str_replace("•", "", 
                BingLiDtoHelper::create($bookingOrder->getBingLiSource())->getDiseasesStr());
            $order['disease'] = $disease;
            $order['schedule'] = date('Y-m-d H:i',strtotime($bookingOrder->schedule->toString()));
            $order['address'] = $bookingOrder->address;
            $order['status'] = $this->getBookingOrderStatus($bookingOrder);
            $order['showstatus'] = $bookingOrder->status;
            $order['invalidcause'] = $bookingOrder->invalidcause;
            $order['phonestatus'] = $bookingOrder->phonestatus;
            $order['time'] = $time.' '.XDateTime::getWeek($time);
            $results[] = $order;
        }
        $this->content = $results;
    }/*}}}*/
 /**
  * getOtherAllFlows 取患者所有流 
  * 
  * @param mixed $userId 
  * @param mixed $patientId 
  * @access public
  * @return void
  */
 public function getOtherAllFlows($userId, $patientId, $pageId = 0, $pageSize = 5, $isOtherFlow = 0, $changeArr = 0)
 {/*{{{*/
     $infos = array();
     $doctorOwner = DAL::get()->find_by_userid('doctorOwner',$userId);
     $space = DAL::get()->find('space', $userId);
     if($doctorOwner->isNull())
     {
         $this->setErrorCode(328);
         return 0;
     }
     if($doctorOwner->source instanceof PreDoctor)
     {
         $this->getOtherAllFlows4Predoctor( $patientId, $pageId, $pageSize);
     }
     else
     {
         $pageSize = MainDataBucket::_initFetchCount($pageSize);
         $curSize = $pageSize;
         $pageId = MainDataBucket::_initPageId($pageId, $pageSize);
         $selfFlow = null;
         if ($pageId == 1)
         {
             $selfFlow = FlowClient::getInstance()->getValidFlowRef($space->id, $patientId);
             if (false == $selfFlow->isNull() && !$isOtherFlow)
             {
                 $curSize--;
             }
         }
         $patient = DAL::get()->find('patient', $patientId);
         extract(FlowClient::getInstance()->getFlowListWithOtherSpace($patient, $space, $pageId, $curSize));
         $otherFlows = $list;
         array_unshift($otherFlows, $selfFlow); //将患者和医生收费的一条流追加数组第一位置
         $isOtherFlow = empty($isOtherFlow) ? 0 : 1;
         $allCnt = DAL::get()->queryPatientOtherSpaceCnt('doctorpatientref', $patientId, $space);
         if($isOtherFlow)
         {
             array_shift($otherFlows); //取患者除本医生外其他流
             $allCnt = $allCnt > 0 ? $allCnt-- : 0;
         }
         foreach($otherFlows as $otherFlow)
         {
             if($otherFlow==null || $otherFlow->space->isNull() || $otherFlow->space->isHospitalFaculty())
             {
                 continue;
             }
             $info['id'] = $otherFlow->id;
             $info['userId'] = $otherFlow->space->id;
             $info['patientId'] = $otherFlow->patient->id;
             $info['isSelf'] =  $otherFlow->space->id == $userId  ? 1 : 0; 
             $info['name'] = $otherFlow->space->name.' '.$otherFlow->space->host->getGrade4Display();
             $info['doctorName'] = $otherFlow->space->name;
             $info['grade'] = $otherFlow->space->host->getGrade4Display();
             $info['diseaseName'] = $otherFlow->getDiseaseName4Flow();
             $info['title'] = XString::truncate($otherFlow->title, 20, "...");
             $info['showtime'] = MainDataBucket::getShowTime($otherFlow->lastPostTime);
             $info['hospital'] = $otherFlow->space->host->hospitalfaculty->hospital->name.' '.$otherFlow->space->host->hospitalfaculty->name;
             $infos[] = $info;
         }
         $this->pageInfo = array("nowpage" => $pageId, 'pages' => (int)ceil($allCnt/$pageSize), 
             'total'=>$allCnt, 'pagesize' => $pageSize);
         $changeArr = empty($changeArr) ? 0 : 1;
         if($changeArr)
             $infos = $this->changeArr($infos, $pageId);
         $this->content = array_values($infos);
     }
 }/*}}}*/