public function doAddTreatmentToAppointment(Request $request)
 {
     if ($request->input('appointment_id') == 0) {
         $patient = Patient::findOrFail($request->input('patient_id'));
         $appointment = $patient->getBaseAppointment();
     } else {
         $appointment = Appointment::findOrFail($request->input('appointment_id'));
     }
     $treatment = Treatment::findOrFail($request->input('treatment_id'));
     $appointment->addTreatment($treatment);
     $new_treatment = $appointment->treatments()->where('treatment_id', $treatment->id)->orderBy('pivot_created_at', 'desc')->first();
     $vars = ["treatment" => $new_treatment, "patient" => $appointment->patient];
     $response = ["html" => view('backend.partials.cot-appointment-treatment-row')->with($vars)->render(), "treatment" => $new_treatment->toArray(), "time_estimate" => $appointment->getEstimatedDuration()];
     header('Content-Type: application/json');
     return json_encode($response);
 }
Example #2
0
 public function getFavouriteChartingTreatments()
 {
     $treatments = new Collection();
     $ids = DB::table('user_favourite_treatments')->select('treatment_id')->where('user_id', $this->id)->orderBy('created_at', 'desc')->get();
     foreach ($ids as $id) {
         if (Treatment::where('id', $id->treatment_id)->count() > 0) {
             $treatment = Treatment::findOrFail($id->treatment_id);
             $treatments->push($treatment);
         }
     }
     return $treatments;
 }