/** * Show the form for creating a new resource. * * @return Response */ public function create($patientid) { $pps = Patientprofile::where('pp_patientid', '=', $patientid)->first(); if (is_null($pps)) { $err_msg = "患者资料不存在!!<br>請先建立患者资料後才能新增出院指导..."; return view('discharge.create', compact('err_msg')); } else { $sex = $pps->pp_sex; $uid = $pps->user_id; $ppname = User::find($pps->user_id)->name; $today = Carbon::today()->toDateString(); $year = Carbon::today()->year; $patientprofiles = Patientprofile::where('pp_patientid', '=', $patientid)->first(); $residencies = User::where('position', '=', '门诊医生')->orderBy('name', 'ASC')->lists('name', 'id'); $residencies = array('' => '请选择') + $residencies; $err_msg = null; EventController::SaveEvent('discharge', 'create(创建)'); return view('discharge.create', compact('err_msg', 'year', 'today', 'patientprofiles', 'sex', 'uid', 'ppname', 'patientid', 'residencies')); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $caselist = Caselist::findOrFail($id); $sex = Patientprofile::where('id', '=', $caselist->pp_id)->first()->pp_sex; // $uid = $caselist->user_id; $ppname = User::find($caselist->user_id)->name; $patientid = User::find($caselist->user_id)->pid; $today = Carbon::today()->toDateString(); $year = Carbon::today()->year; $casetypes = array('' => '请选择', '1' => '初诊', '2' => '复诊', '3' => '年度检查', '4' => '一般'); $doctors = User::where('position', '门诊医生')->orWhere('position', '住院医生')->orderBy('name', 'ASC')->lists('name', 'id'); $doctors = array('' => '请选择') + $doctors; EventController::SaveEvent('caselist', 'edit(编辑)'); return view('case.edit', compact('caselist', 'year', 'today', 'casetypes', 'sex', 'ppname', 'patientid', 'doctors')); }
public function gosoap($pid, $bid) { $pps = Patientprofile::where('pp_patientid', '=', $pid)->first(); if (is_null($pps)) { return Redirect::route("soap"); } else { $ppid = $pps->id; $hns = HospitalNo::where('patient_profile_id', '=', $ppid)->first(); $uuid = $hns->hospital_no_uuid; $buildcase = Buildcase::where('id', '=', $bid)->first(); $buildcase->hospital_no_uuid = $uuid; $buildcase->save(); return Redirect::to("/soap/{$uuid}"); } }
public function page($uuid = null, $end = null) { $users = Auth::user(); if ($uuid == null) { $patient = Patientprofile::where('user_id', '=', $users->id)->first(); if ($patient != null) { $hospital_no = $patient->hospital_no; } else { $err_msg = '请重新登入!'; } if (isset($hospital_no) && $hospital_no != null) { $uuid = $hospital_no->hospital_no_uuid; } else { $err_msg = '没有血糖资料!'; } } else { $hospital_no = null; $hospital_no = HospitalNo::find($uuid); if ($hospital_no != null) { $patient = $hospital_no->patient; // if($hospital_no -> patient_user_id != $users -> id){ // $user_feature = Feature::where('href', '=', '/patient') -> first() -> hasfeatures() -> where('user_id', '=', $users -> id)->first(); // if($user_feature == null){ // $hospital_no = null; // } // } } if ($hospital_no == null) { $err_msg = '您没有权限查看此血糖资料!'; } } if (!isset($hospital_no) || $hospital_no == null) { return view('bdata.error', compact('err_msg')); } if ($end > date('Y-m-d')) { return redirect('/bdata/' . $uuid); } if ($end == null) { $data['next'] = null; $end = date('Y-m-d'); } else { $next = date('Y-m-d', strtotime("1 month", strtotime($end))); if ($end == date('Y-m-d')) { $data['next'] = null; } else { if ($next == date('Y-m-d')) { $data['next'] = "/bdata/" . $uuid; } else { $data['next'] = "/bdata/" . $uuid . "/" . $next; } } } $start = date('Y-m-d', strtotime("-1 month", strtotime($end))); $data['previous'] = "/bdata/" . $uuid . "/" . $start; if ($hospital_no->count() == 0) { $invalid = true; return view('bdata.bdata', compact('invalid')); } $data['displayname'] = $hospital_no->hospital_no_displayname; $data['patient_displayname'] = User::find($hospital_no->patient_user_id)->name; $data['patient_bday'] = $patient->pp_birthday; $data['patient_age'] = $patient->pp_age; $data['patient_id'] = $patient->pp_patientid; $blood_records = $hospital_no->blood_sugar()->where('calendar_date', '<=', $end)->where('calendar_date', '>', $start)->orderBy('calendar_date', 'DESC')->get(); $stat = $this->get_stat($blood_records); $notes = $this->get_notes($blood_records); $blood_records = $this->fillup($blood_records, $start, $end); $data['food_categories'] = FoodCategory::all(); $food_records = $this->get_has_food($uuid); $soap_link = ""; // if(isset($user_feature) && $user_feature != null){ $soap_link = '/soap/' . $uuid; // } $contact_data = $hospital_no->contact_info; if ($contact_data != null) { $duty = Buildcase::where('hospital_no_uuid', '=', $uuid)->orderBy('duty_at', 'desc')->first(); if ($duty == null) { $duty = $hospital_no->nurse_user_id; } else { $duty = $duty->duty; } $contact_data["nurse_name"] = User::find($duty)->name; $contact_data["trace_method"] = $this->convert_trace_method($contact_data["trace_method"]); $contact_data["contact_time"] = $this->convert_contact_time($contact_data["contact_time"]); $contact_data["phone"] = User::find($hospital_no->patient_user_id)->phone; $contact_data["email"] = User::find($hospital_no->patient_user_id)->email; } $goal = $hospital_no->hba1c_goal; $goal_matrix = $hospital_no->hba1c_goal_matrix(); Session::put('uuid', $uuid); return view('bdata.bdata', compact('blood_records', 'data', 'food_categories', 'stat', 'food_records', 'soap_link', 'notes', 'contact_data', 'goal', 'goal_matrix')); }
/** * 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); }