123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace app\manage\controller;
- use think\Controller;
- use think\Db;
- use think\Session;
- use think\Config;
- use think\Cookie;
- use think\Request;
- use app\common\library\SysLogs;
- use app\common\library\UUIDs;
- /**
- *
- */
- class Counts extends Base {
- public function index(){
- return $this->fetch();
- }
- public function datas(){
- $admin = Session::get('session_manager');
- $institution_id = $admin['institution_id'];
- $request = Request::instance();
- $params = $request->param();
- $where = array();
- foreach ($params as $k=>$v) {
- switch($k){
- case 'upload1':
- if($params['upload1'] == null){
- continue;
- }
- $where[] = ' s.createdAt > \''.$params['upload1'].'\' ';
- break;
- case 'upload2':
- if($params['upload2'] == null){
- continue;
- }
- $where[] = ' s.createdAt < \''.$params['upload2'].'\' ';
- break;
- case 'exam1':
- if($params['exam1'] == null){
- continue;
- }
- $exam1 = str_replace('-', '', $params['exam1']);
- $where[] = ' s.studydate > \''.$exam1.'\' ';
- break;
- case 'exam2':
- if($params['exam2'] == null){
- continue;
- }
- $exam2 = str_replace('-', '', $params['exam2']);
- $where[] = ' s.studydate < \''.$exam2.'\' ';
- break;
- case 'exam_class':
- if($params['exam_class'] == null){
- continue;
- }
- $where[] = 's.modality=\''.$params['exam_class'].'\' ';
- break;
- }
- }
- if(count($where) <= 1){
- $where1 = implode('',$where);
- $search = $where1;
- }else{
- $where1 = implode(' and ',$where);
- $search = $where1;
- }
- $page = empty($_GET["page"]) ? 1 : $_GET["page"];
- $pagesize = empty($_GET["rows"]) ? 1 : $_GET["rows"];
- if (empty($page) || $page < 1) {
- $page = 1;
- }
- if (empty($pagesize) || $pagesize < 1) {
- $pagesize = 30;
- }
- $count = DB::table('studies')
- ->alias('s')
- ->join(['patient_infos'=>'p'],'p.id=s.patient_id')
- ->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left')
- ->where('s.institution_id='.$institution_id)
- ->where($search)
- ->count();
- $list = DB::table('studies')
- ->alias('s')
- ->join(['patient_infos'=>'p'],'p.id=s.patient_id')
- ->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left')
- ->where('s.institution_id='.$institution_id)
- ->where($search)
- ->page($page, $pagesize)
- ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id')
- ->order('s.createdAt desc')
- ->select();
- $data["total"] = $count;
- $data["rows"] = $list;
- echo json_encode($data);
- }
- }
|