Browse Source

Merge branch 'pro' of http://code.pacsonline.cn/zskk_bg/yuanchengpasc into pro

root 5 years ago
parent
commit
4cf2a97c98

+ 1 - 1
application/index/controller/Index.php

@@ -15,7 +15,7 @@ class Index extends Controller
 {
     public function  index(){
         // echo "index";
-        return $this->redirect('http://work.pacsonline.cn',302);;
+        return $this->redirect('http://work.pacsonline.cn',302);
     }
     public function get_studiesinfo(){
         $study_id = $_REQUEST['study_id'];

+ 5 - 5
application/inter/controller/Application.php

@@ -355,11 +355,11 @@ class Application extends Base
                 $application_info['is_urgent'] = 0;
                 $remote_doctor_id = isset($param['remote_doctor_id']) ? $param['remote_doctor_id'] : '';
                 $d_time = date('H:i',strtotime('+1 hour'));
-            }
-            if($remote_doctor_id === '') {
-                $manager = DB::table('doctors')->where('institution_id',$application_info['remote_institution_id'])->where('is_admin', '1')->field('id')->find();
-                if(!empty($manager)) {
-                    $remote_doctor_id = $manager['id'];
+                if($remote_doctor_id === '') {
+                    $manager = DB::table('doctors')->where('institution_id',$application_info['remote_institution_id'])->where('is_admin', '1')->field('id')->find();
+                    if(!empty($manager)) {
+                        $remote_doctor_id = $manager['id'];
+                    }
                 }
             }
             $application_info['application_desc'] = isset($param['description']) ? $param['description'] : '';

+ 5 - 5
application/inter/controller/Dcquery.php

@@ -135,13 +135,13 @@ class Dcquery extends Controller
             if($study_id && strlen($study_id) == '16') {
                 Log::record('study_info');
                 Log::record($study_id);
-                $study_info = DB::table('studies')->where('id',$study_id)->field('id,studyuid,studyid,patient_id')->find();
+                $study_info = DB::table('studies')->where('id',$study_id)->field('id,studyuid,studyid,patient_id,studydate')->find();
                 
                 Log::record($study_info);
             } else if($study_uid) {
-                $study_info = DB::table('studies')->where('studyuid', $study_uid)->field('id,studyuid,studyid,patient_id')->find();
+                $study_info = DB::table('studies')->where('studyuid', $study_uid)->field('id,studyuid,studyid,patient_id,studydate')->find();
             } else if($acc_num) {
-                $study_info = DB::table('studies')->where('accession_num', $acc_num)->field('id,studyuid,studyid,patient_id')->find();
+                $study_info = DB::table('studies')->where('accession_num', $acc_num)->field('id,studyuid,studyid,patient_id,studydate')->find();
             }
             if(!$study_info) {
                 return json_encode([
@@ -155,7 +155,7 @@ class Dcquery extends Controller
             // }
             $info['studyInstanceUid'] = $study_info['studyuid'];
             $patient_info = DB::table('patient_infos')->where('id',$study_info['patient_id'])->field('birthday,institution_id,temp_patient_id,name,age,sex')->find();
-            $date = DB::table('exams')->where('patient_id',$study_info['patient_id'])->field('exam_datetime')->find();
+            // $date = DB::table('exams')->where('patient_id',$study_info['patient_id'])->field('exam_datetime')->find();
             $institution = DB::table('institution')->where('id',$patient_info['institution_id'])->field('name')->find();
             $info['patientName'] = $patient_info['name'];
             // 根据series_num排序
@@ -222,7 +222,7 @@ class Dcquery extends Controller
                 $info['patientAge'] = '';
             }
             $info['patientSex'] = $patient_info['sex'];
-            $info['studyDate'] = $date['exam_datetime'];
+            $info['studyDate'] = $study_info['studydate']; // $date['exam_datetime'];
             $info['studyid'] = $study_info['studyid'];
             $info['patientId'] = $patient_info['temp_patient_id'];
             $info['institution'] = $institution['name'];

+ 2 - 1
application/inter/controller/Reciveremote.php

@@ -303,7 +303,8 @@ class Reciveremote extends Base
                     }
                 }
             }
-            $where = $where1." and ".$where2." and ".$where3.$queryWhere;
+            $where = $where1." and ".$where2." and ".$where3.$queryWhere." and e.status = '1'" ;
+
             $listSql = "select ".$filed." from ".$table." where ".$where." order by ".$order." limit ".$limit;
             $countSql = "select count(*) as count from ".$table." where ".$where;
             log::record("----countSql----");

+ 30 - 4
application/inter/controller/Report.php

@@ -127,6 +127,8 @@ class Report extends Base
                         case 'exam_status':
                             if($v != 10 && !empty($v)){
                                 $where .= " and a.exam_status=".$v;
+                            }else{
+                                $where .= " and a.exam_status>2";
                             }
                             break;
                         case 'exam_class' :
@@ -149,8 +151,8 @@ class Report extends Base
                     }
                 }
             }
-            $page =  $_REQUEST['page'];
-            $num =  $_REQUEST['num'];
+            $page = $_REQUEST['page'];
+            $num = $_REQUEST['num'];
             $fnum = ($page-1)*$num;
             $limit = " limit ".$fnum.",".$num;
             /*if(empty($where)){
@@ -163,10 +165,21 @@ class Report extends Base
 
                 $sql = '('.$sql1.') union ('.$sql2.') union ('.$sql3.')'.$limit;
             }else{*/
-                $sql = "SELECT a.id,a.severe,a.urgent,a.is_remote,a.accession_num,a.patient_num,a.exam_report,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 ".$where." order by a.createdAt desc".$limit;
+
+            $sql = "SELECT a.id,a.severe,a.urgent,a.is_remote,a.accession_num,a.patient_num,a.exam_report,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 ".$where." order by a.createdAt desc".$limit;
 //            }
+            // if($doctor['institution_id'] == '13000003' and $page == 1 and empty($where)){
+            //     if(Cache::get('13000003_2')){
+            //         $list = Cache::get('13000003_2');
+            //     }else{
+            //         $list = DB::query($sql);
+            //         Cache::set('13000003_2',$list,86400);
+            //     }
+            // }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 ".$where;
+            $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 ".$where;
             $count = DB::query($csql);
             log::record('请求的sql语句');
             log::record($sql);
@@ -234,4 +247,17 @@ class Report extends Base
 
     }
 
+    public function del()
+    {
+        $id = $_REQUEST['id'];
+        $sessionid = Request::instance()->param('sessionid');
+        $user = Cache::get($sessionid);
+        $info = DB::table('exams')->where('id',$id)->update(['status'=>0,'del_time'=>date('Y-m-d H:i:s',time()),'del_doctor_name'=>$user['realname']]);
+        if($info){
+            return json_encode(['status'=>'ok','code'=>'0000']);
+        }else{
+            return json_encode(['status'=>'fail','code'=>'2000','msg'=>'删除失败']);
+        }
+    }
+
 }

+ 46 - 0
application/inter/controller/Wechat.php

@@ -107,6 +107,52 @@ class Wechat extends Base {
         }
 
 
+        // $order_id = $param['order_id'];
+        // $remote_order = DB::table('remote_order')->where('id', $order_id)->find();
+        // if(!$remote_order) {
+        //     return json_encode(['status'=>'fail','code'=>'3001','msg'=> "没有找到该订单"]);
+        // }
+        // if($remote_order !== Application::ORDER_STATUS['CREATE']) {
+        //     return json_encode(['status'=>'fail','code'=>'3002','msg'=> "订单状态出错"]);
+        // }
+        // DB::table('remote_order')->where('id', $order_id)->update(["status" => Application::ORDER_STATUS['PAYCOMPLTET']]);
+        // return json_encode(['status'=>'ok','code'=>'0000','msg'=> "支付回调成功"]);
+    }
+
+    public function wechatStudyPayCallback() {
+        try {
+             // $param = $_REQUEST['param'];
+            Log::record('---电子胶片--微信支付回调----开始----');
+
+            Log::record('---电子胶片--微信支付返回----xml----');
+            $xml = file_get_contents("php://input");
+            Log::record($xml);
+            Log::record('-----xml转数组--------');
+            $data = (array)simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA); //将微信返回的XML 转换成数组
+            Log::record($data);
+            $out_trade_no = $data['out_trade_no'];
+            $data['timestamp'] = time();
+            Log::record('---电子胶片--添加流水记录----');
+            Log::record($data);
+            Db::table("wechat_pay_log")->insert($data);
+            Log::record('-----获取订单信息-----');
+            $order = Db::table("exams")->where("id", $out_trade_no)->field("id, pay_status")->find();
+            Log::record($order);
+            if($order && $order['pay_status'] === '0') {
+                $order['pay_status'] = '1';
+                // todo 消息通知
+                Log::record('-----更新检查状态-----');
+                DB::table("exams")->where("id", $out_trade_no)->update($order);
+            }
+            Log::record('--电子胶片---微信支付回调---结束---');
+            return self::SUCCESS;
+        } catch (\Throwable $th) {
+            Log::record('支付回调异常');
+            Log::record($th->getMessage());
+            //throw $th;
+        }
+
+
         // $order_id = $param['order_id'];
         // $remote_order = DB::table('remote_order')->where('id', $order_id)->find();
         // if(!$remote_order) {

+ 21 - 3
application/inter/controller/Writereport.php

@@ -61,7 +61,7 @@ class Writereport extends Base
             $institution = DB::table('institution')->where('id',$doctor['institution_id'])->field('name,report_subtitle')->find();
             $param = $_REQUEST['param'];
             $id = $param['id'];
-            $info = DB::table('exams')->where('id',$id)->field(['id','ext','study_id','exam_class','exam_status','exam_datetime','exam_sub_class','body_part','accession_num','patient_id','film_type'])->find();
+            $info = DB::table('exams')->where('id',$id)->field(['id','ext','study_id','exam_class','exam_status','exam_datetime','exam_sub_class','body_part','accession_num','patient_id','film_type','patient_area','bed_no','hopitalized_no'])->find();
             $exam_class = DB::table('constant')->where('id',$info['exam_class'])->field('constant_value')->find();
             $info['exam_class'] = $exam_class['constant_value'];
             $exam_subclass = DB::table('exam_subclass')->where('id',$info['exam_sub_class'])->field('name')->find();
@@ -114,6 +114,9 @@ class Writereport extends Base
                 $info['sex'] = isset($cache['sex']) ? $cache['sex'] : '';
                 $info['age'] = isset($cache['age']) ? $cache['age'] : '';
                 $info['phone'] = isset($cache['phone']) ? $cache['phone'] : '';
+                $info['patient_area']    = isset($cache['patient_area']) ? $cache['patient_area'] : '';
+                $info['hopitalized_no']    = isset($cache['hopitalized_no']) ? $cache['hopitalized_no'] : '';
+                $info['bed_no']    = isset($cache['bed_no']) ? $cache['bed_no'] : '';
             }
             return json_encode(['status'=>'ok','code'=>'0000','info'=>$info,'sessionid'=>$sessionid,'is_remote'=>$is_remote]);
         }catch(\Exception $e){
@@ -268,12 +271,19 @@ class Writereport extends Base
             $info['exam_id'] = $param['id'];
             $info['impression']       = isset($param['impression']) ? $param['impression'] : '';
             $info['description']      = isset($param['description']) ? $param['description'] : '';
+            $exam_info = [];
+            $exam_info['patient_area']    = isset($param['patient_area']) ? $param['patient_area'] : '';
+            $exam_info['hopitalized_no']    = isset($param['hopitalized_no']) ? $param['hopitalized_no'] : '';
+            $exam_info['bed_no']    = isset($param['bed_no']) ? $param['bed_no'] : '';
+            $exam_info['film_type']    = $film_type;
+            $exam_info['phone']    = isset($param['phone']) ? $param['phone'] : '';
+            $exam_info['exam_report']    = isset($param['report_result']) ? $param['report_result'] : '';
             if(isset($param['r_result']) && $param['r_result'] == 'true'){
                 $info['report_result'] = 2;
             }else{
                 $info['report_result'] = 1;
             }
-            DB::table('exams')->where('id',$param['id'])->update(['film_type'=>$film_type,'phone'=>isset($param['phone']) ? $param['phone'] : '','exam_report'=>$info['report_result']]);
+            DB::table('exams')->where('id',$param['id'])->update($exam_info);
             // 报告的id
             $report_id = $param['report_id'];
             if(isset($_REQUEST['is_remote']) && !empty($_REQUEST['is_remote'])){
@@ -908,9 +918,10 @@ class Writereport extends Base
             $report = DB::table('report')->where('id',$report_id)->field('qr_code,remote_application_id,report_datetime,impression,description,report_doctor_id,review_doctor_id')->find();
             $info = array();
             // 检查日期 住院号 床号 本地申请科室 本地申请医生
-            $exam_info = DB::table('exams')->where('id',$id)->field('id,ext,accession_num,exam_datetime,exam_class,hopitalized_no,bed_no,exam_project,patient_id,application_department,application_doctor')->find();
+            $exam_info = DB::table('exams')->where('id',$id)->field('id,ext,accession_num,exam_datetime,exam_class,hopitalized_no,bed_no,exam_project,patient_id,application_department,application_doctor,patient_area')->find();
             $info['id'] = $exam_info['id'];
             $info['ext'] = $exam_info['ext'];
+            $info['patient_area'] = $exam_info['patient_area'];
             $info['accession_num'] = $exam_info['accession_num'];
             if(!empty($exam_info['exam_datetime'])){
                 $datetime = explode(' ',$exam_info['exam_datetime']);
@@ -971,6 +982,12 @@ class Writereport extends Base
             // $hospital = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
             $hospital = DB::table('institution')->where('id',$report_doctor['institution_id'])->field('name')->find();
             $info['hospital'] = $hospital['name'];
+            if(empty($report['qr_code'])){
+                $url = 'http://wechat.pacsonline.cn/wx_patient/api/unifyGetWxQrcode?reportId='.$report_id;
+                $code = $this->curl_get($url);
+                $qr_code = DB::table('report')->where('id',$report_id)->value('qr_code');
+                $info['qr_code'] = $qr_code;
+            }
             return json_encode(['status'=>'ok','code'=>'0000','info'=>$info,'sessionid'=>$sessionid]);
         }catch(\Exception $e){
             return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]);
@@ -1179,6 +1196,7 @@ class Writereport extends Base
         }*/
         $doctor = Cache::get($sessionid);
         $is_remote = $_REQUEST['is_remote'];
+        $param = $_REQUEST['param'];
         $patient_info['name']       = isset($param['name']) ? $param['name'] : '';
         $patient_info['sex']       = isset($param['sex']) ? $param['sex'] : '';
         $patient_info['age']       = isset($param['age']) ? $param['age'] : '';

+ 49 - 14
application/manage/controller/Counts.php

@@ -31,38 +31,50 @@ class Counts extends Base {
         $params = $request->param();
         $where = [];
         $where[] = ' e.film_type=2';
+        $datetime = 1;
+        if(isset($params['upload1']) && ($params['upload1'] == $params['upload2']) && !empty($params['upload1'])){
+            $where[] = ' s.createdAt > \''.$params['upload1'].' 00:00:00\' ';
+            $where[] = ' s.createdAt < \''.$params['upload2'].' 23:59:59\' ';
+            $datetimme = 2;
+        }
+        $examtime = 1;
+        if(isset($params['exam1']) && ($params['exam1'] == $params['exam2']) && !empty($params['exam1'])){
+            $exam1 = str_replace('-', '', $params['exam1']);
+            $where[] = ' s.studydate = \''.$exam1.'\' ';
+            $examtime = 2;
+        }
         foreach ($params as $k=>$v) {
+            if(empty($v)){
+                continue;
+            }
             switch($k){
                 case 'upload1':
-                    if($params['upload1'] == null){
-                        continue 2;
+                    if($datetime == 2){
+                        break;
                     }
                     $where[] = ' s.createdAt > \''.$params['upload1'].'\' ';
                     break;
                 case 'upload2':
-                    if($params['upload2'] == null){
-                        continue 2;
+                    if($datetime == 2){
+                        break;
                     }
                     $where[] = ' s.createdAt < \''.$params['upload2'].'\' ';
                     break;
                 case 'exam1':
-                    if($params['exam1'] == null){
-                        continue 2;
+                    if($examtime == 2){
+                        break;
                     }
                     $exam1 = str_replace('-', '', $params['exam1']);
                     $where[] = ' s.studydate > \''.$exam1.'\' ';
                     break;
                 case 'exam2':
-                    if($params['exam2'] == null){
-                        continue 2;
+                    if($examtime == 2){
+                        break;
                     }
                     $exam2 = str_replace('-', '', $params['exam2']);
                     $where[] = ' s.studydate < \''.$exam2.'\' ';
                     break;
                 case 'exam_class':
-                    if($params['exam_class'] == null){
-                        continue 2;
-                    }
                     $where[] = 's.modality=\''.$params['exam_class'].'\' ';
                     break;
             }
@@ -89,14 +101,13 @@ class Counts extends Base {
         }
         $count = DB::table('studies')
             ->alias('s')
-            ->distinct(true)
             ->join(['patient_infos'=>'p'],'p.id=s.patient_id')
             ->join(['exams'=>'e'],'e.study_id=s.id')
             ->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left')
             ->join(['institution'=>'ins'],'ins.id=e.institution_id','left')
             ->where($institution_where)
             ->where($search)
-            ->count();
+            ->count('DISTINCT e.id');
         $list = DB::table('studies')
             ->alias('s')
             ->distinct(true)
@@ -107,7 +118,7 @@ class Counts extends Base {
             ->where($institution_where)
             ->where($search)
             ->page($page, $pagesize)
-            ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id,ins.name as institution_name,e.accession_num')
+            ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id,ins.name as institution_name,e.accession_num,e.register,e.del_time,e.del_doctor_name')
             ->order('s.createdAt desc')
             ->select();
         $data["total"] = $count;
@@ -128,22 +139,46 @@ class Counts extends Base {
             $institution_where['s.institution_id'] = ['in',$institution];
         }
         $where[] = ' e.film_type=2';
+        $datetime = 1;
+        if(($params['upload_datetime1'] == $params['upload_datetime2']) && !empty($params['upload_datetime1'])){
+            $where[] = ' s.createdAt > \''.$params['upload_datetime1'].' 00:00:00\' ';
+            $where[] = ' s.createdAt < \''.$params['upload_datetime2'].' 23:59:59\' ';
+            $datetime = 2;
+        }
+        $examtime = 1;
+        if(($params['exam_datetime1'] == $params['exam_datetime1']) && !empty($params['exam_datetime1'])){
+            $exam1 = str_replace('-', '', $params['exam_datetime1']);
+            $where[] = ' s.studydate = \''.$exam1.'\' ';
+            $examtime = 2;
+        }
         foreach ($params as $k=>$v) {
             if(empty($v)){
                 continue;
             }
             switch($k){
                 case 'upload_datetime1':
+                    if($datetime == 2){
+                        break;
+                    }
                     $where[] = ' s.createdAt > \''.$params['upload_datetime1'].'\' ';
                     break;
                 case 'upload_datetime2':
+                    if($datetime == 2){
+                        break;
+                    }
                     $where[] = ' s.createdAt < \''.$params['upload_datetime2'].'\' ';
                     break;
                 case 'exam_datetime1':
+                    if($examtime == 2){
+                        break;
+                    }
                     $exam1 = str_replace('-', '', $params['exam_datetime1']);
                     $where[] = ' s.studydate > \''.$exam1.'\' ';
                     break;
                 case 'exam_datetime2':
+                    if($examtime == 2){
+                        break;
+                    }
                     $exam2 = str_replace('-', '', $params['exam_datetime2']);
                     $where[] = ' s.studydate < \''.$exam2.'\' ';
                     break;

+ 1 - 1
application/manage/controller/Doctors.php

@@ -347,7 +347,7 @@ class Doctors extends Base {
                 if(empty($v[2])){
                     continue;
                 }
-                $doctor_info = DB::table('doctors')->where('username',$v[2])->where('password',md5('123456'))->find();
+                $doctor_info = DB::table('doctors')->where('username',$v[2])->find();
                 if($doctor_info){
                     continue;
                 }

+ 192 - 3
application/manage/controller/Statistics.php

@@ -14,7 +14,6 @@ use app\common\library\UUIDs;
 class Statistics extends Base {
 
     public function index() {
-
         return $this->fetch('index');
     }
 
@@ -58,8 +57,21 @@ class Statistics extends Base {
         $review_num = 0;
         $list = [];
         foreach($doctor as $k=>$v){
-            $report = DB::table('report')->where('report_doctor_id',$v['id'])->where($search)->count();
-            $review = DB::table('report')->where('review_doctor_id',$v['id'])->where($search)->count();
+            $report = DB::table('report')
+                ->alias('r')
+                ->join(['remote_application'=>'ra'],'r.remote_application_id=ra.id')
+                ->where('report_doctor_id',$v['id'])
+                ->where('review_doctor_id','not null')
+                ->where('ra.report_status=9')
+                ->where($search)
+                ->count();
+            $review = DB::table('report')
+                ->alias('r')
+                ->join(['remote_application'=>'ra'],'r.remote_application_id=ra.id')
+                ->where('review_doctor_id',$v['id'])
+                ->where('ra.report_status=9')
+                ->where($search)
+                ->count();
             $list[$k]['name'] = $v['realname'];
             $list[$k]['report'] = $report;
             $list[$k]['review'] = $review;
@@ -74,6 +86,59 @@ class Statistics extends Base {
 
     }
 
+
+    public function infos()
+    {
+        $admin = Session::get('session_manager');
+        $institution_id = $admin['institution_id'];
+        $request = Request::instance();
+        $params = $request->param();
+        $where = array();
+        foreach ($params as $k=>$v) {
+            switch($k){
+                case 'upload1':
+                    if($params['upload1'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime > \''.$params['upload1'].' 00:00:00\' ';
+                    break;
+                case 'upload2':
+                    if($params['upload2'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime < \''.$params['upload2'].' 23:59:59\' ';
+                    break;
+            }
+        }
+        if(count($where) <= 1){
+            $where1  =  implode('',$where);
+            $search = $where1;
+        }else{
+            $where1 = implode(' and ',$where);
+            $search = $where1;
+        }
+        if($search == ''){
+            $time1 = date('Y-m-d 00:00:00',time());
+            $time2 = date('Y-m-d 23:59:59',time());
+            $search = 'r.report_datetime >\''.$time1.'\' and r.report_datetime < \''.$time2.'\'';
+        }
+        $list = DB::table('remote_application')
+            ->alias('ra')
+            ->join(['report'=>'r'],'ra.id=r.remote_application_id')
+            ->join(['exams'=>'e'],'ra.exam_id=e.id')
+            ->join(["(select id,realname from doctors )"=>'reportd'],'reportd.id=r.report_doctor_id','left')
+            ->join(["(select id,realname from doctors )"=>'reviewd'],'reviewd.id=r.review_doctor_id','left')
+            ->join(["(select id,name from institution )"=>'ins'],'ins.id=ra.local_institution_id','left')
+            ->join(["(select id,realname from doctors )"=>'req'],'req.id=ra.req_doctor_id','left')
+            ->where('ra.remote_institution_id='.$institution_id)
+            ->where('ra.report_status=9')
+            ->where($search)
+            ->field('ins.name as insname,req.realname as reqname,e.patient_num,e.exam_class,ra.req_date_time,r.report_datetime,reportd.realname as rpname,reviewd.realname as rvname,r.review_datetime')
+            ->select();
+        echo json_encode($list);
+
+    }
+
     public function out() {
         $admin = Session::get('session_manager');
         $institution_id = $admin['institution_id'];
@@ -140,6 +205,127 @@ class Statistics extends Base {
         $this->getExcel($filename, $headArr, $list);
     }
 
+    public function outs() {$admin = Session::get('session_manager');
+        $institution_id = $admin['institution_id'];
+        $request = Request::instance();
+        $params = $request->param();
+        $where = array();
+        $begin = '';
+        $finish = '';
+        foreach ($params as $k=>$v) {
+            switch($k){
+                case 'upload1':
+                    if($params['upload1'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime > \''.$params['upload1'].' 00:00:00\' ';
+                    $begin = $params['upload1'];
+                    break;
+                case 'upload2':
+                    if($params['upload2'] == null){
+                        continue;
+                    }
+                    $where[] = ' report_datetime < \''.$params['upload2'].' 23:59:59\' ';
+                    $finish = $params['upload2'];
+                    break;
+            }
+        }
+        if(count($where) <= 1){
+            $where1  =  implode('',$where);
+            $search = $where1;
+        }else{
+            $where1 = implode(' and ',$where);
+            $search = $where1;
+        }
+        if($search == ''){
+            $time1 = date('Y-m-d 00:00:00',time());
+            $time2 = date('Y-m-d 23:59:59',time());
+            $search = 'r.report_datetime >\''.$time1.'\' and r.report_datetime < \''.$time2.'\'';
+        }
+        $list = DB::table('remote_application')
+            ->alias('ra')
+            ->join(['report'=>'r'],'ra.id=r.remote_application_id')
+            ->join(['exams'=>'e'],'ra.exam_id=e.id')
+            ->join(["(select id,realname from doctors )"=>'reportd'],'reportd.id=r.report_doctor_id','left')
+            ->join(["(select id,realname from doctors )"=>'reviewd'],'reviewd.id=r.review_doctor_id','left')
+            ->join(["(select id,name from institution )"=>'ins'],'ins.id=ra.local_institution_id','left')
+            ->join(["(select id,realname from doctors )"=>'req'],'req.id=ra.req_doctor_id','left')
+            ->where('ra.remote_institution_id='.$institution_id)
+            ->where('ra.report_status=9')
+            ->where($search)
+            ->field('ins.name as insname,req.realname as reqname,e.patient_num,e.exam_class,ra.req_date_time,r.report_datetime,reportd.realname as rpname,reviewd.realname as rvname,r.review_datetime')
+            ->select();
+        if($begin == $finish){
+            $filename = $begin."数据详情表";
+        }else{
+            if(empty($finish)){
+                $finish = date('Y-m-d');
+            }
+            $filename = $begin.'至'.$finish."数据详情表";
+        }
+        $headArr = array("申请医院","申请医生","病历号","检查类型","申请时间", "报告时间","报告医生","审核医生","审核时间");
+        $this->getExcels($filename, $headArr, $list);
+    }
+
+    public function getExcels($fileName, $headArr, $data) {
+        //对数据进行检验
+        if (empty($data) || !is_array($data)) {
+            die("data must be a array");
+        }
+        //检查文件名
+        if (empty($fileName)) {
+            exit;
+        }
+
+        $date = date("Y_m_d", time());
+        $fileName .= ".xls";
+
+        //创建PHPExcel对象,注意,不能少了\
+        $objPHPExcel = new \PHPExcel();
+        $objProps = $objPHPExcel->getProperties();
+
+        $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(25);
+        $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(25);
+        //设置表头
+        $key = ord("A");
+        foreach ($headArr as $v) {
+            $colum = chr($key);
+            $objPHPExcel->setActiveSheetIndex(0)->setCellValue($colum . '1', $v);
+            $key += 1;
+        }
+
+        $column = 2;
+        $objActSheet = $objPHPExcel->getActiveSheet();
+        foreach ($data as $key => $rows) { //行写入
+            $span = ord("A");
+            foreach ($rows as $keyName => $value) {// 列写入
+                $j = chr($span);
+                $objActSheet->setCellValue($j . $column, $value);
+                $span++;
+            }
+            $column++;
+        }
+
+        $fileName = iconv("utf-8", "gb2312", $fileName);
+        //重命名表
+        // $objPHPExcel->getActiveSheet()->setTitle('test');
+        //设置活动单指数到第一个表,所以Excel打开这是第一个表
+        $objPHPExcel->setActiveSheetIndex(0);
+        header('Content-Type: application/vnd.ms-excel');
+        header("Content-Disposition: attachment;filename=\"$fileName\"");
+        header('Cache-Control: max-age=0');
+
+        $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
+        $objWriter->save('php://output'); //文件通过浏览器下载
+        exit;
+    }
     public function getExcel($fileName, $headArr, $data) {
         //对数据进行检验
         if (empty($data) || !is_array($data)) {
@@ -194,4 +380,7 @@ class Statistics extends Base {
         exit;
     }
 
+    public function list() {
+        return $this->fetch('list');
+    }
 }

+ 4 - 1
application/manage/view/counts/index.html

@@ -109,9 +109,12 @@
                     {field:'sex',title:'患者性别',width:100 , formatter:sfromFormatter  },
                     {field:'age',title:'患者年龄', hidden:true,width:115  },
                     {field:'modality',title:'检查类型',width:135  },
-                    {field:'studydate',title:'检查时间',width:200  },
+                    {field:'studydate',title:'检查时间',width:100  },
                     {field:'accession_num',title:'检查号',width:200 },
+                    {field:'register',title:'操作上传技师',width:100 },
                     {field:'createdAt',title:'上传时间',width:200 },
+                    {field:'del_doctor_name',title:'删除操作人',width:100 },
+                    {field:'del_time',title:'删除时间',width:100 },
                     {field:'exam_id',title:'是否绑定微信',width:115  , formatter:pfromFormatter  },
                 ]],
                 onDblClickRow :function(rowIndex,rowData){

+ 2 - 2
application/manage/view/index/agent.html

@@ -140,10 +140,10 @@
                         <div data-options="iconCls:'icon-help'" onclick="showAbout()">关于</div>
                     </div>
                 </div>
-                <div id="topbar-info" class="left" style="line-height: 50px;width:450px;height: 50px;" >
+                <!--<div id="topbar-info" class="left" style="line-height: 50px;width:450px;height: 50px;" >
                     <img src="/static/images/manage/logo.png" height="45" style="float: left;margin: 2px 0 0 2px;" />
                     <div style="width: 250px;height: 40px;line-height:40px ;margin: 5px;font-size: 22px;float: left;color: #333;" >(远程诊断系统)</div>
-                </div>
+                </div>-->
             </div>
         </div>
 		<div data-options="region:'south',split:false,border:true" style="height: 25px;text-align: center;line-height: 25px;"  ></div>

+ 4 - 4
application/manage/view/index/index.html

@@ -144,11 +144,11 @@
                         <div data-options="iconCls:'icon-help'" onclick="showAbout()">关于</div>
                     </div>
                 </div>
-                <div id="topbar-info" class="left" style="line-height: 50px;width:450px;height: 50px;" >
+                <!--<div id="topbar-info" class="left" style="line-height: 50px;width:450px;height: 50px;" >
                     <img src="/static/images/manage/logos.png" height="40" style="float: left;margin: 5px 0 0 5px;" />
-                    <span style="line-height:50px ;margin: 5px 0 0 10px;font-size: 28px;color: #eee;" >中世康恺</span>
-                    <span style="line-height:40px ;margin: 5px 0 0 0;font-size: 22px;color: #eee;" >远程诊断系统</span>
-                </div>
+                    &lt;!&ndash;<span style="line-height:50px ;margin: 5px 0 0 10px;font-size: 28px;color: #eee;" >中世康恺</span>&ndash;&gt;
+                    <span style="line-height:40px ;margin: 5px 0 0 0;font-size: 22px;color: #eee;" >远程诊断系统</span>
+                </div>-->
             </div>
         </div>
 		<div data-options="region:'south',split:false,border:true" style="height: 25px;text-align: center;line-height: 25px;"  ></div>

+ 4 - 5
application/manage/view/index/ins.html

@@ -90,9 +90,8 @@
             var urls=new Array();
             urls[0]={ name :"医生管理", url :"/manage/insdoctors/index"};
             urls[1]={"name":"科室管理","url":"/manage/insdoctors/deptview"};
-            urls[2]={"name":"数据统计","url":"/manage/insdoctors/stats"};
-            urls[3]={"name":"数据统计信息","url":"/manage/counts/index"};
-            urls[4]={"name":"医院报告统计","url":"/manage/statistics/index"};
+            urls[2]={"name":"数据统计信息","url":"/manage/counts/index"};
+            urls[3]={"name":"医院远程报告统计","url":"/manage/statistics/index"};
             var intV=null;
             
             function openUserPanels(){
@@ -124,10 +123,10 @@
                         <div data-options="iconCls:'icon-help'" onclick="showAbout()">关于</div>
                     </div>
                 </div>
-                <div id="topbar-info" class="left" style="line-height: 50px;width:450px;height: 50px;" >
+                <!--<div id="topbar-info" class="left" style="line-height: 50px;width:450px;height: 50px;" >
                     <img src="/static/images/manage/logo.png" height="45" style="float: left;margin: 2px 0 0 2px;" />
                     <div style="width: 250px;height: 40px;line-height:40px ;margin: 5px;font-size: 22px;float: left;color: #333;" >(远程诊断系统)</div>
-                </div>
+                </div>-->
             </div>
         </div>
 		<div data-options="region:'south',split:false,border:true" style="height: 25px;text-align: center;line-height: 25px;"  ></div>

+ 5 - 5
application/manage/view/manager/edit.html

@@ -17,10 +17,10 @@
             institutionsData.push(topInsData);
                 
             $(function(){
-                $('#parent_institution').combotree({
-                    required:true,multiple:true,cascadeCheck: false,
-                    valueField:'id',textField:'name',
-                    data:institutionsData
+                $('#institution_id').combotree({
+                    required:true,multiple:false,editable:false,
+                    valueField:'id',textField:'name',panelWidth:350,
+                    url:"/manage/doctors/insCombobox"
                 });
                 $('#role_id').combotree({
                     required:true,multiple:false,cascadeCheck: false,
@@ -75,7 +75,7 @@
             <tr>
                     <th height="32" align="right" >所在机构:</th>
                     <td colspan="3" >
-                    <input name="institution_id[]" id="parent_institution" type="text" size="55" value="{if  isset($manager) }{$manager.institution_id}{/if}" />
+                    <input name="institution_id[]" id="institution_id" type="text" size="55" value="{if  isset($manager) }{$manager.institution_id}{/if}" />
                     </td>
             </tr>
             <tr>

+ 7 - 1
application/manage/view/statistics/index.html

@@ -34,7 +34,12 @@
 	    	if(typeof date=="undefined"){ return "--"; }
 	    	return new Date(date).format("yy-MM-dd hh:mm");
 	    }
-            
+            // 显示编辑窗口
+            function showEditWin(id){
+                if("undefined"== typeof id){
+                    $editWin.window('open');$('#editFrame').attr('src','/manage/statistics/list');
+                }
+            }
             function statusFormatter(status){
                 if(status=="1"){
                     return "正常";
@@ -132,6 +137,7 @@
                 统计报告时间:<input type="text" id="upload1"  name="upload1" class="easyui-datebox" style="width: 120px;" />----<input type="text" id="upload2"  name="upload2" class="easyui-datebox" style="width: 120px;" />&nbsp;&nbsp;&nbsp;
                 <a id="submit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 80px" onclick="reload()" >查询</a>&nbsp;&nbsp;&nbsp;
                 <a id="excel" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 140px" onclick="derive()" >导出excel</a>
+                <a id="add" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="javascript:showEditWin()" style="width: 120px">查看明细</a>
             </form>
         </div>
         <div id="edit-window" class="easyui-window" style="overflow: hidden" ><iframe src="about:blank" id="editFrame" style="width:100%;height:100%" frameborder="0" scrolling="yes" ></iframe></div>

+ 151 - 0
application/manage/view/statistics/list.html

@@ -0,0 +1,151 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>TODO supply a title</title>
+        {include file="../application/manage/view/commons/headers.html" }
+        <script >
+            
+            // 编辑窗口
+            var $editWin;
+            var editWinHeight=$(window).height()-35;
+            var editWinWidth=$(window).width()*0.98;
+            
+            $(function(){
+                    $editWin = $('#edit-window').window({
+                        title: '医院报告统计',
+                        width: editWinWidth,height: editWinHeight,
+                        top: ($(window).height() -editWinHeight ) /2 ,
+                        left: ($(window).width() -editWinWidth ) /2 ,
+                        shadow: true,modal: true,
+                        iconCls: 'icon-edit',closed: true,resizable:true,
+                        minimizable: false,maximizable: true,collapsible: false
+                    });
+
+            });
+
+            $(window).resize(function() {
+                editWinWidth=$(window).width()*0.98;
+                $('#edit-window').window('resize',{
+                    width: editWinWidth,height: editWinHeight
+                });
+            });
+            
+            function dateFormatter(date){
+	    	if(typeof date=="undefined"){ return "--"; }
+	    	return new Date(date).format("yy-MM-dd hh:mm");
+	    }
+            // 显示编辑窗口
+            function showEditWin(id){
+                if("undefined"== typeof id){
+                    $editWin.window('open');$('#editFrame').attr('src','/manage/statistics/edit');
+                }
+            }
+            function statusFormatter(status){
+                if(status=="1"){
+                    return "正常";
+                }else if(status=="0"){
+                    return "屏蔽";
+                }else{
+                    return "非正常";
+                }
+            }
+            
+            function insFormatter(id,row){
+                for(var i=0;i<institutionsData.length;i++){
+                    var row=institutionsData[i];
+                    if(row.id==id){
+                        return row.name;
+                    }
+                }
+	    	return "<font color='#ccc' >顶级机构<font>";
+            }
+            
+            function commandsFormatter(id,row){
+	    	var cmdEdit="<a href='#' onclick=\"javascript:showEditWin('"+row.id+"');\" >编辑</a>&nbsp;";
+                cmdEdit+="<a href='#' onclick=\"javascript:deleteRow('"+row.id+"');\" >删除</a>";
+	    	return cmdEdit;
+	    }
+            
+            
+            
+            function statusFormatter(status){
+                if(status=="0"){
+                    return "屏蔽";
+                }else if(status=="1"){
+                    return "正常";
+                }else{
+                    return status;
+                }
+            }
+
+
+
+
+            $(function(){
+                
+                var height=$(document).height();
+                $("#dg").height(height);
+                                
+                $('#dg').datagrid({
+                    url:'/manage/statistics/infos',
+                    idField:'id',method: 'get',rownumbers: true,showFooter: true,singleSelect:true,selectOnCheck:false,
+                    toolbar: '#tb',pageList: [dgRowSize,dgRowSize*2,50,100],pagination:true,pageSize:dgRowSize,
+                    columns:[[
+                        {field:'insname',title:'申请医院',width:"200",align:'left'},
+                        {field:'reqname',title:'申请医生',width:"120",align:'left'},
+                        {field:'exam_class',title:'检查类型',width:"120",align:'left'},
+                        {field:'patient_num',title:'病历号',width:"120",align:'left'},
+                        {field:'req_date_time',title:'申请时间',width:"160",align:'left'},
+                        {field:'rpname',title:'报告医生',width:"80",align:'left'},
+                        {field:'report_datetime',title:'写报告时间',width:"160",align:'left'},
+                        {field:'rvname',title:'审核医生',width:"80",align:'left'},
+                        {field:'review_datetime',title:'审报告时间',width:"160",align:'left'}
+                    ]],
+                    onDblClickRow :function(rowIndex,rowData){
+                        showEditWin(rowData.id);
+                    },
+                });
+
+
+            });
+            
+            function reload(){
+                var upload1 = $("#upload1").val();
+                var upload2 = $("#upload2").val();
+                var url="/manage/Statistics/infos?upload1="+(upload1==null?"":upload1)+"&upload2="+(upload2==null?"":upload2);
+                $('#dg').datagrid("reload",url);
+            }
+
+            function derive(){
+                var form = $("#form");
+                var upload1 = $("#upload1").val();
+                var upload2 = $("#upload2").val();
+                var url="/manage/Statistics/outs?upload1="+(upload1==null?"":upload1)+"&upload2="+(upload2==null?"":upload2);
+                form.attr('action',url);
+                form.submit();
+            }
+            
+            $(function(){
+                $('#institution_id').combotree({
+                    required:true,multiple:false,editable:false,
+                    valueField:'id',textField:'name',panelWidth:550,
+                    url:"/manage/institution/insCombobox"
+                });
+            });
+            
+        </script>
+        
+    </head>
+    <body>
+        <div id="dg" class="easyui-datagrid" style="width:100%;height:auto;" ></div>
+        <div id="tb" class="editform" style="display: none; padding-top: 1px;">&nbsp;
+            <form id="form">
+                统计报告时间:<input type="text" id="upload1"  name="upload1" class="easyui-datebox" style="width: 120px;" />----<input type="text" id="upload2"  name="upload2" class="easyui-datebox" style="width: 120px;" />&nbsp;&nbsp;&nbsp;
+                <a id="submit" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 80px" onclick="reload()" >查询</a>&nbsp;&nbsp;&nbsp;
+                <a id="excel" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width: 140px" onclick="derive()" >导出excel</a>
+            </form>
+        </div>
+        <div id="edit-window" class="easyui-window" style="overflow: hidden" ><iframe src="about:blank" id="editFrame" style="width:100%;height:100%" frameborder="0" scrolling="yes" ></iframe></div>
+        
+    </body>
+</html>