| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- namespace app\api\dao\link;
- use app\api\actions\ZskkCache;
- use app\api\dao\ZskkDefaultDao;
- use app\api\model\exam\ExamModel;
- use app\api\model\institution\InstitutionModel;
- use app\api\model\report\ReportModel;
- /**
- * 后台控制器基类
- * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
- */
- class LinkDao extends ZskkDefaultDao {
- protected $flag = true;
- protected $logName = "LinkDao";
- protected $institution;
- protected $examModel;
- protected $reportModel;
- public function __construct(InstitutionModel $institutionModel,ExamModel $examModel,ReportModel $reportModel)
- {
- parent::__construct();
- $this->institution = $institutionModel;
- $this->examModel = $examModel;
- $this->reportModel = $reportModel;
- }
- public function getAllIns()
- {
- return $this->institution->cache('3600')->select();
- }
- public function getinsExam()
- {
- return $this->examModel->field('count(*) AS num,institution_id')->group('institution_id')->select();
- }
- public function getPacsDateExam()
- {
- $data = $this->examModel->field("TO_CHAR(TRUNC(createdat,'MM'),'yyyy/mm') AS month_begin, COUNT(*) AS row_cnt")->group("TO_CHAR(TRUNC(createdat,'MM'),'yyyy/mm')")->order('month_begin')->select();
- return $data;
- }
- public function getPacsAgeExam()
- {
- $data = $this->examModel->field("age, COUNT(*) AS row_cnt")->group("age")->order('age')->select();
- return $data;
- }
- public function countExam()
- {
- return $this->examModel->count();
- }
- public function getSexData()
- {
- $arr = $this->examModel->group('sex')->field('sex,count(*) AS cnt')->select();
- return $arr;
- }
- public function getReportResult()
- {
- return $this->examModel->alias('e')->join(['report'=>'r'],'r.exam_id=e.id','left')->field('r.report_result,count(*) AS cnt')->group('r.report_result')->select();
- }
- public function getMiddleProjectList()
- {
- 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();
- }
- public function getExamsCheck($where,$institution,$value)
- {
- $data = $this->examModel->where($institution)->where($where)->value($value);
- return $data;
- }
- public function getPatientReportList($where,$institution,$whereTime,$mustWhere)
- {
- $field = [
- 'e.name',
- 'e.patient_num',
- 'e.accession_num',
- 'e.exam_class',
- 'e.exam_project',
- 'e.exam_datetime',
- 'e.exam_status',
- 'i.name AS institution',
- 'e.id AS exam_id',
- 'e.pay_status',
- 'e.is_dcm',
- 'i.charge_mode',
- 'i.film_price',
- 'e.institution_id',
- 'i.report_see',
- 'e.out_patient',
- 'e.hopitalized_no',
- 'e.study_id',
- 'e.patient_source',
- 'i.patient_send_email',
- 'i.pay_switch',
- 'i.wechat_link_unpay_message AS message',
- 'i.interpret AS report_interpret',
- 'i.interpret_code AS scene'
- ];
- $info = $this->examModel
- ->alias('e')
- ->join(['institution'=>'i'],'e.institution_id=i.id')
- ->where('e.status',1)
- ->where($institution)
- ->where($whereTime)
- ->where($mustWhere)
- ->where(function ($query) use ($where){
- $query->whereOr($where);
- })
- ->field($field)
- // ->order('exam_datetime desc')
- ->select();
- return $info;
- }
- public function getConfirmReportInfo($examId)
- {
- $field = [
- 'r.id AS report_id','r.report_doctor_name','r.review_doctor_name','r.confirm_doctor_name','r.description','r.impression','r.report_result','r.type','r.report_datetime','r.qr_code',
- 'e.name','e.sex','e.age','e. application_department','e.accession_num','e.hopitalized_no','e.bed_no','e.exam_class','e.exam_datetime','e.exam_project',"e.study_id",'e.node_type','e.pay_status','e.id AS exam_id','e.exam_status','e.institution_id','e.patient_num','e.out_patient','e.patient_source','e.is_dcm','e.his_patient_id','i.interpret AS report_interpret','i.interpret_code AS scene',
- 'i.name AS local_institution_name','i.film_price','i.charge_mode','i.pay_switch','i.report_subtitle','i.report_title',
- "'医学影像远程诊断意见报告单' AS remote_institution_name",'i.wechat_link_unpay_message AS message','i.keyword_text'
- ];
- $report =$this->examModel
- ->alias('e')
- ->join(['report'=>'r'],'r.exam_id=e.id','left')
- ->join(['institution'=>'i'],'i.id=e.institution_id','left')
- ->where('e.id',$examId)
- ->where('e.status',1)
- ->where('e.exam_status=9 and r.type=1')
- ->field($field)
- ->order('r.type asc')
- ->select();
- if(empty($report))
- {
- $examField = ['name','sex','age','is_dcm','application_department','accession_num','hopitalized_no','bed_no','exam_class','exam_datetime','exam_project',"study_id",'pay_status','id AS exam_id','exam_status','institution_id',"'' AS id",'patient_num',"'' AS message","'' AS report_subtitle","'' AS report_title"];
- $report = $this->examModel->where('id',$examId)->where('status',1)->field($examField)->select();
- }
- return $report;
- }
- }
|