瀏覽代碼

添加 特殊类医生

刘桂岩 5 年之前
父節點
當前提交
6327d2c3a4

+ 47 - 1
application/manage/controller/Doctors.php

@@ -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"])) {

+ 46 - 1
application/manage/controller/Insdoctors.php

@@ -73,6 +73,10 @@ class Insdoctors extends Base {
             echo "not login ?";
             return;
         }
+        $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) {
@@ -98,7 +102,14 @@ class Insdoctors extends Base {
                     // 医生的exam报告类权限
                 }
             }
+            $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);
 //
         $examCla = DB::table('constant')->where('parent_id','exam_class')->select();
         $this->assign('examclass',$examCla);
@@ -123,6 +134,41 @@ class Insdoctors extends Base {
         }
 
         $info = $_GET;
+        $data = $_GET;
+        //预创建医生id
+        $id = UUIDs::uuid16();
+        if(isset($data['id']) && !empty($data['id'])){
+            $id = $data['id'];
+        }
+        unset($info['special_name']);
+        foreach ($data['special_name'] as $v){
+            unset($info['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'=>$info['institution_id'],
+                        'describe'=>'',
+                        'sort'=>$sort+10,
+                        'status'=>1,
+                        'cost'=>0
+                    ];
+                    DB::table('special_contact')->insert($special);
+                }else{
+                    //存在  修改信息
+                    DB::table('special_contact')->where('did',$info['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]);
+                }
+            }
+        }
         unset($info['doctorcla']);
         if(isset($_GET['doctor_role']) && !empty($_GET['doctor_role'])){
             $info['doctor_role'] = implode(',', $_GET['doctor_role']);
@@ -136,7 +182,6 @@ class Insdoctors extends Base {
         }
         if (empty($_GET['id'])) {
             unset($_GET['id']);
-            $id = UUIDs::uuid16();
             $info['id'] = $id;
             $a = DB::table('doctors')->insert($info);
             SysLogs::log("doctors", "C", json_encode($info));

+ 10 - 0
application/manage/view/doctors/edit.html

@@ -135,6 +135,16 @@
                     {/foreach}
                 </td>
             </tr>
+            {foreach name="special" item="s"}
+            <tr>
+                <th height="32" align="right">{$s.name}</th>
+                <input type="hidden" name="special_name[]" value="{$s.id}">
+                <td colspan="3" >
+                    <input name="special_{$s.id}"  type="radio" size="35" value="1" {if !empty($s.sc_status) && $s.sc_status=='1' }checked="check" {/if}/><label  >开启</label>
+                    <input name="special_{$s.id}"  type="radio" size="35" value="0" {if $s.sc_status=='' || $s.sc_status=='0' }checked="check" {/if}/><label  >关闭</label>
+                </td>
+            </tr>
+            {/foreach}
             <tr>
                 <th height="32">&nbsp;</th>
                 <td colspan="3" height="50" >

+ 10 - 0
application/manage/view/insdoctors/edit.html

@@ -147,6 +147,16 @@
                     {/foreach}
                 </td>
             </tr>
+            {foreach name="special" item="s"}
+            <tr>
+                <th height="32" align="right">{$s.name}</th>
+                <input type="hidden" name="special_name[]" value="{$s.id}">
+                <td colspan="3" >
+                    <input name="special_{$s.id}"  type="radio" size="35" value="1" {if !empty($s.sc_status) && $s.sc_status=='1' }checked="check" {/if}/><label  >开启</label>
+                    <input name="special_{$s.id}"  type="radio" size="35" value="0" {if $s.sc_status=='' || $s.sc_status=='0' }checked="check" {/if}/><label  >关闭</label>
+                </td>
+            </tr>
+            {/foreach}
             <tr>
                 <th height="32">&nbsp;</th>
                 <td>