',$time)->where('report_doctor_id',$id)->count(); return $number; } public function getAllNum($id) { $number = PublicReportModel::where('report_doctor_id',$id)->where('type',2)->count(); return $number; } public function getCountNum($id,$field) { $ids = PublicReportModel::alias('r') ->join(['remote_application'=>'a'],'a.id=r.remote_application_id') ->where('report_doctor_id',$id) ->distinct($field) ->field($field) ->select(); return count($ids); } public function getRemoteInfo($ids,$field) { $remote = $this->distinct(true)->where('id','in',$ids)->field($field)->select(); return $remote; } public function getRemoteByIns($institution,$field) { $info = $this->where('remote_institution_id',$institution)->field($field)->select(); return $info; } public function getInstitutionInfo($ids) { $info = PublicInstitutionModel::where('id','in',$ids)->field('id,name')->select(); return $info; } public function getExamInfo($ids,$field) { $info = ExamModel::distinct(true)->where('id','in',$ids)->field($field)->select(); return $info; } public function getPatient($ids) { $info = RemoteModel::distinct(true)->where('id','in',$ids)->field('patient_num')->select(); return $info; } public function querySql($sql) { $info = $this->query($sql); } public function getTodayTnfo($doctor,$where,$where_status,$report_where,$review_where,$class_where,$fuzzyWhere,$params) { $field = [ 'ra.*', 'r.id AS rid' ]; if(isset($params['num']) && !empty($params['num'])) { $page = $params['page']; $num = $params['num']; $total = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','left') ->where(function ($query) use($where, $where_status,$report_where,$review_where) { $query->where(function ($query) use($where, $where_status) { $query->where($where) ->where($where_status); }) ->whereOr($report_where) ->whereOr(function ($query) use($review_where) { $query->where($review_where); }); }) ->where($class_where) ->where($fuzzyWhere) ->where('ra.status',0) ->where('ra.remote_institution_id',$doctor['institution_id']) ->page($page,$num) ->order('ra.req_date_time desc') ->field($field) ->select(); }else{ $total = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','left') ->where(function ($query) use($where, $where_status,$report_where,$review_where) { $query->where(function ($query) use($where, $where_status) { $query->where($where) ->where($where_status); }) ->whereOr($report_where) ->whereOr(function ($query) use($review_where) { $query->where($review_where); }); }) ->where($class_where) ->where($fuzzyWhere) ->where('ra.status',0) ->where('ra.remote_institution_id',$doctor['institution_id']) ->order('ra.req_date_time desc') ->field($field) ->select(); } $count = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','left') ->where(function ($query) use($where, $where_status,$report_where,$review_where) { $query->where(function ($query) use($where, $where_status) { $query->where($where) ->where($where_status); }) ->whereOr($report_where) ->whereOr(function ($query) use($review_where) { $query->where($review_where); }); }) ->where($class_where) ->where($fuzzyWhere) ->where('ra.status',0) ->where('ra.remote_institution_id',$doctor['institution_id']) ->count(); $info = ['total'=>$total,'count'=>$count]; return $info; } //未完成 列表 public function getIncomplete($params,$doctor,$where,$where_status,$report_where,$review_where,$class_where,$search) { $field = [ 'ra.*', 'r.id AS rid' ]; $date1 = []; $date2 = []; if(($search[0] ?? null) && is_array($search)) { $date1[] = $search[0]; unset($search[0]); }; if(($search[1] ?? null) && is_array($search)) { $date2[] = $search[1]; unset($search[1]); }; // $order = NEW \think\db\Expression("field(ra.report_status ,6,7,8,4)"); $total = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','left') ->where(function ($query) use($where, $where_status,$report_where,$review_where) { $query->where(function ($query) use($where, $where_status) { $query->where($where) ->where($where_status); }) ->whereOr($report_where) ->whereOr(function ($query) use($review_where) { $query->where($review_where); }); }) ->where($class_where) ->where($date1) ->where($date2) ->where($search) ->where('ra.status',0) ->where('ra.remote_institution_id',$doctor['institution_id']) ->page($params['page'],$params['num']) ->order('ra.req_date_time desc') ->field($field) ->select(); $count = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','left') ->where(function ($query) use($where, $where_status,$report_where,$review_where) { $query->where(function ($query) use($where, $where_status) { $query->where($where) ->where($where_status); }) ->whereOr($report_where) ->whereOr(function ($query) use($review_where) { $query->where($review_where); }); }) ->where($class_where) ->where($date1) ->where($date2) ->where($search) ->where('ra.status',0) ->where('ra.remote_institution_id',$doctor['institution_id']) ->count(); $info = ['total'=>$total,'count'=>$count]; return $info; } public function getConfirm($params,$doctor,$report_where,$review_where,$review_status,$report_status,$report_review_where,$class_where,$where) { $field = [ 'ra.*', 'r.id AS rid' ]; $date1 = []; $date2 = []; if(($where[0] ?? null) && is_array($where)) { $date1[] = $where[0]; unset($where[0]); }; if(($where[1] ?? null) && is_array($where)) { $date2[] = $where[1]; unset($where[1]); }; $total = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','left') ->where(function ($query) use($report_where,$review_where,$review_status,$report_status,$report_review_where) { $query->where(function ($query) use($report_where, $report_status,$report_review_where) { $query->where($report_where) ->where($report_status) ->where($report_review_where); }) ->whereOr(function ($query) use($review_where,$review_status) { $query->where($review_where)->where($review_status); }); }) ->where($class_where) ->where($date1) ->where($date2) ->where($where) ->where('ra.remote_institution_id',$doctor['institution_id']) ->where('ra.status',0) ->page($params['page'],$params['num']) ->order('ra.req_date_time desc') ->field($field) ->select(); $count = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','left') ->where(function ($query) use($report_where,$review_where,$review_status,$report_status,$report_review_where) { $query->where(function ($query) use($report_where, $report_status,$report_review_where) { $query->where($report_where) ->where($report_status) ->where($report_review_where); }) ->whereOr(function ($query) use($review_where,$review_status) { $query->where($review_where)->where($review_status); }); }) ->where($class_where) ->where($date1) ->where($date2) ->where($where) ->where('ra.remote_institution_id',$doctor['institution_id']) ->where('ra.status',0) ->count(); $info = ['total'=>$total,'count'=>$count]; return $info; } public function getDoctorName($id) { $name = DoctorModel::where('id',$id)->value('realname'); return $name; } public function getInstitutionName($id) { $name = InstitutionModel::where('id',$id)->value('name'); return $name; } public function getInstitutionApplyTime($id) { $time = InstitutionModel::where('id',$id)->value('handling_time'); return $time; } public function getDoctorAdmin($id) { $admin = DoctorModel::where('institution_id',$id)->where('is_admin',1)->value('id'); return $admin; } public function getDoctorClass($id) { $doctor_class = DoctorClassModel::where('doctor_id',$id)->value('doctor_class'); return $doctor_class; } public function getAllInfo($params,$doctor,$where,$where_status,$report_where,$report_status,$remote_where,$search,$class_where) { $field = [ 'ra.*', 'r.id AS rid' ]; $date1 = []; $date2 = []; if(($search[0] ?? null) && is_array($search)) { $date1[] = $search[0]; unset($search[0]); }; if(($search[1] ?? null) && is_array($search)) { $date2[] = $search[1]; unset($search[1]); }; // $order = NEW \think\db\Expression("field(ra.report_status ,6,7,8,4,9,5,12,10,13)"); $total = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','LEFT') ->where(function ($query) use($where,$where_status,$report_where,$report_status,$remote_where) { $query->where(function ($query) use($where,$where_status) { $query->where($where) ->where($where_status); }) ->whereOr($remote_where) ->whereOr($report_status) ->whereOr($report_where); }) ->where($class_where) ->where($date1) ->where($date2) ->where('ra.remote_institution_id',$doctor['institution_id']) ->where($search) ->where('ra.report_status','not in','1,2,3,11') ->where('ra.status',0) ->page($params['page'],$params['num']) ->order('ra.req_date_time desc') ->field($field) ->select(); $count = $this->alias('ra') ->join(['report'=>'r'],'r.remote_application_id=ra.id','LEFT') ->where(function ($query) use($where,$where_status,$report_where,$report_status,$remote_where) { $query->where(function ($query) use($where,$where_status) { $query->where($where) ->where($where_status); }) ->whereOr($remote_where) ->whereOr($report_status) ->whereOr($report_where); }) ->where($class_where) ->where($date1) ->where($date2) ->where('ra.remote_institution_id',$doctor['institution_id']) ->where($search) ->where('ra.report_status','not in','1,2,3,11') ->where('ra.status',0) ->count(); $info = ['total'=>$total,'count'=>$count]; return $info; } public function getRejectList($params,$doctor,$class_where,$where) { $where_status['ra.report_status'] = '5'; $doctorWhere = []; if($doctor['is_admin'] != 1){ $doctorWhere['remote_doctor_id'] = $doctor['id']; } $date1 = []; $date2 = []; if(($search[0] ?? null) && is_array($search)) { $date1[] = $where[0]; unset($where[0]); }; if(($search[1] ?? null)) { $date2[] = $where[1]; unset($where[1]); }; $field = [ 'ra.*' ]; $total = $this->alias('ra') ->where($where_status) ->where($doctorWhere) ->where('ra.remote_institution_id',$doctor['institution_id']) ->where($class_where) ->where($where) ->where($date1) ->where($date2) ->where('ra.status',0) ->page($params['page'],$params['num']) ->order('ra.req_date_time desc') ->field($field) ->select(); $count = $this->alias('ra') ->where($where_status) ->where($doctorWhere) ->where($where) ->where($date1) ->where($date2) ->where('ra.status',0) ->where('ra.remote_institution_id',$doctor['institution_id']) ->where($class_where) ->count(); $info = ['total'=>$total,'count'=>$count]; return $info; } public function getOne($params) { $info = $this ->where('id', $params['id']) ->find(); return $info; } public function getReportId($id) { $rid = PublicReportModel::where('remote_application_id',$id)->value('id'); return $rid; } public function getRemote($id) { $info = $this->alias('re') ->join(['report'=>'r'],'r.remote_application_id=re.id','LEFT') ->where('re.id',$id) ->find(); return $info; } public function getDcmPath($where,$study) { $info = DcmpathModel::where($where)->where('study_id',$study)->value('dcm_path'); return $info; } public function getTtace($id) { $data = RecordModel::alias('r') ->join(['doctors'=>'d'], 'r.doctor_id = d.id') ->where('r.report_id', $id) ->field('r.impression, r.description, r.createdAt AS handle_time, d.realname, r.type') ->select(); return $data; } public function getApplicationById($id,$field) { try{ $info = $this->where('id',$id)->field($field)->find(); return $info; }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } public function distribute($params) { try{ $info = $this->where('id',$params['id'])->update(['remote_doctor_id'=>$params['doctor_id'],'remote_doctor_name'=>$params['doctor_name']]); return $info; }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } public function getDoctorList($id) { try{ $list = DoctorModel::where('institution_id',$id)->field('id,realname')->select(); return $list; }catch(Exception $e){ $this->throwError($e->getMessage(),0001); } } public function getVideoList($doctor) { $list = VideoModel::where('doctor_id',$doctor)->select()->toArray(); return $list; } public function getExamList($where_status,$class_where,$page,$doctor) { $field = [ 'id', 'exam_id', 'name', 'exam_class', 'req_date_time', 'req_doctor_name', 'local_institution_name', 'patient_num', 'accession_num' ]; $list = $this->where($where_status) ->where($class_where) ->where('remote_institution_id',$doctor['institution_id']) ->where('status <> 2') ->page($page,10) ->field($field) ->order('req_date_time desc') ->select() ->toArray(); return $list; } public function rejectStatus($id) { return $this->where('id',$id)->update(['report_status'=>6]); } }