Ejemplo n.º 1
0
 /**
  * Display a listing of Tests. Factors in filter parameters
  * The search string may match: patient_number, patient name, test type name, specimen ID or visit ID
  *
  * @return Response
  */
 public function index()
 {
     $fromRedirect = Session::pull('fromRedirect');
     if ($fromRedirect) {
         $input = Session::get('TESTS_FILTER_INPUT');
     } else {
         $input = Input::except('_token');
     }
     $searchString = isset($input['search']) ? $input['search'] : '';
     $testStatusId = isset($input['test_status']) ? $input['test_status'] : '';
     $dateFrom = isset($input['date_from']) ? $input['date_from'] : '';
     $dateTo = isset($input['date_to']) ? $input['date_to'] : '';
     // Search Conditions
     if ($searchString || $testStatusId || $dateFrom || $dateTo) {
         $testSet = Test::search($searchString, $testStatusId, $dateFrom, $dateTo);
         if (count($tests) == 0) {
             Session::flash('message', trans('messages.empty-search'));
         }
     } else {
         // List all the active tests
         $testSet = Test::orderBy('time_created', 'DESC');
     }
     // Create Test Statuses array. Include a first entry for ALL
     $testStatus = array('all') + TestStatus::all()->lists('name', 'id')->toArray();
     foreach ($testStatus as $key => $value) {
         $testStatus[$key] = trans("messages.{$value}");
     }
     // Pagination
     $testSet = $testSet->paginate(config('blis.page-items'))->appends($input);
     //	Barcode
     $barcode = Barcode::first();
     // Load the view and pass it the tests
     return view('test.index', compact('testSet', 'testStatus', 'barcode'))->withInput($input);
 }