コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $action = Input::get('action');
     $user_id = Auth::user()->id;
     $test = Input::get('test');
     $organism = Input::get('organism');
     $drug = Input::get('drug');
     $zone = Input::get('zone');
     $interpretation = Input::get('interpretation');
     for ($i = 0; $i < count($test); $i++) {
         $sensitivity = Susceptibility::getDrugSusceptibility($test[$i], $organism[$i], $drug[$i]);
         if (count($sensitivity) > 0) {
             $drugSusceptibility = Susceptibility::find($sensitivity->id);
             $drugSusceptibility->user_id = $user_id;
             $drugSusceptibility->test_id = $test[$i];
             $drugSusceptibility->organism_id = $organism[$i];
             $drugSusceptibility->drug_id = $drug[$i];
             $drugSusceptibility->zone = $zone[$i];
             $drugSusceptibility->interpretation = $interpretation[$i];
             $drugSusceptibility->save();
         } else {
             $drugSusceptibility = new Susceptibility();
             $drugSusceptibility->user_id = $user_id;
             $drugSusceptibility->test_id = $test[$i];
             $drugSusceptibility->organism_id = $organism[$i];
             $drugSusceptibility->drug_id = $drug[$i];
             $drugSusceptibility->zone = $zone[$i];
             $drugSusceptibility->interpretation = $interpretation[$i];
             $drugSusceptibility->save();
         }
     }
     if ($action == "results") {
         $test_id = Input::get('testId');
         $organism_id = Input::get('organismId');
         $susceptibility = Susceptibility::where('test_id', $test_id)->where('organism_id', $organism_id)->where('zone', '!=', 0)->get();
         foreach ($susceptibility as $drugSusceptibility) {
             $drugSusceptibility->drugName = Drug::find($drugSusceptibility->drug_id)->name;
             $drugSusceptibility->pathogen = Organism::find($drugSusceptibility->organism_id)->name;
             if ($drugSusceptibility->interpretation == 'I') {
                 $drugSusceptibility->sensitivity = 'Intermediate';
             } else {
                 if ($drugSusceptibility->interpretation == 'R') {
                     $drugSusceptibility->sensitivity = 'Resistant';
                 } else {
                     if ($drugSusceptibility->interpretation == 'S') {
                         $drugSusceptibility->sensitivity = 'Sestitive';
                     }
                 }
             }
         }
         return json_encode($susceptibility);
     }
 }
コード例 #2
0
 /**
  * Tests the update function in the DrugController
  * @param  void
  * @return void
  */
 public function testUpdate()
 {
     // Update the Drug
     Input::replace($this->drugData);
     $drug = new DrugController();
     $drug->store();
     $drugStored = Drug::orderBy('id', 'desc')->take(1)->get()->toArray();
     Input::replace($this->drugUpdate);
     $drug->update($drugStored[0]['id']);
     $drugSaved = Drug::find($drugStored[0]['id']);
     $this->assertEquals($drugSaved->name, $this->drugUpdate['name']);
     $this->assertEquals($drugSaved->description, $this->drugUpdate['description']);
 }
コード例 #3
0
ファイル: DrugController.php プロジェクト: echiteri/iBLIS
 /**
  * Remove the specified resource from storage (soft delete).
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the drug
     $drug = Drug::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-drug'));
 }