LinkDao.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. namespace app\api\dao\link;
  3. use app\api\actions\ZskkCache;
  4. use app\api\dao\ZskkDefaultDao;
  5. use app\api\model\exam\ExamModel;
  6. use app\api\model\institution\InstitutionModel;
  7. use app\api\model\report\ReportModel;
  8. /**
  9. * 后台控制器基类
  10. * 接口方法权限 必传参数 接口返回 错误抛出 通用参数处理
  11. */
  12. class LinkDao extends ZskkDefaultDao {
  13. protected $flag = true;
  14. protected $logName = "LinkDao";
  15. protected $institution;
  16. protected $examModel;
  17. protected $reportModel;
  18. public function __construct(InstitutionModel $institutionModel,ExamModel $examModel,ReportModel $reportModel)
  19. {
  20. parent::__construct();
  21. $this->institution = $institutionModel;
  22. $this->examModel = $examModel;
  23. $this->reportModel = $reportModel;
  24. }
  25. public function getAllIns()
  26. {
  27. return $this->institution->cache('3600')->select();
  28. }
  29. public function getinsExam()
  30. {
  31. return $this->examModel->field('count(*) AS num,institution_id')->group('institution_id')->select();
  32. }
  33. public function getPacsDateExam()
  34. {
  35. $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();
  36. return $data;
  37. }
  38. public function getPacsAgeExam()
  39. {
  40. $data = $this->examModel->field("age, COUNT(*) AS row_cnt")->group("age")->order('age')->select();
  41. return $data;
  42. }
  43. public function countExam()
  44. {
  45. return $this->examModel->count();
  46. }
  47. public function getSexData()
  48. {
  49. $arr = $this->examModel->group('sex')->field('sex,count(*) AS cnt')->select();
  50. return $arr;
  51. }
  52. public function getReportResult()
  53. {
  54. 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();
  55. }
  56. public function getMiddleProjectList()
  57. {
  58. 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();
  59. }
  60. public function getExamData($where, $where2)
  61. {
  62. return $this->examModel->where($where)->where($where2)->select();
  63. }
  64. public function getReportData($where)
  65. {
  66. return $this->reportModel->where($where)->find();
  67. }
  68. public function getInsData($where)
  69. {
  70. return $this->institution->where($where)->cache('ins_'.json_encode($where),'3600')->find();
  71. }
  72. public function getExamsCheck($where,$institution,$value)
  73. {
  74. $data = $this->examModel->where($institution)->where($where)->value($value);
  75. return $data;
  76. }
  77. public function getPatientReportList($where,$institution,$whereTime,$mustWhere)
  78. {
  79. $field = [
  80. 'e.name',
  81. 'e.patient_num',
  82. 'e.accession_num',
  83. 'e.exam_class',
  84. 'e.exam_project',
  85. 'e.exam_datetime',
  86. 'e.exam_status',
  87. 'i.name AS institution',
  88. 'e.id AS exam_id',
  89. 'e.pay_status',
  90. 'e.is_dcm',
  91. 'i.charge_mode',
  92. 'i.film_price',
  93. 'e.institution_id',
  94. 'i.report_see',
  95. 'e.out_patient',
  96. 'e.hopitalized_no',
  97. 'e.study_id',
  98. 'e.patient_source',
  99. 'i.patient_send_email',
  100. 'i.pay_switch',
  101. 'i.wechat_link_unpay_message AS message',
  102. 'i.interpret AS report_interpret',
  103. 'i.interpret_code AS scene'
  104. ];
  105. $info = $this->examModel
  106. ->alias('e')
  107. ->join(['institution'=>'i'],'e.institution_id=i.id')
  108. ->where('e.status',1)
  109. ->where($institution)
  110. ->where($whereTime)
  111. ->where($mustWhere)
  112. ->where(function ($query) use ($where){
  113. $query->whereOr($where);
  114. })
  115. ->field($field)
  116. // ->order('exam_datetime desc')
  117. ->select();
  118. return $info;
  119. }
  120. public function getConfirmReportInfo($examId)
  121. {
  122. $field = [
  123. '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',
  124. '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',
  125. 'i.name AS local_institution_name','i.film_price','i.charge_mode','i.pay_switch','i.report_subtitle','i.report_title',
  126. "'医学影像远程诊断意见报告单' AS remote_institution_name",'i.wechat_link_unpay_message AS message','i.keyword_text'
  127. ];
  128. $report =$this->examModel
  129. ->alias('e')
  130. ->join(['report'=>'r'],'r.exam_id=e.id','left')
  131. ->join(['institution'=>'i'],'i.id=e.institution_id','left')
  132. ->where('e.id',$examId)
  133. ->where('e.status',1)
  134. ->where('e.exam_status=9 and r.type=1')
  135. ->field($field)
  136. ->order('r.type asc')
  137. ->select();
  138. if(empty($report))
  139. {
  140. $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"];
  141. $report = $this->examModel->where('id',$examId)->where('status',1)->field($examField)->select();
  142. }
  143. return $report;
  144. }
  145. }