예제 #1
0
 /**
  * @return \Illuminate\Routing\Route|null|string
  */
 public function ingnoreId()
 {
     $id = $this->route('measure');
     $measure_type_id = $this->input('measure_type_id');
     $name = $this->input('name');
     return Measure::where(compact('id', 'measure_type_id', 'name'))->exists() ? $id : '';
 }
예제 #2
0
 /**
  * Tests the update funtion in the MeasureController
  * 
  * @return void
  */
 public function testIfUpdateWorks()
 {
     //Save again because teardown() dropped the db :(
     $this->runStore($this->inputNumeric);
     $this->runStore($this->inputAlphanumeric);
     $this->runStore($this->inputAutocomplete);
     $this->runStore($this->inputFreetext);
     $measurestored = Measure::orderBy('id', 'desc')->take(4)->get()->toArray();
     $measureUricAcid = Measure::where('name', 'LIKE', '%uric%')->orderBy('id', 'desc')->first();
     $uricMeasureRanges = array();
     $alphanumericRanges = array();
     $autoCompleteRanges = array();
     foreach ($measureUricAcid->measureRanges as $range) {
         $uricMeasureRanges[] = $range->id;
     }
     foreach (Measure::find($measurestored[2]['id'])->measureRanges as $range) {
         $alphanumericRanges[] = $range->id;
     }
     foreach (Measure::find($measurestored[1]['id'])->measureRanges as $range) {
         $autoCompleteRanges[] = $range->id;
     }
     // Update the Measure Types
     // The second argument is the test type ID
     $this->runUpdate($this->inputNumericUpdate, $measureUricAcid->id, $uricMeasureRanges);
     $this->runUpdate($this->inputAlphanumericUpdate, $measurestored[2]['id'], $alphanumericRanges);
     $this->runUpdate($this->inputAutocompleteUpdate, $measurestored[1]['id'], $autoCompleteRanges);
     $this->runUpdate($this->inputFreetextUpdate, $measurestored[0]['id'], 0);
     $measureupdated = Measure::orderBy('id', 'desc')->take(4)->get()->toArray();
     $measureNewUricAcid = Measure::find($measureUricAcid->id);
     // Check that the measure values for the uric acid measure were updated
     $this->assertEquals($measureNewUricAcid->name, $this->inputNumericUpdate[0]['name']);
     $this->assertEquals($measureNewUricAcid->measure_type_id, $this->inputNumericUpdate[0]['measure_type_id']);
     $this->assertEquals($measureNewUricAcid->unit, $this->inputNumericUpdate[0]['unit']);
     $this->assertEquals($measureNewUricAcid->description, $this->inputNumericUpdate[0]['description']);
     $this->assertEquals($measureupdated[2]['name'], $this->inputAlphanumericUpdate[0]['name']);
     $this->assertEquals($measureupdated[2]['measure_type_id'], $this->inputAlphanumericUpdate[0]['measure_type_id']);
     $this->assertEquals($measureupdated[2]['description'], $this->inputAlphanumericUpdate[0]['description']);
     $this->assertEquals($measureupdated[1]['name'], $this->inputAutocompleteUpdate[0]['name']);
     $this->assertEquals($measureupdated[1]['measure_type_id'], $this->inputAutocompleteUpdate[0]['measure_type_id']);
     $this->assertEquals($measureupdated[1]['description'], $this->inputAutocompleteUpdate[0]['description']);
     $this->assertEquals($measureupdated[0]['name'], $this->inputFreetextUpdate[0]['name']);
     $this->assertEquals($measureupdated[0]['measure_type_id'], $this->inputFreetextUpdate[0]['measure_type_id']);
     $this->assertEquals($measureupdated[0]['description'], $this->inputFreetextUpdate[0]['description']);
     $measurerangeupdated = MeasureRange::orderBy('id', 'desc')->take(6)->get()->toArray();
     $this->assertEquals($measurerangeupdated[5]['age_min'], $this->inputNumericUpdate[0]['agemin'][0]);
     $this->assertEquals($measurerangeupdated[5]['age_max'], $this->inputNumericUpdate[0]['agemax'][0]);
     $this->assertEquals($measurerangeupdated[5]['gender'], $this->inputNumericUpdate[0]['gender'][0]);
     $this->assertEquals($measurerangeupdated[5]['range_lower'], $this->inputNumericUpdate[0]['rangemin'][0]);
     $this->assertEquals($measurerangeupdated[5]['range_upper'], $this->inputNumericUpdate[0]['rangemax'][0]);
     $this->assertEquals($measurerangeupdated[4]['age_min'], $this->inputNumericUpdate[0]['agemin'][1]);
     $this->assertEquals($measurerangeupdated[4]['age_max'], $this->inputNumericUpdate[0]['agemax'][1]);
     $this->assertEquals($measurerangeupdated[4]['gender'], $this->inputNumericUpdate[0]['gender'][1]);
     $this->assertEquals($measurerangeupdated[4]['range_lower'], $this->inputNumericUpdate[0]['rangemin'][1]);
     $this->assertEquals($measurerangeupdated[4]['range_upper'], $this->inputNumericUpdate[0]['rangemax'][1]);
     $this->assertEquals($measurerangeupdated[3]['alphanumeric'], $this->inputAlphanumericUpdate[0]['val'][0]);
     $this->assertEquals($measurerangeupdated[2]['alphanumeric'], $this->inputAlphanumericUpdate[0]['val'][1]);
     $this->assertEquals($measurerangeupdated[1]['alphanumeric'], $this->inputAutocompleteUpdate[0]['val'][0]);
     $this->assertEquals($measurerangeupdated[0]['alphanumeric'], $this->inputAutocompleteUpdate[0]['val'][1]);
 }
예제 #3
0
파일: Measure.php 프로젝트: echiteri/iBLIS
 /**
  * Given the measure name we return the measure ID
  *
  * @param $measureName the name of the measure
  */
 public static function getMeasureIdByName($measureName)
 {
     try {
         $measure = Measure::where('name', 'like', $measureName)->firstOrFail();
         return $measure->id;
     } catch (ModelNotFoundException $e) {
         Log::error("The measure ` {$measureName} ` does not exist:  " . $e->getMessage());
         //TODO: send email?
         return null;
     }
 }
예제 #4
0
파일: TestType.php 프로젝트: echiteri/iBLIS
 /**
  * Get cd4 counts based on either baseline/follow-up and <500/>500
  *
  * @return counts
  */
 public function cd4($from = null, $to = null, $range, $comment)
 {
     $tests = array();
     $measureIds = Measure::where('name', 'CD4')->lists('id');
     $toPlusOne = date_add(new DateTime($to), date_interval_create_from_date_string('1 day'));
     $tests = $this->tests()->whereBetween('time_created', [$from, $toPlusOne])->lists('id');
     $results = TestResult::whereIn('test_id', $tests)->whereIn('measure_id', $measureIds)->where('result', $comment)->lists('test_id')->toArray();
     $qualifier = TestResult::whereIn('test_id', $tests)->whereIn('measure_id', $measureIds)->whereRaw("result REGEXP '^[0-9]+\$'");
     if ($range == '< 500') {
         $qualifier = $qualifier->where('result', '<', 500);
     } else {
         if ($range == '> 500') {
             $qualifier = $qualifier->where('result', '>', 500);
         }
     }
     $qualifier = $qualifier->lists('test_id')->toArray();
     return count(array_intersect(array_unique($qualifier), array_unique($results)));
 }