Example #1
0
 /**
  * @return \Illuminate\Routing\Route|null|string
  */
 public function ingnoreId()
 {
     $id = $this->route('testtype');
     $name = $this->input('name');
     $test_category_id = $this->input('test_category_id');
     return TestType::where(compact('id', 'name', 'test_category_id'))->exists() ? $id : '';
 }
Example #2
0
 /**
  * Set compatible specimen types
  *
  * @return void
  */
 public function setTestTypes($testTypes)
 {
     $testTypesAdded = array();
     if (is_array($testTypes)) {
         foreach ($testTypes as $name) {
             try {
                 $testTypesAdded[] = TestType::where('name', '=', $name)->first()->id;
             } catch (\Exception $e) {
                 Log::error($e);
             }
         }
     }
     if (count($testTypesAdded) > 0) {
         // Delete existing instrument test_type mappings
         $this->testTypes()->detach();
         // Add the new mapping
         $this->testTypes()->attach($testTypesAdded);
     }
 }
 /**
  * Remove the specified resource from storage (soft delete).
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the test category
     $testcategory = TestCategory::find($id);
     $testCategoryInUse = TestType::where('test_category_id', '=', $id)->first();
     if (empty($testCategoryInUse)) {
         // The test category is not in use
         $testcategory->delete();
     } else {
         // The test category is in use
         $url = session('SOURCE_URL');
         return redirect()->to($url)->with('message', trans('messages.failure-test-category-in-use'));
     }
     // redirect
     $url = session('SOURCE_URL');
     return redirect()->to($url)->with('message', trans_choice('messages.record-successfully-deleted', 1));
 }
Example #4
0
 /**
  * Display a form for creating a new Test.
  *
  * @return Response
  */
 public function create($patientID = 0)
 {
     if ($patientID == 0) {
         $patientID = Input::get('patient_id');
     }
     $testtypes = TestType::where('orderable_test')->orderBy('name', 'asc')->get();
     $patient = Patient::find($patientID);
     //Load Test Create View
     return view('test.create', compact('testtypes', 'patient'));
 }
Example #5
0
 /**
  * Given the test name we return the test type ID
  *
  * @param $testname the name of the test
  */
 public static function getTestTypeIdByTestName($testName)
 {
     try {
         $testName = trim($testName);
         $testTypeId = TestType::where('name', 'like', $testName)->orderBy('name')->firstOrFail();
         return $testTypeId->id;
     } catch (ModelNotFoundException $e) {
         \Log::error("The test type ` {$testName} ` does not exist:  " . $e->getMessage());
         //TODO: send email?
         return null;
     }
 }