remote = $remoteDao; } public function getUser($token) { $user = $this->remote->getUser($token); return $user; } public function get_today_report($id){ $today = date('Y-m-d 00:00:00',time()); $number = $this->remote->getReportNum($id,$today); return $number; } public function get_all_report($id){ $number = $this->remote->getAllNum($id); return $number; } public function get_institution_num($id){ $count = $this->remote->getCountNum($id,'local_institution_id'); return $count; // $field = ['local_institution_id']; // $remote = $this->remote->getRemoteInfo($ids,$field); // $institution_num = count($remote); // return $institution_num; } // public function get_local_institution($id){ // $ids = $this->get_ids($id); // $field = ['local_institution_id']; // $remote = $this->remote->getRemoteInfo($ids,$field); // $ins_ids = array(); // foreach ($remote as $k => $v) { // $ins_ids[] = $v['local_institution_id']; // } // $info = $this->remote->getInstitutionInfo($ins_ids); // return $info; // } public function get_local_ins($institution) { $field = ['local_institution_id']; $remote = $this->remote->getRemoteByIns($institution,$field); $ins_ids = array(); foreach ($remote as $k => $v) { $ins_ids[] = $v['local_institution_id']; } $info = $this->remote->getInstitutionInfo($ins_ids); return $info; } public function get_patient_num($id){ $count = $this->remote->getCountNum($id,'r.id'); return $count; // $patient = $this->remote->getPatient($ids); // $patient_num = count(json_decode(json_encode($patient),true)); // return $patient_num; /* $field = ['exam_id']; $exam = $this->remote->getRemoteInfo($ids,$field); $pids = array(); foreach($exam as $k=>$v){ $pids[] = $v['exam_id']; } $patientField = ['patient_num']; $patient = $this->remote->getExamInfo($pids,$patientField); $patient_num = count(json_decode(json_encode($patient),true)); return $patient_num;*/ } // public function get_ids($id,$field){ // $institution = $this->remote->getApplicationId($id,$field); // $ids = array(); // foreach($institution as $k=>$v){ // $ids[] = $v['remote_application_id']; // } // return $ids; // } public function getwhere($params) { if(isset($params['search']) && !empty($params['search'])){ $field = ['local_institution_id','name','sex','req_date_time','report_datetime','is_urgent','exam_class','report_status']; $data = []; $data['more_search'] = $params['search']; $where = $this->getListSpecificWhere($data,$field); // 精准搜索 // $where = $this->get_where_search($params['search']); }elseif(isset($params['fuzzy']) && !empty($params['fuzzy'])){ $field = ['name','accession_num','patient_num','body_part_text']; // 模糊搜索 $data = []; $data['fuzzy_search'] = $params['fuzzy']; $where = $this->getListFuzzyWhere($data,$field); // $where = $this->get_fuzzy_search($params['fuzzy']); }else{ $where = ''; } return $where; } public function get_where_search($param){ $where = ''; foreach ($param as $k => $v) { switch ($k) { case 'local_institution_id': if(empty($v['value'])){ break; } $where .= " and ra." . $k . "='" . $v['value'] . "' "; break; case 'name': if(empty($v['value'])){ break; } $where .= " and name like '".$v['value']."%' "; break; case 'sex': if(empty($v['value'])){ break; } $where .= " and sex=".$v['value']; break; case 'req_date_time': if(empty($v['value'])){ break; } $time1 = $v['value'][0]; $time2 = $v['value'][1]; $where .= " and ra.req_date_time between '$time1' and '$time2'"; break; case 'report_datetime': if(empty($v['value'])){ break; } $time11 = $v['value'][0]; $time22 = $v['value'][1]; $where .= " and r.report_datetime between '$time11' and '$time22'"; break; case 'is_urgent': if(empty($v['value'])){ break; } $where .= " and ra.is_urgent=".$v['value']; break; case 'exam_class': if(empty($v['value'])){ break; } $where .= " and exam_class=".$v['value']; break; case 'report_status': if(empty($v['value'])){ break; } if($v != 10){ $where .= " and ra.report_status=".$v['value']; } break; } } return $where; } // 获取模糊搜索条件 public function get_fuzzy_search($fuzzy){ $where = "(name like '%$fuzzy%' or patient_num='$fuzzy' or accession_num='$fuzzy') "; return $where; } public function getLimit($params) { $page = $params['page']; $num = $params['num']; $fnum = ($page-1)*$num; $limit = " limit ".$fnum.",".$num; return $limit; } public function getTimeWhere($params) { $twhere = ''; if(isset($params['today']) && !empty($params['today'])){ $date1 = date('Y-m-d 00:00:00'); $date2 = date('Y-m-d 23:59:59'); $twhere = "ra.req_date_time between '$date1' and '$date2'"; } return $twhere; } public function getTodayInfo($doctor,$fuzzyWhere,$params) { $data = $this->makeTodayWhere($doctor); if(empty($data)){ //没有写、审核权限 return []; } $where = $data['where']; $where_status = $data['where_status']; $report_where = $data['report_where']; $review_where = $data['review_where']; if($doctor['exam_class'] == '*') { $class_where = []; }else{ $class_where[] = ['exam_class','in',explode(',',$doctor['exam_class'])]; } $info = $this->remote->getTodayInfo($doctor,$where,$where_status,$report_where,$review_where,$class_where,$fuzzyWhere,$params); return $info; } // 处理未完成状态的where条件 public function makeTodayWhere($doctor) { $where = []; $where_status = []; $report_where = []; $review_where = []; if($doctor['is_admin'] == 1){ $where[] = ['ra.report_status','in','4,6,7,8']; //申请 接收 已写 已审 $data = ['where'=>$where,'where_status'=>$where_status,'report_where'=>$report_where,'review_where'=>$review_where]; return $data; }else{ //医院内是否存在管理员 $institution_admin = $this->remote->getDoctorAdmin($doctor['institution_id']); // 医生权限类 $doctor_class = $this->remote->getDoctorClass($doctor['id']); if(strpos($doctor_class, '7,8') !== false){ //有 写 审核 权限 $where_status[] = ['ra.report_status','in','4,6']; if($institution_admin){ //医院内存在超级管理员 $where['ra.remote_doctor_id'] = $doctor['id']; }else{ $did = $doctor['id']; $where = "remote_doctor_id = '$did' OR `remote_doctor_id` = '' OR `remote_doctor_id` IS NULL"; // $where[] = ['remote_doctor_id', ['=', $doctor['id']], ['=', ''],['=',null], 'or']; } //所有已写 $report_where['report_status'] = '7'; //当前医生的审核 $review_where['report_status'] = '8'; $review_where['review_doctor_id'] = $doctor['id']; $data = ['where'=>$where,'where_status'=>$where_status,'report_where'=>$report_where,'review_where'=>$review_where]; return $data; }else{ if(strpos($doctor_class, '8') !== false){ //有远程审核权限 //所有已写 $report_where['report_status'] = '7'; //当前医生的审核 $review_where['report_status'] = '8'; $review_where['review_doctor_id'] = $doctor['id']; $data = ['where'=>$where,'where_status'=>$where_status,'report_where'=>$report_where,'review_where'=>$review_where]; return $data; }elseif(strpos($doctor_class, '7') !== false){ //没有远程审核权限 $where_status[] = ['ra.report_status','in','4,6']; if($institution_admin){ //医院内存在超级管理员 $where['ra.remote_doctor_id'] = $doctor['id']; }else{ $did = $doctor['id']; $where = "remote_doctor_id = '$did' OR `remote_doctor_id` = '' OR `remote_doctor_id` IS NULL"; // $where[] = ['remote_doctor_id', ['=', $doctor['id']], ['=', ''],['=',null], 'or']; } $data = ['where'=>$where,'where_status'=>$where_status,'report_where'=>$report_where,'review_where'=>$review_where]; return $data; }else{ //没有写、审核权限 返回空 return []; } } } } public function getAllInfo($params,$doctor,$where) { if($doctor['exam_class'] == '*') { $class_where = []; }else{ $class_where[] = ['exam_class','in',$doctor['exam_class']]; } if($params['zt'] == 0){ //所有 $info = $this->getAll($params,$doctor,$where,$class_where); return $info; }elseif ($params['zt'] == 1){ //未完成 $info = $this->getIncomplete($params,$doctor,$where,$class_where); return $info; }elseif ($params['zt'] == 2){ //已确认 $info = $this->getConfirm($params,$doctor,$class_where,$where); return $info; }elseif ($params['zt'] == 3){ //已驳回 $info = $this->getReject($params,$doctor,$class_where,$where); return $info; } } //全部诊断 全部tab页 public function getAll($params,$doctor,$search,$class_where) { $where_status = []; $where = []; $report_status = []; $report_where = []; $remote_where = []; //医院内是否存在管理员 $institution_admin = $this->remote->getDoctorAdmin($doctor['institution_id']); // 医生权限类 $doctor_class = $this->remote->getDoctorClass($doctor['id']); if($doctor['is_admin'] == 1){ //超级管理员 展示所有的信息 $where_status[] = ['ra.report_status','not in','2,3']; $info = $this->remote->getAllInfo($params,$doctor,$where,$where_status,$report_where,$remote_where,$report_status,$search,$class_where); return $info; }else{ if(strpos($doctor_class, '7,8') !== false){ //既是写 又是审 if($institution_admin){ //医院内存在超级管理员 $remote_where['ra.remote_doctor_id'] = $doctor['id']; $report_status['ra.report_status'] = '7'; // $report_where['review_doctor_id'] = $doctor['id']; $info = $this->remote->getAllInfo($params,$doctor,$where,$where_status,$report_where,$report_status,$remote_where,$search,$class_where); return $info; }else{ // 无管理员 //受邀人是自己或者为空 状态为申请和接收 $remote_where['ra.remote_doctor_id'] = $doctor['id']; //申请人是自己 $where_status['ra.report_status'] = '4'; $where['remote_doctor_id'] = null; $report_where[] = ['ra.report_status','in','7,8,9,10']; $info = $this->remote->getAllInfo($params,$doctor,$where,$where_status,$report_where,$report_status,$remote_where,$search,$class_where); return $info; } }else{ if(strpos($doctor_class, '8') !== false){ //有远程审核权限 if($institution_admin){ //医院内存在超级管理员 $report_status = '7'; $report_where['review_doctor_id'] = $doctor['id']; }else{ //无管理 $report_status[] = ['report_status','in','7,8,9,10']; } $info = $this->remote->getAllInfo($params,$doctor,$where,$where_status,$report_where,$report_status,$remote_where,$search,$class_where); return $info; }elseif(strpos($doctor_class, '7') !== false){ // 只有写权限 if($institution_admin){ //医院内存在超级管理员 $remote_where['ra.remote_doctor_id'] = $doctor['id']; }else{ //无管理 $remote_where['ra.remote_doctor_id'] = $doctor['id']; // $where_status['ra.report_status'] = '4'; $where['remote_doctor_id'] = ''; } $info = $this->remote->getAllInfo($params,$doctor,$where,$where_status,$report_where,$report_status,$remote_where,$search,$class_where); return $info; } } } } // 全部诊断 未完成 public function getIncomplete($params,$doctor,$search,$class_where) { $data = $this->makeTodayWhere($doctor); $where = $data['where'] ?? ''; $where_status = $data['where_status'] ?? ''; $report_where = $data['report_where'] ?? ''; $review_where = $data['review_where'] ?? ''; $info = $this->remote->getIncomplete($params,$doctor,$where,$where_status,$report_where,$review_where,$class_where,$search); return $info; } //全部诊断 已确认 public function getConfirm($params,$doctor,$class_where,$where) { $report_where = []; $review_where = []; $review_status = []; $report_status = []; $report_review_where = []; $doctor_class = $this->remote->getDoctorClass($doctor['id']); if($doctor['is_admin'] == 1){ //超级管理员 $report_status[] = ['report_status','in','9,10']; $info = $this->remote->getConfirm($params,$doctor,$report_where,$review_where,$review_status,$report_status,$report_review_where,$class_where,$where); return $info; }else{ if(strpos($doctor_class, '7,8') !== false){ //既是写 又是审 //作为审核 审核医生是自己 $review_where['review_doctor_id'] = $doctor['id']; //作为审核 状态大于审核 (本地确认,远程确认) $review_status[] = ['report_status','in','9,10']; //作为报告 审核医生不是自己 $report_review_where[] = ['review_doctor_id','<>',$doctor['id']]; //作为报告 写报告是自己 $report_where['report_doctor_id'] = $doctor['id']; //作为报告 状态大于写报告 (审核,远程确认,本地确认) $report_status[] = ['report_status','in','8,9,10']; $info = $this->remote->getConfirm($params,$doctor,$report_where,$review_where,$review_status,$report_status,$report_review_where,$class_where,$where); return $info; }else{ if(strpos($doctor_class, '8') !== false){ //审核医生 //作为审核 审核医生是自己 $review_where['review_doctor_id'] = $doctor['id']; //作为审核 状态大于审核 (本地确认,远程确认) $review_status[] = ['report_status','in','9,10']; $info = $this->remote->getConfirm($params,$doctor,$report_where,$review_where,$review_status,$report_status,$report_review_where,$class_where,$where); return $info; }elseif (strpos($doctor_class, '7') !== false){ //写报告医生 //作为报告 审核医生不是自己 $report_review_where[] = ['review_doctor_id','<>',$doctor['id']]; //作为报告 写报告是自己 $report_where['report_doctor_id'] = $doctor['id']; //作为报告 状态大于写报告 (审核,远程确认,本地确认) $report_status[] = ['report_status','in','8,9,10']; $info = $this->remote->getConfirm($params,$doctor,$report_where,$review_where,$review_status,$report_status,$report_review_where,$class_where,$where); return $info; } } } } //全部诊断 已驳回 public function getReject($params,$doctor,$class_where,$where) { $info = ['total'=>[],'count'=>0]; $doctor_class = $this->remote->getDoctorClass($doctor['id']); if(strpos($doctor_class, '7') !== false || $doctor['is_admin'] == '1'){ // 只有存在写权限或者医院管理员 才有驳回数据 $info = $this->remote->getRejectList($params,$doctor,$class_where,$where); } return $info; } public function getOne($params,$doctor) { $info = $this->remote->getOne($params); $info['study_id'] = $info['study_id'].'&node_type='.$info['node_type']; $rid = $this->remote->getReportId($params['id']); $info['rid'] = $rid; $local_doctor = $this->remote->getDoctorName($info['req_doctor_id']); $institution = $this->remote->getInstitutionName($info['local_institution_id']); $remote_time = $this->remote->getInstitutionApplyTime($info['remote_institution_id']); $info['local_institution'] = $institution; $info['req_doctor'] = $local_doctor; $info['remote_time'] = $remote_time; $admin = $this->remote->getDoctorAdmin($doctor['institution_id']); if($info['report_status'] == 7 || $info['report_status'] == 8){ $class = $this->remote->getDoctorClass($doctor['id']); if(strpos($class,'8')){ $info['operator'] = 1; }else{ $info['operator'] = 0; } if($info['report_status'] == 7 && strpos($class,'7')){ $info['operator'] = 1; } }else{ if($info['remote_doctor_id'] == $doctor['id'] || $doctor['is_admin'] == 1 || (empty($admin) && empty($info['remote_doctor_id']))){ $info['operator'] = 1; }else{ $info['operator'] = 0; } } return $info; } public function getRemote($id,$userId) { $info = $this->remote->getRemote($id); $info['report_id'] = $info['id']; $info['is_remote'] = 1; $info['is_creating_dcm'] = empty($this->getCache($info['study_id'].'_zip')) ? 0 : 1; $time = date('Y-m-d H:i:s',time()); //过期时间 大于当前 则 还没过期 $where = "effective_date > '$time'"; $dcm = $this->remote->getDcmPath($where,$info['study_id']); $info['dcm_path'] = empty($dcm) ? '' : $dcm; if($info['id'] == null){ $trace = ''; }else{ $info['trace'] = $this->remote->getTtace($info['id']); $cacheToken = $this->getStageKey($info['id'],$userId); $stage = $this->remote->getCache($cacheToken); if(!empty($stage)) { $info['impression'] = $stage['impression']; $info['description'] = $stage['description']; } } return $info; } public function distribute($doctor,$params) { if($doctor['is_admin'] != '1'){ $this->throwError('只有管理员才可以进行分配','0042'); } $field = ['report_status']; $status = $this->remote->getApplicationById($params['id'],$field); if($status['report_status'] != '4'){ $this->throwError('该数据已经被接收处理,无法进行分配','0043'); } $info = $this->remote->distribute($params); return $info; } public function getDoctorList($institution_id) { $info = $this->remote->getDoctorList($institution_id); return $info; } public function getVideoList($user) { $list = $this->remote->getVideoList($user['id']); foreach ($list as $k=>$v) { $list[$k]['video_url'] = $this->makeFileUrl($v['video_url'],$v['video_type'],'inline'); $file = explode('/',$v['video_url']); $name = explode('.',$file[count($file)-1]); $list[$k]['video_name'] = $name[0] ?? ''; } return $list; } public function getExamList($user,$params) { if(!($params['page'] ?? null)) { $this->throwError('无法识别当前页数','0043'); } $page = $params['page']; $class_where = []; $where_status[] = ['report_status','in','4,6,7,8,10']; if($user['is_admin'] == 1) { //获取所有的检查 $class_where =[]; }else{ if($user['exam_class'] == '*') { $class_where = []; }else{ $class_where[] = ['exam_class','in',explode(',',$user['exam_class'])]; } } $list = $this->remote->getExamList($where_status,$class_where,$page,$user); return $list; } public function rejectStatus($id) { $info = $this->remote->rejectStatus($id); return $info; } }