Registerlist.php 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace app\inter\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use think\Session;
  6. use app\common\library\ResultTools;
  7. use think\Log;
  8. use think\Cache;
  9. class Registerlist extends Base
  10. {
  11. public function index(){
  12. try{
  13. log::record('------------接收的值--------------------');
  14. log::record($_REQUEST);
  15. log::record('--------------------------------');
  16. $sessionid = $_REQUEST['sessionid'];
  17. $doctor = Cache::get($sessionid);
  18. if(!$doctor){
  19. return ResultTools::faile('1008', '您还未登录');
  20. }
  21. log::record($doctor);
  22. log::record('-------------doctor-------------------');
  23. $search = array();
  24. $where = '';
  25. if(isset($_REQUEST['param'])){
  26. $search = $_REQUEST['param'];
  27. foreach ($search as $k => $v) {
  28. /*if($k == 'name' && !empty($v)){
  29. $where .= ' and p.name like \''.$v.'%\'';
  30. }elseif($k == 'exam_datetime' && !empty($v)){
  31. $where .= " and e.exam_datetime between '$v[0]' and '$v[1]'";
  32. }else{
  33. if(!empty($v)){
  34. $where .= ' and e.'.$k.'=\''.$v.'\'';
  35. }
  36. }*/
  37. switch($k){
  38. case 'name':
  39. if(empty($v)){
  40. break;
  41. }
  42. $where .= ' and p.name like \''.$v.'%\'';
  43. break;
  44. case 'exam_datetime':
  45. if(empty($v)){
  46. break;
  47. }
  48. $where .= " and e.exam_datetime between '$v[0]' and '$v[1]'";
  49. break;
  50. default:
  51. if(empty($v)){
  52. break;
  53. }
  54. $where .= ' and e.'.$k.'=\''.$v.'\'';
  55. break;
  56. }
  57. }
  58. }
  59. $page = $_REQUEST['page'];
  60. $num = $_REQUEST['num'];
  61. $fnum = ($page-1)*$num;
  62. $limit = " limit ".$fnum.",".$num;
  63. log::record("SELECT e.id,e.is_remote,e.study_id,e.patient_num,e.institution_id,e.exam_datetime,e.exam_project,e.exam_status,p.name,p.sex,p.age from exams as e ,patient_infos as p where e.institution_id='".$doctor['institution_id']."' and p.id=e.patient_id".$where);
  64. $sql = "SELECT e.id,e.is_remote,e.study_id,e.patient_num,e.institution_id,e.exam_datetime,e.exam_project,e.exam_status,p.name,p.sex,p.age from exams as e ,patient_infos as p where e.institution_id='".$doctor['institution_id']."' and p.id=e.patient_id".$where." order by e.ctime desc,e.urgent desc ".$limit;
  65. $list = DB::query($sql);
  66. foreach ($list as $k => $v) {
  67. $report_info = DB::table('report')->where('exam_id',$v['id'])->field(['report_datetime','report_doctor_id'])->find();
  68. $list[$k]['report_datetime'] = $report_info['report_datetime'];
  69. $dinfo = DB::table('doctors')->where('id',$report_info['report_doctor_id'])->field('realname,institution_id')->find();
  70. $list[$k]['report_doctor'] = $dinfo['realname'];
  71. $institution_name = DB::table('institution')->where('id',$dinfo['institution_id'])->cache(300)->field('name')->find();
  72. $list[$k]['institution_name'] = $institution_name['name'];
  73. }
  74. $sql1 = "SELECT count(1) from exams as e ,patient_infos as p where e.institution_id='".$doctor['institution_id']."' and p.id=e.patient_id".$where;
  75. $count = DB::query($sql1);
  76. return json_encode(['status'=>'ok','code'=>'0000','info'=>$list,'count'=>$count[0]['count(1)'],'sessionid'=>$sessionid]);
  77. }catch(\Exception $e){
  78. return json_encode(['status'=>'fail','code'=>'2000','msg'=>$e->getMessage()]);
  79. }
  80. }
  81. }