|
@@ -31,38 +31,50 @@ class Counts extends Base {
|
|
$params = $request->param();
|
|
$params = $request->param();
|
|
$where = [];
|
|
$where = [];
|
|
$where[] = ' e.film_type=2';
|
|
$where[] = ' e.film_type=2';
|
|
|
|
+ $datetime = 1;
|
|
|
|
+ if(isset($params['upload1']) && ($params['upload1'] == $params['upload2']) && !empty($params['upload1'])){
|
|
|
|
+ $where[] = ' s.createdAt > \''.$params['upload1'].' 00:00:00\' ';
|
|
|
|
+ $where[] = ' s.createdAt < \''.$params['upload2'].' 23:59:59\' ';
|
|
|
|
+ $datetimme = 2;
|
|
|
|
+ }
|
|
|
|
+ $examtime = 1;
|
|
|
|
+ if(isset($params['exam1']) && ($params['exam1'] == $params['exam2']) && !empty($params['exam1'])){
|
|
|
|
+ $exam1 = str_replace('-', '', $params['exam1']);
|
|
|
|
+ $where[] = ' s.studydate = \''.$exam1.'\' ';
|
|
|
|
+ $examtime = 2;
|
|
|
|
+ }
|
|
foreach ($params as $k=>$v) {
|
|
foreach ($params as $k=>$v) {
|
|
|
|
+ if(empty($v)){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
switch($k){
|
|
switch($k){
|
|
case 'upload1':
|
|
case 'upload1':
|
|
- if($params['upload1'] == null){
|
|
|
|
- continue 2;
|
|
|
|
|
|
+ if($datetime == 2){
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
$where[] = ' s.createdAt > \''.$params['upload1'].'\' ';
|
|
$where[] = ' s.createdAt > \''.$params['upload1'].'\' ';
|
|
break;
|
|
break;
|
|
case 'upload2':
|
|
case 'upload2':
|
|
- if($params['upload2'] == null){
|
|
|
|
- continue 2;
|
|
|
|
|
|
+ if($datetime == 2){
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
$where[] = ' s.createdAt < \''.$params['upload2'].'\' ';
|
|
$where[] = ' s.createdAt < \''.$params['upload2'].'\' ';
|
|
break;
|
|
break;
|
|
case 'exam1':
|
|
case 'exam1':
|
|
- if($params['exam1'] == null){
|
|
|
|
- continue 2;
|
|
|
|
|
|
+ if($examtime == 2){
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
$exam1 = str_replace('-', '', $params['exam1']);
|
|
$exam1 = str_replace('-', '', $params['exam1']);
|
|
$where[] = ' s.studydate > \''.$exam1.'\' ';
|
|
$where[] = ' s.studydate > \''.$exam1.'\' ';
|
|
break;
|
|
break;
|
|
case 'exam2':
|
|
case 'exam2':
|
|
- if($params['exam2'] == null){
|
|
|
|
- continue 2;
|
|
|
|
|
|
+ if($examtime == 2){
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
$exam2 = str_replace('-', '', $params['exam2']);
|
|
$exam2 = str_replace('-', '', $params['exam2']);
|
|
$where[] = ' s.studydate < \''.$exam2.'\' ';
|
|
$where[] = ' s.studydate < \''.$exam2.'\' ';
|
|
break;
|
|
break;
|
|
case 'exam_class':
|
|
case 'exam_class':
|
|
- if($params['exam_class'] == null){
|
|
|
|
- continue 2;
|
|
|
|
- }
|
|
|
|
$where[] = 's.modality=\''.$params['exam_class'].'\' ';
|
|
$where[] = 's.modality=\''.$params['exam_class'].'\' ';
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -107,7 +119,7 @@ class Counts extends Base {
|
|
->where($institution_where)
|
|
->where($institution_where)
|
|
->where($search)
|
|
->where($search)
|
|
->page($page, $pagesize)
|
|
->page($page, $pagesize)
|
|
- ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id,ins.name as institution_name')
|
|
|
|
|
|
+ ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id,ins.name as institution_name,e.accession_num')
|
|
->order('s.createdAt desc')
|
|
->order('s.createdAt desc')
|
|
->select();
|
|
->select();
|
|
$data["total"] = $count;
|
|
$data["total"] = $count;
|
|
@@ -119,25 +131,55 @@ class Counts extends Base {
|
|
public function out() {
|
|
public function out() {
|
|
$admin = Session::get('session_manager');
|
|
$admin = Session::get('session_manager');
|
|
$institution_id = $admin['institution_id'];
|
|
$institution_id = $admin['institution_id'];
|
|
|
|
+ $institution = explode(',',$institution_id);
|
|
$request = Request::instance();
|
|
$request = Request::instance();
|
|
$params = $request->param();
|
|
$params = $request->param();
|
|
|
|
+ if(isset($params['institution']) && $params['institution'] != null){
|
|
|
|
+ $institution_where['s.institution_id'] = $params['institution'];
|
|
|
|
+ }else{
|
|
|
|
+ $institution_where['s.institution_id'] = ['in',$institution];
|
|
|
|
+ }
|
|
$where[] = ' e.film_type=2';
|
|
$where[] = ' e.film_type=2';
|
|
|
|
+ $datetime = 1;
|
|
|
|
+ if(($params['upload_datetime1'] == $params['upload_datetime2']) && !empty($params['upload_datetime1'])){
|
|
|
|
+ $where[] = ' s.createdAt > \''.$params['upload_datetime1'].' 00:00:00\' ';
|
|
|
|
+ $where[] = ' s.createdAt < \''.$params['upload_datetime2'].' 23:59:59\' ';
|
|
|
|
+ $datetime = 2;
|
|
|
|
+ }
|
|
|
|
+ $examtime = 1;
|
|
|
|
+ if(($params['exam_datetime1'] == $params['exam_datetime1']) && !empty($params['exam_datetime1'])){
|
|
|
|
+ $exam1 = str_replace('-', '', $params['exam_datetime1']);
|
|
|
|
+ $where[] = ' s.studydate = \''.$exam1.'\' ';
|
|
|
|
+ $examtime = 2;
|
|
|
|
+ }
|
|
foreach ($params as $k=>$v) {
|
|
foreach ($params as $k=>$v) {
|
|
if(empty($v)){
|
|
if(empty($v)){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
switch($k){
|
|
switch($k){
|
|
case 'upload_datetime1':
|
|
case 'upload_datetime1':
|
|
|
|
+ if($datetime == 2){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
$where[] = ' s.createdAt > \''.$params['upload_datetime1'].'\' ';
|
|
$where[] = ' s.createdAt > \''.$params['upload_datetime1'].'\' ';
|
|
break;
|
|
break;
|
|
case 'upload_datetime2':
|
|
case 'upload_datetime2':
|
|
|
|
+ if($datetime == 2){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
$where[] = ' s.createdAt < \''.$params['upload_datetime2'].'\' ';
|
|
$where[] = ' s.createdAt < \''.$params['upload_datetime2'].'\' ';
|
|
break;
|
|
break;
|
|
case 'exam_datetime1':
|
|
case 'exam_datetime1':
|
|
|
|
+ if($examtime == 2){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
$exam1 = str_replace('-', '', $params['exam_datetime1']);
|
|
$exam1 = str_replace('-', '', $params['exam_datetime1']);
|
|
$where[] = ' s.studydate > \''.$exam1.'\' ';
|
|
$where[] = ' s.studydate > \''.$exam1.'\' ';
|
|
break;
|
|
break;
|
|
case 'exam_datetime2':
|
|
case 'exam_datetime2':
|
|
|
|
+ if($examtime == 2){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
$exam2 = str_replace('-', '', $params['exam_datetime2']);
|
|
$exam2 = str_replace('-', '', $params['exam_datetime2']);
|
|
$where[] = ' s.studydate < \''.$exam2.'\' ';
|
|
$where[] = ' s.studydate < \''.$exam2.'\' ';
|
|
break;
|
|
break;
|
|
@@ -157,11 +199,12 @@ class Counts extends Base {
|
|
->alias('s')
|
|
->alias('s')
|
|
->distinct(true)
|
|
->distinct(true)
|
|
->join(['patient_infos'=>'p'],'p.id=s.patient_id')
|
|
->join(['patient_infos'=>'p'],'p.id=s.patient_id')
|
|
- ->join(['exams'=>'e'],'e.patient_id=p.id')
|
|
|
|
|
|
+ ->join(['exams'=>'e'],'e.study_id=s.id')
|
|
->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left')
|
|
->join(['user_bind'=>'u'],'u.patient_id=s.patient_id','left')
|
|
- ->where('s.institution_id='.$institution_id)
|
|
|
|
|
|
+ ->join(['institution'=>'ins'],'ins.id=e.institution_id','left')
|
|
|
|
+ ->where($institution_where)
|
|
->where($search)
|
|
->where($search)
|
|
- ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id')
|
|
|
|
|
|
+ ->field('p.name,p.age,p.sex,s.studydate,s.createdAt,s.modality,u.exam_id,ins.name as institution_name,e.accession_num')
|
|
->order('s.createdAt desc')
|
|
->order('s.createdAt desc')
|
|
->select();
|
|
->select();
|
|
//导入PHPExcel类库,因为PHPExcel没有用命名空间,只能inport导入
|
|
//导入PHPExcel类库,因为PHPExcel没有用命名空间,只能inport导入
|
|
@@ -187,7 +230,7 @@ class Counts extends Base {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$filename = time()."数据统计表";
|
|
$filename = time()."数据统计表";
|
|
- $headArr = array("患者姓名","患者年龄", "患者性别","检查时间", "上传时间", "患者类型", "是否绑定微信");
|
|
|
|
|
|
+ $headArr = array("患者姓名","患者年龄", "患者性别","检查时间", "上传时间", "患者类型", "是否绑定微信","科室检查号");
|
|
$this->getExcel($filename, $headArr, $data);
|
|
$this->getExcel($filename, $headArr, $data);
|
|
}
|
|
}
|
|
public function getExcel($fileName, $headArr, $data) {
|
|
public function getExcel($fileName, $headArr, $data) {
|