public static function addNew($data) { $treatment_plan = new TreatmentPlan(); $treatment_plan->patient_id = $data['patient_id']; $treatment_plan->save(); $appointment = Appointment::addNew(2, 'CoT #' . $treatment_plan->id, $treatment_plan->patient_id, $treatment_plan->patient->dentist_id, '', '', '', '', '', '', $treatment_plan->id, '0', '1'); $patient = Patient::findOrFail($data['patient_id']); $patient->addHistoryItem("Course of Treatment Added", "A Course of Treatment has been added for this patient", Auth::user()->id, 19); return $treatment_plan; }
public function getPatientChart($id, $cot_id = 0) { $patient = Patient::findOrFail($id); $patient->checkTeethData(); $treatment_plans = TreatmentPlanRepository::forPatient($patient); if ($treatment_plans->count() == 0) { $treatment_plans->push($patient->createTreatmentPlan()); } if ($cot_id) { $active_treatment_plan = TreatmentPlan::find($cot_id); } else { $active_treatment_plan = $treatment_plans->first(); } if (!is_object($active_treatment_plan)) { return redirect()->to(url('patient/' . $patient->id . '/chart')); } $treatments = Treatment::all(); $recent_treatments = Auth::user()->getRecentChartingTreatments(); $favourite_treatments = Auth::user()->getFavouriteChartingTreatments(); $templates = TreatmentTemplate::all(); $charting_images = $patient->getChartingImages(); $base_treatments = []; foreach ($patient->appointments as $appointment) { foreach ($appointment->treatments()->wherePivot('completed', 1)->get() as $treatment) { $base_treatments[] = $treatment; } } view()->share('show_patient_nav', true); $vars = array('current_nav' => 3, 'patient' => $patient, 'treatments' => $treatments, 'recent_treatments' => $recent_treatments, 'favourite_treatments' => $favourite_treatments, 'templates' => $templates, 'treatment_plans' => $treatment_plans, 'active_treatment_plan' => $active_treatment_plan, 'base_treatments' => $base_treatments, 'charting_images' => $charting_images); return view('backend.page.patient-chart')->with($vars); }
public function createTreatmentPlan() { return TreatmentPlan::addNew(['patient_id' => $this->id]); }
public function doDeleteCoT($id) { $treatment_plan = TreatmentPlan::findOrFail($id); $treatment_plan->remove(); return redirect()->back(); }
public function doAddCoTAppointment(Request $request) { $treatment_plan = TreatmentPlan::findOrFail($request->cot_id); $appointment = Appointment::addNew(2, 'CoT #' . $treatment_plan->id, $treatment_plan->patient_id, $treatment_plan->patient->dentist_id, '', '', '', '', '', '', $treatment_plan->id, '0', $treatment_plan->appointments->count() + 1); $vars = ["appointment" => $appointment, "last_appointment" => true, "first_appointment" => false]; $response = ["appointment" => $appointment, "html" => view('backend.partials.cot-appointment-row')->with($vars)->render()]; header('Content-Type: application/json'); return json_encode($response); }
public static function forPatient(Patient $patient) { return TreatmentPlan::where('patient_id', $patient->id)->orderBy('created_at', 'desc')->get(); }