/**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $casecare = Caselist::find($id);
     $casecare->delete();
     $msg = '方案资料成功删除。';
     EventController::SaveEvent('caselist', 'destroy(删除)');
     return redirect()->back()->with('message', $msg);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $casecare = Discharge::find($id);
     $casecare->delete();
     $msg = '出院指导删除成功。';
     EventController::SaveEvent('discharge', 'destroy(删除)');
     return redirect()->back()->with('message', $msg);
 }
 public function upload_user(Request $request)
 {
     $this->validate($request, User::rules1());
     $user = User::where('id', $request->user_id)->first();
     $user->account = $request->account;
     $user->name = $request->name;
     $user->password = Hash::make($request->password);
     $user->pid = $request->pid;
     $user->departmentno = $request->departmentno;
     $user->department = $request->department;
     $user->positionno = $request->positionno;
     $user->position = $request->position;
     $user->phone = $request->phone;
     $user->email = $request->email;
     $user->save();
     session()->flash('message', '人员更新成功');
     EventController::SaveEvent('users', 'update(更新)');
     return Redirect::back();
 }
 public function uupdate(Request $request)
 {
     $this->validate($request, ['personid' => 'required|alpha_num']);
     $buildcase = Buildcase::where('id', $request->id)->first();
     $buildcase->personid = $request->personid;
     $buildcase->cardid = $request->cardid;
     $today = Carbon::now();
     $today->toDateTimeString();
     $buildcase->memo = $request->memo;
     if ($request->duty) {
         $buildcase->duty = $request->duty;
         $buildcase->duty_at = $today;
     }
     if ($request->nurse) {
         $buildcase->nurse = $request->nurse;
         $soa_nurse_class_pks0 = Input::get('soa_nurse_class_pks0', true);
         if (is_array($soa_nurse_class_pks0)) {
             $pks0 = implode(",", $soa_nurse_class_pks0);
         } else {
             $pks0 = array();
         }
         $buildcase->soa_nurse_class_pks0 = $pks0;
         $buildcase->nurse_at = $today;
     }
     if ($request->dietitian) {
         $buildcase->dietitian = $request->dietitian;
         $soa_nurse_class_pks1 = Input::get('soa_nurse_class_pks1', true);
         if (is_array($soa_nurse_class_pks1)) {
             $pks1 = implode(",", $soa_nurse_class_pks1);
         } else {
             $pks1 = array();
         }
         $buildcase->soa_nurse_class_pks1 = $pks1;
         $buildcase->dietitian_at = $today;
     }
     $buildcase->soap_status = 0;
     $buildcase->save();
     session()->flash('message', "建案修改成功");
     EventController::SaveEvent('buildcases', 'update(更新)');
     return Redirect::route('dm_home');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     DB::beginTransaction();
     try {
         DB::statement('SET FOREIGN_KEY_CHECKS = 0');
         $casecare = CaseCare::where('patientprofile1_id', '=', $id)->first();
         if ($casecare) {
             $casecare->delete();
             $patientprofile = Patientprofile::find($id);
             if ($patientprofile) {
                 $this->cleanUpHospital($patientprofile->hospital_no);
                 //                    $hasfeature = Hasfeature::where('user_id', '=', $patientprofile->user_id) -> first();
                 //                    if($hasfeature != null){
                 //                        $hasfeature -> delete();
                 //                    }
                 $patientprofile->delete();
                 $user = User::find($patientprofile->user_id);
                 if ($user) {
                     $user->delete();
                     $msg = '患者资料成功删除。';
                 } else {
                     $msg = '使用者删除失败。';
                 }
             } else {
                 $msg = '患者资料删除失败。';
             }
         } else {
             $msg = '患者资料删除失败。';
         }
         DB::commit();
         DB::statement('SET FOREIGN_KEY_CHECKS = 1');
         EventController::SaveEvent('patientprofile', 'destroy(删除)');
     } catch (\Exception $e) {
         $msg = '资料删除失败。';
         DB::rollback();
     }
     return redirect()->back()->with('message', $msg);
 }