PatientInfo.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\admin\controller\patient;
  3. use app\common\controller\Backend;
  4. /**
  5. * 患者信息管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class PatientInfo extends Backend
  10. {
  11. /**
  12. * PatientInfoModel模型对象
  13. * @var \app\admin\model\patient\PatientInfoModel
  14. */
  15. protected $model = null;
  16. /**
  17. * 快速搜索时执行查找的字段
  18. */
  19. protected $searchFields = ['patient_infos.name'];
  20. public function _initialize()
  21. {
  22. parent::_initialize();
  23. $this->model = new \app\admin\model\patient\PatientInfoModel;
  24. }
  25. public function index()
  26. {
  27. //设置过滤方法
  28. $this->request->filter(['strip_tags']);
  29. if ($this->request->isAjax()) {
  30. //如果发送的来源是Selectpage,则转发到Selectpage
  31. if ($this->request->request('keyField')) {
  32. return $this->selectpage();
  33. }
  34. list($where, $sort, $order, $offset, $limit) = $this->buildparams($this->searchFields, true);
  35. $join = [
  36. ['institution i','p.institution_id = i.id','LEFT']
  37. ];
  38. $field = ['p.*','i.name as institution_name'];
  39. // 过滤机构
  40. $childInsIds = $this->auth->getMyInsId();
  41. if($childInsIds == false){
  42. $more = false;
  43. } else {
  44. $more = ['p.institution_id' => ['in', $childInsIds]];
  45. }
  46. $total = $this->model->alias('p')
  47. ->join($join)
  48. ->where($more)
  49. ->where($where)
  50. ->order($sort, $order)
  51. ->count();
  52. $list = $this->model->alias('p')
  53. ->join($join)
  54. ->where($more)
  55. ->where($where)
  56. ->order($sort, $order)
  57. ->limit($offset, $limit)
  58. ->field($field)
  59. ->select();
  60. $list = collection($list)->toArray();
  61. $result = array("total" => $total, "rows" => $list);
  62. return json($result);
  63. }
  64. return $this->view->fetch();
  65. }
  66. }