protected function getData($nowPage, $pageSize)
 {/*{{{*/
     $hospitalFacultys = HospitalFacultyClient::getInstance()->getHospitalFacultyByOption($nowPage, $pageSize);
     if(true == empty($hospitalFacultys))
     {
         return array();
     }
     $hospitalFacultyIds = array_keys($hospitalFacultys);
     $doctors = $this->getDoctors($hospitalFacultyIds);
     BeanFinder::get('LocalCache')->removeAll(); 
     return $this->buildData($hospitalFacultys, $doctors);
 }/*}}}*/
 protected function getData($nowPage,$pageSize)
 {/*{{{*/
     $facultyInfoArray = array();
     $facultyInfo = HospitalFacultyClient::getInstance()->getHospitalFacultyByOption($nowPage, $pageSize, array('hospitalId' => $this->hospitalId));
     foreach($facultyInfo as $key => $faculty)
     {
         $facultyInfoArray[] = array('item' => $this->getRealData($faculty));
         unset($faculty);
     }
     unset($facultyInfo);
     BeanFinder::get('LocalCache')->removeAll(); 
     return $facultyInfoArray;
 }/*}}}*/
 protected function getData($nowPage, $pageSize)
 {/*{{{*/
     $option['hospitalIsActivated'] = Hospital::ISACTIVATED_YES;
     $option['isVirtual'] = HospitalFaculty::ISVIRTUAL_NO;
     $option['voteCount'] = 10;
     $option['hospitalFacultyCount'] = 5;
     $option['hospitalSpaceCount'] = 0;
     $hospitalFacultys = HospitalFacultyClient::getInstance()->getHospitalFacultyByOption($nowPage, $pageSize, $option);
     if(true == empty($hospitalFacultys))
     {
         return array();
     }
     $hospitalFacultyIds = array_keys($hospitalFacultys);
     $diseases = $this->getDiseaseList($hospitalFacultyIds);
     $doctors = $this->getDoctorList($hospitalFacultyIds);
     BeanFinder::get('LocalCache')->removeAll(); 
     return $this->buildData($hospitalFacultys, $diseases, $doctors);
 }/*}}}*/
Example #4
0
    private function getHospitalFacultyForm($hospitalId)
    {/*{{{*/
        $option['hospitalId'] = $hospitalId;
        $option['isVirtual'] = HospitalFaculty::ISVIRTUAL_NO;
        $option['orderBy']['voteCount'] = 'desc';

        $hospitalFacultys = HospitalFacultyClient::getInstance()->getHospitalFacultyByOption(1, 12, $option);
        $resArray = array();
        foreach($hospitalFacultys as $key=>$hospitalFaculty)
        {
            $resArray[$key] = array(
                'name'=>$hospitalFaculty->name,
                'link'=>$hospitalFaculty->getUrl(),
                'doctorCount'=>$hospitalFaculty->doctorCount,
            );
            unset($hospitalFaculty);
        }
        BeanFinder::get('LocalCache')->removeAll();
        return $resArray;
    }/*}}}*/
	public function facultyExpertList($request, $response) {
		$facultyid = Codec::getInstance()->decodeId($request->faculty_id);
		if(!$facultyid){
			throw new BizException('科室id不可为空');
		}
		$response->hospital = $this->_hospital;
		$response->pageModule = 'disease';
		$response->disease = 1;
		$response->hospitalFacultyList = $this->_hospital->getHospitalFacultyList(HospitalFaculty::IS_SELECT_FACULTY_BY_VOTE_YES);
	
        $options = array();
        $options['limit'] = 200;
        $facultyDiseaseList = HospitalFacultyClient::getInstance()->getDiseaseHospitalFacultyList($facultyid, $options);
        $facultyDiseaseList = $facultyDiseaseList['list'];
		$diseaseRes = array();
		$facultyExperts = array();
		if(!empty($facultyDiseaseList)){
            foreach ($facultyDiseaseList as $facultyDisease){
                if (false == $facultyDisease->disease->isNull()) {
                    $diseaseRes[$facultyDisease->disease->id] = array( 
                                                'diseaseName' => $facultyDisease->disease->name,
                                                'key' => $facultyDisease->disease->key,
                                                'doctorCount' => $facultyDisease->doctorCount );
                    
                 	$facultyExpertList = DiseaseClient::getInstance()->getDiseaseDoctorByFaculty($facultyDisease->disease->id,$facultyid,array('limit'=> self::EXPERT_DISEASE_DOCTOR_NUM));;
                        foreach($facultyExpertList as $expert){
                            $facultyExperts[$facultyDisease->disease->id][] = array(
                                                'doctorid'=>$expert->doctor->id,
                                                'doctorName'=>$expert->doctor->name,
                                                'goodVoteCount'=>$expert->goodVoteCount );
                        }
                    }
                }
            }	         
		$response->diseaseRes = $diseaseRes;
		$response->facultyExperts = $facultyExperts;
        $hospitalFaculty = DAL::get()->find('HospitalFaculty',$facultyid);
		$response->faculty = $hospitalFaculty;
        if (false == $hospitalFaculty->isNull())
        {
            $this->getSidePhoneServiceListByHF($hospitalFaculty, $response, 6);
        }

		$pageTitleInfo = $this->getFacultyPageTitleinfo($response->faculty);
		$response->title = $pageTitleInfo['title'];
		$response->keywords = $pageTitleInfo['keywords'];
		$response->description = $pageTitleInfo['description'];
		$response->content = $pageTitleInfo['content'];
	}
 private function getHospitalFacultyListByHospitalName($hospitalName)
 {
     /*{{{*/
     $hospitals = HospitalClient::getInstance()->searchByName($hospitalName, false);
     $hospital = array_shift($hospitals);
     if (isset($hospital) && false == $hospital->isNull()) {
         $hospitalFacultyList = HospitalFacultyClient::getInstance()->getListByHospitalId($hospital->id, $limit = 500);
     } else {
         $hospitalFacultyList = array();
     }
     return array($hospitalFacultyList, $hospital);
 }
    public function doctorList4mgr($request, $response)
    {/*{{{*/
    	$hospitalFacultyId = $request->hospitalFacultyId;
    	$hospitalName = $request->hospitalName;
    	$opentype = $request->opentype;
    	
    	$hospital = new NullEntity();
    	$hospitalFacultyList = array();
    	$doctorList = array();
    	$phoneDoctorList = array();
    	$phoneDoctorIds = array();
    	
    	if($hospitalName)
    	{
    		$hospitals = HospitalClient::getInstance()->searchByName($hospitalName);
    		if(is_array($hospitals))
    		{
    			$hospital = array_shift($hospitals);
    		}
    	}
    	
    	if($hospitalFacultyId>0)
    	{
    		$hospitalFaculty = DAL::get()->find("hospitalFaculty",$hospitalFacultyId);
    		$hospital = $hospitalFaculty->hospital;
    		
    		$doctorList = $hospitalFaculty->doctors;
    		$phoneDoctorList = $hospitalFaculty->getPhoneDoctorList();
    		$phoneDoctorIds = array_keys($phoneDoctorList);
    		
    		$doctorList_0 = array();
    		switch($opentype)
    		{
    			case 0: //全部
    				$doctorList_0 = $doctorList;
    				break;
    			case 1: //已开通
    				foreach($doctorList as $a){ 
    					if(in_array($a->id, $phoneDoctorIds))
    					{
    						$doctorList_0[$a->id] = $a;
    					}
    				}    				
    				break;
    			case 2: //未开通
    				foreach($doctorList as $a){ 
    					if(false == in_array($a->id, $phoneDoctorIds) && $a->userId>0)
    					{
    						$doctorList_0[$a->id] = $a;
    					}
    				}   				
    				break;
    			case 3: //未注册
    				foreach($doctorList as $a){ 
    					if($a->userId == 0)
    					{
    						$doctorList_0[$a->id] = $a;
    					}
    				}   				
    				break;
    		}
    		
    		$doctorList = $doctorList_0;    		
    	}
    	
    	
    	if($hospital && false == $hospital->isNull())
    	{
    		$hospitalName = $hospital->name;
    		$hospitalFacultyList = HospitalFacultyClient::getInstance()->getListByHospitalId($hospital->id,$limit=500);
    	}
    	
		$response->hospitalFacultyId= $hospitalFacultyId;
		$response->hospitalName= $hospitalName;
		$response->hospital= $hospital;
		$response->hospitalFacultyList= $hospitalFacultyList;
		$response->doctorList= $doctorList;
		$response->opentype= $opentype;
		$response->phoneDoctorList= $phoneDoctorList;
		$response->phoneDoctorIds= $phoneDoctorIds;
    }/*}}}*/
 private function getHospitalFacultyInfo($hpId)
 {/*{{{*/
     $res = array();
     if($hpId)
     {
         $display = array();
         $facultyIds = HospitalFacultyClient::getInstance()->getFacultyIdsByHospitalId($hpId); 
         $facultyList = DAL::get()->find('faculty', $facultyIds);
         $newFacultyList =  $this->unsetFacultyParentKey($facultyList);
         foreach($newFacultyList as $key=>$faculty)
         {
             if('neike'  == $faculty->parentKey)
             {
                 $neikeArr[] = $faculty->name;
                 //$neikeArr = $neikeArr ? ($neikeArr.','.$neike) : $neike;
                 unset($newFacultyList[$key]);
             }
             elseif('waike'  == $faculty->parentKey)
             {
                 $waikeArr[] = $faculty->name;
                 //$waikeStr = $waikeStr ? ($waikeStr.','.$waike) : $waike;
                 unset($newFacultyList[$key]);
             }
             elseif('xiaoerke'  == $faculty->parentKey || 'fuchanke' == $faculty->parentKey)
             {
                 $fuerkeArr[] = $faculty->name;
                 //$fuerkeStr = $fuerkeStr ? ($fuerkeStr.','.$fuerke) : $fuerke;
                 unset($newFacultyList[$key]);
             }
             elseif('zhongyike'  == $faculty->parentKey)
             {
                 $zhongyikeArr[] = $faculty->name;
                 //$zhongyikeStr = $zhongyikeStr ? ($zhongyikeStr.','.$zhongyike) : $zhongyike;
                 unset($newFacultyList[$key]);
             }
             else
             {
                 $qitaArr[] = $faculty->name;
                 //$qitaStr = $qitaStr ? ($qitaStr.','.$qita) : $qita;
             }
         }
         $res['neike'] = $neikeArr;
         $res['waike'] = $waikeArr;
         $res['fuerke'] = $fuerkeArr;
         $res['zhongyike'] = $zhongyikeArr;
         $res['qita'] = $qitaArr;
     }
     return $res;
 }/*}}}*/
 public function loadMoreDisease($request, $response)
 {/*{{{*/
     $this->initialize($request, $response);
     $response->selected = $request->{self::SELECT_PAGE_PARAM};
     $nowPage = $request->getRequest('p', 1);
     $options = array();
     $options['nowPage'] = $nowPage;
     $options['pageSize'] = self::PAGESIZE_DISEASE;
     $res = HospitalFacultyClient::getInstance()->getDiseaseHospitalFacultyList($this->hospitalFaculty->id, $options);
     $response->diseaseHospitalFacultyList = $res['list'];
     $response->nowPage = $nowPage;
     $response->pages = $res['pageInfo']['pages'];
     $response->loadUrl = $response->touchUrl.'/hospitalfaculty/loadmoredisease?id='.$request->id.'&selected='.$response->selected.'&p=';
 }/*}}}*/
    protected function getData($nowPage, $pageSize)
    {/*{{{*/
        $facultyIds = FacultyClient::getInstance()->getFacultyListByOption($nowPage, $pageSize);
        $faculties = DAL::get()->find('Faculty', $facultyIds['ids']);
        $provinces = Area::getAllProvinceNameList();
        $provinces[] = "全国";
        $res = array();
        foreach ($faculties as $faculty)
        {
            $info['key'] = $faculty->name;
            $offices = $doctorInfos = array();
            foreach ($provinces as $province)
            {
                if (Area::isZXS($province))
                {
                    $cities = array($province);
                }
                elseif($province == "全国")
                {
                   $cities = array("全国"); 
                }
                else
                {
                    $cities = Area::getProvinceCities($province);
                    $cities[] = $province;
                }

                foreach ($cities as $city)
                {
                    $options = array();
                    $options['facultyId'] = $faculty->id;
                    $options['orderBy']['rank'] = true;
                    $options['isVirtual'] = 0;
                    $options['hospitalIsActivated'] = 1;
                    if ($city != "全国")
                    {
                        if (Area::isProvince($city) || Area::isZXS($city))
                        {
                            $options['province'] = $city;
                            $areaUrl = "http://haoping.haodf.com/keshi/".$faculty->getEncodeId()."/keshi/".Area::getProvKeyByName($city).".htm";
                        }
                        else
                        {
                            $options['city'] = $city;
                            $str = Area::retrieveCityEnglishName($province, Area::getProvKeyByName($province), $city);
                            $areaUrl = "http://haoping.haodf.com/keshi/".$faculty->getEncodeId()."/keshi/".Area::getProvKeyByName($province).".htm?city=".$str;
                        }
                    }
                    else
                    {
                        $areaUrl = "http://haoping.haodf.com/keshi/".$faculty->getEncodeId()."/keshi/all.htm";
                    }

                    $hospitalfaculties = HospitalFacultyClient::getInstance()->getHospitalFacultyByOption(1, 30, $options);
                    if (false == empty($hospitalfaculties)) 
                    {
                        $office['area'] = $city;
                        $office['areaurl'] = $areaUrl;
                        foreach ($hospitalfaculties as $hospitalfaculty) 
                        {
                            if ($hospitalfaculty->doctorCount < 1)
                            {
                                continue;
                            }
                            $officeInfo['office']['officename'] = $hospitalfaculty->hospital->name.$hospitalfaculty->name;
                            $officeInfo['office']['city'] = $hospitalfaculty->hospital->city;
                            $officeInfo['office']['officeurl'] = $hospitalfaculty->getUrl();
                            $officeInfo['office']['aptitude'] = $hospitalfaculty->hospital->getGradeStr();
                            $officeInfo['office']['gooddoctornum'] = $hospitalfaculty->doctorCount;
                            $officeInfo['office']['votenum'] = $hospitalfaculty->rank;
                            $office[] = $officeInfo;
                            $officeInfo = array();
                        }

                        $offices[] = array('offices' =>$office);
                        $office = array();
                    }

                    $page = $params = array();
                    $page['nowPage'] = 1;
                    $page['pageSize'] = 30;
                    $doctorList = DoctorClient::getInstance()->getDoctorBetweenFaculty($faculty->id, $faculty->id+1, $options, $page);
                    if (false == empty($doctorList['list'])) 
                    {
                        $doctors['area'] = $city;
                        $pre = "all";
                        if ($city != "全国")
                        {
                            $pre = Area::getProvKeyByName($province);
                        }
                        $doctors['areaurl'] = "http://haoping.haodf.com/keshi/".$faculty->getEncodeId()."/daifu/".$pre.".htm";
                        $doctorInfo = array();
                        foreach ($doctorList['list'] as $doctor)
                        {
                            if (74154 != $doctor->id && $doctor->hospitalfaculty->hospital->isActivated && $doctor->hospitalfaculty->hospital->name != "未收录医院")
                            {
                                $doctors['doctor']['doctorname'] = $doctor->name;    
                                $doctors['doctor']['doctorurl'] = $doctor->getUrl();
                                $doctors['doctor']['doctorgrade'] = $doctor->grade ? $doctor->grade : " ";
                                $doctors['doctor']['doctorjob'] = $doctor->educateGrade ? $doctor->educateGrade : " ";
                                $doctors['doctor']['hospitalname'] = $doctor->hospitalfaculty->hospital->commonName;
                                $doctors['doctor']['hospitalurl'] = $doctor->hospitalfaculty->hospital->getUrl();
                                $doctors['doctor']['votenum'] = $doctor->rank;
                                $doctorInfo[] = $doctors;
                                $doctors = array();
                            }
                        }

                        $doctorInfos[] = array('doctors' => $doctorInfo);
                        $doctorInfo = array();
                    }
                }
                BeanFinder::get('LocalCache')->removeAll(); 
            }
            $offices = array_filter($offices);
            $doctorInfos = array_filter($doctorInfos);

            $info = array_merge($info, $offices, $doctorInfos);
            $res[] = array('item' => $info);
            $info = array();
        }
        return $res;
    }/*}}}*/
 public function delete($request, $response)
 {
     $result = HospitalFacultyClient::getInstance()->deleteHospitalFaculty($request->id);
     $response->result = $result;
     $response->actionDesc = "删除";
     $response->id = $request->id;
     $response->_my_template = '/default/processmsg';
 }
    public function hospitalFacultyList($request, $response)
    {
        $data = $this->dataForCitySwitch();
        $response->recommendProvince = $data['recommendProvince'];
        $response->filtedprovince = $data['filteredProvince']; 
        $response->recommendArea = $data['recommendArea'];
        $response->selection = $this->_prov;
        $city = $data['recommendCities'];
        $provinceforsql = $this->_areaName;
        $pagesize = self::HOSPITAL_FACULTY_PAGE_SIZE;
        if ($request->city)
        {
             $cityName = Area::getNameByCity($request->city);
             if ($cityName)
             {
                 $city = $cityName;
                 $provinceforsql = '';
                 $pagesize = self::HOSPITAL_FACULTY_PAGE_SIZE_UNLIMIT;
             }
        }
        if('all' == $this->_prov) $provinceforsql = "全国"; 
        //好评医院科室
        list($hospitalFacultyList, $hfPageInfo) = array_values(
            HospitalFacultyClient::getInstance()->getListBetweenFaculty($this->_facultyIdFrom, $this->_facultyIdTo, 
                array('isVirtual' => $this->_faculty->isVirtual, 'province' => $provinceforsql , 'city' => $city), 
                array('nowPage' =>$this->_p, 'pageSize' => $pagesize))
        );

        $response->cityPinyin_cityNames = Area::getCityByProv($this->_prov, false);
        $response->FacultyIdForUrl = $request->id;
        $response->city = $request->city;
                
        $response->pageLink = PageNav::getNavLink(PageNav::getPageNavTemplate(
            $this->_faculty->getFacultyUrl()."?prov=$this->_prov&p="), 
            $hfPageInfo['nowpage'], $hfPageInfo['pagesize'], $hfPageInfo['total']);
            
        $hospitalFacultyStat = HospitalFacultyClient::getInstance()
            ->getCountEveryProvinceBetweenFaculty($this->_facultyIdFrom, $this->_facultyIdTo);
        foreach ($hospitalFacultyStat as $key => $hospitalFacultyCount) {
            if (in_array($hospitalFacultyCount['province'], $this->_otherProv)) {
                if (isset($hospitalFacultyCountList['其他']) == false) 
                    $hospitalFacultyCountList['其他'] = '';
                $hospitalFacultyCountList['其他'] += $hospitalFacultyCount['cnt'];
            } else {
                if ($hospitalFacultyCount['province'] == '其他')
                    continue;
                $hospitalFacultyCountList[$hospitalFacultyCount['province']] = $hospitalFacultyCount['cnt'];
            }
            unset($hospitalFacultyCountList[$key]);
        }
        //右侧大夫列表
        $params = array();
        $page = array();
        $params['facultyIdFrom'] = $this->_facultyIdFrom;
        $params['facultyIdTo'] = $this->_facultyIdTo;
        $params['province'] = $this->_provinceStr;
        $params['city'] = $city;
        $params['limit'] = self::CASE_DOCTOR_NUM;
        $params['postcount'] = 0;
        $params['spaceAdminLevel'] = 3;
        list($caseSpaceList,$oPageInfo) = array_values(
                         SpaceClient::getInstance()->getCaseOpenedSpaceList($params));
        //两周内回复数
        $spacePostCntInfos = $this->getspacePostCntInfo($caseSpaceList);
        $response->spacePostCntInfos = $spacePostCntInfos;  

        $hospitalFacultyCount = isset($hospitalFacultyCountList[$this->_areaName])?$hospitalFacultyCountList[$this->_areaName]:0;
        $response->title = "{$this->_areaName}{$this->_faculty->name}医院_好大夫在线";
        $response->keywords = "{$this->_areaName}最好的{$this->_faculty->name}医院,{$this->_areaName}{$this->_faculty->name}医院排名";
        $response->description = "{$this->_areaName}{$this->_faculty->name}医院,根据患者投票评选的{$this->_areaName}{$this->_faculty->name}医院排名,含{$this->_areaName}{$this->_faculty->name}医院{$hospitalFacultyCount}家。查询门诊时间、咨询专家、预约专家门诊,帮您找到{$this->_areaName}最好的{$this->_faculty->name}医院。";
        $response->pageModule = 'faculty';
        $response->hospitalFacultyList = $this->filterTestHospitalFromHospitalFaculty($hospitalFacultyList); 
        $response->hospitalFacultyCountList = $hospitalFacultyCountList;
        $response->caseSpaceList = $caseSpaceList;
    }
 private function getHospitalFacultyGroupByFacultyId($facultyId)
 {/*{{{*/
     $items = array();
     $items['hospitalGrade'] = 0;
     $items['hospitalIsActivated'] = Hospital::ISACTIVATED_YES;
     $items['voteCount'] = 4;
     $items['facultyId'] = $facultyId;
     $items['orderBy']['rank'] = 'rank';
     $items['keyFilter'] = BeanFinder::get('configs')->excludeHospitalIds;
     $nowPage = 1;
     $pageSize = 5;
     return HospitalFacultyClient::getInstance()->getHospitalFacultyByOption($nowPage, $pageSize, $items);
 }/*}}}*/
 protected function getTotalDBTimes()
 {/*{{{*/
     $res = HospitalFacultyClient::getInstance()->getHospitalFacultyByOption(1, $this->getStepLen(), array(), true);
     return $res['pageInfo']['pages'];
 }/*}}}*/
	public function showDetail($request, $response)
    {  	
    	//得到一级科室
        //$parentFacultyList = HospitalFacultyClient::getInstance()->getTopFacultyList();
        $parentFacultyList = array(
        0 => array('fld_facultyid' => '1000000', 'fld_facultyparentid' => '1000000', 'fld_facultyname' => '内科', 'fld_facultykey' => 'neike'),
        1 => array('fld_facultyid' => '2000000', 'fld_facultyparentid' => '2000000', 'fld_facultyname' => '外科', 'fld_facultykey' => 'waike'),
        2 => array('fld_facultyid' => '6000000', 'fld_facultyparentid' => '6000000', 'fld_facultyname' => '妇产科', 'fld_facultykey' => 'fuchanke'),
        3 => array('fld_facultyid' => '32000000', 'fld_facultyparentid' => '32000000', 'fld_facultyname' => '生殖医学中心' ,'fld_facultykey' => 'shengzhiyixuezhongxin' ),
        4 => array('fld_facultyid' => '3000000', 'fld_facultyparentid' => '3000000', 'fld_facultyname' => '小儿科', 'fld_facultykey' => 'xiaoerke' ),
        5 => array('fld_facultyid' => '43000000', 'fld_facultyparentid' => '43000000', 'fld_facultyname' => '骨科', 'fld_facultykey' => 'guke' ),
        6 => array('fld_facultyid' => '33000000', 'fld_facultyparentid' => '33000000', 'fld_facultyname' => '眼科', 'fld_facultykey' => 'yanke' ),
        7 => array('fld_facultyid' => '10000000', 'fld_facultyparentid' => '10000000', 'fld_facultyname' => '口腔科', 'fld_facultykey' => 'kouqiangke' ),
        8 => array('fld_facultyid' => '5000000', 'fld_facultyparentid' => '5000000', 'fld_facultyname' => '耳鼻咽喉头颈科', 'fld_facultykey' => 'erbiyanhoutoujingke' ),
        9 => array('fld_facultyid' => '27000000', 'fld_facultyparentid' => '27000000', 'fld_facultyname' => '肿瘤科', 'fld_facultykey' => 'zhongliuke' ),
        10 => array('fld_facultyid' => '12000000', 'fld_facultyparentid' => '12000000', 'fld_facultyname' => '皮肤性病科', 'fld_facultykey' => 'pifuxingbingke'),
        11 => array('fld_facultyid' => '34000000', 'fld_facultyparentid' => '34000000', 'fld_facultyname' => '男科', 'fld_facultykey' => 'nanke' ),
        12 => array('fld_facultyid' => '18000000', 'fld_facultyparentid' => '18000000', 'fld_facultyname' => '医疗美容科', 'fld_facultykey' => 'yiliaomeirongke'),
        13 => array('fld_facultyid' => '31000000', 'fld_facultyparentid' => '31000000', 'fld_facultyname' => '烧伤科', 'fld_facultykey' => 'shaoshangke' ),
        14 => array('fld_facultyid' => '9000000', 'fld_facultyparentid' => '9000000', 'fld_facultyname' => '精神病科', 'fld_facultykey' => 'jingshenbingke' ),
        15 => array('fld_facultyid' => '26000000', 'fld_facultyparentid' => '26000000', 'fld_facultyname' => '中医科', 'fld_facultykey' => 'zhongyike' ),
        16 => array('fld_facultyid' => '25000000', 'fld_facultyparentid' => '25000000', 'fld_facultyname' => '中西医结合科', 'fld_facultykey' => 'zhongxiyijieheke'),
        17 => array('fld_facultyid' => '4000000', 'fld_facultyparentid' => '4000000', 'fld_facultyname' => '传染病科', 'fld_facultykey' => 'chuanranbingke' ),
        18 => array('fld_facultyid' => '8000000', 'fld_facultyparentid' => '8000000', 'fld_facultyname' => '结核病科', 'fld_facultykey' => 'jiehebingke' ),
        19 => array('fld_facultyid' => '47000000', 'fld_facultyparentid' => '47000000', 'fld_facultyname' => '介入医学科','fld_facultykey' => 'jieruyixueke' ),
        20 => array('fld_facultyid' => '44000000', 'fld_facultyparentid' => '44000000', 'fld_facultyname' => '康复医学科', 'fld_facultykey' => 'kangfuyixueke'),
        21 => array('fld_facultyid' => '22000000', 'fld_facultyparentid' => '22000000', 'fld_facultyname' => '运动医学科', 'fld_facultykey' => 'yundongyixueke'),
        22 => array('fld_facultyid' => '45000000', 'fld_facultyparentid' => '45000000', 'fld_facultyname' => '麻醉医学科', 'fld_facultykey' => 'mazuiyixueke'),      
        23 => array('fld_facultyid' => '37000000', 'fld_facultyparentid' => '37000000', 'fld_facultyname' => '营养科', 'fld_facultykey' => 'yingyangke' ),
        24 => array('fld_facultyid' => '46000000', 'fld_facultyparentid' => '46000000', 'fld_facultyname' => '医学影像学' ,'fld_facultykey' => 'yixueyingxiangxue'),
        25 => array('fld_facultyid' => '14000000', 'fld_facultyparentid' => '14000000', 'fld_facultyname' => '病理科', 'fld_facultykey' => 'binglike' ),
        26 => array('fld_facultyid' => '15000000', 'fld_facultyparentid' => '15000000', 'fld_facultyname' => '其他科室' ,'fld_facultykey' => 'qitakeshi' )
        );  

        //得到二级科室
        if($request->key == "" || $request->key == 'all'){
        	$request->key = "neike";
        }
        $faculty = DAL::get()->find_by_key('faculty', $request->key);
        $facultyList = HospitalFacultyClient::getInstance()->getZhuantiDisease4Faculty($faculty->parentId);
        //得到科室下的热点疾病                       
        $partnerConfig = $request->partnerConfig;//得到合作页面参数
        $hotFacultyList = HospitalFacultyClient::getInstance()->getHotDiseaseFaculty($faculty->id,$partnerConfig->ztHomeParam);
        //得到疾病下的专题
        foreach($hotFacultyList as $zhuantiResults){ 	
        	$zhuanTi = DAL::get()->find('zhuanti', explode(',',$zhuantiResults['fld_diseasezhuantiids']) );
        	$zhuanTiList[$zhuantiResults['fld_diseaseid']] = DAL::get()->find('zhuanti', explode(',',$zhuantiResults['fld_diseasezhuantiids']) );
        	
        	$topicList = DAL::get()->find('topic',explode(',', $zhuantiResults['fld_diseasetopicids']));  
  	        	        	
        	$topic = $topicList[array_rand($topicList)];
        	if(empty($topic))
        		$doctorId =""; 
            else 
                $doctorId = $topic->doctorId;	     	
        }
               
        $doctor = DAL::get()->find('doctor',$doctorId); 

        $response->parentFacultyList = $parentFacultyList ;//一级科室
        $response->facultyList = $facultyList;//二级科室    
        $response->hotFacultyList = $hotFacultyList;//热点疾病
        $response->zhuanTiList = $zhuanTiList;//疾病下所有专题
        $response->zhuanTi = $zhuanTi;//随机产生疾病下专题
        $response->topic = $topic;//随机产生专题下topic
        $response->doctor = $doctor;//医生信息
        $response->key = $request->key;
        $response->facultyParentKey = $faculty->parentKey;
        
    }
	/** 查看医院所有医生门诊时间 */
	public function schedule($request,$response)
	{
		$id = $request->id;
		$id = (int)Codec::getInstance()->decodeId($id);
	if($id == 0)
		{
			exit();
		}
		
		$page = (int)$request->page;
		$page = ($page > 0) ? $page : 1;
		$pageSize = 20;
		
		$hospitalInfo = DAL::get()->find('hospital', $id);
		//最新评论
        $option['commentType'] = DoctorComment::COMMENT_TYPE_PROCESS;  
        $option['hospital'] = $hospitalInfo->id;
        $pageInfo['pageSize'] = 7;                                                         
		$latestCommentList = DoctorCommentClient::getInstance()->getCommentList($option, $pageInfo);
        $latestCommentList = $latestCommentList['commentList'];
		//获得医院等级
		$grade=$hospitalInfo->getGradeStr();
		$result = DoctorClient::getInstance()->getPageListByHospital($id, $page, $pageSize, $options=array());
		$doctorList = $result['doctorList'];
		//分页
		$pageInfo = $result['pageInfo'];
		$router = $response->getRouter();
		$response->pagelink = PageNav::getNavLink(
                PageNav::getPageNavTemplate($router->urlfor('hospital/schedule', array('id'=>$hospitalInfo->getEncodeId()))."?page="), 
                $pageInfo['nowpage'], $pageInfo['pagesize'], $pageInfo['total']); 
		
		//获得门诊时间
		$ids = array();
		foreach($doctorList as $doctor)
		{
			$ids[] = $doctor->id;
		}
		$tables = DoctorClient::getInstance()->getFormatScheduleList($ids);
		$hospitalFacultyList = HospitalFacultyClient::getInstance()->getListByHospitalId($hospitalInfo->id, $limit=100);
		$response->hospitalInfo=$hospitalInfo;
		$response->hospitalGrade=$grade;
		$response->hospitalFacultyList=$hospitalFacultyList;
		$response->doctorList=$doctorList;
		$response->tables=$tables;
		$response->latestCommentList=$latestCommentList;
		
	}
	public function showDetail($request, $response)
	{
		$encodeId = $request->id;
		
		$id = (int)Codec::getInstance()->decodeId($encodeId);
		if($id == 0)
		{
			exit();
		}
		
		$searchProv = $request->prov;
		$page = (int)$request->page;
		$page = ($page > 0) ? $page : 1;
		$pageSize = 20;

		$provInfo = Area::provDefineInfo();
		$provReverseInfo = Area::provReverseDefineInfo();
		$options = array();
		if(empty($searchProv) == false)
		{
			$tmpProvInfo = $provInfo["$searchProv"];
			$options['provAry'] = explode(',', $tmpProvInfo['Province']);
		}
		$facultyList = array();
		
        $options['commentType'] = DoctorComment::COMMENT_TYPE_PROCESS;  
        $options['faculty'] = $id;
        $pageInfo['pageSize'] = 15;
        $commentList = DoctorCommentClient::getInstance()->getCommentList($options, $pageInfo);
		$result = DoctorClient::getInstance()->getPageListByFaculty($id, $page, $pageSize, $options);
		$doctorList = array();
		$pageInfo = array();
		$pageInfo = $result['pageInfo'];
		if(empty($result) == false)
		{
			$doctorList = $result['doctorList'];
		}
		$facultyList = HospitalFacultyClient::getInstance()->getListByFacultyId($id);

		$LIMIT_COUNT = (empty($searchProv)) ? 4 : 20;
		$provFaculty=array();
		$facultyInfo='';
		foreach($facultyList as $hospitalFaculty)
		{
			if($hospitalFaculty->goodVoteCount==0 || $hospitalFaculty->hospital->id == 2118 ){continue;}
			$facultyInfo = $hospitalFaculty->faculty;
			$pro = $hospitalFaculty->hospital->province;
			$hospitalName = $hospitalFaculty->hospital->name;
            if (false == ($hospitalFaculty->hospital instanceof Hospital))
            {
                continue;
            }
			$name = $provReverseInfo[$pro]['Name'];
			if(empty($searchProv) == false)
			{
				if($name != $provInfo["$searchProv"]['Name'])
				{
					continue;
				}
			}
			if(isset($provFaculty[$name]))
			{
				$provFaculty[$name]['faculty'][] = $hospitalFaculty;
				if($provFaculty[$name]['count']>=$LIMIT_COUNT) { continue; }
				$provFaculty[$name]['count']++;
			}
			else
			{
				$provFaculty[$name] = array('count'=>1, 'faculty'=>array($hospitalFaculty));
			}
		}
		//еепР
		$dspProvFacultys = array();
		foreach($provInfo as $prov)
		{
			if(isset($provFaculty[$prov['Name']]))
			$dspProvFacultys[$prov['Name']] = $provFaculty[$prov['Name']];
		}
		$response->facultyInfo = $facultyInfo;
		$response->facultyList = $dspProvFacultys;
		$response->provInfo = $provInfo;
		$response->commentList = $commentList['commentList'];
		$response->doctorList = $doctorList;
		$response->searchProv = $searchProv;
		$router = $response->getRouter();
		$response->pagelink = PageNav::getNavLink(
		PageNav::getPageNavTemplate($router->urlfor('faculty/showdetail', array('id'=>$encodeId, 'prov'=>$searchProv))."&page="),
		$pageInfo['nowpage'], $pageInfo['pagesize'], $pageInfo['total']);
	}
 private function _searchHospitalFaculty($result, $confirm, $key, $nowPage, $t, $type, $url, $frame)
 {
     $targetdesc = "医院科室";
     $pageLink = '';
     if ($confirm) {
         $result = HospitalFacultyClient::getInstance()->searchHospitalFacultys($key, $nowPage, 50);
         $pageLink = self::_pageInfo($result, $confirm, $key, $nowPage, $t, $type, $url, $frame);
     }
     return array($targetdesc, $result, $pageLink);
 }
 protected function getTotalDBTimes()
 {/*{{{*/
     $hospitalFacultyInfo = HospitalFacultyClient::getInstance()->getHospitalFacultyByOption($nowPage=1, $this->stepLen, $options=array(), $needPageInfo=true);
     return $hospitalFacultyInfo['pageInfo']['pages'];
 }/*}}}*/
	public function virtualIndex($request, $response)
	{
		$this->initialize($request, $response);
		$hospitalFaculty = $this->hospitalFaculty;
		$title = $hospitalFaculty->hospital->commonName . $hospitalFaculty->name . '_门诊时间,咨询本科室'; 
		$hospitalFacultyList = HospitalFacultyClient::getInstance()->
			getListByFacultyIdAndHospitalId($hospitalFaculty->faculty->id, $hospitalFaculty->hospital->id);
		
		$response->title = $title; 
		$response->pageModule = 'index';
		$response->descString = '';
		$response->currentSite = '首页';
		$response->hospitalFacultyList = $hospitalFacultyList;
		
		return self::VIRTUAL_FACULTY;
	}
 private function getHospitalFacultyName($hospitalName)
 {
     /*{{{*/
     if ('' == $hospitalName) {
         return array();
     }
     $hospital = DAL::get()->find_by_fld_HospitalCommonName('hospital', $hospitalName);
     foreach ($hospital->hospitalFaculties as $hospitalFaculty) {
         $facultyIds[] = $hospitalFaculty->fld_facultyid;
         $facultyNames[] = $hospitalFaculty->faculty->name;
     }
     return $facultyNames;
     $topFacultyIds = HospitalFacultyClient::getInstance()->getTopFacultyList();
     foreach ($topFacultyIds as $value) {
         if ($key = array_search($value['fld_facultyid'], $facultyIds)) {
             unset($facultyIds[$key]);
         }
     }
     if (isset($facultyIds) && false == empty($facultyIds)) {
         return HospitalFacultyClient::getInstance()->getTopFacultyListByFacultyIds($facultyIds);
     }
     return array();
 }