/** * @brief 获取医生的文章列表 * @author * @exampleUrl http://dev.mobile-api.haodf.com/patientapi/article_getDoctorArticleList?userId=581662815&pageId=1&pageSize=10 * * @Param $doctorId 用户id * @Param $pageSize 每页显示数 * @Param $nowPage 当前页码 * * @Returns array('id', 'sn', 'price', 'statusDesc', 'flowId', 'spaceId', 'doctorName', 'hospitalName', 'hospitalFacultyName', 'alertMsg', 'needPay', 'caseType', 'doctorAssistant', 'doctorAssistantTel'); */ public function getDoctorArticleList($userId, $doctorId, $pageSize = 10, $pageId = 1) {/*{{{*/ $doctor = DAL::get()->find('doctor', $doctorId); $user = DAL::get()->find('user', $userId); if($userId != $this->currentUserId) { $this->setErrorCode(309); return 0; } if ($user->isNull() || $user->id == 0) { $this->setErrorCode(107); return 0; } if($doctor->isNull()) { $this->setErrorCode(132); return 0; } if ($doctor->space->isNull()) { $this->setErrorCode(144); return 0; } $res = ArticleClient::getInstance()->getList($doctor->space->id, '', $pageId, $pageSize, array('articleLevel' => Article::LEVEL_2, 'orderby' => 'topLevel desc, fld_ArticleCreateTime desc')); $myDoctor = DAL::get()->find_by_userIdAndDoctorId('userdoctor', $userId, $doctor->id); $results = array(); $articleIds = array(); foreach($res['articleList'] as $article) { $result = array(); $result['id'] = $article->id; $result['title'] = $article->title; $result['doctorName'] = $article->space->host->name." ".$article->space->host->hospitalfaculty->hospital->commonName; $result['content'] = XString::truncate(str_replace(array("\n", "\t", "\r", " "), "", strip_tags(htmlspecialchars_decode($article->content))), 50); $result['ctime'] = $article->ctime; $result['hits'] = HitClient::getInstance()->getArticleHitsForMobile($article->id) + $article->hits; $result['url'] = ''; $result['type'] = "article"; $result['isSelfOwner'] = 0; $result['subscriptionId'] = $myDoctor->id; $result['subscriptionType'] = 'userdoctor'; $articleIds[] = $article->id; $results[$article->id] = $result; } $readStatus = SubscriptionClient::getInstance()->getUserSubscriptionReadStatus($userId, $articleIds); foreach($readStatus as $contentId => $status) { $results[$contentId]['readStatus'] = $status; } $this->content = array_values($results); $pageInfo['pages'] = $res['pageInfo']['pages']; $pageInfo['pagesize'] = $pageSize; $pageInfo['nowpage'] = $pageId; $pageInfo['total'] = $res['pageInfo']['total']; $this->pageInfo = $pageInfo; }/*}}}*/
public function ajaxAddReadRecord($request, $response) {/*{{{*/ $subscriptId = $request->subscriptId; $subscriptType = $request->subscriptType; $contentId = $request->contentId; $contentType = strtolower($request->contentType); SubscriptionClient::getInstance()->addReadRecord($this->user->id, $subscriptId, $contentId, $contentType, $subscriptType, UserSubscriptionRecord::DEVICE_TYPE_PC); return parent::DIRECT_OUTPUT; }/*}}}*/
private function getUserSubscribed($doctor, $user) {/*{{{*/ $ids = SubscriptionClient::getInstance()->checkRepeat($doctor->id, $user->id); return count($ids); }/*}}}*/
/** * @brief 获取医生的回复列表 * @author * @exampleUrl http://dev.mobile-api.haodf.com/patientapi/flow_getDoctorFlowList?userId=581662815&pageId=1&pageSize=10 * * @Param $doctorId 用户id * @Param $pageSize 每页显示数 * @Param $nowPage 当前页码 * * @Returns array('id', 'sn', 'price', 'statusDesc', 'flowId', 'spaceId', 'doctorName', 'hospitalName', 'hospitalFacultyName', 'alertMsg', 'needPay', 'caseType', 'doctorAssistant', 'doctorAssistantTel'); */ public function getDoctorFlowList($userId, $doctorId, $pageSize = 10, $pageId = 1) {/*{{{*/ $doctor = DAL::get()->find('doctor', $doctorId); $user = DAL::get()->find('user', $userId); if($userId != $this->currentUserId) { $this->setErrorCode(309); return 0; } if ($user->isNull() || $user->id == 0) { $this->setErrorCode(107); return 0; } if($doctor->isNull()) { $this->setErrorCode(132); return 0; } if ($doctor->space->isNull()) { $this->setErrorCode(144); return 0; } $res = FlowClient::getInstance()->queryFlowListByUserIdAndLevel($doctor->space->id, $pageId, $pageSize); $myDoctor = DAL::get()->find_by_userIdAndDoctorId('userdoctor', $userId, $doctor->id); $results = array(); $flowIds = array(); foreach($res['flowList'] as $flow) { $result = array(); $result['id'] = $flow->id; $result['title'] = $flow->title; $result['doctorName'] = ''; $result['content'] = $flow->diseaseName; $result['ctime'] = $flow->ctime; $result['hits'] = ''; $result['url'] = ''; $result['type'] = "flow"; $result['isSelfOwner'] = ($flow->user->id == $userId) ? 1 : 0; $result['subscriptionId'] = $myDoctor->id; $result['subscriptionType'] = 'userdoctor'; $flowIds[] = $flow->id; $results[$flow->id] = $result; } $readStatus = SubscriptionClient::getInstance()->getUserSubscriptionReadStatus($userId, $flowIds); foreach($readStatus as $contentId => $status) { $results[$contentId]['readStatus'] = $status; } $this->content = array_values($results); $pageInfo['pages'] = $res['pageInfo']['pages']; $pageInfo['pagesize'] = $pageSize; $pageInfo['nowpage'] = $pageId; $pageInfo['total'] = $res['pageInfo']['total']; $this->pageInfo = $pageInfo; }/*}}}*/
public function delete( $request, $response ) {/*{{{*/ $mydId = (int)Codec::getInstance()->decodeId($request->mydid); SubscriptionClient::getInstance()->deleteMyDoctor($mydId); $response->setRedirect($response->router->urlfor('userdoctor/showindex')); }/*}}}*/
/** * * @brief 新建订阅文章的阅读记录 * @author oylw * @exampleUrl http://dev.mobile-api.haodf.com/patientapi/subscription_addReadState * * @param $ userId * @param $ contentId * @param $ contentType * @param $ subscriptionId * * @return void */ public function addReadRecord($userId, $contentId, $contentType, $subscriptionId, $subscriptionType) {/*{{{*/ if($userId != $this->currentUserId) { $this->setErrorCode(309); return 0; } SubscriptionClient::getInstance()->addReadRecord($userId, $subscriptionId, $contentId, $contentType, $subscriptionType); $this->content = ''; }/*}}}*/
public function listOfDiseaseBookRank($request, $response) { /*{{{*/ $nowPage = (int) $request->getRequest('p', 1); $pageSize = (int) $request->getRequest('pageSize', 20); $keyWord = $request->keyWord; $beginTime = $request->beginTime; $endTime = $request->endTime; $type = $request->type; $res = SubscriptionClient::getInstance()->getDiseaseIdsAndSubscriptCnt4Search($beginTime, $endTime, $keyWord, $pageSize, $nowPage); $pageLink = ''; if (empty($res['pageInfo']) == false) { $url = "/articlemodel/listofdiseasebookrank?pageSize=" . urlencode($pageSize) . "&keyWrod=" . urlencode($keyWord) . "&beginTime=" . urlencode($beginTime) . "&endTime=" . urlencode($endTime); $pageLink = PageNav::getNavLink(PageNav::getPageNavTemplate($url . "&p="), $res['pageInfo']['nowpage'], $res['pageInfo']['pagesize'], $res['pageInfo']['total']); } array_pop($res); $response->arr = $res; $response->type = $type; $response->nowPage = $nowPage; $response->pageSize = $pageSize; $response->pageLink = $pageLink; $response->beginTime = $beginTime; $response->endTime = $endTime; $response->keyWord = $keyWord; }
public function attentDoctor($request, $response) {/*{{{*/ $response->topTitle = "您已成功关注医生"; $response->title = "您已成功关注医生"; $myDoctorType = UserDoctor::TYPE_ATTENTION; $sourceType = UserDoctor::SOURCE_TYPE_USER_SPACE; if(true == $this->user->isNull()) { $response->setRedirect($response->router->urlfor('user/login',array('forward' => $response->router->urlfor('doctor/attentdoctor', array('doctorId' => $request->doctorId))))); return false; } $myDoctor = SubscriptionClient::getInstance()->addMyDoctor($this->user->id, $request->doctorId, $myDoctorType, $sourceType); $response->doctor = DAL::get()->find('Doctor', $request->doctorId); }/*}}}*/
public function registerDevice($deviceId, $os, $deviceType, $app, $vd = "", $userId = "") {/*{{{*/ if('' == trim($deviceId) || $deviceId == null) { $this->setErrorCode(179); return 0; } if('' == trim($app) || $app == null) { $this->setErrorCode(180); return 0; } $phoneRegisterLog = DAL::get()->find_by_devicetoken_and_app('phoneRegisterLog', $deviceId, $app); $isFirst = 0;//默认是第一次 if(false == $phoneRegisterLog->isNull()) { $isFirst = 1; } // 拿出这一天是不是第一次 $phoneRegisterLog2 = StationLetterClient::getInstance()->getTodayLogin($deviceId, $app); if($phoneRegisterLog2->isNull()) { if ($userId || (isset($_REQUEST['currentUserId']) && $_REQUEST['currentUserId'])) { $userId = $userId ? $userId : $_REQUEST['currentUserId']; $user = DAL::get()->find('user', $userId); if (false == $user->isNull()) { $lastSubscriptionRecordId = DAL::get()->queryLastSubscriptionRecordId('usersubscriptionrecord', $user->id); if ($lastSubscriptionRecordId) { $record = DAL::get()->find('usersubscriptionrecord', $lastSubscriptionRecordId); if ($record->isNull() || XDateTime::dayDiff(XDateTime::valueOf($record->ctime), XDateTime::now()) > 0) { SubscriptionClient::getInstance()->addReadRecord4User($user->id); } } else { SubscriptionClient::getInstance()->addReadRecord4User($user->id); } } } StationLetterClient::getInstance()->createPhoneRegisterLog($os, $app, $deviceType, $deviceId, $vd, $isFirst); } //记录手机用户 $user = DAL::get()->find('user', $userId); if(false == $user->isNull()) { self::recordWapUser($user, $app, $os); } }/*}}}*/
private function getLastDoctorSubscriptionId($user) {/*{{{*/ $allList = SubscriptionClient::getInstance()->getAllDoctorSubscriptionList($user->id); if (empty($allList)) { return 0; } $lastEntity = array_shift($allList); return $lastEntity->id; }/*}}}*/
public function refuse($request, $response) { /*{{{*/ $applyId = $request->applyid; $apply = DAL::get()->find('SubscriptionDiseaseApplication', $applyId); SubscriptionClient::getInstance()->refuseSubscriptionDiseaseApplication($applyId); S3LogClient::getInstance()->add($this->auditor, $apply->getLogable()->action(SubscriptionDiseaseApplicationLog::TYPE_REFUZE, '拒绝了申请')); $refuseReason = XString::convertToGbk($request->refusereason); if (in_array($apply->source, array(SubscriptionDiseaseApplication::FROM_WEB_APPLY, SubscriptionDiseaseApplication::FROM_PHONE_APPLY))) { $title = '订阅提醒'; $user = DAL::get()->find('user', $apply->user->id); $content = $refuseReason; $this->sendSubscriptionMsg($user->id, $title, $content, array()); } echo json_encode(array('res' => 'success')); return self::DIRECT_OUTPUT; }
public function index($request,$response) {/*{{{*/ if($this->user->isNull()) { $response->setRedirect('http://'.URL_PREFIX.'passport.haodf.com/user/login'); return; } $user = $this->user; $signin = $this->user->getFollowupPatientSignin(); if($signin->isNull() == false) { if($signin->isOpenFollowup() || $signin->isSuspendedFollowup()) { header("Location: http://".URL_PREFIX."passport.haodf.com/myhealth/healthdiary"); return; } //在审核通过与待审核状态下 elseif(false == $signin->isCloseFollowup() && false == $signin->isRefused()) { //同意条款,进中间页 if($signin->isNoticedYes()) { $response->setRedirect('http://'.URL_PREFIX.'passport.haodf.com/myhealth/followupserviceinfo'); return; } //管理员拒绝前,未确认条款(也就是没点同意,也没有点不同意),进知情同意书 if(false == $signin->isNoticed()) { $response->setRedirect('http://'.URL_PREFIX.'passport.haodf.com/myhealth/manhua'); return; } } } $limit = 10; $flows = DAL::get()->find_all_lastSpacePost_by_user('doctorpatientref', $this->user, $limit); // $telProposals = DAL::get()->find_all_by_servicedef_and_userId_and_status('proposal', $this->user, ServiceDef::TYPE_TELORDER, Proposal::STATUS_NORMAL); $statuses = array(TelDto::STATUS_UNPAID, TelDto::STATUS_WAITING); $telProposals = TelDto::getListByStatuses($this->user, $statuses); $bookingOrder = DAL::get()->find_all_by_userid_and_valid('bookingOrder', $this->user->id); $relatedObjs = array_merge($telProposals, $bookingOrder, $flows); $relatedObjs = $this->sortUpdateTime($relatedObjs); $response->relatedObjs = $relatedObjs; $indexCnt = 5; $myDoctorList = SubscriptionClient::getInstance()->getMyDoctorInfos( $this->user->id ); $subList = SubscriptionClient::getInstance()->getSubcriptDiseaseList( $this->user->id, $indexCnt ); $articleRes = SubscriptionClient::getInstance()->getUserSubscriptionArticleList4Web($this->user->id, $total=1); $response->articleRes = isset($articleRes['list']) ? $articleRes['list'] : array(); $lastestTopics = ResidentEvilClient::getInstance()->getTopicsByUserId($this->user->id, 5); $answerNaireRes = NfsClient::getInstance()->getAnswerNaireList($user->id, 1, 5); $answerNaireList = $answerNaireRes['answerNaireList']; $response->answerNaireList = $answerNaireList; $response->user = $user; $response->lastestTopics = $lastestTopics; $response->myDoctorList = $myDoctorList; $response->subList = $subList; }/*}}}*/