/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create(Request $request) { $a = new schedule(); $a->faculty_id = Auth::user()->id; $a->location = $request->location; $a->available_days = $request->availabledays; $a->available_time = $request->availabletiming; // dd($a); $a->save(); return redirect('availability'); }
public function getDiagStats($year, $month) { $schedules = schedule::diagDateInRange($year, $month)->join('scheduleLog', 'schedule.scheduleLogId', '=', 'scheduleLog.scheduleLogId')->join('doctor', 'scheduleLog.doctorId', '=', 'doctor.userId')->where('doctor.userId', '=', $this->userId)->where('schedule.diagDate', '<', Carbon::now())->orderBy('diagDate')->get(); $i = -1; $lastDate = ''; $results = array(); foreach ($schedules as $s) { $schedule = schedule::where('scheduleId', $s['scheduleId'])->first(); if ($s->diagDate != $lastDate) { $i++; $results[$i]['morning'] = '-'; $results[$i]['afternoon'] = '-'; $results[$i]['sum'] = 0; $results[$i]['date'] = $schedule['diagDate']; $lastDate = $s->diagDate; } $patientNo = $schedule->patientsAmount(); $results[$i][$s->getOriginal('diagTime')] = $patientNo; $results[$i]['sum'] += $patientNo; } $results['sum']['date'] = 'รวม'; $results['sum']['morning'] = 0; $results['sum']['afternoon'] = 0; foreach ($results as $date) { if ($date['morning'] != '-') { $results['sum']['morning'] += $date['morning']; } if ($date['afternoon'] != '-') { $results['sum']['afternoon'] += $date['afternoon']; } } $results['sum']['sum'] = $results['sum']['morning'] + $results['sum']['afternoon']; return $results; }
public function showDiagnosisHistory(Request $request) { $input = $request->all(); $doctor = doctor::where('userId', Auth::user()->userId)->first(); $stats = $doctor->getDiagStats($input['year'] - 543, $input['month']); return view('doctor.showDiagnosisHistory')->with('stats', $stats)->with('year', $input['year'])->with('month', schedule::getMonthName($input['month']))->with('rawYear', $input['year'] - 543)->with('rawMonth', $input['month']); }
public function showDiagnosisHistoryPdf($year, $month) { $doctor = doctor::where('userId', Auth::user()->userId)->first(); $stats = $doctor->getDiagStats($year, $month); $data = ['month' => schedule::getMonthName($month), 'date' => schedule::formatDiagDate(Carbon::now()->format('Y-m-d')), 'doctorName' => $doctor->fullname(), 'department' => $doctor->department()->departmentName, 'diag' => $stats]; $pdf = PDF::loadView('doctor/showDiagnosisHistoryPdf', $data)->setOption('page-size', 'A4'); return $pdf->stream(); }
public function testfunc() { echo '<!DOCTYPE html> <meta charset="utf-8">'; $pp = patient::where('userId', 3)->first(); $app = appointment::where('appointmentId', 1)->first(); $doc = doctor::where('userId', 4)->first(); $schedule = schedule::where('scheduleId', 1)->first(); $dep = department::where('departmentId', 2)->first(); // $doc->getScheduleInRange(2015, 12); $results = $doc->getDiagStats(2015, 12); foreach ($results as $date) { echo $date['date'] . ' ' . $date['morning'] . ' ' . $date['afternoon'] . ' ' . $date['sum'] . '<br>'; } // return view('testSearch')->with('patient', $pp)->with('ap', $app)->with('doctor', $doc)->with('sc', $schedule)->with('idd', $schedule->scheduleId)->with('department', $dep); }
public function createSchedule() { $date = $this->startDate; $morning = scheduleLog::getCheckedArray(substr($this->diagDateList, 0, 7)); $afternoon = scheduleLog::getCheckedArray(substr($this->diagDateList, 7, 7)); while (strtotime($date) <= strtotime($this->endDate)) { $dayOfWeek = date("w", strtotime($date)); if ($morning[$dayOfWeek]) { schedule::storeSchedule($this->scheduleLogId, $date, 'morning'); } if ($afternoon[$dayOfWeek]) { schedule::storeSchedule($this->scheduleLogId, $date, 'afternoon'); } // next date $date = date("Y-m-d", strtotime("+1 day", strtotime($date))); } }
public function appointmentSorted() { // return appointment::where('appointment.patientId', '=', $this->userId) // ->join('schedule', 'appointment.scheduleId', '=', 'schedule.scheduleId') // ->orderBy('schedule.diagDate', 'asc') // ->orderBy('schedule.diagTime', 'asc') // ->get(); return schedule::join('appointment', 'schedule.scheduleId', '=', 'appointment.scheduleId')->where('appointment.patientId', '=', $this->userId)->where('schedule.diagDate', '>', Carbon::now())->orderBy('schedule.diagDate', 'asc')->orderBy('schedule.diagTime', 'asc')->get(); }
public static function newAppointmentByDoctor($input, $doctorId, $patientId) { $newDiagDate = scheduleLog::changeDateFormat($input['nextAppDate']); $schedule = schedule::join('scheduleLog', 'schedule.scheduleLogId', '=', 'scheduleLog.scheduleLogId')->where('scheduleLog.doctorId', $doctorId)->where('schedule.diagDate', $newDiagDate)->where('schedule.diagTime', $input['nextAppTime'])->first(); if ($schedule != null) { $appointment = new appointment(); $appointment->patientId = $patientId; $appointment->scheduleId = $schedule->scheduleId; $appointment->symptom = $input['nextAppDetail']; $appointment->save(); } return $schedule; }
public function viewScheduleByNurse($doctorId) { $dt = schedule::getDateTimeToCalendar($doctorId); return view('nurse.doctorScheduleByNurse')->with('calendar2', $dt); }
public static function getDateTimeToCalendar($userId) { $query = schedule::join('scheduleLog', 'schedule.scheduleLogId', '=', 'scheduleLog.scheduleLogId')->where('scheduleLog.doctorId', $userId)->get(); $arr = []; foreach ($query as $schedule) { $st = "'" . $schedule->getOriginal('diagDate') . '-' . $schedule->getOriginal('diagTime') . "'"; array_push($arr, $st); } $textArr = implode(", ", $arr); $textArr = "[" . $textArr . "]"; return $textArr; }
public function confirmReappointmentByStaffShow(Request $request) { $input = $request->all(); $appointment = appointment::where('appointmentId', $input['appointmentId'])->first(); $schedule = schedule::where('scheduleId', $input['scheduleId'])->first(); return view('staff.confirmReAppointmentByStaff')->with('appointment', $appointment)->with('schedule', $schedule); }