public function page($uuid, Request $request)
 {
     $main_classes = MainClass::all();
     $sub_classes = $this->get_sub_class($main_classes->first()->main_class_pk);
     $soa_classes = $this->get_soa_class($sub_classes->first()->sub_class_pk);
     $soa_nurse_classes[0] = SoaNurseClass::where('type', '=', 1)->orderBy('soa_nurse_class_pk')->get();
     $soa_nurse_classes[1] = SoaNurseClass::where('type', '=', 2)->orderBy('soa_nurse_class_pk')->get();
     $hospital_no = HospitalNo::find($uuid);
     $users = Auth::user();
     if ($hospital_no == null) {
         $err_msg = "没有SOAP资料!";
     } else {
         if ($hospital_no->patient_user_id == $users->id) {
             return Redirect::route('bdata');
         }
         //            $user_feature = Feature::where('href', '=', '/patient') -> first() -> hasfeatures() -> where('user_id', '=', $users -> id)->first();
         //            if($user_feature == null){
         //                $hospital_no = null;
         //                $err_msg = "您没有权限查看此资料";
         //            }
         $psn = array("患者");
         if (in_array($users->position, $psn)) {
             $hospital_no = null;
             $err_msg = "您没有权限查看此资料";
         }
     }
     $history_pk = null;
     if ($hospital_no == null) {
         return view('soap.soap', compact('err_msg', 'history_pk'));
     }
     $user_soa_nurse_pks = [];
     $user_soap = null;
     $user_data = array();
     if (isset($request['history'])) {
         $history = UserSoapHistory::find($request['history']);
         if ($history != null) {
             $user_soap = $history;
             $history_pk = $history->user_soap_history_pk;
         }
     }
     if (isset($request['calendar_date'])) {
         $blood_sugar = $hospital_no->blood_sugar()->where('calendar_date', '=', $request['calendar_date'])->first();
         if ($blood_sugar != null) {
             $history = $blood_sugar->history_soap;
             if ($history != null) {
                 $user_soap = $history;
                 $history_pk = $history->user_soap_history_pk;
             }
         }
         Session::put('calendar_date', $request['calendar_date']);
     } else {
         Session::forget('calendar_date');
     }
     $buildcase = Buildcase::where('hospital_no_uuid', '=', $uuid)->orderBy('build_at', 'desc')->first();
     $memo = "";
     $burl = "#";
     if ($buildcase !== null) {
         $memo = $buildcase->memo;
         $burl = "/dm/eedit/" . $buildcase->id;
     }
     if ($user_soap == null || isset($request['new']) && $request['new'] == true) {
         $user_data['S'] = "";
         $user_data['O'] = "";
         $user_data['A'] = "";
         $user_data['P'] = "";
         $user_data['E'] = "";
         $user_data['R'] = "";
         if ($buildcase !== null && $buildcase->soap_status == 0) {
             $user_soa_nurse_pks = $buildcase->soa_nurse_class_pks0 . ',' . $buildcase->soa_nurse_class_pks1;
             $user_soa_nurse_pks = $this->get_user_soa_array($user_soa_nurse_pks, false);
         }
     } else {
         $user_data['S'] = $user_soap->s_text;
         $user_data['O'] = $user_soap->o_text;
         $user_data['A'] = $user_soap->a_text;
         $user_data['P'] = $user_soap->p_text;
         $user_data['E'] = $user_soap->e_text;
         $user_data['R'] = $user_soap->r_text;
         $user_soa_nurse_pks = $this->get_user_soa_array($user_soap->soa_nurse_class_pks, $user_soap->is_finished);
     }
     Session::put('uuid', $uuid);
     return view('soap.soap', compact('main_classes', 'sub_classes', 'soa_classes', 'user_data', 'uuid', 'history_pk', 'soa_nurse_classes', 'user_soa_nurse_pks', 'memo', 'burl'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function eedit($id)
 {
     $buildcase = Buildcase::findOrFail($id);
     $dutys = User::where('position', '=', '院长')->orWhere('position', '=', '副院长')->orWhere('position', '=', '病区主任')->orWhere('position', '=', '门诊医生')->orWhere('position', '=', '住院医生')->orWhere('position', '=', '护理师')->orWhere('position', '=', '营养师')->orWhere('position', '=', '医助')->orderBy('name', 'ASC')->lists('name', 'id');
     $dutys = array('' => '请选择') + $dutys;
     $nurses = User::where('position', '=', '护理师')->orderBy('name', 'ASC')->lists('name', 'id');
     $nurses = array('' => '请选择') + $nurses;
     $soa_nurse_classes[0] = SoaNurseClass::where('type', '=', 1)->orderBy('soa_nurse_class_pk')->get();
     $dietitians = User::where('position', '=', '营养师')->orderBy('name', 'ASC')->lists('name', 'id');
     $dietitians = array('' => '请选择') + $dietitians;
     $soa_nurse_classes[1] = SoaNurseClass::where('type', '=', 2)->orderBy('soa_nurse_class_pk')->get();
     EventController::SaveEvent('buildcases', 'edit(编辑)');
     return view('dm.eedit', compact('buildcase', 'dutys', 'nurses', 'dietitians', 'soa_nurse_classes'));
 }