Пример #1
0
 public function addTime(Request $request)
 {
     $user = \App\User::getCurrentUser();
     $busy_time = new \App\Appointment();
     $busy_time->user()->associate($user);
     $busy_time->day = $request->input('day');
     $busy_time->reason = $request->input('reason');
     $busy_time->save();
     return 'Added';
 }
Пример #2
0
 public function getAlerts($request)
 {
     $patient_ids = array();
     $today = Carbon::now();
     $today->hour = 0;
     $today->minute = 0;
     $today->second = 0;
     $tomorrow = $today->copy()->addDay();
     if ($request->session()->get('global_branch') == 'all') {
         foreach (Appointment::whereIn('status_id', [3, 4])->where('start_date', '>', $today)->where('end_date', '<', $tomorrow)->get() as $a) {
             $patient_ids[] = $a->patient_id;
         }
     } else {
         foreach (Appointment::whereIn('status_id', [3, 4])->where('branch_id', $request->session()->get('global_branch'))->where('start_date', '>', $tomorrow)->where('end_date', '<', $today)->get() as $a) {
             $patient_ids[] = $a->patient_id;
         }
     }
     $alerts = new Collection();
     if (count($patient_ids) > 0) {
         foreach ($patient_ids as $id) {
             $patient = Patient::findOrFail($id);
             if ($patient->hasAlert()) {
                 $alerts->push($patient->getAlert());
             }
         }
     }
     view()->share('alerts', $alerts);
 }
Пример #3
0
 public function getAppointments()
 {
     $appointments = Appointment::all();
     $response = ["appointments" => $appointments->toArray()];
     header('Content-type: application/json');
     die(json_encode($response));
 }
 public function makeAppointmentCreate()
 {
     $validator = Validator::make(Input::all(), array('doctor' => 'required_without:department', 'department' => 'required_without:doctor', 'apptDate' => 'already_have_appointment_patient'), array('doctor.required_without' => 'กรุณาเลือกแพทย์หรือแผนกที่ต้องการนัด', 'department.required_without' => 'กรุณาเลือกแพทย์หรือแผนกที่ต้องการนัด', 'apptDate.already_have_appointment_patient' => 'ท่านมีนัดแล้วในช่วงเวลาที่ท่านเลือก'));
     if ($validator->passes()) {
         if (Input::get('doctor') >= 0) {
             $depentOnDr = 1;
             $n = Input::get('doctor');
             $doctors = DB::table('users')->where('type', 'doctor')->get();
             $i = 0;
             foreach ($doctors as $doctor) {
                 if ($i++ == $n) {
                     $doctorEmpID = $doctor->username;
                     break;
                 }
             }
         } else {
             if (Input::get('department') >= 0) {
                 $depentOnDr = 0;
                 $d = Input::get('department');
                 $departmentsList = ['อายุรกรรม', 'ศัลยกรรม', 'ออร์โธปีดิกส์', 'กุมารเวชกรรม', 'สูตินรีเวช', 'ทันตกรรม', 'เวชปฏิบัติ', 'แพทย์เฉพาะทางอื่นๆ'];
                 $department = $departmentsList[$d];
                 $doctorEmpID = DB::table('users')->where('department', $department)->first()->username;
             }
         }
         $addAppointment = new Appointment();
         $addAppointment->HN = Session::get('username');
         $addAppointment->dependOnDr = $depentOnDr;
         $addAppointment->doctorEmpID = $doctorEmpID;
         $str = Input::get('apptDate');
         $cut = strpos($str, " ");
         $len = strlen($str);
         $date = substr($str, 0, $cut);
         $addAppointment->appointmentDate = $date;
         if (strcmp(substr($str, $cut + 1, $len - $cut - 1), "เช้า") == 0) {
             $morning = 0;
         } else {
             $morning = 1;
         }
         $addAppointment->morning = $morning;
         $addAppointment->symptomOrReason = Input::get('cause');
         $addAppointment->save();
         DB::table('ondutySchedule')->where('doctorEmpID', $doctorEmpID)->where('date', $date)->where('morning', $morning)->update(array('appointed' => 1));
         return Redirect::to('patient/makeAppointment')->with('flash_notice', 'ดำเนินการทำนัดสำเร็จ');
     } else {
         return Redirect::to('patient/makeAppointment')->withErrors($validator)->withInput();
     }
 }
Пример #5
0
 public function generateAppointment(User $issuer, Business $business, Contact $contact, Service $service, Carbon $datetime, $comments = null)
 {
     $appointment = new Appointment();
     $appointment->doReserve();
     $appointment->setStartAtAttribute($datetime);
     $appointment->business()->associate($business);
     $appointment->issuer()->associate($issuer);
     $appointment->contact()->associate($contact);
     $appointment->service()->associate($service);
     $appointment->comments = $comments;
     $appointment->doHash();
     return $appointment;
 }
Пример #6
0
 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();
 }
 /**
  * Construct a new AppointmentReminder
  *
  * @param Illuminate\Support\Collection $twilioClient The client to use to query the API
  */
 function __construct()
 {
     $this->appointments = \App\Appointment::appointmentsDue()->get();
     $twilioConfig = config('services.twilio');
     $accountSid = $twilioConfig['twilio_account_sid'];
     $authToken = $twilioConfig['twilio_auth_token'];
     $this->sendingNumber = $twilioConfig['twilio_sending_number'];
     $this->twilioClient = new \Services_Twilio($accountSid, $authToken);
 }
Пример #8
0
 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;
 }
Пример #9
0
 public function updateAppointments()
 {
     $appointments = Appointment::all();
     foreach ($appointments as $appointment) {
         $lead = Lead::where('id', $appointment->lead_id)->first();
         if ($lead) {
             $appointment->agent_id = $lead->agent_crest_id;
             $appointment->save();
         }
     }
 }
Пример #10
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $appointmentId = $this->get('appointment');
     $businessId = $this->get('business');
     $issuer = auth()->user();
     $business = Business::find($businessId);
     $appointment = Appointment::find($appointmentId);
     $authorize = $appointment->issuer->id == $issuer->id || $issuer->isOwner($business);
     # \Log::info("Authorize AlterAppointmentRequest for issuer:{$issuer->id} appointment:$appointmentId business:$businessId authorize:$authorize");
     return $authorize;
 }
 public function update(Request $request, $id)
 {
     $updatedAppointment = $this->appointmentFromRequest($request);
     $existingAppointment = \App\Appointment::find($id);
     $existingAppointment->name = $updatedAppointment->name;
     $existingAppointment->phoneNumber = $updatedAppointment->phoneNumber;
     $existingAppointment->timezoneOffset = $updatedAppointment->timezoneOffset;
     $existingAppointment->when = $updatedAppointment->when;
     $existingAppointment->notificationTime = $updatedAppointment->notificationTime;
     $existingAppointment->save();
     return redirect()->route('appointment.index');
 }
Пример #12
0
 public static function getUserAppointment(User $user)
 {
     if ($user->userable->role == 'Doctor') {
         $appointments = Appointment::getAppointmentDoctor($user->userable->emp_id);
     } else {
         if ($user->userable->role == null) {
             $appointments = Appointment::getAppointmentPatient($user->userable->id);
         } else {
             $appointments = null;
         }
     }
     return $appointments;
 }
Пример #13
0
 /**
  * post Action for booking
  *
  * @param  AlterAppointmentRequest $request
  * @return JSON                    Action result object
  */
 public function postAction(AlterAppointmentRequest $request)
 {
     $this->log->info('BookingController: postAction');
     $issuer = auth()->user();
     $businessId = $request->input('business');
     $appointmentId = $request->input('appointment');
     $action = $request->input('action');
     $widget = $request->input('widget');
     $this->log->info("AJAX postAction.request:[issuer:{$issuer->email}, action:{$action}, business:{$businessId}, appointment:{$appointmentId}]");
     $appointment = Appointment::find($appointmentId);
     switch ($action) {
         case 'annulate':
             $appointment->doAnnulate();
             break;
         case 'confirm':
             $appointment->doConfirm();
             break;
         case 'serve':
             $appointment->doServe();
             break;
         default:
             # Ignore Invalid Action
             $this->log->warning('Invalid Action request');
             break;
     }
     /**
      * Widgets MUST be rendered before being returned on Response
      * as they need to be interpreted as HTML
      *
      */
     switch ($widget) {
         case 'row':
             $html = Widget::AppointmentsTableRow(['appointment' => $appointment, 'user' => auth()->user()])->render();
             break;
         case 'panel':
         default:
             $html = Widget::AppointmentPanel(['appointment' => $appointment, 'user' => auth()->user()])->render();
             break;
     }
     $appointmentPresenter = $appointment->getPresenter();
     // TODO: It is probably possible to move Notifynder to a more proper place
     $date = $appointment->start_at->toDateString();
     $code = $appointmentPresenter->code();
     Notifynder::category('appointment.' . $action)->from('App\\User', auth()->user()->id)->to('App\\Business', $appointment->business->id)->url('http://localhost')->extra(compact('code', 'action', 'date'))->send();
     $this->log->info("postAction.response:[appointment:{$appointment->toJson()}]");
     return response()->json(['code' => 'OK', 'html' => $html]);
 }
 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);
 }
Пример #15
0
 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]);
 }
Пример #16
0
 public function importAppointments()
 {
     if (Input::hasFile('file')) {
         $file = Input::file('file');
         Appointment::truncate();
         Excel::load($file, function ($reader) {
             $reader->setDateFormat('j/n/Y H:i:s');
             $results = $reader->get();
             foreach ($results as $result) {
                 $args = ['user_id' => 2, 'lead_id' => $result->lead_id, 'agent_id' => NULL, 'appointment_confirmed' => $result->confirmed, 'appointment_date' => Carbon::parse($result->appointment_set_date)];
                 Appointment::create($args);
                 $lead = Lead::find($result->lead_id);
                 if ($lead) {
                     $lead->lead_acceptance_type = $result->dta;
                     $lead->save();
                 }
                 var_dump($result);
             }
         });
     }
 }
 public function getLastAppointment($patient_id)
 {
     if (!Patient::isPatient() && !HospitalEmployee::isDoctor() && !HospitalEmployee::isStaff()) {
         return response()->json(["success" => false, "error" => 'notlogin or notvalid']);
     }
     return response()->json(["success" => true, "data" => Appointment::getLastAppointment($patient_id)]);
 }
Пример #18
0
 public function appointments()
 {
     $patients = $this->id;
     $patient = User::where('id', $patients)->first();
     return Appointment::where('patient_id', $patient->id)->get();
 }
Пример #19
0
 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];
 }
Пример #20
0
 public static function getLastAppointment($patient_id)
 {
     return array(Appointment::order('time', 'desc')->where('patient_id', $patient_id)->first());
 }
Пример #21
0
 /**
  * make booking for the user
  */
 public function makeBooking(Request $request)
 {
     //dd($request->get('booking'));
     if (Auth::user()->type != 4) {
         # code...
         return redirect()->back();
     }
     $val = $this->customValidation($request->get('booking'));
     if ($val == 0) {
         # code...
         return redirect()->back()->withErrors("You haven't made a booking.");
     } elseif ($val > 1) {
         return redirect()->back()->withErrors("You can only book one appointment at a time.");
     }
     foreach ($request->get('booking') as $_temp) {
         # code...
         if ($_temp != "none") {
             # code...
             $appointId = $_temp;
         }
     }
     //dd($appointId);
     $appointment = Appointment::findOrFail($appointId);
     if ($appointment->available == 1) {
         # code...
         $booking = Booking::create(['appointment_id' => $appointment->id, 'user_id' => Auth::user()->id]);
         $appointment->update(['available' => 0]);
         return redirect('home/patient');
     }
     return redirect()->back()->withErrors("Error creating the booking");
 }
Пример #22
0
 public function doScheduleAppointment($appointment_id, $date, $start, $end)
 {
     $appointment = Appointment::findOrFail($appointment_id);
     $appointment->schedule($date, $start, $end);
     return redirect()->back();
 }
Пример #23
0
 /**
  * Update appointment status
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function arrange(Request $request, $id)
 {
     $appointment = Appointment::findOrFail($id);
     if ($appointment->mastori->id !== Auth::user()->userable->id) {
         return response('Unauthorised', 401);
     }
     if ($appointment['status'] !== 'pending') {
         return response('Appointment has already been ' . $appointment['status'], 401);
     }
     $data = $request->only('status');
     $validator = Validator::make($data, ['status' => 'required|in:approved,cancelled']);
     if ($validator->fails()) {
         return response(['errors' => $validator->messages()], 400);
     }
     // store
     $appointment->status = $data['status'];
     $appointment->save();
     return $appointment->load('user');
 }
Пример #24
0
 /**
  * is holding given Appointment
  *
  * ToDo: Remove from here as needs knowledge from Appointment
  *
  * @param  Appointment $appointment Appointment to check against
  * @return boolean                  Appointment is held by the Vacancy
  */
 public function isHolding(Appointment $appointment)
 {
     return $appointment->isActive() && $this->start_at <= $appointment->start_at && $this->finish_at >= $appointment->finish_at && $this->service_id == $appointment->service_id && $this->business_id == $appointment->business_id;
 }
Пример #25
0
 public function createAppointment(Request $request)
 {
     $value = $this->getAuthenticatedUser()->getData();
     try {
         $appointment = Appointment::create(['doctorId' => $request->input('doctorId'), 'screeningId' => $request->input('screeningId'), 'requestedBy' => $value->result->id, 'status' => 'pending']);
     } catch (\Exception $e) {
         return response()->json(['error' => ['message' => 'Could not assign doctor', 'code' => 400]], HttpResponse::HTTP_CONFLICT);
     }
     return response()->json(['result' => $appointment]);
 }
Пример #26
0
 public function getSidebar(Request $request)
 {
     $appointment = Appointment::findOrFail($request->input('appointment_id'));
     $vars = array("patient" => $appointment->patient);
     $html = view('backend/partials/patient-sidebar')->with($vars)->render();
     $response = array("status" => "success", "html" => $html);
     return json_encode($response);
 }
Пример #27
0
 public function schedule($date, $start, $end)
 {
     $start_date = Carbon::createFromFormat("d-m-Y", $date);
     $start_time = explode(":", $start);
     $start_date->hour = $start_time[0];
     $start_date->minute = $start_time[1];
     $end_date = Carbon::createFromFormat("d-m-Y", $date);
     $end_time = explode(":", $end);
     $end_date->hour = $end_time[0];
     $end_date->minute = $end_time[1];
     if (Appointment::checkClashingAppointment($this->dentist->id, $start_date, $end_date)) {
         die('An error has occured. This appointment clashes with another. Please try again.');
     }
     $this->start_date = $start_date;
     $this->end_date = $end_date;
     $this->booked = 1;
     Appointment::incrementBookingStats();
     $this->save();
 }
Пример #28
0
 private function getAppointments($expression)
 {
     $this->results['appointments'] = Appointment::whereIn('business_id', $this->scope['businessesIds'])->where('hash', 'like', $expression . '%')->get();
 }
Пример #29
0
 public function createBaseAppointment()
 {
     $date = Carbon::now()->format('d/m/Y');
     $start_hour = Carbon::now()->format('H');
     $start_minute = Carbon::now()->format('i');
     $end_hour = Carbon::now()->addHour()->format('H');
     $end_minute = Carbon::now()->addHour()->format('i');
     $appointment = Appointment::addNew(2, 'Base Treatments', $this->id, $this->dentist_id, $date, $start_hour, $start_minute, $end_hour, $end_minute, 'Automatically created during base charting', '0', '1', '');
     $appointment->base_appointment = 1;
     $appointment->save();
     return $appointment;
 }
Пример #30
0
 public function run()
 {
     DB::table('appointments')->delete();
     Appointment::create(['id' => 1, 'date' => "9/3/2015", 'time' => "8:00-10:00AM", 'location' => "Warrensburg"]);
     Appointment::create(['id' => 2, 'date' => "4/3/2015", 'time' => "9:00-10:00AM", 'location' => "Lee Summit"]);
 }