コード例 #1
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', 1)->orderBy('name', 'asc')->get();
     $patient = Patient::find($patientID);
     //Load Test Create View
     return View::make('test.create')->with('testtypes', $testTypes)->with('patient', $patient);
 }
コード例 #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);
     }
 }
コード例 #3
0
ファイル: TestType.php プロジェクト: BaobabHealthTrust/iBLIS
 /**
  * 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;
     }
 }
コード例 #4
0
 /**
  * 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::get('SOURCE_URL');
         return Redirect::to($url)->with('message', trans('messages.failure-test-category-in-use'));
     }
     // redirect
     $url = Session::get('SOURCE_URL');
     return Redirect::to($url)->with('message', trans('messages.success-deleting-test-category'));
 }