123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527 |
- <?php
- namespace app\api\model\remote;
- use app\api\model\dcmpath\DcmpathModel;
- use app\api\model\video\VideoModel;
- use app\api\model\doctor\DoctorModel;
- use app\api\model\doctorclass\DoctorClassModel;
- use app\api\model\exam\ExamModel;
- use app\api\model\inspect\InspectModel;
- use app\api\model\institution\InstitutionModel;
- use app\api\model\institution\PublicInstitutionModel;
- use app\api\model\record\RecordModel;
- use app\api\model\report\PublicReportModel;
- use app\api\model\report\ReportModel;
- use app\api\model\ZskkDefaultModel;
- use think\facade\Log;
- class RemoteModel extends ZskkDefaultModel {
- protected $connection = 'db_config_public';
- protected $table= 'remote_application';
- protected $logName = "RemoteModel";
- public function getReportNum($id,$time)
- {
- $number = PublicReportModel::where('report_datetime','>',$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]);
- }
- }
|