DoctorModel.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace app\common\model;
  3. /**
  4. * 员工信息表
  5. * Class StaffModel
  6. * @package app\common\model
  7. */
  8. class DoctorModel extends BaseModel
  9. {
  10. protected $table = 'doctor';
  11. /**
  12. *添加医生
  13. *@param array 医院信息
  14. *@return int 医院id
  15. */
  16. public function doctor_add($params){
  17. return $this->kuyun_insert($params,'');
  18. }
  19. /**
  20. *查询医生单条信息
  21. *@param array 查询条件
  22. *@return array 医生信息
  23. */
  24. public function doctor_find($where){
  25. return $this->kuyun_find($where,'','');
  26. }
  27. /**
  28. *查询所有的医生
  29. *@param array 联合查询
  30. *@param string 查询字段
  31. *@param int 页码
  32. *@param bull 是否查数量
  33. *@return array 医生信息
  34. */
  35. public function doctor_select($join,$field,$page,$is_count){
  36. return $this->kuyun_select('',$join,'',$field,'',$page,$is_count);
  37. }
  38. /**
  39. *编辑医生
  40. *@param array 添加的数据
  41. *@param array 条件
  42. *@return int
  43. */
  44. public function doctor_edit($data,$where){
  45. return $this->kuyun_insert($data,$where);
  46. }
  47. /**
  48. *删除医生
  49. *@param array 删除条件
  50. *@return int 返回删除id
  51. */
  52. public function doctor_delete($where){
  53. return $this->kuyun_delete($where);
  54. }
  55. public function getDoctorPage($page,$pageSize,$condition=[],$is_count = false,$order=''){
  56. $join=[
  57. ['hospital h','doctor.hospital_id=h.hospital_id','LEFT'],
  58. ['department d','doctor.department_id = d.department_id','LEFT']
  59. ];
  60. $this->alias('doctor')
  61. ->field('doctor.*,h.name as hospital_name,d.department_name')
  62. ->join($join);
  63. if($condition){
  64. $this->where($condition);
  65. }
  66. if($is_count){
  67. return $this->count();
  68. }
  69. if($order){
  70. $this->order($order);
  71. }
  72. return $this->select();
  73. }
  74. //获取医生列表信息
  75. public function getDoctorList($condition=[],$order=''){
  76. $join=[
  77. ['hospital hospital','hospital.hospital_id=doctor.hospital_id','LEFT'],
  78. ['department department','department.department_id = doctor.department_id','LEFT']
  79. ];
  80. $this->alias('doctor')
  81. ->field('doctor.*,hospital.hospital_id,department.department_id')
  82. ->join($join);
  83. if(!empty($condition)){
  84. $this->where($condition);
  85. }
  86. if(!empty($order)){
  87. $this->order($order);
  88. }
  89. return $this->select();
  90. }
  91. /**
  92. * 获取医生一条信息
  93. * @param array $condition
  94. * @return mixed
  95. */
  96. public function getDoctorOne($condition=[]){
  97. $join=[
  98. ['department department','department.department_id=doctor.department_id','LEFT'],
  99. ['hospital hospital','hospital.hospital_id=doctor.hospital_id','LEFT'],
  100. ];
  101. $this->alias('doctor')
  102. ->field('doctor.*,department.department_name,hospital.name hospital_name')
  103. ->join($join);
  104. if($condition){
  105. $this->where($condition);
  106. }
  107. return $this->BaseModel($this->find());
  108. }
  109. }