예제 #1
0
 public static function listAppointments($doctor_id)
 {
     #return Response::json($citas);
     if (Input::get('date') == '') {
         $date = date('Y-m-d');
     } else {
         $date = Input::get('date');
     }
     $datos = DB::table('appointments')->Join('agendas', 'agendas.id', '=', 'appointments.agenda_id')->Join('business_clinics', 'business_clinics.agenda_id', '=', 'agendas.id')->Join('doctors', 'doctors.id', '=', 'business_clinics.doctor_id')->Join('patients', 'patients.id', '=', 'appointments.patient_id')->Join('users', 'users.id', '=', 'patients.user_id')->Join('profiles', 'profiles.user_id', '=', 'users.id')->Join('addresses', 'addresses.id', '=', 'profiles.address_id')->where('appointments.day', '=', $date)->where('doctors.id', '=', $doctor_id)->select('patients.id as patient_id', DB::raw('CONCAT(first_name," ",last_name) as patient_name'), 'addresses.my_address as address', 'appointments.id as appointments_id', 'appointments.day as date', 'doctors.id as doctor_id', 'appointments.reason as reason', 'appointments.state as state_appointment', 'appointments.start_date as hour_appointment', 'appointments.end_date as hour_stimate', 'appointments.last_date_update as last_update')->get();
     $array = array();
     foreach ($datos as $d) {
         $array[] = array('patient_id' => $d->patient_id, 'patient_name' => $d->patient_name, 'appointments_id' => $d->appointments_id, 'reason' => $d->reason, 'date' => $d->date, 'doctor_id' => $d->doctor_id, 'state_appointment' => $d->state_appointment, 'hour_appointment' => Helpers::cupHours($d->hour_appointment), 'hour_stimate' => Helpers::cupHours($d->hour_stimate), 'last_update' => Helpers::cupHours($d->last_update));
     }
     return Response::json($array);
 }