lgy 6 سال پیش
والد
کامیت
2848aca83b
4فایلهای تغییر یافته به همراه151 افزوده شده و 17 حذف شده
  1. 4 0
      application/common/versionsql/Version2
  2. 5 2
      application/database.php
  3. 122 1
      application/index/controller/Index.php
  4. 20 14
      application/inter/controller/Index.php

+ 4 - 0
application/common/versionsql/Version2

@@ -0,0 +1,4 @@
+ALTER  TABLE  `images`  ADD  local_url varchar(255);
+ALTER  TABLE  `images`  ADD  remote_url varchar(100);
+ALTER  TABLE  `images`  ADD  status  int(11) default 2;
+ALTER  TABLE  `exams`  ADD  ext  json;

+ 5 - 2
application/database.php

@@ -13,9 +13,12 @@ return [
     // 数据库类型
     // 数据库类型
     'type'            => 'mysql',
     'type'            => 'mysql',
     // 服务器地址
     // 服务器地址
-    'hostname'        => '47.104.4.5',
+     'hostname'        => '47.104.6.21',
+    //'hostname'        => '47.104.4.5',
     // 数据库名
     // 数据库名
-    'database'        => 'db_remote_diag',
+//    'database'        => 'pacsonline',
+    'database'        => 'ceshi',
+    //'database'        => 'db_remote_diag',
     // 用户名
     // 用户名
     'username'        => 'pacs',
     'username'        => 'pacs',
     // 密码
     // 密码

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

@@ -15,7 +15,128 @@ class Index extends Controller
 {
 {
     public function  index(){
     public function  index(){
         echo "index";
         echo "index";
+        var_dump(json_decode(LC_IPS,TRUE));
+    }
+    public function get_studiesinfo(){
+        $study_id = $_REQUEST['study_id'];
+        /*if(isset($_REQUEST['address']) && !empty($_REQUEST['address'])){
+            $url = "dicomweb://".$_REQUEST['address']."/";
+        }else{
+            $url = '';
+        }*/
+        $info = array();
+        if(strlen($study_id) == '16'){
+            $study_info = DB::table('studies')->where('id',$study_id)->field('id,studyuid,studyid,patient_id')->find();
+        }else{
+            $study_info = DB::table('studies')->where('studyuid',$study_id)->field('id,studyuid,studyid,patient_id')->find();
+        }
+        $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();
+        $institution = DB::table('institution')->where('id',$patient_info['institution_id'])->field('name')->find();
+        $info['patientName'] = $patient_info['name'];
+        // 根据series_num排序
+        $series_list = DB::table('series')->where('study_id',$study_info['id'])->where('modality','not in','PR,SR')->field('id,series_num,seriesuid,description')->order('series_num asc')->select();
+        $series = array();
+        foreach($series_list as $k=>$v){
+            // image_number排序
+            $image = DB::table('images')->where('series_id',$v['id'])->field('remote_url,local_url,status,columns,image_number as instanceNumber,rows,image_id as sopInstanceUid,metadata,url')->order('image_number asc')->select();
+            foreach($image as $key=>$value){
+                /*if(empty($url)){
+                    if(substr($value['metadata'], 0, strlen('group')) === 'group'){
+                        $image[$key]['url'] = "dicomweb://dcm.pacsonline.cn/".$value['metadata'];
+                    }else{
+                        $image[$key]['url'] = "dicomweb://static.dcm.pacsonline.cn/".$value['metadata'];
+                    }
+                }else{
+                    $image[$key]['url'] = $url.$value['metadata'];
+                }*/
+                $imageUrl = $this->generateUrl($value['url'],$_REQUEST['address'],$value['remote_url'],$value['local_url'],$value['status']);
+                if(!$imageUrl){
+                    $dir = ROOT_PATH . 'public' . DS . 'get_studiesinfo';
+                    if (!file_exists($dir)){
+                        mkdir ($dir,0777,true);
+                    }
+                    $file = ROOT_PATH . 'public' . DS . 'get_studiesinfo/'.date('Ymd').'-fail.log';
+                    $log = 'url错误,传值为--'.$_REQUEST['address'];
+                    file_put_contents($file, $log,FILE_APPEND);
+                    continue;
+                }
+                $image[$key]['url'] = $imageUrl;
+                $image[$key]['imageNumber'] = $value['instanceNumber'];
+            }
+            $series[$k]['instances'] = $image;
+            $series[$k]['seriesInstanceUid'] = $v['seriesuid'];
+            $series[$k]['seriesDescription'] = $v['description'];
+            $series[$k]['seriesNumber'] = $v['series_num'];
+        }
+        $info['seriesList'] = $series;
+        $return  = array();
+        $return['transactionId'] = $study_info['studyuid'];
+        if(!empty($patient_info['age'])){
+            $info['patientAge'] = $patient_info['age'];
+        }elseif(!empty($patient_info['birthday'])){
+            $time = date('Ymd',time());
+            $age = floor(($time - $patient_info['birthday'])/10000);
+            $info['patientAge'] =  $age;
+        }else{
+            $info['patientAge'] = '';
+        }
+        $info['patientSex'] = $patient_info['sex'];
+        $info['studyDate'] = $date['exam_datetime'];
+        $info['studyid'] = $study_info['studyid'];
+        $info['patientId'] = $patient_info['temp_patient_id'];
+        $info['institution'] = $institution['name'];
+        $return['studies'][] = $info;
+        return json_encode($return);
+    }
+    public function generateUrl($url, $address, $remote_url, $local_url, $status) {
+        if(empty($address)) {
+            return self::generateNormalUrl($url);
+        }
+        if(preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/",$address)) {
+            return self::generateIpUrl($url,$address,$remote_url, $local_url, $status);
+        }
+        return  self::generateNormalUrl($url,$address);
+    }
+    public function generateIpUrl($url, $address, $remote_url, $local_url, $status) {
+        //获取ip
+        $ip = $this->getIpbyAddress($address);
+        if(in_array($ip,json_decode(LC_IPS,TRUE))) {
+            //浪潮政务云访问
+            return "dicomweb://$address/$remote_url";
+        }
+        if($status & STATUS_LOCAL) {
+            //内网url有效
+            return "dicomweb://$address/$local_url";
+        }
+        if($status & STATUS_REMOTE) {
+            //外网url有效
+            return "dicomweb://$address/".REMOTE_FLAG."/$remote_url";
+        }
+        return  null;
+    }
+    public function getIpbyAddress($url){
+        $ip = explode(':',$url);
+        return $ip[0];
+    }
+    public function generateNormalUrl($url , $domain = 'dcm.pacsonline.cn') {
+        if(substr($url, 0, strlen('dicomweb://')) === 'dicomweb://'){
+            return $url;
+        }elseif(substr($url, 0, strlen('http://')) === 'http://'){
+            $httpurl = str_replace("'http://","dicomweb://",$url);
+            return $httpurl;
+        }elseif(substr($url, 0, strlen('https://')) === 'https://'){
+            $httpsurl = str_replace("'https://","dicomweb://",$url);
+            return $httpsurl;
+        }elseif(strstr($domain,'://')){
+            $lujing = explode('://',$domain);
+            $dicurl = 'dicomweb://'.$lujing[1].'/'.$url;
+            return $dicurl;
+        }else{
+            $dicurl = 'dicomweb://'.$domain.'/'.$url;
+            return $dicurl;
+        }
     }
     }
-    
     
     
 }
 }

+ 20 - 14
application/inter/controller/Index.php

@@ -28,6 +28,12 @@ class Index extends Controller
     }
     }
 
 
     public function  index(){
     public function  index(){
+        $a = '127.0.0.111:80';
+        $b = preg_match("/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/",$a);
+        var_dump($b);
+        $ip = explode(':',$a);
+        return $ip[0];
+        var_dump(STATUS_LOCAL);die;
         /*$a = DB::table('doctors')->where('institution_id','73090001')->select();
         /*$a = DB::table('doctors')->where('institution_id','73090001')->select();
         foreach($a as $k=>$v){
         foreach($a as $k=>$v){
             $c = DB::table('dr_cla_permission')->where('doctor_id',$v['id'])->where('pass','bdb52c21d1687709')->delete();
             $c = DB::table('dr_cla_permission')->where('doctor_id',$v['id'])->where('pass','bdb52c21d1687709')->delete();
@@ -35,7 +41,7 @@ class Index extends Controller
         }
         }
         // bdb52c21d1687709  预约登记
         // bdb52c21d1687709  预约登记
         // 0eac42ef01de23ff 登记列表*/
         // 0eac42ef01de23ff 登记列表*/
-        die;
+       /* die;
         $doctor = '1';
         $doctor = '1';
         $dr = DB::table('dr_cla_permission')->where('doctor_id',1)->field('pass')->select();
         $dr = DB::table('dr_cla_permission')->where('doctor_id',1)->field('pass')->select();
         $a = array();
         $a = array();
@@ -43,7 +49,7 @@ class Index extends Controller
         if(in_array($a,$dr)){
         if(in_array($a,$dr)){
             echo 1;die;
             echo 1;die;
         }
         }
-        foreach ($dr as $k => $v) {
+        foreach ($dr as $k => $v) {*/
 
 
             /*if($v['pass'] ==  'bdb52c21d1687709'){
             /*if($v['pass'] ==  'bdb52c21d1687709'){
                 //预约登记
                 //预约登记
@@ -62,10 +68,10 @@ class Index extends Controller
                     return '科室报告';
                     return '科室报告';
                     break;
                     break;
             }*/
             }*/
-        }
-        die;
+        /*}
+        die;*/
         // DR->DX
         // DR->DX
-        $a = DB::table('templates')->where('is_public','1')->where('exam_class_id','DR')->select();
+        /*$a = DB::table('templates')->where('is_public','1')->where('exam_class_id','DR')->select();
         foreach ($a as $k => $v) {
         foreach ($a as $k => $v) {
             $b = array();
             $b = array();
             $p = DB::table('templates')->where('parent_id',$v['id'])->select();
             $p = DB::table('templates')->where('parent_id',$v['id'])->select();
@@ -87,9 +93,9 @@ class Index extends Controller
                 DB::table('templates')->insert($y);
                 DB::table('templates')->insert($y);
             }
             }
         }
         }
-        die;
+        die;*/
         // 菜单权限
         // 菜单权限
-        /*$a = DB::table('doctors')->where('institution_id','74500001')->select();
+        /*$a = DB::table('doctors')->where('institution_id','4400001')->select();
         $i = 1;
         $i = 1;
         foreach($a as $k=>$v){
         foreach($a as $k=>$v){
             $info = array();
             $info = array();
@@ -102,19 +108,19 @@ class Index extends Controller
                 echo $i;
                 echo $i;
                 $i++;
                 $i++;
             }
             }
-        }*/
+        }
+        die;*/
         //  报告权限
         //  报告权限
-        $qx = DB::table('doctors')->where('institution_id','74500001')->select();
+        $qx = DB::table('doctors')->where('institution_id','4400001')->select();
         foreach($qx as $k=>$v){
         foreach($qx as $k=>$v){
             $qxinfo = array();
             $qxinfo = array();
-            if($v['department_id'] == 'd131507b77044283'){
+            if($v['department_id'] == '4be1b7354592e3b3' || $v['department_id'] == '9156b1ddb9127c3b' || $v['department_id'] == '99037aa160453538'){
                 // 写报告权限
                 // 写报告权限
-                $qxinfo['department_id'] = 'd131507b77044283';
-                $qxinfo['doctor_class'] = '2,3,4';
+                $qxinfo['doctor_class'] = '2,3,4,6';
             }else{
             }else{
-                $qxinfo['department_id'] = $v['department_id'];
                 $qxinfo['doctor_class'] = '1';
                 $qxinfo['doctor_class'] = '1';
             }
             }
+            $qxinfo['department_id'] = $v['department_id'];
             $qxinfo['id'] = UUIDs::uuid16();
             $qxinfo['id'] = UUIDs::uuid16();
             $qxinfo['doctor_id'] = $v['id'];
             $qxinfo['doctor_id'] = $v['id'];
             $qxx = DB::table('doctor_class')->insert($qxinfo);
             $qxx = DB::table('doctor_class')->insert($qxinfo);
@@ -122,7 +128,7 @@ class Index extends Controller
                 var_dump($qxinfo);
                 var_dump($qxinfo);
             }
             }
         }
         }
-        die;
+        die('over');
         $a = "select count(1) from templates where id='00'";
         $a = "select count(1) from templates where id='00'";
         $b = DB::query($a);
         $b = DB::query($a);
         var_dump($b);
         var_dump($b);