fetch(); } public function datas(){ $admin = Session::get('session_manager'); $institution_id = $admin['institution_id']; $request = Request::instance(); $params = $request->param(); $where = array(); foreach ($params as $k=>$v) { switch($k){ case 'upload1': if($params['upload1'] == null){ continue; } $where[] = ' s.createdAt > \''.$params['upload1'].'\' '; break; case 'upload2': if($params['upload2'] == null){ continue; } $where[] = ' s.createdAt < \''.$params['upload2'].'\' '; break; case 'exam1': if($params['exam1'] == null){ continue; } $exam1 = str_replace('-', '', $params['exam1']); $where[] = ' s.studydate > \''.$exam1.'\' '; break; case 'exam2': if($params['exam2'] == null){ continue; } $exam2 = str_replace('-', '', $params['exam2']); $where[] = ' s.studydate < \''.$exam2.'\' '; break; case 'exam_class': if($params['exam_class'] == null){ continue; } $where[] = 's.modality=\''.$params['exam_class'].'\' '; break; } } if(count($where) <= 1){ $where1 = implode('',$where); $search = $where1; }else{ $where1 = implode(' and ',$where); $search = $where1; } $page = empty($_GET["page"]) ? 1 : $_GET["page"]; $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"]; if (empty($page) || $page < 1) { $page = 1; } if (empty($pagesize) || $pagesize < 1) { $pagesize = 30; } $count = DB::table('studies') ->alias('s') ->join(['patient_infos'=>'p'],'p.id=s.patient_id') ->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left') ->where('s.institution_id='.$institution_id) ->where($search) ->count(); $list = DB::table('studies') ->alias('s') ->join(['patient_infos'=>'p'],'p.id=s.patient_id') ->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left') ->where('s.institution_id='.$institution_id) ->where($search) ->page($page, $pagesize) ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id') ->order('s.createdAt desc') ->select(); $data["total"] = $count; $data["rows"] = $list; echo json_encode($data); } }