public function editTime(Request $request) { $current_id = \Auth::user()->id; $busy_time = Appointment::where('user_id', '=', $current_id)->where('day', '=', $request->input('day'))->first(); $busy_time->day = $request->input('day'); $busy_time->reason = $request->input('reason'); $busy_time->save(); }
public function testDestroyAppointment() { Session::start(); $newAppointment = new \App\Appointment(); $newAppointment->name = 'Martin Fowler'; $newAppointment->phoneNumber = '6692216251'; $newAppointment->when = '2015-07-24T18:00:00.000Z'; $newAppointment->notificationTime = '2015-07-24T17:45:00.000Z'; $newAppointment->timezoneOffset = '300'; $newAppointment->save(); $idToDelete = $newAppointment->id; $appointments = \App\Appointment::where(['name' => 'Martin Fowler'])->get(); $this->assertCount(1, $appointments); $this->call('DELETE', '/appointment/' . $idToDelete, ['_token' => csrf_token()]); $appointments = \App\Appointment::where(['name' => 'Martin Fowler'])->get(); $this->assertCount(0, $appointments); }
public function getDoctorAppointment($doctor_id) { if (!HospitalEmployee::isDoctor()) { return response()->json(["success" => false, "messages" => ['notlogin or notvalid']]); } $appointments = Appointment::where('emp_id', $doctor_id)->get(); $appointments_array = []; foreach ($appointments as $appointment) { $tmp = $appointment->toArray(); $patient = $appointment->patient; $tmp['patient'] = $patient->toArray(); $patientReport = $patient->latestPatientReport(); $tmp['patient']['patientReport'] = $patientReport; $tmp['patient']['symptomReports'] = $patient->symptomReports; $tmp['patient']['drugRecords'] = $patient->drugRecords; $appointments_array[] = $tmp; } return response()->json(['success' => true, 'data' => $appointments_array]); }
public function scheduledAppointments() { $appointments = new Collection(); $now = Carbon::now(); foreach (Appointment::where('patient_id', $this->id)->where('booked', 1)->where('start_date', '>', $now->format('Y-m-d H:i:s'))->get() as $a) { $appointments->push($a); } return $appointments; }
public function moveDownCoT() { $max = $this->treatmentPlan->appointments->last()->treatment_plan_order; if ($this->treatment_plan_order < $max) { $next = Appointment::where('treatment_plan_id', $this->treatment_plan_id)->where('treatment_plan_order', $this->treatment_plan_order + 1)->first(); $next->treatment_plan_order = $this->treatment_plan_order; $next->save(); $this->treatment_plan_order = $this->treatment_plan_order + 1; $this->save(); } }
public static function deleteAppointment($appointment_id) { //$appointment_id = $appointment->input('appointment_id'); if ($appointment_id == null) { return ["success" => false, "message" => 'appointment_id_not_found']; } if (Appointment::where('appointment_id', $appointment_id)->first()) { Appointment::where('appointment_id', $appointment_id)->delete(); return ["success" => true]; } else { return ["success" => false, "message" => 'this_appointment_does_not_exist_in_database']; } }
public function doFindNextSlot(Request $request, $override_start_date = 0, $override_duration = 0, $override_appointment_type = 0, $override_redirect = 0) { if ($override_start_date) { $start_date = Carbon::createFromFormat('d/m/Y', $override_start_date); } else { $start_date = Carbon::createFromFormat('d/m/Y', $request->input('start_date')); } if ($override_duration) { $duration = $override_duration; } else { $duration = $request->input('minutes'); } if ($override_appointment_type) { $appointment_type = $override_appointment_type; } else { $appointment_type = $request->input('appointment_type'); } $dentist_id = $request->input('dentist'); $found_slot = false; for ($i = 8; $i < 19; $i++) { if ($i < 10) { $times[] = "0" . $i . ":00"; $times[] = "0" . $i . ":05"; $times[] = "0" . $i . ":10"; $times[] = "0" . $i . ":15"; $times[] = "0" . $i . ":20"; $times[] = "0" . $i . ":25"; $times[] = "0" . $i . ":30"; $times[] = "0" . $i . ":35"; $times[] = "0" . $i . ":40"; $times[] = "0" . $i . ":45"; $times[] = "0" . $i . ":50"; $times[] = "0" . $i . ":55"; } else { $times[] = $i . ":00"; $times[] = $i . ":05"; $times[] = $i . ":10"; $times[] = $i . ":15"; $times[] = $i . ":20"; $times[] = $i . ":25"; $times[] = $i . ":30"; $times[] = $i . ":35"; $times[] = $i . ":40"; $times[] = $i . ":45"; $times[] = $i . ":50"; $times[] = $i . ":55"; } if ($i == 18) { $times[] = "19:00"; } } $today = $start_date->copy(); \DB::enableQueryLog(); $slot_start = 'beep'; $slots_found = 0; $slots = array(); $leave_clear = 0; while ($slots_found < 12) { $today_with_timeslot = $today->copy(); foreach ($times as $time) { if ($leave_clear == 0) { $time_exploded = explode(":", $time); $today_with_timeslot->hour = $time_exploded[0]; $today_with_timeslot->minute = $time_exploded[1]; $today_with_timeslot->second = 0; $end_of_slot = $today_with_timeslot->copy()->addMinutes($duration); $end_of_slot->second = 59; if (Appointment::where('dentist_id', $dentist_id)->where(function ($query) use($today_with_timeslot, $end_of_slot) { $query->whereBetween('start_date', array($today_with_timeslot->format('Y-m-d H:i:s'), $end_of_slot->format('Y-m-d H:i:s')))->orWhereBetween('end_date', array($today_with_timeslot->format('Y-m-d H:i:s'), $end_of_slot->format('Y-m-d H:i:s'))); })->count() == 0 && ($end_of_slot->hour < 19 || $end_of_slot->hour == 19 && $end_of_slot->minute == 19)) { $slot_is_good = true; $interval_start = $today_with_timeslot->copy(); $interval_end = $end_of_slot->copy(); $duration = $interval_start->diffInMinutes($interval_end); while ($interval_start->format('H:i') != $interval_end->format('H:i')) { if (CalendarRestriction::where('day', $today_with_timeslot->format('l'))->where('appointment_type_id', '!=', 0)->where('time', $interval_start->format('H:i'))->where('appointment_type_id', '!=', $appointment_type)->count() > 0) { $slot_is_good = false; break; } $interval_start = $interval_start->copy()->addMinutes(5); } if ($slot_is_good) { $slots[$slots_found]['start'] = $today_with_timeslot->copy()->format('H:i'); $slots[$slots_found]['end'] = $end_of_slot->copy()->format('H:i'); $slots[$slots_found]['date'] = $today->copy()->format('d-m-Y'); $slots[$slots_found]['dentist_id'] = $dentist_id; $slots_found++; $leave_clear = $duration / 5 - 1; if ($slots_found == 12) { break; break; } } } } else { $leave_clear--; } } $today = $today->copy()->addDay(); } $request->session()->put('find_slot_trigger_open', true); $request->session()->put('slots', $slots); // $request->session()->put('selected_calendar_day', $slot_date->format('Y-m-d H:i:s')); // $request->session()->put('selected_calendar_layout', 'week'); // $request->session()->put('single_filtered_dentist', $dentist_id); // $request->session()->put('prefilled_start_time', $slot_start->format('H:i')); // $request->session()->put('prefilled_end_time', $slot_end->format('H:i')); // $request->session()->put('prefilled_date', $slot_end->format('d/m/Y')); if (!$override_redirect) { return redirect('dashboard'); } }
/** * get available bookings */ public function getAvailableBookings() { return Appointment::where('available', 1)->orderBy('appoint_date', 'asc')->orderBy('appoint_time', 'asc')->get(); }
public function appointments() { $patients = $this->id; $patient = User::where('id', $patients)->first(); return Appointment::where('patient_id', $patient->id)->get(); }
public static function refreshDoctorTime($doctor_id) { $appointments = Appointment::where('emp_id', $doctor_id)->get(); $doctorTimes = DoctorTime::where('doctor_id', $doctor_id)->get(); foreach ($appointments as $appointment) { $aptime = new DateTime($appointment->time); $del = true; foreach ($doctorTimes as $doctorTime) { $begin = new DateTime($doctorTime->doctorTime_begin); $end = new DateTime($doctorTime->doctorTime_end); if ($aptime >= $begin && $aptime < $end) { $del = false; } } if ($del) { // find a new appointment Appointment::createNextAppointment($doctor_id, $appointment); // delete the old one Appointment::deleteAppointment($appointment->appointment_id); } } $docTime = DoctorTime::orderBy('doctorTime_begin', 'asc')->where('doctor_id', $doctor_id)->get(); return ["success" => true, "new doctorTime" => $docTime]; }