Esempio n. 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('visits')->delete();
     $visit = new Visit(['docId' => '2001', 'patId' => '4001', 'month' => '12', 'day' => '7', 'hour' => '12']);
     $visit->save();
     $visit = new Visit(['docId' => '2001', 'patId' => '4001', 'month' => '12', 'day' => '7', 'hour' => '14']);
     $visit->save();
     $visit = new Visit(['docId' => '2001', 'patId' => '4001', 'month' => '12', 'day' => '7', 'hour' => '16']);
     $visit->save();
     $visit = new Visit(['docId' => '2002', 'patId' => '4002', 'month' => '12', 'day' => '7', 'hour' => '6']);
     $visit->save();
     $visit = new Visit(['docId' => '2002', 'patId' => '4002', 'month' => '12', 'day' => '7', 'hour' => '10']);
     $visit->save();
     $visit = new Visit(['docId' => '2002', 'patId' => '4002', 'month' => '12', 'day' => '7', 'hour' => '14']);
     $visit->save();
     $visit = new Visit(['docId' => '2003', 'patId' => '4003', 'month' => '12', 'day' => '7', 'hour' => '10']);
     $visit->save();
     $visit = new Visit(['docId' => '2003', 'patId' => '4003', 'month' => '12', 'day' => '7', 'hour' => '11']);
     $visit->save();
     $visit = new Visit(['docId' => '2003', 'patId' => '4003', 'month' => '12', 'day' => '7', 'hour' => '12']);
     $visit->save();
     $visit = new Visit(['docId' => '2004', 'patId' => '4004', 'month' => '12', 'day' => '7', 'hour' => '6']);
     $visit->save();
     $visit = new Visit(['docId' => '2004', 'patId' => '4004', 'month' => '12', 'day' => '7', 'hour' => '9']);
     $visit->save();
     $visit = new Visit(['docId' => '2004', 'patId' => '4004', 'month' => '12', 'day' => '7', 'hour' => '12']);
     $visit->save();
 }
Esempio n. 2
0
 /**
  * Handle an incoming request.
  *
  * @param  Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!$request->ajax()) {
         $visit = new Visit();
         $visit->page = parse_url($request->fullUrl(), PHP_URL_PATH);
         $visit->ip = $request->ip();
         $visit->host = $request->getHost();
         $visit->user_agent = Agent::browser() . ' ' . Agent::version(Agent::browser());
         $visit->save();
     }
     return $next($request);
 }
 public function scopeVacant($query)
 {
     $ids = \App\Visit::lists('bed_id');
     //dd($ids);
     $beds = $query->select(\DB::raw("CONCAT(bed_type,'bed type : ',floor,'th floor ',section,' section ',rate_per_night, 'per night' ) AS full_name, id"))->whereNotIn('id', $ids)->lists('full_name', 'id');
     return $beds;
 }
Esempio n. 4
0
 /**
  * Return a JSON list of visits
  *
  * @return \Illuminate\Http\Response
  */
 public function visits(Request $request, $method)
 {
     $dates = $this->getCarbonDates($request);
     switch (strtolower($method)) {
         case "count":
             //
             $data = [];
             $visits = Visit::where('created_at', '>', $dates['from'])->where('created_at', '<', $dates['to'])->get(['patients', 'stage'])->groupBy('stage');
             $stages = Stage::where('root', '!=', true)->orderBy('order', 'asc')->get(['id', 'name'])->groupBy('id');
             $stages = $stages->keys()->push("__checkout__")->map(function ($stageID) use($stages, $visits) {
                 $data = ["name" => $stageID == "__checkout__" ? "Checked out" : $stages[$stageID][0]['name']];
                 if ($visits->has($stageID)) {
                     $data["visits"] = $visits->get($stageID)->count();
                     $data["patients"] = $visits->get($stageID)->map(function ($visit) {
                         return count($visit->patients);
                     })->sum();
                 } else {
                     $data["visits"] = 0;
                     $data["patients"] = 0;
                 }
                 return $data;
             });
             return response()->json(["stages" => $stages]);
             break;
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $visit = Visit::findOrFail($id);
     $patient = $visit->patient->fullname($visit->doctor->id);
     $doctor = $visit->doctor->fullname($visit->doctor->id);
     if ($visit->bed) {
         $bed = $visit->bed->getBed($visit->bed->id);
     }
     return view('pages.Visit.discharge', compact('visit', 'doctor', 'bed', 'patient'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $bed = Bed::findOrFail($id);
     $vacant = Visit::select('id')->where('bed_id', '>', $id)->exists();
     if ($vacant) {
         $vacant = 'available';
     } else {
         $vacant = 'occupied';
     }
     return view('pages.beds.show', compact('bed', 'vacant'));
 }
Esempio n. 7
0
 public function goToNewUrl(Request $request, $code)
 {
     $url = Rule::where('short_url', $code)->first();
     if (!$url) {
         $view = view('errors.404');
         return response($view, 404);
     }
     $user_agent = parse_user_agent($request->header('user-agent'));
     $rdr = ['ip_address' => $request->getClientIp(), 'referer' => $request->header('referer'), 'browser' => $user_agent['browser'], 'platform' => $user_agent['platform'], 'country' => $request->header('CF-IPCountry'), 'browser_version' => $user_agent['version']];
     Visit::create($rdr);
     return redirect()->to($url->long_url);
 }
Esempio n. 8
0
 /**
  * Fetch visits for specified stage ID
  */
 public function fetch(Stage $stage)
 {
     $response;
     $visits = Visit::where('stage', '=', $stage->id)->get()->keyBy('id')->toArray();
     $rootStageFields = Stage::where('root', true)->first()->inputFields;
     foreach ($visits as $visitID => $visitData) {
         $models = array();
         foreach ($visitData['patients'] as $patientID) {
             $patient = Patient::where('id', $patientID);
             if ($patient->count() > 0) {
                 $models[$patientID] = $patient->first()->toArray();
             }
         }
         $visits[$visitID]['patient_models'] = $models;
     }
     if (count($visits) > 0) {
         $response = ["status" => "success", "message" => "Visits found.", "visits" => $visits];
     } else {
         $response = ["status" => "success", "message" => "No visits are currently at stage " . $stage->name . "."];
     }
     return response()->json($response);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function timecard($id)
 {
     $member = Member::find($id);
     if (NULL == $member) {
         return response()->json("", 404);
     } else {
         $devices = Visit::where('memberID', $id)->select('deviceID')->groupBy('deviceID')->get();
         $times = array();
         foreach ($devices as $did) {
             $total_hrs = 0;
             $visits = Visit::where('memberID', $id)->where('deviceID', $did->deviceID)->select('checkIn', 'checkOut')->get();
             foreach ($visits as $visit) {
                 if ($visit->checkOut != NULL) {
                     $date_time_in = strtotime($visit->checkIn);
                     $date_time_out = strtotime($visit->checkOut);
                     $total_hrs += round(abs($date_time_out - $date_time_in) / 3600, 2);
                 }
             }
             array_push($times, ['checkInDevice' => $did->deviceID, 'totalTime' => $total_hrs, 'visits' => $visits]);
         }
         $member->times = $times;
         return response()->json($member, 200);
     }
 }
Esempio n. 10
0
 private function visitorDiagramInfo(Article $article)
 {
     $chartDatas = Visit::select([DB::raw('DATE(created_at) AS date'), DB::raw('COUNT(id) AS count')])->whereBetween('created_at', [Carbon::now()->subDays(30), Carbon::now()])->where('visitable_id', $article->id)->where('visitable_type', 'App\\Article')->groupBy('date')->orderBy('date', 'ASC')->get();
     $chartDataByDay = [];
     $chartDataByDayShamsi = [];
     foreach ($chartDatas as $data) {
         $chartDataByDay[$data->date] = $data->count;
     }
     $date = new Carbon();
     for ($i = 0; $i < 30; $i++) {
         $dateString = $date->format('Y-m-d');
         if (!isset($chartDataByDay[$dateString])) {
             $chartDataByDay[$dateString] = 0;
         }
         $date->subDay();
     }
     //        foreach($chartDataByDay as $date=>$value){
     //            $chartDataByDayShamsi[jDate::forge($date)->format('date')] = $value;
     //        }
     return $chartDataByDay;
 }
 /**
  * return a small box that is green or red if the shop is open or clsoed
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function isOpenWidget($did)
 {
     $device = CheckInDevice::find($did);
     if (NULL == $device) {
         return response()->json("", 404);
     } else {
         $open = false;
         $actives = Visit::where('deviceID', $did)->where('checkOut', NULL)->select('memberID')->get();
         foreach ($actives as $visit) {
             $member = Member::find($visit->memberID);
             if (NULL != $member) {
                 if (true == $member->hasKeys) {
                     $open = true;
                     break;
                 }
             }
         }
         return response()->view('isOpenWidget', ['isopen' => $open]);
     }
 }
Esempio n. 12
0
 /**
  * Get all visits
  * 
  * @return \Illuminate\Http\JsonResponse
  */
 public function json()
 {
     $visits = Visit::with('content', 'user')->addSelect(DB::raw('visits.*, count(id) as visits'))->groupBy('http_url', 'user_id', 'content_id')->orderBy('created_at', 'desc')->get();
     return response()->json(['data' => $visits]);
 }
Esempio n. 13
0
 /**
  * Handle the event.
  *
  * @param  UserLogin  $event
  * @return void
  */
 public function handle(UserLogin $event)
 {
     Visit::create(['user_id' => $event->user->id, 'client_ip' => $event->request->getClientIp(), 'visited' => new \DateTime()]);
 }
Esempio n. 14
0
 public function getVisitsOfLastWeek()
 {
     $visits = Visit::select(DB::raw("DATE_FORMAT(created_at, '%w') as week"), DB::raw('count(*) as value'))->whereBetween('created_at', [Carbon::parse('last monday')->startOfDay(), Carbon::parse('next sunday')->endOfDay()])->groupBy(DB::raw("DAYOFWEEK((created_at))"))->get()->toArray();
     //dd($visits);
     return Response::json($visits);
 }