|
@@ -15,7 +15,128 @@ class Index extends Controller
|
|
|
{
|
|
|
public function 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;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
|
|
|
}
|