HospitalModel.php
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2018/11/25
* Time: 17:04
*/
namespace app\admin\model;
use think\Db;
use think\Model;
use traits\model\SoftDelete;
class HospitalModel extends Model
{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $insert =['addtime'];
/**
* 自动填充数据
* @return mixed
*/
protected function setAddtimeAttr()
{
return time();
}
/**
* 返回平台信息
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getPlatment($platment=''){
if (empty($platment)){
$map['parent_id']='0';
$map['delete_time']='0';
$platment=db('portal_category')->where($map)->select();
}else{
$platment=db('portal_category')->where('id',$platment)->select();
}
return $platment;
}
/**
* 获取医院
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHospital($platform_id=''){
if ($platform_id!=''){
$map['platform_id']=$platform_id;
}else{
$map='';
}
$hospital=$this->where($map)->select();
return $hospital;
}
/**
* 删除医院
* @param $hosptial_id
* @return int
*/
public function hospitalDel($hosptial_id){
$result=$this::destroy($hosptial_id);
return $result;
}
public function hospitalAdd($name){
$this->data([
'name' => $name,
]);
return $this->save();
}
/**
* 获取平台内部医院
* @param $platform 平台id
* @return mixed
*/
public function getHospitalByPaltform($platform){
$map['platform_id']=$platform;
$info=db('platform_info_view')->field('hospital_name,hospital_id')->where($map)->select();
return $info;
}
/**
* 通过 平台 医院获取科室
* @param $platform 平台id
* @param $hospital 医院id
* @return mixed
*/
public function getOfficeByHP($platform,$hospital){
if (!empty($platform)){
$map['platform_id']=$platform;
}
$map['hospital_id']=$hospital;
$info=\db('platform_info_view')->field('office_name,office_id')->where($map)->select();
return $info;
}
public function getPaltform($platform=''){
if (empty($platform)){
$map['parent_id']='0';
}else{
$map['id']=$platform;
}
$map['delete_time']='0';
$info=db('portal_category')->field('name,id')->where($map)->select();
return $info;
}
public function getJob(){
}
public function getAllOffice(){
$office=db('office')->select();
return $office;
}
}