/**
     * askPost 
     * 
     * @param mixed $request 
     * @param mixed $response 
     * @access public
     * @return void
     */
    public function askPost($request, $response)
    {/*{{{*/
        AskSessionInfo::checkBindDtos();

        $askSpace = AskSessionInfo::getBindSpace();
        $patient = AskSessionInfo::getBindPatient();

        if($patient->isNull())
        {
            $response->setRedirect($response->router->urlfor('newcase/askindex'));
            return false;
        }

        $bindBingLiDtos = AskSessionInfo::getBindDtos();
        if (empty($bindBingLiDtos))
        {
            $response->setRedirect($response->router->urlfor('newcase/askindex'));
            return false;
        }

        if(false == $askSpace->isNull())
        {
            $product = ProductClient::getInstance()->getFirstFlowProduct($askSpace);
        }
        else
        {
            $product = FirstFlowPoolVirtualProduct::fetch();
         //   $product = new FirstFlowPoolVirtualProduct();
        }

        $intention = IntentionClient::getInstance()->createWithProduct($patient, $product, Intention::SRC_WEB, $bindBingLiDtos);

        if(false == $intention->isNull())
        {
            AskSessionInfo::session_destroy();
            $response->setRedirect($response->router->urlfor('newcase/asksuccess', array('id'=>$intention->id)));
        }
        else
        {
            $this->message('提交医疗请求出错,请重试', $response);
        }
    }/*}}}*/
    public function askPost($request, $response)
    {/*{{{*/
        $this->checkStartMarkSession($response);
        $res = $this->setIntentionTitle();//拼咨询标题
        if (false == $res)
        {
            $response->setRedirect($response->router->urlfor('newcase/askindex'));
            return false;
        }
        $askSpace = AskSessionInfo::getBindSpace();
        $patient = AskSessionInfo::getBindPatient();

        $bindBingLiDtos = AskSessionInfo::getBindDtos();
        if (empty($bindBingLiDtos))
        {
            $response->setRedirect($response->router->urlfor('newcase/askindex'));
            return false;
        }

        $caseTitle = AskSessionInfo::getThreadTitle();
        if(trim($caseTitle) == "")
        {
            throw new BizException('标题不能为空');
        }

        if(false == $askSpace->isNull())
        {
            $isCanAsk = $this->ensureCanAsk($this->user, $askSpace, $response);
            if(false == $isCanAsk)
            {
                return false;
            }

            $product = ProductClient::getInstance()->getFirstFlowProduct($askSpace);
        }
        else
        {
            $product = FirstFlowPoolVirtualProduct::fetch();
        }
        $intention = IntentionClient::getInstance()->createWithProduct($patient, $product, Intention::SRC_TOUCH, $bindBingLiDtos);

        if(false == $intention->isNull())
        {
            AskSessionInfo::session_destroy();
            $response->setRedirect($response->router->urlfor('newcase/asksuccess', array('intentionId'=>$intention->id)));
        }
        else
        {
            throw new BizException('提交咨询出错,请重试');
        }
    }/*}}}*/
    public function add($request, $response)
    {/*{{{*/
        $this->breakIfLessMessage($request, $response);
        if ($response->isQQ)
        {
            $this->checkLogin($request, $response);  
        }
        $isLogin = UserClient::getInstance()->isLogin();
        if ($isLogin == true)
        {
            $curUser = $this->_newUser;
        }
        else
        {
            $username = $request->username;
            $password = $request->password;
            $curUser = UserClient::getInstance()->register($username, $password);
            User::sendRegisterMsg($curUser->id);
            $curUser = UserClient::getInstance()->login($username, $password, false, null, $this->partnerDomain);
        }

        if ($curUser->isNull())
        {
            throw new BizException('该邮箱已被注册!');;
        }

        if (false == $curUser->allowQuestion())
        {
            throw new BizException('不允许提问');
        }

        $patient = $this->getPatient($request, $curUser);
        $space = DAL::get()->find('space', $request->host_id);
        $ip = RequestDelegate::getIp();
        $diseaseDto = BingLiDto::createDiseaseDto(XString::convertToGbk($request->case_disease_tag), $patient->id);
        $titleDto = BingLiDto::createTitleDto(XString::convertToGbk($request->case_title), $patient->id);
        $hospitalDto = BingLiDto::createHospitalDto(XString::convertToGbk($request->case_prehospital), XString::convertToGbk($request->case_prekeshi), $patient->id);
        $hopeHelpDto = BingLiDto::createHopeHelpDto(XString::convertToGbk($request->post_help), $patient->id);
        $content = "检查及化验:\n".XString::convertToGbk($request->post_content).
            "\n治疗情况(当前用药或近期手术):\n".XString::convertToGbk($request->post_effects).
            "\n病史:\n".XString::convertToGbk($request->post_history);
        if(XString::getLengthOfGBKString(XString::getLengthOfGBKString($content)>1000))
        {
            throw new BizException('请精简您所填写的病情信息');
        }
        $contentDto = BingLiDto::createConditionDescDto($content, $patient->id);
        $realBingLiDtos = NodeClient::getInstance()->addBingLis(array(
            $diseaseDto, $titleDto, $hospitalDto, $hopeHelpDto, $contentDto,
        ), NodeObj::SOURCE_PATIENT);

        if(false == $space->isNull())
        {
            $product = ProductClient::getInstance()->getFirstFlowProduct($space);
        }
        else
        {
            $product = FirstFlowPoolVirtualProduct::fetch();
        }

        SpaceClient::getInstance()->ensureAllowAskRule($curUser, $space);
        $src = $_SERVER['HTTP_HOST'];
        $intention = IntentionClient::getInstance()->createWithProduct($patient, $product, $src, $realBingLiDtos, $ip);
        $response->setRedirect('http://'.$_SERVER['HTTP_HOST'].$response->router->urlfor('thread/finish', array('threadId' => $intention->id)));
    }/*}}}*/