|
@@ -62,6 +62,10 @@ class Doctors extends Base {
|
|
|
*/
|
|
|
public function edit() {
|
|
|
$doctors = null;
|
|
|
+ $special = DB::table('special_remote')
|
|
|
+ ->where('status',1)
|
|
|
+ ->field('id,name,0 as sc_status')
|
|
|
+ ->select();
|
|
|
if (isset($_GET["id"])) {
|
|
|
$id = $_GET["id"];
|
|
|
if ($id != null) {
|
|
@@ -85,8 +89,15 @@ class Doctors extends Base {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ $special = DB::table('special_remote')
|
|
|
+ ->alias('sr')
|
|
|
+ ->join(['special_contact'=>'sc'],'sc.did=\''.$id.'\' and sc.sid=sr.id','left')
|
|
|
+ ->where('sr.status',1)
|
|
|
+ ->field('sr.id,sr.name,sc.status as sc_status')
|
|
|
+ ->select();
|
|
|
}
|
|
|
}
|
|
|
+ $this->assign('special', $special);
|
|
|
$doctorClas = Db::table("constant")->where("parent_id", "doctor_class")->order("ordernum", "1")->select();
|
|
|
$this->assign('doctorclas', $doctorClas);
|
|
|
$examCla = DB::table('constant')->where('parent_id','exam_class')->select();
|
|
@@ -94,6 +105,7 @@ class Doctors extends Base {
|
|
|
$institution = DB::table('institution')->select();
|
|
|
$this->assign('institution', $institution);
|
|
|
|
|
|
+
|
|
|
$depWheres = array();
|
|
|
if ($doctors != null) {
|
|
|
$depWheres["institution_id"] = $doctors["institution_id"];
|
|
@@ -106,6 +118,41 @@ class Doctors extends Base {
|
|
|
public function save() {
|
|
|
$request = Request::instance();
|
|
|
$params = $request->param();
|
|
|
+ $data = $params;
|
|
|
+ //预创建医生id
|
|
|
+ $id = UUIDs::uuid16();
|
|
|
+ if(isset($params['id']) && !empty($params['id'])){
|
|
|
+ $id = $params['id'];
|
|
|
+ }
|
|
|
+ unset($params['special_name']);
|
|
|
+ foreach ($data['special_name'] as $v){
|
|
|
+ unset($params['special_'.$v]);
|
|
|
+ $special_contact = DB::table('special_contact')->where('did',$id)->where('sid',$v)->find();
|
|
|
+ if($data['special_'.$v] == '1'){
|
|
|
+ //存在医生则查找
|
|
|
+ if(empty($special_contact)){
|
|
|
+ $sort = DB::table('special_contact')->max('sort');
|
|
|
+ //不存在 创建信息
|
|
|
+ $special = [
|
|
|
+ 'sid'=>$v,
|
|
|
+ 'did'=>$id,
|
|
|
+ 'hid'=>$params['institution_id'],
|
|
|
+ 'describe'=>'',
|
|
|
+ 'sort'=>$sort+10,
|
|
|
+ 'status'=>1,
|
|
|
+ 'cost'=>0
|
|
|
+ ];
|
|
|
+ DB::table('special_contact')->insert($special);
|
|
|
+ }else{
|
|
|
+ //存在 修改信息
|
|
|
+ DB::table('special_contact')->where('did',$params['id'])->where('sid',$v)->update(['status'=>1]);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(!empty($special_contact)){
|
|
|
+ DB::table('special_contact')->where('did',$id)->where('sid',$v)->update(['status'=>0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!isset($params["doctorcla"])) {
|
|
|
echo "fail:doctorcla";
|
|
|
return;
|
|
@@ -127,7 +174,6 @@ class Doctors extends Base {
|
|
|
}
|
|
|
if (empty($params['id'])) {
|
|
|
unset($params['id']);
|
|
|
- $id = UUIDs::uuid16();
|
|
|
$params['id'] = $id;
|
|
|
$a = DB::table('doctors')->insert($params);
|
|
|
if (isset($params["department_id"])) {
|