lgy 2 tuần trước cách đây
mục cha
commit
94de62a12c

+ 5 - 5
server/application/api/controller/butt/ButtController.php

@@ -403,7 +403,7 @@ class ButtController extends ZskkDefaultApiController
     {
         $params = Request::param(false);
         $data = $service->getInsToken($params['data'] ?? '');
-        return $this->success($data);
+        return $this->success2($data);
     }
     
     public function saveDmExam(ButtService $service)
@@ -417,9 +417,9 @@ class ButtController extends ZskkDefaultApiController
             // todo
             $return = $service->saveDmExam($data);
         }else{
-            $this->throwError($data,9001);
+            $this->throwError($data,'-1');
         }
-        return $this->success($return);
+        return $this->success2($return);
     }
 
     public function saveDmReport(ButtService $service)
@@ -432,9 +432,9 @@ class ButtController extends ZskkDefaultApiController
         {
             // todo
             $id = $service->saveDmReport($data);
-            return $this->success($id);
+            return $this->success2($id);
         }else{
-            $this->throwError($data,9001);
+            $this->throwError($data,'-1');
         }
     }
 

+ 21 - 0
server/application/api/controller/link/LinkController.php

@@ -71,4 +71,25 @@ class LinkController extends ZskkDefaultController
         $arr = $linkService->getViewDetail($info);
         return json_encode(['data'=>$arr,'code'=>0,'msg'=>'success'],JSON_UNESCAPED_UNICODE);
     }
+
+    public function getPatientList(LinkService $linkService)
+    {
+        $param = Request::param();
+        $list = $linkService->getPatientList($param);
+        return $this->success($list);
+    }
+
+    public function getPatientInfo(LinkService $linkService)
+    {
+        $param = Request::param();
+        $list = $linkService->getPatientInfo($param);
+        return $this->success($list);
+    }
+
+    public function getJm(LinkService $linkService)
+    {
+        $param = Request::param();
+        $list = $linkService->getJm($param);
+        return $this->success($list);
+    }
 }

+ 76 - 0
server/application/api/dao/link/LinkDao.php

@@ -85,4 +85,80 @@ class LinkDao extends ZskkDefaultDao {
     {
         return $this->institution->where($where)->cache('ins_'.json_encode($where),'3600')->find();
     }
+    public function getExamsCheck($where,$institution,$value)
+    {
+        $data = $this->examModel->where($institution)->where($where)->value($value);
+        return $data;
+    }
+
+    public function getPatientReportList($where,$institution,$whereTime,$mustWhere)
+    {
+        $field = [
+            'e.name',
+            'e.patient_num',
+            'e.accession_num',
+            'e.exam_class',
+            'e.exam_project',
+            'e.exam_datetime',
+            'e.exam_status',
+            'i.name AS institution',
+            'e.id AS exam_id',
+            'e.pay_status',
+            'e.is_dcm',
+            'i.charge_mode',
+            'i.film_price',
+            'e.institution_id',
+            'i.report_see',
+            'e.out_patient',
+            'e.hopitalized_no',
+            'e.study_id',
+            'e.patient_source',
+            'i.patient_send_email',
+            'i.pay_switch',
+            'i.wechat_link_unpay_message AS message',
+            'i.interpret AS report_interpret',
+            'i.interpret_code AS scene'
+        ];
+        $info = $this->examModel
+            ->alias('e')
+            ->join(['institution'=>'i'],'e.institution_id=i.id')
+            ->where('e.status',1)
+            ->where($institution)
+            ->where($whereTime)
+            ->where($mustWhere)
+            ->where(function ($query) use ($where){
+                $query->whereOr($where);
+            })
+            ->field($field)
+    //            ->order('exam_datetime desc')
+            ->select();
+        return $info;
+    }
+
+    public function getConfirmReportInfo($examId)
+    {
+        $field = [
+            'r.id AS report_id','r.report_doctor_name','r.review_doctor_name','r.confirm_doctor_name','r.description','r.impression','r.report_result','r.type','r.report_datetime','r.qr_code',
+            'e.name','e.sex','e.age','e. application_department','e.accession_num','e.hopitalized_no','e.bed_no','e.exam_class','e.exam_datetime','e.exam_project',"e.study_id",'e.node_type','e.pay_status','e.id AS exam_id','e.exam_status','e.institution_id','e.patient_num','e.out_patient','e.patient_source','e.is_dcm','e.his_patient_id','i.interpret AS report_interpret','i.interpret_code AS scene',
+            'i.name AS local_institution_name','i.film_price','i.charge_mode','i.pay_switch','i.report_subtitle','i.report_title',
+            "'医学影像远程诊断意见报告单' AS remote_institution_name",'i.wechat_link_unpay_message AS message','i.keyword_text'
+        ];
+        $report =$this->examModel
+            ->alias('e')
+            ->join(['report'=>'r'],'r.exam_id=e.id','left')
+            ->join(['institution'=>'i'],'i.id=e.institution_id','left')
+            ->where('e.id',$examId)
+            ->where('e.status',1)
+            ->where('e.exam_status=9 and r.type=1')
+            ->field($field)
+            ->order('r.type asc')
+            ->select();
+
+        if(empty($report))
+        {
+            $examField = ['name','sex','age','is_dcm','application_department','accession_num','hopitalized_no','bed_no','exam_class','exam_datetime','exam_project',"study_id",'pay_status','id AS exam_id','exam_status','institution_id',"'' AS id",'patient_num',"'' AS message","'' AS report_subtitle","'' AS report_title"];
+            $report = $this->examModel->where('id',$examId)->where('status',1)->field($examField)->select();
+        }
+        return $report;
+    }
 }

+ 148 - 6
server/application/api/servies/link/LinkService.php

@@ -283,8 +283,8 @@ class LinkService extends ZskkDefaultService {
                 ];
                 $report = $this->linkDao->getReportData(['exam_id'=>$v['id']]);
                 $info = [];
-                $institution = $this->linkDao->getInsData(['id'=>$v['institution_id']],'name');
-                switch ($report['report_result'])
+                $institution = $this->linkDao->getInsData(['id'=>$v['institution_id']]);
+                switch ($report['report_result'] ?? '')
                 {
                     case '1':
                         $result = '阴性';
@@ -297,15 +297,15 @@ class LinkService extends ZskkDefaultService {
                 }
                 $info['EXAM_REPORT'][] = [
                     'ACCESSION_NUM'=>$v['accession_num'],
-                    'AUDITNAME'=>$report['review_doctor_name'],
+                    'AUDITNAME'=>$report['review_doctor_name'] ?? '',
                     'BODYSITE'=>$v['body_part'],
                     'DEPTNAME'=>$v['application_department'],
                     'DEVICETYPE_CODE'=>$v['exam_class'],
                     'EXAM_ITEMNAME'=>$v['exam_project'],
-                    'OBSERVATIONS_COMMENT'=>$report['description'],
-                    'OBSERVATIONS_RESULT'=>$report['impression'],
+                    'OBSERVATIONS_COMMENT'=>$report['description'] ?? '',
+                    'OBSERVATIONS_RESULT'=>$report['impression'] ?? '',
                     'ORGNAME'=>$institution['name'],
-                    'REPORTTIME'=>$report['report_datetime'],
+                    'REPORTTIME'=>$report['report_datetime'] ?? '',
                     'RESULT_STATUS'=>$result,
                     'STUDYTIME'=>$v['exam_datetime'],
                     'STUDY_ID'=>$v['study_id'],
@@ -351,4 +351,146 @@ class LinkService extends ZskkDefaultService {
             return [];
         }
     }
+
+    public function getPatientList($param)
+    {
+        $param['code'] = openssl_decrypt(base64_decode($param['code']), 'AES-128-ECB', Config::get('chengde')['key']);
+        $param['institution_id'] = openssl_decrypt(base64_decode($param['institution_id']), 'AES-128-ECB', Config::get('chengde')['key']);
+        if(empty($param['institution_id']) || empty($param['code']))
+        {
+            $this->throwError('数据解密失败','1210');
+        }
+        if(empty($param['type']) || empty($param['code']))
+        {
+            $this->throwError('没有相应的类型','1211');
+        }
+        $insIds = explode(',',$param['institution_id']);
+        $type = explode(',',$param['type']);
+        $code = explode(',',$param['code']);
+        $where = [];
+        $institution[] = ['institution_id','in',$insIds];
+        $whereTime = [];
+        if(count($type) == 1&& count($code) !== 1)
+        {
+            //1个type多个code
+            if(!(Config::get('institution_docking')[$type[0]] ?? null))
+            {
+                $this->throwError('没有相应的类型','1211');
+            }
+            $field = Config::get('institution_docking')[$type[0]];
+            if($field == 'name')
+            {
+                $field = 'e.name';
+            }
+            $where[] = [$field,'in',$code];
+        }else{
+            foreach ($type as $k=>$v)
+            {
+                $field = Config::get('institution_docking')[$v];
+                if(empty($field) /*|| empty($code[$k])*/){
+                    continue;
+                }
+                if($field == 'name')
+                {
+                    $field = 'e.name';
+                }
+                if($field == 'exam_datetime')
+                {
+                    $whereTime['exam_datetime'] = $code[$k];
+                }else{
+                    if(empty($code[$k]))
+                    {
+                        if(!empty($code[0]))
+                        {
+                            $where[$field] = $code[0];
+                        }
+                    }else{
+                        $where[$field] = $code[$k];
+                    }
+                }
+            }
+        }
+        if(empty($where) && empty($whereTime))
+        {
+            return [];
+        }
+        if(($param['check'] ?? null))
+        {
+            switch ($param['check'])
+            {
+                case 1:
+                    $value = 'card_num';
+                    break;
+                case 2:
+                    $value = 'phone';
+                    break;
+                default:
+                    $value = '';
+                    $this->throwError('验证错误','1223');
+                    break;
+            }
+            $data = $this->linkDao->getExamsCheck($where,$institution,$value);
+            if(empty($data))
+            {
+                $this->throwError('验证错误','1223');
+            }
+            $str = substr($data,-4);
+            if($param['checkcode'] !== $str)
+            {
+                $this->throwError('验证码错误','1224');
+            }
+        }
+        $info = $this->linkDao->getPatientReportList($where,$institution,$whereTime,[]);
+        foreach ($info as $k=>$v)
+        {
+            $info[$k]['insConfig'] = '';
+            $info[$k]['config_number'] = '';
+            $config = Config::get('hospital_config');
+            foreach ($config as $key=>$value)
+            {
+                if(isset($v[$key]) && !empty($v[$key]))
+                {
+                    $info[$k]['insConfig'] = $value;
+                    $info[$k]['config_number'] = $v[$key];
+                }
+            }
+            if(!empty($v['patient_source']))
+            {
+                $sourceArr = Config::get('patient_source');
+                $sourceInfo = $sourceArr[$v['patient_source']] ?? [];
+                if(!empty($sourceInfo))
+                {
+                    $info[$k]['insConfig'] = $sourceInfo['name'];
+                    $info[$k]['config_number'] = $v[$sourceInfo['field']];
+                }
+            }
+        }
+        return $info;
+    }
+
+    public function getPatientInfo($params)
+    {
+        $info = $this->linkDao->getConfirmReportInfo($params['exam_id']);
+        foreach ($info as $k=>$v)
+        {
+            $info[$k]['insConfig'] = '';
+            $info[$k]['config_number'] = '';
+            $config = Config::get('hospital_config');
+            foreach ($config as $key=>$value)
+            {
+                if(isset($v[$key]) && !empty($v[$key]))
+                {
+                    $info[$k]['insConfig'] = $value;
+                    $info[$k]['config_number'] = $v[$key];
+                }
+                $info[$k]['age'] = str_replace('W','周',str_replace('D','天',str_replace('M','月',str_replace('Y','岁',ltrim($info[$k]['age'],'0')))));
+            }
+        }
+        return $info;
+    }
+
+    public function getJm($param)
+    {
+        return base64_encode(openssl_encrypt($param['code'], 'AES-128-ECB', Config::get('chengde')['key']));
+    }
 }

+ 1 - 0
server/application/api/servies/xz/XzService.php

@@ -375,6 +375,7 @@ class XzService extends ZskkDefaultService {
             //         }
             //     }
             // }
+            $update['study_id'] = $params['study_id'] ?? null;
             if($exam['exam_status'] == -1){
                 $update['exam_status'] = '9';
                 $this->xz->updateExam($id,$update);

+ 20 - 0
server/config/app.php

@@ -306,4 +306,24 @@ return [
     'query_url'=>'https://query.pacsonline.cn',
     'wechat_url'=>'http://wechat.pacsonline.cn',
     'dingding_url'=>'https://oapi.dingtalk.com',
+
+    //医院对接检查条件  外链接
+    'institution_docking'=>[
+        '1'=>'patient_num',   //病历号
+        '2'=>'accession_num',  //检查号
+        '3'=>'hopitalized_no',  //住院号
+        '4'=>'card_num',   //身份证
+        '5'=>'phone',   //手机号
+        '6'=>'name',   //姓名
+        '7'=>'out_patient',  //门诊号
+        '8'=>'his_patient_id', //医院his病人id
+        '9'=>'exam_datetime', //检查时间
+    ],
+    'hospital_config'=>[
+        'hopitalized_no'=>'住院号',
+        'out_patient'=>'门诊号'
+    ],
+    'chengde'  =>[
+        'key'   =>'ghbfdmlyhxdxlyjl'
+    ],
 ];

+ 3 - 0
server/route/route.php

@@ -248,6 +248,9 @@ Route::group('', function () {
     Route::get('bi/getPacsMapExam', 'app\api\controller\link\LinkController/getPacsMapExam');
     Route::post('basic-api/getShareToken', 'app\api\controller\butt\ButtController/getShareToken');
     Route::post('getViewDetail', 'app\api\controller\link\LinkController/getViewDetail');
+    Route::post('getPatientList', 'app\api\controller\link\LinkController/getPatientList');
+    Route::post('getPatientInfo', 'app\api\controller\link\LinkController/getPatientInfo');
+    Route::get('getJm', 'app\api\controller\link\LinkController/getJm');
 })->header('Access-Control-Allow-Headers','X-Requested-With,Content-Type,zskk-random,zskk_institution,zskk-signature,zskk-timestamp,zskk-token,zskk-version')
     ->allowCrossDomain();