|
@@ -165,8 +165,34 @@ class Report extends Base
|
|
|
|
|
|
$sql = '('.$sql1.') union ('.$sql2.') union ('.$sql3.')'.$limit;
|
|
|
}else{*/
|
|
|
-
|
|
|
- $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;
|
|
|
+ $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)
|
|
|
+ ->select();
|
|
|
+ $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;
|
|
|
// }
|
|
|
// if($doctor['institution_id'] == '13000003' and $page == 1 and empty($where)){
|
|
|
// if(Cache::get('13000003_2')){
|
|
@@ -178,69 +204,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;
|
|
|
- }
|
|
|
- /*if($v['is_remote'] == 1){
|
|
|
- // 远程报告 获取发送的报告医院
|
|
|
- $remote = DB::table('remote_application')->where('exam_id',$v['id'])->field('remote_institution_id')->find();
|
|
|
- $remote_name = DB::table('institution')->where('id',$remote['remote_institution_id'])->cache(300)->field('name')->find();
|
|
|
- $project = DB::table('exam_project')->where('id',$v['exam_project'])->field('name')->find();
|
|
|
- $list[$k]['exam_project_name'] = $project['name'];
|
|
|
- $list[$k]['report_app_name'] = $remote_name['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{*/
|
|
|
- $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'] = '';
|
|
|
- }
|
|
|
+// $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;
|
|
|
// }
|
|
|
- }
|
|
|
- /*if($is_urgent == 1){
|
|
|
- //远程报告申请机构
|
|
|
- $doctor = Cache::get('doctor');
|
|
|
- //当前科室ID和name
|
|
|
- $p_institution = DB::table('institution')->where('id',$doctor['institution_id'])->field(['id','name'])->find();
|
|
|
- // 子科室ID name
|
|
|
- $child_institution = DB::table('institution')->where('parent_institution',$doctor['institution_id'])->field(['id','name'])->select();
|
|
|
- $institution[] = $p_institution;
|
|
|
- if($child_institution){
|
|
|
- foreach ($child_institution as $k => $v) {
|
|
|
- $institution[] = $v;
|
|
|
- }
|
|
|
- }
|
|
|
- $list['institution'] = $institution;
|
|
|
- }*/
|
|
|
- return json_encode(['status'=>'ok','code'=>'0000','count'=>$count[0]['count(1)'],'info'=>$list,'sessionid'=>$sessionid]);
|
|
|
+// $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]);
|
|
|
}catch(\Exception $e){
|
|
|
return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]);
|
|
|
}
|