Counts.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace app\manage\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use think\Session;
  6. use think\Config;
  7. use think\Cookie;
  8. use think\Request;
  9. use app\common\library\SysLogs;
  10. use app\common\library\UUIDs;
  11. /**
  12. *
  13. */
  14. class Counts extends Base {
  15. public function index(){
  16. return $this->fetch();
  17. }
  18. public function datas(){
  19. $admin = Session::get('session_manager');
  20. $institution_id = $admin['institution_id'];
  21. $request = Request::instance();
  22. $params = $request->param();
  23. $where = array();
  24. foreach ($params as $k=>$v) {
  25. switch($k){
  26. case 'upload1':
  27. if($params['upload1'] == null){
  28. continue;
  29. }
  30. $where[] = ' s.createdAt > \''.$params['upload1'].'\' ';
  31. break;
  32. case 'upload2':
  33. if($params['upload2'] == null){
  34. continue;
  35. }
  36. $where[] = ' s.createdAt < \''.$params['upload2'].'\' ';
  37. break;
  38. case 'exam1':
  39. if($params['exam1'] == null){
  40. continue;
  41. }
  42. $exam1 = str_replace('-', '', $params['exam1']);
  43. $where[] = ' s.studydate > \''.$exam1.'\' ';
  44. break;
  45. case 'exam2':
  46. if($params['exam2'] == null){
  47. continue;
  48. }
  49. $exam2 = str_replace('-', '', $params['exam2']);
  50. $where[] = ' s.studydate < \''.$exam2.'\' ';
  51. break;
  52. case 'exam_class':
  53. if($params['exam_class'] == null){
  54. continue;
  55. }
  56. $where[] = 's.modality=\''.$params['exam_class'].'\' ';
  57. break;
  58. }
  59. }
  60. if(count($where) <= 1){
  61. $where1 = implode('',$where);
  62. $search = $where1;
  63. }else{
  64. $where1 = implode(' and ',$where);
  65. $search = $where1;
  66. }
  67. $page = empty($_GET["page"]) ? 1 : $_GET["page"];
  68. $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"];
  69. if (empty($page) || $page < 1) {
  70. $page = 1;
  71. }
  72. if (empty($pagesize) || $pagesize < 1) {
  73. $pagesize = 30;
  74. }
  75. $count = DB::table('studies')
  76. ->alias('s')
  77. ->join(['patient_infos'=>'p'],'p.id=s.patient_id')
  78. ->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left')
  79. ->where('s.institution_id='.$institution_id)
  80. ->where($search)
  81. ->count();
  82. $list = DB::table('studies')
  83. ->alias('s')
  84. ->join(['patient_infos'=>'p'],'p.id=s.patient_id')
  85. ->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left')
  86. ->where('s.institution_id='.$institution_id)
  87. ->where($search)
  88. ->page($page, $pagesize)
  89. ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id')
  90. ->order('s.createdAt desc')
  91. ->select();
  92. $data["total"] = $count;
  93. $data["rows"] = $list;
  94. echo json_encode($data);
  95. }
  96. }