123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595 |
- <?php
- namespace app\api\dao\report;
- use app\api\actions\ZskkCache;
- use app\api\dao\ZskkDefaultDao;
- use app\api\model\analysis\AnalysisModel;
- use app\api\model\exam\ExamModel;
- use app\api\model\institution\InstitutionModel;
- use app\api\model\keyword\KeywordreportModel;
- use app\api\model\keyword\KeywordvisitModel;
- use app\api\model\report\ReportModel;
- use app\api\model\smslog\SmslogModel;
- use app\api\model\visit\VisitModel;
- use think\facade\Log;
- use think\facade\Cache;
- /**
- * 后台控制器基类
- * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
- */
- class ReportDao extends ZskkDefaultDao {
- protected $flag = true;
- protected $logName = "ExamDao";
- protected $report = null;
- protected $institution = null;
- protected $exam = null;
- protected $reportKeyword = null;
- protected $visitKeyword = null;
- protected $visitModel = null;
- protected $smsLogModel = null;
- protected $analysisModel = null;
- public function __construct(ReportModel $reportModel,InstitutionModel $institutionModel,ExamModel $examModel,KeywordreportModel $keywordreportModel,KeywordvisitModel $keywordvisitModel,VisitModel $visitModel,SmslogModel $smsLogModel,AnalysisModel $analysisModel)
- {
- parent::__construct();
- $this->report = $reportModel;
- $this->institution = $institutionModel;
- $this->exam = $examModel;
- $this->reportKeyword = $keywordreportModel;
- $this->visitKeyword = $keywordvisitModel;
- $this->visitModel = $visitModel;
- $this->smsLogModel = $smsLogModel;
- $this->analysisModel = $analysisModel;
- }
- public function getAllExamCount($where, $whereTime)
- {
- $all = $this->exam->where($where)->where($whereTime)->count();
- return $all;
- }
- public function getAllNum($dateWhere,$where,$anotherWhere=[])
- {
- return $this->exam->where($dateWhere)->where($where)->where($anotherWhere)->count();
- }
- public function getExamGroupByIns($dateWhere,$where = [],$anotherWhere=[])
- {
- return $this->exam->where($dateWhere)->where($where)->where($anotherWhere)->field('institution_id, count(*) as num')->group('institution_id')->select();
- }
- public function getSmsNum($dateWhere,$where)
- {
- return $this->smsLogModel->where($dateWhere)->where($where)->count();
- }
- public function getSmsNumGroupByIns($dateWhere,$where = [],$anotherWhere=[])
- {
- return $this->smsLogModel->where($dateWhere)->where($where)->where($anotherWhere)->field('institution_id, count(*) as num')->group('institution_id')->select();
- }
- public function saveAnalysis($arr)
- {
- $this->analysisModel->saveAll($arr);
- }
- public function getPvWechatVisit($where, $whereTime)
- {
- $all = $this->visitModel->where($where)->where($whereTime)->count();
- return $all;
- }
- public function getUvWechatVisit($where, $whereTime)
- {
- $all = $this->visitModel
- ->where($where)
- ->where($whereTime)
- ->count('DISTINCT exam_id');
- return $all;
- }
- function getPvUvWechatVisitGroupByIns($dateWhere, $where = [],$anotherWhere=[])
- {
- $all = $this->visitModel
- ->where($dateWhere)
- ->where($where)
- ->where($anotherWhere)
- ->field('institution_id, count(*) as pv, count(DISTINCT exam_id) as uv')
- ->group('institution_id')
- ->select();
- return $all;
- }
- public function getReportInfo($examId)
- {
- $info = $this->report->getReportInfo($examId);
- return $info;
- }
- public function getRemoteReportInfo($ra_id)
- {
- $info = $this->report->getRemoteReportInfo($ra_id);
- return $info;
- }
- public function getInstitutionData($where, $field)
- {
- $info = $this->report->getInstitutionData($where, $field);
- return $info;
- }
- public function getReportStatus($id)
- {
- $status = $this->report->getStatus($id);
- return $status;
- }
- public function getDoctorsName($id)
- {
- $doctorNames = $this->report->getDoctorName($id);
- if(empty($doctorNames)){
- return null;
- }
- return $doctorNames;
- }
- public function getInstitution($dcotorId)
- {
- $info = $this->report->getInstitutionInfo($dcotorId);
- return $info;
- }
- public function getUser($token)
- {
- $user = $this->getCache($token);
- if(!$user){
- $this->throwError('登陆信息失效,请重新进行登陆','0099');
- }
- return $user;
- }
- public function saveBbs($info)
- {
- $info = $this->report->saveBbs($info);
- return $info;
- }
- public function getUserId($token)
- {
- $user = $this->getCache($token);
- if(!$user){
- $this->throwError('登陆信息失效,请重新进行登陆','0099');
- }
- return $user['id'];
- }
- public function getTrace($reportId)
- {
- $trace = $this->report->getTrace($reportId);
- return $trace;
- }
- public function remoteStage($token)
- {
- $trace = $this->getCache($token);
- if($trace){
- Cache::rm($token);
- }
- }
- public function getOrderMoney($id)
- {
- $money = $this->report->getOrderMoney($id);
- return $money;
- }
- public function getStage($cacheToken)
- {
- $trace = $this->getCache($cacheToken);
- return $trace;
- }
- public function updateInstititonMoney($id,$money)
- {
- $info = $this->report->updateInstititonMoney($id,$money);
- return $info;
- }
- public function getCurrentMoney($id)
- {
- $money = $this->report->getCurrentMoney($id);
- return $money;
- }
- public function updateOrder($id,$status)
- {
- $info = $this->report->updateOrder($id,$status);
- return $info;
- }
- public function getExam($id)
- {
- $info = $this->report->getExam($id);
- return $info;
- }
- public function getOrderId($id)
- {
- $info = $this->report->getOrderId($id);
- return $info;
- }
- public function insertReport($data)
- {
- $info = $this->report->insertReport($data);
- return $info;
- }
- public function getMiddle($where)
- {
- $info = $this->report->getMiddle($where);
- return $info;
- }
- public function saveRmiddle($middle,$middleWhere = [])
- {
- $info = $this->report->saveRmiddle($middle,$middleWhere);
- return $info;
- }
- public function delStage($key)
- {
- $info = $this->delCache($key);
- return $info;
- }
- public function insertShare($data)
- {
- $info = $this->report->insertShare($data);
- return $info;
- }
- public function insertSMSLog($data)
- {
- $info = $this->smsLogModel->insert($data);
- return $info;
- }
- public function updateExamMsg($examId, $patientId, $examUp)
- {
- $info = $this->report->updateExam($examId, $patientId, $examUp);
- return $info;
- }
- public function updateRemote($id,$update)
- {
- $info = $this->report->updateRemote($id,$update);
- return $info;
- }
- public function getReportId($examId,$reportType)
- {
- $id = $this->report->getReportId($examId,$reportType);
- return $id;
- }
- public function getRemoteReportId($id)
- {
- $id = $this->report-> getRemoteReportId($id);
- return $id;
- }
- public function getInstitutionSms($id)
- {
- $sms = $this->report->getInstitutionSms($id);
- return $sms;
- }
- public function getInstitutionName($id)
- {
- $name = $this->report->getInstitutionName($id);
- return $name;
- }
- public function getApplicationId($examId)
- {
- $id = $this->report->getApplicationId($examId);
- return $id;
- }
- public function saveCache($key,$value,$time)
- {
- $this->setCache($key,$value,$time);
- }
- public function getDoctorInfo($id,$field)
- {
- $info = $this->report->getDoctorInfo($id,$field);
- return $info;
- }
- public function getPrintInfo($reportId,$is_remote)
- {
- $info = $this->report->getPrintInfo($reportId,$is_remote);
- return $info;
- }
- public function updateReport($examId,$type,$update)
- {
- $info = $this->report->updateReport($examId,$type,$update);
- return $info;
- }
- public function readMessage($id)
- {
- $info = $this->report->readMessage($id);
- return $info;
- }
- public function updateRemoteReport($id,$update)
- {
- $info = $this->report->updateRemoteReport($id,$update);
- return $info;
- }
- public function updateExamStatus($examId,$status)
- {
- $info = $this->report->updateExamStauts($examId,$status);
- return $info;
- }
- public function updateExamInfo($id,$update)
- {
- $info = $this->report->updateExamInfo($update,$id);
- return $info;
- }
- public function insertMessage($data)
- {
- $info = $this->report->insertMessage($data);
- return $info;
- }
- public function updateRemoteStauts($examId,$status)
- {
- $info = $this->report->updateRemoteStauts($examId,$status);
- return $info;
- }
- public function updateremoteExamStatus($examId,$status)
- {
- $info = $this->report->updateremoteExamStatus($examId,$status);
- return $info;
- }
- public function insertReportRecord($info)
- {
- $info = $this->report->insertRecord($info);
- return $info;
- }
- public function getDoctorClass($userId)
- {
- $info = $this->report->getDoctorClass($userId);
- return $info;
- }
- public function getReportById($id,$field)
- {
- $info = $this->report->getReportById($id,$field);
- return $info;
- }
- public function getReport($examId,$type,$ra_id=null)
- {
- $info = $this->report->getReport($examId,$type,$ra_id);
- return $info;
- }
- public function deleteAiReport($examId,$type)
- {
- $info = $this->report->deleteAiReport($examId,$type);
- return $info;
- }
- public function getXzData($id)
- {
- $info = $this->report->getXzData($id);
- return $info;
- }
- public function getDoctorName($id)
- {
- $info = $this->report->getDoctorRealName($id);
- return $info;
- }
- public function getUid($id)
- {
- $uid = $this->report->getUid($id);
- return $uid;
- }
- public function getAccession($id)
- {
- $info = $this->report->getAccession($id);
- return $info;
- }
- public function savePregressLog($log)
- {
- $this->report->savePregressLog($log);
- }
- public function saveVideo($data,$where)
- {
- $info = $this->report->saveVideo($data,$where);
- return $info;
- }
- public function cancel_video($id)
- {
- $info = $this->report->cancel_video($id);
- return $info;
- }
- public function getVideo($id)
- {
- $info = $this->report->getVideo($id);
- return $info;
- }
- public function insertDcmPath($data)
- {
- $info = $this->report->insertDcmPath($data);
- return $info;
- }
- public function updateDcmPath($where,$update)
- {
- $info = $this->report->updateDcmPath($where,$update);
- return $info;
- }
- public function getDcmPath($where,$study)
- {
- $info = $this->report->getDcmPath($where,$study);
- return $info;
- }
- public function getDcmPathData($where,$study)
- {
- $info = $this->report->getDcmPathData($where,$study);
- return $info;
- }
- public function insertReject($data)
- {
- $info = $this->report->insertReject($data);
- return $info;
- }
- public function checkLock($id)
- {
- $info = $this->report->checkLock($id);
- return $info;
- }
- public function updateEmailStatus($study, $email)
- {
- $info = $this->report->updateEmailStatus($study, $email);
- return $info;
- }
- public function getPatientName($study)
- {
- $name = $this->report->getPatientName($study);
- return $name;
- }
- public function insertNote($data)
- {
- $id = $this->report->insertNote($data);
- return $id;
- }
- public function saveDcmReportData($data,$exam,$type,$tsTime)
- {
- $info = $this->report->saveDcmReportData($data,$exam,$type,$tsTime);
- return $info;
- }
- public function getExamByStudy($study)
- {
- $info = $this->report->getExamByStudy($study);
- return $info;
- }
- public function getDmReport($date1, $date2)
- {
- $info = $this->report->getDmReport($date1, $date2);
- return $info;
- }
- public function getInsReport($date1, $date2,$ins,$remote,$page,$num)
- {
- $info = $this->report->getInsReport($date1, $date2,$ins,$remote,$page,$num);
- return $info;
- }
- public function insertDcmCompress($data)
- {
- $info = $this->report->insertDcmCompress($data);
- return $info;
- }
- public function updateDcmCompress($where,$data)
- {
- $info = $this->report->updateDcmCompress($where,$data);
- return $info;
- }
- public function getWechatData($openid)
- {
- $info = $this->report->getWechatData($openid);
- return $info;
- }
- public function getInsKeywordIds()
- {
- return $this->institution->where('keyword_switch',1)->column('id');
- }
- public function getExamCount($where,$insWhere)
- {
- return $this->exam->where($where)->where($insWhere)->count();
- }
- public function getAllPush($where)
- {
- return $this->reportKeyword->where($where)->select();
- }
- public function getAllVisit($where,$where2 = [])
- {
- return $this->visitKeyword->where($where)->where($where2)->select();
- }
-
- public function getLwSyncExam($institution, $num,$field)
- {
- $data = $this->exam->where('institution_id', $institution)->field($field)->limit(0, $num)->select();
- return $data;
- }
- public function changeLwSyncStatus($id)
- {
- return $this->exam->where('id',$id)->update(['lw_sync_status'=>2]);
- }
- public function changeLwSyncReportStatus($id)
- {
- return $this->exam->where('id',$id)->update(['lw_report_sync_status'=>2]);
- }
- public function getAllIns()
- {
- return $this->institution->column('id,name');
- }
- public function getExamList($where)
- {
- $exam = $this->exam->where($where)->field('id,name,card_num,patient_num,accession_num,exam_class,exam_datetime,sex,age,birthday,body_part_text')->select();
- return $exam;
- }
- public function getExamReport($where)
- {
- $data = $this->exam->alias('e')
- ->join(['report'=>'r'],'r.exam_id = e.id and r.type=1','left')
- ->where($where)
- ->field('e.study_id,e.name,e.sex,e.age,e.exam_datetime,e.exam_class,e.body_part,e.body_part_text,r.impression,r.description,r.report_doctor_name,r.review_doctor_name,r.confirm_doctor_name,r.review_datetime,r.report_datetime,r.confirm_datetime,r.report_result')
- ->find();
- return $data;
- }
- }
|