瀏覽代碼

修改代码

fuyu 6 年之前
父節點
當前提交
e19409889e
共有 1 個文件被更改,包括 17 次插入4 次删除
  1. 17 4
      application/inter/controller/Reciveremote.php

+ 17 - 4
application/inter/controller/Reciveremote.php

@@ -215,12 +215,25 @@ class Reciveremote extends Base
             $page =  $_REQUEST['page'];
             $num =  $_REQUEST['num'];
 
+            $dclass = DB::table('doctor_class')->where('doctor_id',$doctor['id'])->cache(300)->field('doctor_class')->find();
+            if(empty($dclass['doctor_class'])){
+                $dclass['doctor_class'] = 0;
+            }
+            log::record($dclass);
+            $sql1 = "SELECT e.exam_status,e.exam_class,e.body_part,e.device,e.exam_sub_class,e.exam_datetime,p.name,p.sex,p.temp_patient_id,p.age,ra.*,r.report_doctor_id,r.report_datetime,r.report_result,e.id from exams as e,remote_application as ra,patient_infos as p,report as r where ra.exam_id=e.id and e.patient_id=p.id and r.exam_id=e.id and ra.remote_institution_id='" . $doctor['institution_id'] . "' and ra.is_urgent=1 and e.exam_status in (".$dclass['doctor_class'].")";
+            $sql2 = "SELECT e.exam_status,e.exam_class,e.body_part,e.device,e.exam_sub_class,e.exam_datetime,p.name,p.sex,p.temp_patient_id,p.age,ra.*,r.report_doctor_id,r.report_datetime,r.report_result,e.id from exams as e,remote_application as ra,patient_infos as p,report as r where ra.exam_id=e.id and e.patient_id=p.id and r.exam_id=e.id and ra.remote_institution_id='" . $doctor['institution_id'] . "' and ra.is_urgent=0  and e.exam_status in (".$dclass['doctor_class'].")";
+            $sql3 = "SELECT e.exam_status,e.exam_class,e.body_part,e.device,e.exam_sub_class,e.exam_datetime,p.name,p.sex,p.temp_patient_id,p.age,ra.*,r.report_doctor_id,r.report_datetime,r.report_result,e.id from exams as e,remote_application as ra,patient_infos as p,report as r where ra.exam_id=e.id and e.patient_id=p.id and r.exam_id=e.id and ra.remote_institution_id='" . $doctor['institution_id'] . "'and e.exam_status not in (".$dclass['doctor_class'].")";
+
+            $doc_class = DB::table('doctor_class')->where('doctor_id',$doctor['id'])->value('doctor_class');
+            if(strpos('8', $doc_class) !== false){
+                $where2 = "((`ra`.`report_status` = '7' or `ra`.`report_status` = '8' or `ra`.`report_status` = '9') or ((`ra`.`report_status` = '4' or `ra`.`report_status` = '6') and (`ra`.`remote_doctor_id`= ? or `ra`.`remote_doctor_id` = '')))";
+            } else {
+                $where2 = "(`ra`.`report_status` = '4' or `ra`.`report_status` = '6' or `ra`.`report_status` = '7' or `ra`.`report_status` = '8' or `ra`.`report_status` = '9') and (`ra`.`remote_doctor_id`= ? or `ra`.`remote_doctor_id` = '')";
+            }
             $filed = "`ra`.`id` as `ra_id`, `ra`.`anamnesis`, `ra`.`application_desc`, `ra`.`attachment`, `ra`.`clin_diag`, `ra`.`clin_symp`, `ra`.`createdAt`, `ra`.`exam_id`, `ra`.`family_ill`, `ra`.`illness_desc`, `ra`.`is_urgent`, `ra`.`local_institution_id`, `ra`.`marrital`, `ra`.`phys_sign`, `ra`.`remark`, `ra`.`remote_doctor_id`, `ra`.`remote_institution_id`, `ra`.`report_status`, `ra`.`req_date_time`, `ra`.`req_doctor_id`, `ra`.`status`, `e`.`body_part`, `e`.`exam_class`, `e`.`device`, `e`.`exam_datetime`, `e`.`id` as `exam_id`, `e`.`exam_status`, `e`.`exam_sub_class`, `e`.`id`, `e`.`severe`, `e`.`patient_id`, `r`.`report_datetime` as `rdatetime`, `r`.`report_datetime`, `r`.`report_doctor_id`, `r`.`id` as `report_id`, `r`.`report_result`, `pi`.`age`, `pi`.`name`, `pi`.`sex`, `i`.`name` as `local_institution_name`";
             $table = "`remote_application` `ra` left join `remote_order` `ro` on `ro`.`id` = (select `id` from `remote_order` `rot` where `rot`.`application_id` = `ra`.`id` order by `timestamp` desc limit 1) left join `exams` `e` on `ra`.`exam_id` = `e`.`id` left join `report` `r` on `ra`.`id` = `r`.`remote_application_id` left join `patient_infos` `pi` on `e`.`patient_id` = `pi`.`id` left join `institution` `i` on `ra`.`local_institution_id` = `i`.`id`";
             $where1 = "`ra`.`remote_institution_id` = ?";
-            $where2 = "(`ra`.`report_status` = '4' or `ra`.`report_status` = '6' or `ra`.`report_status` = '7' or `ra`.`report_status` = '8' or `ra`.`report_status` = '9')";
-            $where3 = "(`ra`.`remote_doctor_id`= ? or `ra`.`remote_doctor_id` = '')";
-            $where4 = "(`ro`.`status` is null or `ro`.`status` = 2 or `ro`.`status` = 3)";
+            $where3 = "(`ro`.`status` is null or `ro`.`status` = 2 or `ro`.`status` = 3)";
             $order = "(`ra`.`is_urgent` = '1' and `ra`.`report_status` = '4') desc, (`ra`.`is_urgent` = '1' and `ra`.`report_status` = '6') desc, (`ra`.`is_urgent` = '1' and `ra`.`report_status` = '7'), `ra`.`req_date_time` desc";
             $limit = "?, ?";
 
@@ -277,7 +290,7 @@ class Reciveremote extends Base
                     }
                 }
             }
-            $where = $where1." and ".$where2." and ".$where3." and ".$where4.$queryWhere;
+            $where = $where1." and ".$where2." and ".$where3.$queryWhere;
             $sql = "select ".$filed." from ".$table." where ".$where." order by ".$order." limit ".$limit;
             $options[] = ($page - 1) * $num;
             $options[] = $num;