Jelajahi Sumber

共享接口

lgy 3 minggu lalu
induk
melakukan
44098e2684

+ 6 - 1
server/application/api/controller/ZskkDefaultController.php

@@ -138,9 +138,14 @@ class ZskkDefaultController extends BaseController implements IBaseAction, IBase
 
     protected function success($data)
     {
-        log::record('请求结束--------------'.date('Y-m-d h:i:s'));
+        log::record('请求结束1--------------'.date('Y-m-d h:i:s'));
         return ZskkDefaultResponse::getSuccess($data);
     }
+    protected function success2($data,$code=1)
+    {
+        log::record('请求结束2--------------'.date('Y-m-d h:i:s'));
+        return ZskkDefaultResponse::getSuccess($data,'success',$code);
+    }
 
 
 

+ 10 - 0
server/application/api/controller/butt/ButtController.php

@@ -5,6 +5,7 @@ namespace app\api\controller\butt;
 use app\api\controller\ZskkDefaultApiController;
 use app\api\servies\butt\ButtService;
 use app\api\servies\exam\ExamService;
+use app\api\servies\link\LinkService;
 use app\api\servies\report\ReportService;
 use think\Exception;
 use think\facade\Cache;
@@ -454,4 +455,13 @@ class ButtController extends ZskkDefaultApiController
         }
         return $data[1] ?? '';
     }
+
+    public function getShareToken(LinkService  $linkService)
+    {
+        $this->getHeaderToken();
+        $params = Request::param(false);
+        $data = $this->getDecryptData($params['data']);
+        $token = $linkService->getShareToken($data);
+        return $this->success2($token,1);
+    }
 }

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

@@ -60,4 +60,15 @@ class LinkController extends ZskkDefaultController
         $list = $linkService->getPacsMapExam();
         return $this->success($list);
     }
+
+    public function getViewDetail(LinkService $linkService)
+    {
+        $param = Request::param();
+        $info = $this->getCache($param['token']);
+        if(empty($info)){
+            $this->throwError('token过期或已失效','-1');
+        }
+        $arr = $linkService->getViewDetail($info);
+        return json_encode(['data'=>$arr,'code'=>0,'msg'=>'success'],JSON_UNESCAPED_UNICODE);
+    }
 }

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

@@ -70,4 +70,19 @@ class LinkDao extends ZskkDefaultDao {
     {
         return $this->examModel->alias('e')->join(['institution'=>'i'],'i.id=e.institution_id')->field('i.name AS ORGNAME,e.EXAM_CLASS,e.NAME,e.EXAM_CLASS,e.CREATEDAT AS STUDYTIME,e.exam_project AS EXAM_ITEMNAME')->order('e.CREATEDAT desc')->limit(10)->select();
     }
+
+    public function getExamData($where, $where2)
+    {
+        return $this->examModel->where($where)->where($where2)->select();
+    }
+
+    public function getReportData($where)
+    {
+        return $this->reportModel->where($where)->find();
+    }
+
+    public function getInsData($where)
+    {
+        return $this->institution->where($where)->cache('ins_'.json_encode($where),'3600')->find();
+    }
 }

+ 121 - 0
server/application/api/servies/link/LinkService.php

@@ -4,6 +4,8 @@ namespace app\api\servies\link;
 
 use app\api\dao\link\LinkDao;
 use app\api\servies\ZskkDefaultService;
+use app\api\utils\UUIDUtils;
+use think\facade\Cache;
 use think\facade\Config;
 use think\facade\Log;
 use think\Db;
@@ -229,4 +231,123 @@ class LinkService extends ZskkDefaultService {
         }
         return $arr;
     }
+
+    public function getShareToken($param)
+    {
+        if(empty($param['B']))
+        {
+            $this->throwError('证件号不能为空','-1');
+        }
+        $token = UUIDUtils::uuid();
+        $this->setCache($token,$param,32400);
+        return $token;
+    }
+
+    public function getViewDetail($info)
+    {
+        $cardNum = $info['B'];
+        $cardWhere = ['card_num'=>$cardNum];
+        $where = [];
+        if($info['H'] == 1)
+        {
+            $where['institution_id'] = $info['C'];
+        }
+        $data = $this->linkDao->getExamData($where,$cardWhere);
+        if(!empty($data))
+        {
+            $patient = [];
+            $report = [];
+            $examReport = [];
+            foreach ($data as $k=>$v)
+            {
+                switch ($v['sex'])
+                {
+                    case 'M':
+                        $sex = '男';
+                        break;
+                    case 'F':
+                        $sex = '女';
+                        break;
+                    default:
+                        $sex = '未知';
+                }
+                $patient = [
+                    'BIRTH_DATE'=>$v['birthday'],
+                    'CARDNUM'=>$v['card_num'],
+                    'GENDER'=>$sex,
+                    'ID_CARDNUM'=>$v['card_num'],
+                    'MPI'=>$v['accession_num'],
+                    'NAME'=>$v['name'],
+                    'PATIENTNAME'=>$v['name'],
+                ];
+                $report = $this->linkDao->getReportData(['exam_id'=>$v['id']]);
+                $info = [];
+                $institution = $this->linkDao->getInsData(['id'=>$v['institution_id']],'name');
+                switch ($report['report_result'])
+                {
+                    case '1':
+                        $result = '阴性';
+                        break;
+                    case '2':
+                        $result = '阳性';
+                        break;
+                    default:
+                        $result = '未知';
+                }
+                $info['EXAM_REPORT'][] = [
+                    'ACCESSION_NUM'=>$v['accession_num'],
+                    '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'],
+                    'ORGNAME'=>$institution['name'],
+                    'REPORTTIME'=>$report['report_datetime'],
+                    'RESULT_STATUS'=>$result,
+                    'STUDYTIME'=>$v['exam_datetime'],
+                    'STUDY_ID'=>$v['study_id'],
+                ];
+                //患者来源
+                //'1'=>'急诊号  '2'=>住院号', '3'=>'门诊号' '4'=>'体检号'
+                switch ($v['patient_source'])
+                {
+                    case '1':
+                        $source = '急诊';
+                        break;
+                    case '2':
+                        $source = '住院';
+                        break;
+                    case '3':
+                        $source = '门诊';
+                        break;
+                    case '4':
+                        $source = '体检';
+                        break;
+                    default:
+                        $source = '';
+                }
+                $info['MEDICAL_INFORMATION'] = [
+                    'AGE'=>$v['age'],
+                    'CHIEFCOMPLAINT'=>$v['clin_diag'],
+                    'CLASS'=>$source,
+                    'DEPTNAME'=>$v['application_department'],
+                    'DIAGNOSENAME'=>$v['clin_diag'],
+                    'DOCTORNAME'=>$v['application_doctor'],
+                    'ENCOUNTER_DATE'=>$v['exam_datetime'],
+                    'GENDER'=>$sex,
+                    'NAME'=>$v['name'],
+                    'ORGCODE'=>$v['institution_id'],
+                    'ORGNAME'=>$institution['name'],
+                    'PATIENT_CODE'=>$v['accession_num']
+                ];
+                $examReport[] = $info;
+            }
+            $return = ['data'=>$examReport,'patient'=>$patient];
+            return $return;
+        }else{
+            return [];
+        }
+    }
 }

+ 2 - 0
server/route/route.php

@@ -246,6 +246,8 @@ Route::group('', function () {
     Route::get('bi/getPacsSex', 'app\api\controller\link\LinkController/getPacsSex');
     Route::get('bi/getMiddleProjectList', 'app\api\controller\link\LinkController/getMiddleProjectList');
     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');
 })->header('Access-Control-Allow-Headers','X-Requested-With,Content-Type,zskk-random,zskk_institution,zskk-signature,zskk-timestamp,zskk-token,zskk-version')
     ->allowCrossDomain();