$v) { /*if($k == 'name' && !empty($v)){ $where .= ' and p.name like \''.$v.'%\''; }elseif($k == 'exam_datetime' && !empty($v)){ $where .= " and e.exam_datetime between '$v[0]' and '$v[1]'"; }else{ if(!empty($v)){ $where .= ' and e.'.$k.'=\''.$v.'\''; } }*/ switch($k){ case 'name': if(empty($v)){ break; } $where .= ' and p.name like \''.$v.'%\''; break; case 'exam_datetime': if(empty($v)){ break; } $where .= " and e.exam_datetime between '$v[0]' and '$v[1]'"; break; default: if(empty($v)){ break; } $where .= ' and e.'.$k.'=\''.$v.'\''; break; } } } $page = $_REQUEST['page']; $num = $_REQUEST['num']; $fnum = ($page-1)*$num; $limit = " limit ".$fnum.",".$num; log::record("SELECT e.id,e.is_remote,e.study_id,e.patient_num,e.institution_id,e.exam_datetime,e.exam_project,e.exam_status,p.name,p.sex,p.age from exams as e ,patient_infos as p where e.institution_id='".$doctor['institution_id']."' and p.id=e.patient_id".$where); $sql = "SELECT e.id,e.is_remote,e.study_id,e.patient_num,e.institution_id,e.exam_datetime,e.exam_project,e.exam_status,p.name,p.sex,p.age from exams as e ,patient_infos as p where e.institution_id='".$doctor['institution_id']."' and p.id=e.patient_id".$where." order by e.createdAt desc,e.urgent desc ".$limit; $list = DB::query($sql); foreach ($list as $k => $v) { $report_info = DB::table('report')->where('exam_id',$v['id'])->field(['report_datetime','report_doctor_id'])->find(); $list[$k]['report_datetime'] = $report_info['report_datetime']; $dinfo = DB::table('doctors')->where('id',$report_info['report_doctor_id'])->field('realname,institution_id')->find(); $list[$k]['report_doctor'] = $dinfo['realname']; $institution_name = DB::table('institution')->where('id',$dinfo['institution_id'])->cache(300)->field('name')->find(); $list[$k]['institution_name'] = $institution_name['name']; } $sql1 = "SELECT count(1) from exams as e ,patient_infos as p where e.institution_id='".$doctor['institution_id']."' and p.id=e.patient_id".$where; $count = DB::query($sql1); return json_encode(['status'=>'ok','code'=>'0000','info'=>$list,'count'=>$count[0]['count(1)'],'sessionid'=>$sessionid]); }catch(\Exception $e){ return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]); } } }