Пример #1
0
 /**
  * 科室搜索页
  * @return array res 数据列表 paging 分页 deparmentlevel1 一级部位列表 tab 标识 t1疾病标识 t2 症状标识
  */
 public function actionDepartmentSearch()
 {
     $size = 10;
     $request = \Yii::$app->request;
     $tab = $request->get('tab');
     $departmentLevel1 = $this->department->getDepartmentLevel1();
     //获取页面的一级科室
     $paging = $this->helpPaging('wap_pager_search')->setSize($size)->setPageSetSize(7);
     $offset = $paging->getOffset();
     if ($tab == "t1") {
         $res = DiseaseSymptomMerge::search(array('source_flag' => 1), $offset, $size, array('id' => SORT_ASC), true);
     } else {
         if ($tab == "t2") {
             $res = DiseaseSymptomMerge::search(array('source_flag' => 2), $offset, $size, array('id' => SORT_ASC), true);
         } else {
             //tab='',默认查询所有疾病或症状
             $res = DiseaseSymptomMerge::search([], $offset, $size, array('id' => SORT_ASC), true);
         }
     }
     $paging->setTotal($res['total']);
     $data = array('res' => $res['list'], 'paging' => $paging, 'departmentLevel1' => $departmentLevel1, 'tab' => $tab);
     return $this->render('department_search_index', $data);
 }
Пример #2
0
 /**
  * 
  * @param type $wd
  * @param type $offset
  * @param type $size
  * @param type $explainflag
  * @param array $conditions
  * @return type
  */
 public static function search_disease_symptom_merge_data($sphinx_data)
 {
     $total = 0;
     $ret_list = array();
     if (!empty($sphinx_data['matches'])) {
         $arr_ids = array();
         foreach ($sphinx_data['matches'] as $k => $v) {
             $attr = $v['attrs'];
             if ($attr['tmp_source_id'] == 1) {
                 $arr_ids[] = sprintf("'%s%d'", 'disease', $k);
             } else {
                 $arr_ids[] = sprintf("'%s%d'", 'symptom', $k);
             }
         }
         $symptom_list = DiseaseSymptomMerge::List_ByIds($arr_ids);
         if ($symptom_list) {
             foreach ($symptom_list as $k => $v) {
                 $v['tmp_source_id'] = $v['source_flag'];
                 if ($v['source_flag'] == 1) {
                     $v['url'] = sprintf('%s/%s/', Yii::getAlias('@jb_domain'), $v['pinyin_initial']);
                     $v['wap_url'] = sprintf('%s/%s/', Yii::getAlias('@mjb_domain'), $v['pinyin_initial']);
                 } else {
                     $v['url'] = sprintf('%s/zhengzhuang/%s/', Yii::getAlias('@jb_domain'), $v['pinyin_initial']);
                     $v['wap_url'] = sprintf('%s/zhengzhuang/%s/', Yii::getAlias('@mjb_domain'), $v['pinyin_initial']);
                 }
                 $ret_list[] = $v;
             }
         }
         $total = $sphinx_data['total'];
     }
     $explain_words = $sphinx_data['explain_words'];
     return array('list' => $ret_list, 'total' => $total, 'explain_words' => $explain_words);
 }
Пример #3
0
 /**
  *查询所有症状或疾病数据
  * @param string select 查询的数据字段
  * @param string typeId 标识 t1疾病 t2症状
  * @param int offset 第几条开始
  * @param int size 每页显示条数
  * @param array orderBy 排序
  * return array res 相关的疾病症状集合
  */
 public function queryAllList($select = '', $typeId = '', $offset = 0, $size = 10, $orderBy = [])
 {
     if ($typeId == 't1') {
         //查询疾病
         $res = DiseaseSymptomMerge::search(array('source_flag' => 1), $offset, $size, $orderBy, true);
         //根据疾病,查询相关症状
     } elseif ($typeId == 't2') {
         //查询症状
         $res = DiseaseSymptomMerge::search(array('source_flag' => 2), $offset, $size, $orderBy, true);
         //根据症状查询相关疾病
     } else {
         //关键词搜索,综合
         $res = DiseaseSymptomMerge::search([], $offset, $size, $orderBy, true);
         //判断疾病,查询相关症状,症状,查询相关疾病
     }
     foreach ($res['list'] as $k => $val) {
         if ($val['source_flag'] == '1') {
             $res['list'][$k]['relevance'] = $this->seek->relevanceSymptom($val['id']);
         } else {
             $res['list'][$k]['relevance'] = $this->seek->relevanceDisease($val['id']);
         }
     }
     return $res;
 }
Пример #4
0
 public static function search_disease_symptom_words_byinitial($wd, $offset, $size, array $condition = array())
 {
     $total = 0;
     $ret_list = array();
     if (!empty($wd)) {
         $wd_obj = new DiseaseSymptomMerge();
         $where_arr = array();
         $where_arr[] = sprintf("%s='%s'", 'capital', $wd);
         foreach ($condition as $k => $v) {
             if (isset($v['args']) && is_array($v['args'])) {
                 $column_id = $v['args'][0];
                 $search_ids = implode(',', $v['args'][1]);
                 $where_arr[] = " {$column_id} in ({$search_ids})";
             }
         }
         $where = implode(' and ', $where_arr);
         $search_result = $wd_obj->list_forpaging($where, 'unique_key desc', $size, $offset);
         $ret_list = $search_result['list'];
         $total = $search_result['total'];
     }
     return array('list' => $ret_list, 'total' => $total);
 }
 private function rand_words()
 {
     $letter_list = 'abcdefghijklmnopqrstuvwxyz';
     $len = strlen($letter_list);
     $return_list = array();
     $max_kw_length = 40;
     //获取最多多少关键词
     $max_dis_length = 32;
     $filter_array = $this->getFilterArray();
     $cache_rand_words = \common\models\DiseaseSymptomMerge::getCacheRandWords($max_kw_length, $filter_array);
     for ($i = 0; $i < $len; $i++) {
         $wd = strtoupper($letter_list[$i]);
         $ret = isset($cache_rand_words[$wd]) ? $cache_rand_words[$wd] : array();
         if (count($ret) > 0) {
             $rand_num = count($ret) > $max_dis_length ? $max_dis_length : count($ret);
             $rand_keys = array_rand($ret, $rand_num);
             if (is_array($rand_keys)) {
                 foreach ($rand_keys as $k) {
                     $return_list[$wd][] = $ret[$k];
                 }
             } else {
                 $return_list[$wd][] = $ret[0];
             }
         } else {
             $return_list[$wd] = array();
         }
     }
     return $return_list;
 }