|
@@ -165,35 +165,7 @@ class Report extends Base
|
|
|
|
|
|
$sql = '('.$sql1.') union ('.$sql2.') union ('.$sql3.')'.$limit;
|
|
|
}else{*/
|
|
|
- $field = 'a.id,a.severe,a.urgent,a.accession_num,a.patient_num,a.report_result,a.study_id,a.exam_datetime,a.exam_project,a.exam_status,a.exam_class,a.application_doctor,a.application_department,p.name,p.sex,p.age,ra.report_status,i.name as report_app_name,ep.name as exam_project_name,r.report_datetime,dr.realname as report_doctor,dv.realname as review_doctor';
|
|
|
- $list = DB::table('exams')
|
|
|
- ->alias('a')
|
|
|
- ->join(['patient+info'=>'p'],'p.id=a.patient_id and a.status=1 and a.exam_status>2')
|
|
|
- ->join(['institution'=>'i'],'i.id=a.institution_id')
|
|
|
- ->join(['report'=>'r'],'a.id=r.exam_id and r.type=1','left')
|
|
|
- ->join(['doctors'=>'dr','dr.id=r.report_doctor_id','left'])
|
|
|
- ->join(['doctors'=>'dv','dv.id=r.review_doctor_id','left'])
|
|
|
- ->join(['remote_application'=>'ra'],'ra.exam_id=a.id','left')
|
|
|
- ->join(['exam_project'=>'ep'],'ep.id=a.exam_project','left')
|
|
|
- ->where('a.institution_id=\''.$doctor['institution_id'].'\'')
|
|
|
- ->where($where)
|
|
|
- ->order('a.createdAt desc')
|
|
|
- ->limit($limit)
|
|
|
- ->buildSql();
|
|
|
- var_dump($list);die;
|
|
|
- $count = DB::table('exams')
|
|
|
- ->alias('a')
|
|
|
- ->join(['patient+info'=>'p'],'p.id=a.patient_id and a.status=1 and a.exam_status>2')
|
|
|
- ->join(['institution'=>'i'],'i.id=a.institution_id')
|
|
|
- ->join(['report'=>'r'],'a.id=r.exam_id and r.type=1','left')
|
|
|
- ->join(['doctors'=>'dr','dr.id=r.report_doctor_id','left'])
|
|
|
- ->join(['doctors'=>'dv','dv.id=r.review_doctor_id','left'])
|
|
|
- ->join(['remote_application'=>'ra'],'ra.exam_id=a.id','left')
|
|
|
- ->join(['exam_project'=>'ep'],'ep.id=a.exam_project','left')
|
|
|
- ->where('a.institution_id=\''.$doctor['institution_id'].'\'')
|
|
|
- ->where($where)
|
|
|
- ->count();
|
|
|
-// $sql = "SELECT a.id,a.severe,a.urgent,a.accession_num,a.patient_num,a.report_result,a.study_id,a.exam_datetime,a.exam_project,a.exam_status,a.exam_class,a.application_doctor,a.application_department,p.name,p.sex,p.age,ra.report_status FROM (exams as a,patient_infos as p) LEFT JOIN remote_application as ra on ra.exam_id=a.id where a.institution_id='".$doctor['institution_id']."' and p.id=a.patient_id and a.status=1 and a.exam_status>2 ".$where." order by a.createdAt desc".$limit;
|
|
|
+ $sql = "SELECT a.id,a.severe,a.urgent,a.accession_num,a.patient_num,a.report_result,a.study_id,a.exam_datetime,a.exam_project,a.exam_status,a.exam_class,a.application_doctor,a.application_department,p.name,p.sex,p.age,ra.report_status FROM (exams as a,patient_infos as p) LEFT JOIN remote_application as ra on ra.exam_id=a.id where a.institution_id='".$doctor['institution_id']."' and p.id=a.patient_id and a.status=1 and a.exam_status>2 ".$where." order by a.createdAt desc".$limit;
|
|
|
// }
|
|
|
// if($doctor['institution_id'] == '13000003' and $page == 1 and empty($where)){
|
|
|
// if(Cache::get('13000003_2')){
|
|
@@ -205,37 +177,37 @@ class Report extends Base
|
|
|
// }else{
|
|
|
// $list = DB::query($sql);
|
|
|
// }
|
|
|
-// $list = DB::query($sql);
|
|
|
-// $csql = "SELECT count(1) FROM (exams as a,patient_infos as p) LEFT JOIN remote_application as ra on ra.exam_id=a.id where a.institution_id='".$doctor['institution_id']."' and p.id=a.patient_id and a.status=1 and a.exam_status>2 ".$where;
|
|
|
-// $count = DB::query($csql);
|
|
|
-// log::record('请求的sql语句');
|
|
|
-// log::record($sql);
|
|
|
-// log::record('请求到的数据');
|
|
|
-// log::record($list);
|
|
|
-// foreach ($list as $k => $v) {
|
|
|
-// $cache_key = $doctor['id'].'_'.$v['id'];
|
|
|
-// if(Cache::get($cache_key)){
|
|
|
-// $list[$k]['status'] = 1;
|
|
|
-// }else{
|
|
|
-// $list[$k]['status'] = 0;
|
|
|
-// }
|
|
|
-// $remote_name = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
|
-// $list[$k]['report_app_name'] = $remote_name['name'];
|
|
|
-// $project = DB::table('exam_project')->where('id',$v['exam_project'])->field('name')->find();
|
|
|
-// $list[$k]['exam_project_name'] = $project['name'];
|
|
|
-// $report = DB::table('report')->where('exam_id',$v['id'])->field('report_datetime,report_doctor_id,review_doctor_id')->find();
|
|
|
-// if($report){
|
|
|
-// $report_doctor = DB::table('doctors')->where('id',$report['report_doctor_id'])->field('realname')->find();
|
|
|
-// $review_doctor = DB::table('doctors')->where('id',$report['review_doctor_id'])->field('realname')->find();
|
|
|
-// $list[$k]['review_doctor'] = $review_doctor['realname'];
|
|
|
-// $list[$k]['report_doctor'] = $report_doctor['realname'];
|
|
|
-// $list[$k]['report_datetime'] = $report['report_datetime'];
|
|
|
-// }else{
|
|
|
-// $list[$k]['report_doctor'] = '';
|
|
|
-// $list[$k]['report_datetime'] = '';
|
|
|
-// }
|
|
|
-// }
|
|
|
- return json_encode(['status'=>'ok','code'=>'0000','count'=>$count,'info'=>$list,'sessionid'=>$sessionid]);
|
|
|
+ $list = DB::query($sql);
|
|
|
+ $csql = "SELECT count(1) FROM (exams as a,patient_infos as p) LEFT JOIN remote_application as ra on ra.exam_id=a.id where a.institution_id='".$doctor['institution_id']."' and p.id=a.patient_id and a.status=1 and a.exam_status>2 ".$where;
|
|
|
+ $count = DB::query($csql);
|
|
|
+ log::record('请求的sql语句');
|
|
|
+ log::record($sql);
|
|
|
+ log::record('请求到的数据');
|
|
|
+ log::record($list);
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ $cache_key = $doctor['id'].'_'.$v['id'];
|
|
|
+ if(Cache::get($cache_key)){
|
|
|
+ $list[$k]['status'] = 1;
|
|
|
+ }else{
|
|
|
+ $list[$k]['status'] = 0;
|
|
|
+ }
|
|
|
+ $remote_name = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
|
|
|
+ $list[$k]['report_app_name'] = $remote_name['name'];
|
|
|
+ $project = DB::table('exam_project')->where('id',$v['exam_project'])->field('name')->find();
|
|
|
+ $list[$k]['exam_project_name'] = $project['name'];
|
|
|
+ $report = DB::table('report')->where('exam_id',$v['id'])->field('report_datetime,report_doctor_id,review_doctor_id')->find();
|
|
|
+ if($report){
|
|
|
+ $report_doctor = DB::table('doctors')->where('id',$report['report_doctor_id'])->field('realname')->find();
|
|
|
+ $review_doctor = DB::table('doctors')->where('id',$report['review_doctor_id'])->field('realname')->find();
|
|
|
+ $list[$k]['review_doctor'] = $review_doctor['realname'];
|
|
|
+ $list[$k]['report_doctor'] = $report_doctor['realname'];
|
|
|
+ $list[$k]['report_datetime'] = $report['report_datetime'];
|
|
|
+ }else{
|
|
|
+ $list[$k]['report_doctor'] = '';
|
|
|
+ $list[$k]['report_datetime'] = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return json_encode(['status'=>'ok','code'=>'0000','count'=>$count[0]['count(1)'],'info'=>$list,'sessionid'=>$sessionid]);
|
|
|
}catch(\Exception $e){
|
|
|
return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]);
|
|
|
}
|