fuyu il y a 5 ans
Parent
commit
5d73bdf679
1 fichiers modifiés avec 58 ajouts et 5 suppressions
  1. 58 5
      application/inter/controller/Reciveremote.php

+ 58 - 5
application/inter/controller/Reciveremote.php

@@ -214,8 +214,9 @@ class Reciveremote extends Base
             $remote_doctor_id = $doctor['id'];
             $page =  $_REQUEST['page'];
             $num =  $_REQUEST['num'];
-            $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`';
+
+            $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` left join";
             $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` = '')";
@@ -223,11 +224,63 @@ class Reciveremote extends Base
             $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 = "?, ?";
 
-            $where = $where1." and ".$where2." and ".$where3." and ".$where4;
-            $sql = "select ".$filed." from ".$table." where ".$where." order by ".$order." limit ".$limit;
             $options = [
-                $remote_institution_id,$remote_doctor_id,($page - 1) * $num,$num
+                $remote_institution_id,$remote_doctor_id
             ];
+            $queryWhere = "";
+            if(isset($_REQUEST['param'])){
+                $param = $_REQUEST['param'];
+                foreach ($param as $k => $v) {
+                    switch ($k) {
+                        case 'patient_num':
+                            $queryWhere.= " and `e`.`patient_num` like %?%";
+                            $options[] = $v;
+                            break;
+                        case 'exam_class' :
+                            if(empty($v)){
+                                break;
+                            }
+                            $queryWhere.= " and `e`.`exam_class` in ?";
+                            $options[] = $v;
+                            break;
+                        case 'name':
+                            $queryWhere.= " and `pi`.`name` like %?%";
+                            $options[] = $v;
+                            break;
+                        case 'applicationtime':
+                            if(empty($v)){
+                                break;
+                            }
+                            $queryWhere.= " and `ra`.`req_date_time` between ? and ?";
+                            $options[] = $v[0];
+                            $options[] = $v[1];
+                            break;
+                        case 'is_urgent':
+                            if($v == 0){
+                                break;
+                            }
+                            $queryWhere.= " and `ra`.`is_urgent` = ?";
+                            $options[] = $v[0];
+                            break;
+                        case 'report_result':
+                            if($v == 1 || $v == 2) {
+                                $queryWhere.= " and `r`.`report_result` = ?";
+                                $options[] = $v[0];
+                            }
+                            break;
+                        case 'exam_status':
+                            if($v != 10){
+                                $queryWhere.= " and `ra`.`report_status` = ?";
+                                $options[] = $v[0];
+                            }
+                            break;
+                    }
+                }
+            }
+            $where = $where1." and ".$where2." and ".$where3." and ".$where4.$queryWhere;
+            $sql = "select ".$filed." from ".$table." where ".$where." order by ".$order." limit ".$limit;
+            $options[] = ($page - 1) * $num;
+            $options[] = $num;
             // var_dump($sql);
             $res = DB::query($sql, $options);
             // var_dump($res);