Пример #1
0
 function &run(&$suite, $listener)
 {
     $result = new TestResult();
     $result->addListener($listener);
     $suite->run($result);
     return $result;
 }
 protected function get_test_fail(TestResult $result)
 {
     $exception = $result->get_exception();
     $output = "<li class='fail'>\n<span class='fail'>" . self::FAIL . "</span>\n";
     $output .= "<span class='test_name'>{$result->get_name()} line {$result->get_error_line()}</span>\n";
     $output .= "<pre class='message'>{$exception->getMessage()}</pre>\n";
     $output .= "<pre class='stack_trace'>{$exception->getTraceAsString()}</pre>\n</li>\n";
     return $output;
 }
 public function getPreviousResult($sessionId)
 {
     $qa_generic = sfConfig::get("app_table_qa_generic");
     $tableName = Doctrine_Core::getTable("TableName")->findOneByName("test_result");
     $query = Doctrine_Manager::getInstance()->getCurrentConnection();
     $result = $query->execute("\n\t\t\tSELECT * FROM " . $qa_generic . ".test_result tr\n\t\t\t\tJOIN " . $qa_generic . ".complementary_tool_relation ctr ON ctr.table_entry_id = tr.id\n\t\t\tWHERE ctr.table_name_id = " . $tableName->getId() . "\n\t\t\t\tAND tr.test_session_id = " . $sessionId . "\n\t\t\t\tAND tr.name = '" . $this->getName() . "'\n\t\t");
     $array = $result->fetchAll();
     if (count($array) > 0) {
         $testResult = new TestResult();
         $testResult->fromArray($array[0]);
         return $testResult;
     }
     return null;
 }
Пример #4
0
 private function reflectedXss()
 {
     $result = new TestResult();
     $result->setName("reflectedXss");
     $message = "message";
     $this->session->open($this->url . "<script>alert('" . $message . "')</script>");
     $p = $this->session->switch_to_alert();
     if ($p != null && $p->text === $message) {
         $result->setResult(false);
         //fail
     } else {
         $result->setResult(true);
         //pass
     }
     return $result;
 }
Пример #5
0
 private function reflectedXssAjax()
 {
     $result = new TestResult();
     $result->setName("reflectedXssAjax");
     $message = "message";
     $this->webdriver->get($this->url . "feed.gtl?uid=<script>alert('" . $message . "')</script>");
     $p = $this->webdriver->switchTo()->alert()->getText();
     if ($p != null && $p === $message) {
         $result->setResult(false);
         //fail
     } else {
         $result->setResult(true);
         //pass
     }
     return $result;
 }
Пример #6
0
 /**
  * @param int $resultId
  * @return TestResult[]|\Generator
  */
 public function getAllTestsBefore($resultId)
 {
     if ($resultId >= count($this->results)) {
         throw new \InvalidArgumentException("Requested more tests then were run!");
     }
     for ($i = 0; $i < $resultId; $i++) {
         (yield TestResult::fromArray($this->results[$i]));
     }
 }
 protected function print_test_fail(TestResult $result)
 {
     $case_name = $result->get_testcase();
     $running_time = $this->format_time($result->get_running_time());
     $exception = $result->get_exception();
     $line = $result->get_error_line();
     echo "\n[" . self::RED_TEXT . self::FAIL . self::WHITE_TEXT . "] [{$running_time} ms] [{$case_name}] " . self::RED_TEXT . "{$result->get_name()}" . self::WHITE_TEXT . " line {$result->get_error_line()}\n\n";
     echo $exception->getMessage() . "\n";
     echo $exception->getTraceAsString() . "\n\n";
 }
 function test_belongs_to_with_preloaded_data()
 {
     setup_sqlite_test_db();
     preload_sqlite_data();
     $result1 = TestResult::find(1);
     $test = $result1->test;
     $this->assertEqual($test->dummy, "Test1");
     $result2 = TestResult::find(2);
     $test = $result2->test;
     $this->assertEqual($test->dummy, "Test2");
     $result3 = TestResult::find(3);
     $test = $result3->test;
     $this->assertEqual($test->dummy, "Test2");
 }
Пример #9
0
 /**
  * Import CSV file
  *
  * @param report_file_path The file path to import.
  * @param test_session_id The session's id.
  */
 public static function import_csv($report_file_path, $test_session_id, $conn, $merge_flag)
 {
     $qa_generic = sfConfig::get("app_table_qa_generic");
     // Retrieve table_name_id from table_name table
     $table_name_test_result = Doctrine_Core::getTable("TableName")->findOneByName("test_result");
     $table_name_test_result_id = $table_name_test_result->getId();
     $test_result_exists_flag = false;
     // Open the file
     $csv_report_file = @fopen($report_file_path, 'r');
     if ($csv_report_file) {
         // Get file first line
         $first_line = fgets($csv_report_file);
         // Detect delimiter
         if (preg_match("#,#", $first_line)) {
             $delimiter = ',';
         } else {
             if (preg_match("#;#", $first_line)) {
                 $delimiter = ';';
             } else {
                 return 2001;
             }
         }
         // Detect structure type
         // CSV old
         if (preg_match("#(?=.*Feature)(?=.*Check ?points)(?=.*Notes ?\\(bugs\\))(?=.*Status)#i", $first_line)) {
             // Return at the beginning of file
             fseek($csv_report_file, 0);
             // Determine order between different fields on the first line
             $idx = 0;
             $ref_tab = array();
             foreach (fgetcsv($csv_report_file, 0, $delimiter) as $element) {
                 if (preg_match("#^ ?Feature.?\$#i", $element)) {
                     $ref_tab[0] = $idx;
                 } elseif (preg_match("#^ ?Check ?points.?\$#i", $element)) {
                     $ref_tab[1] = $idx;
                 } elseif (preg_match("#^ ?Notes ?\\(bugs\\).?\$#i", $element)) {
                     $ref_tab[2] = $idx;
                 } elseif (preg_match("#^ ?Status.?\$#i", $element)) {
                     $ref_tab[3] = $idx;
                 } elseif (preg_match("#^ ?Duration.?\$#i", $element)) {
                     $ref_tab[4] = $idx;
                 } elseif (preg_match("#^ ?Bug.?\$#i", $element)) {
                     $ref_tab[5] = $idx;
                 }
                 $idx++;
             }
             // Go through file and fill datas
             $data_tab = array();
             while ($data_tab = fgetcsv($csv_report_file, 0, $delimiter)) {
                 if (count($data_tab) > 3) {
                     // Check if feature is not empty
                     if (empty($data_tab[$ref_tab[0]])) {
                         return 2101;
                     } else {
                         $feature = $data_tab[$ref_tab[0]];
                     }
                     // Check if check points is not empty
                     if (empty($data_tab[$ref_tab[1]])) {
                         return 2102;
                     } else {
                         $case_id = $data_tab[$ref_tab[1]];
                     }
                     // Check if status is not empty
                     if (empty($data_tab[$ref_tab[3]])) {
                         return 2103;
                     } else {
                         $status = $data_tab[$ref_tab[3]];
                     }
                     // Check if execution time is not empty
                     if (!empty($data_tab[$ref_tab[4]])) {
                         $executionTime = $data_tab[$ref_tab[4]];
                     } else {
                         $executionTime = 0;
                     }
                     // Check if bug list is not empty
                     if (!empty($data_tab[$ref_tab[5]])) {
                         $bugs = $data_tab[$ref_tab[5]];
                     } else {
                         $bugs = "";
                     }
                     // Write datas into qa_generic database
                     if (preg_match("#^ ?pass(ed)? ?\$#i", $status)) {
                         $decision_criteria_id = -1;
                     } else {
                         if (preg_match("#^ ?fail(ed)? ?\$#i", $status)) {
                             $decision_criteria_id = -2;
                         } else {
                             if (preg_match("#^ ?block(ed)? ?\$#i", $status)) {
                                 $decision_criteria_id = -3;
                             } else {
                                 if (preg_match("#^ ?defer(red)? ?\$#i", $status)) {
                                     $decision_criteria_id = -4;
                                 } else {
                                     if (preg_match("#^ ?not ?run ?\$#i", $status) || preg_match("#^ ?not_run ?\$#i", $status)) {
                                         $decision_criteria_id = -5;
                                     } else {
                                         return 2104;
                                     }
                                 }
                             }
                         }
                     }
                     // Status hard coded
                     $resultStatus = 0;
                     if ($merge_flag) {
                         // Retrieve test result id relying on test name and feature label, if it exists
                         $query = "SELECT tr.id tr_id\n\t\t\t\t\t\t\t\t\tFROM " . $qa_generic . ".test_result tr\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".table_name tn ON tn.name = 'test_result'\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".complementary_tool_relation ctr ON ctr.table_name_id = tn.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.table_entry_id = tr.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.label = '" . addslashes($feature) . "'\n\t\t\t\t\t\t\t\t\tWHERE tr.test_session_id = " . $test_session_id . "\n\t\t\t\t\t\t\t\t\t\tAND tr.name = '" . addslashes($case_id) . "'";
                         $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
                         if (!empty($result)) {
                             $test_result_exists_flag = true;
                             $testResultId = $result['tr_id'];
                         }
                     }
                     // Write into test_result table
                     if ($test_result_exists_flag) {
                         $testResult = Doctrine_Core::getTable("TestResult")->findOneById($testResultId);
                     } else {
                         $testResult = new TestResult();
                         $testResult->setName($case_id);
                         $testResult->setTestSessionId($test_session_id);
                     }
                     $testResult->setDecisionCriteriaId($decision_criteria_id);
                     $testResult->setComplement($test_case);
                     $testResult->setComment($comment);
                     $testResult->setStatus($resultStatus);
                     $testResult->setExecutionTime($executionTime);
                     $testResult->setBugs($bugs);
                     $testResult->save($conn);
                     // Retrieve test_result id created
                     $test_result_id = $testResult->getId();
                     // Category = Feature = 1
                     $category = 1;
                     // Write into complementary_tool_relation table
                     if (!$test_result_exists_flag) {
                         $complementaryToolRelation = new ComplementaryToolRelation();
                         $complementaryToolRelation->setLabel($feature);
                         $complementaryToolRelation->setTableNameId($table_name_test_result_id);
                         $complementaryToolRelation->setTableEntryId($test_result_id);
                         $complementaryToolRelation->setCategory($category);
                         $complementaryToolRelation->save($conn);
                     }
                 }
                 $data_tab = array();
                 $test_result_exists_flag = false;
             }
         } elseif (preg_match("#(?=.*Feature)(?=.*Check ?points)(?=.*Notes ?\\(bugs\\))(?=.*Pass)(?=.*Fail)(?=.*N/A)#i", $first_line)) {
             // Return at the beginning of file
             fseek($csv_report_file, 0);
             // Determine order between different fields on the first line
             $idx = 0;
             $ref_tab = array();
             foreach (fgetcsv($csv_report_file, 0, $delimiter) as $element) {
                 if (preg_match("#^ ?Feature.?\$#i", $element)) {
                     $ref_tab[0] = $idx;
                 } elseif (preg_match("#^ ?Check ?points.?\$#i", $element)) {
                     $ref_tab[1] = $idx;
                 } elseif (preg_match("#^ ?Notes ?\\(bugs\\).?\$#i", $element)) {
                     $ref_tab[2] = $idx;
                 } elseif (preg_match("#^ ?Pass.?\$#i", $element)) {
                     $ref_tab[3] = $idx;
                 } elseif (preg_match("#^ ?Fail.?\$#i", $element)) {
                     $ref_tab[4] = $idx;
                 } elseif (preg_match("#^ ?N/?A.?\$#i", $element)) {
                     $ref_tab[5] = $idx;
                 } elseif (preg_match("#^ ?Defer(red)?.?\$#i", $element)) {
                     $ref_tab[8] = $idx;
                 } elseif (preg_match("#^ ?Not ?run.?\$#i", $element) || preg_match("#^ ?Not_run.?\$#i", $element)) {
                     $ref_tab[9] = $idx;
                 } elseif (preg_match("#^ ?Duration.?\$#i", $element)) {
                     $ref_tab[6] = $idx;
                 } elseif (preg_match("#^ ?Bug.?\$#i", $element)) {
                     $ref_tab[7] = $idx;
                 }
                 $idx++;
             }
             // Go through file and fill datas
             $data_tab = array();
             while ($data_tab = fgetcsv($csv_report_file, 0, $delimiter)) {
                 if (count($data_tab) > 5) {
                     // Check if feature is not empty
                     if (empty($data_tab[$ref_tab[0]])) {
                         return 2201;
                     } else {
                         $feature = $data_tab[$ref_tab[0]];
                     }
                     // Check if case_id is not empty
                     if (empty($data_tab[$ref_tab[1]])) {
                         return 2202;
                     } else {
                         $case_id = $data_tab[$ref_tab[1]];
                     }
                     // Check if bug list is not empty
                     if (empty($data_tab[$ref_tab[7]])) {
                         $bugs = "";
                     } else {
                         $bugs = $data_tab[$ref_tab[7]];
                     }
                     $comment = empty($data_tab[$ref_tab[2]]) ? " " : $data_tab[$ref_tab[2]];
                     if (!($data_tab[$ref_tab[3]] == "1" or $data_tab[$ref_tab[4]] == "1" or $data_tab[$ref_tab[5]] == "1" or $data_tab[$ref_tab[8]] == "1" or $data_tab[$ref_tab[9]] == "1")) {
                         return 2203;
                     }
                     $pass = empty($data_tab[$ref_tab[3]]) ? "" : $data_tab[$ref_tab[3]];
                     $fail = empty($data_tab[$ref_tab[4]]) ? "" : $data_tab[$ref_tab[4]];
                     $block = empty($data_tab[$ref_tab[5]]) ? "" : $data_tab[$ref_tab[5]];
                     $deferred = empty($data_tab[$ref_tab[8]]) ? "" : $data_tab[$ref_tab[8]];
                     $notrun = empty($data_tab[$ref_tab[9]]) ? "" : $data_tab[$ref_tab[9]];
                     if ($pass == "1") {
                         $decision_criteria_id = -1;
                     } elseif ($fail == "1") {
                         $decision_criteria_id = -2;
                     } elseif ($block == "1") {
                         $decision_criteria_id = -3;
                     } elseif ($deferred == "1") {
                         $decision_criteria_id = -4;
                     } elseif ($notrun == "1") {
                         $decision_criteria_id = -5;
                     }
                     if (!empty($data_tab[$ref_tab[6]])) {
                         $executionTime = $data_tab[$ref_tab[6]];
                     } else {
                         $executionTime = 0;
                     }
                     // Status hard coded
                     $status = 0;
                     if ($merge_flag) {
                         // Retrieve test result id relying on test name and feature label, if it exists
                         $query = "SELECT tr.id tr_id\n\t\t\t\t\t\t\t\t\tFROM " . $qa_generic . ".test_result tr\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".table_name tn ON tn.name = 'test_result'\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".complementary_tool_relation ctr ON ctr.table_name_id = tn.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.table_entry_id = tr.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.label = '" . addslashes($feature) . "'\n\t\t\t\t\t\t\t\t\tWHERE tr.test_session_id = " . $test_session_id . "\n\t\t\t\t\t\t\t\t\t\tAND tr.name = '" . addslashes($case_id) . "'";
                         $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
                         if (!empty($result)) {
                             $test_result_exists_flag = true;
                             $testResultId = $result['tr_id'];
                         }
                     }
                     // Write into test_result table
                     if ($test_result_exists_flag) {
                         $testResult = Doctrine_Core::getTable("TestResult")->findOneById($testResultId);
                     } else {
                         $testResult = new TestResult();
                         $testResult->setName($case_id);
                         $testResult->setTestSessionId($test_session_id);
                     }
                     $testResult->setDecisionCriteriaId($decision_criteria_id);
                     $testResult->setComplement($test_case);
                     $testResult->setComment($comment);
                     $testResult->setStatus($status);
                     $testResult->setExecutionTime($executionTime);
                     $testResult->setBugs($bugs);
                     $testResult->save($conn);
                     // Retrieve test_result id created
                     $test_result_id = $testResult->getId();
                     // Category = Feature = 1
                     $category = 1;
                     // Write into complementary_tool_relation table
                     if (!$test_result_exists_flag) {
                         $complementaryToolRelation = new ComplementaryToolRelation();
                         $complementaryToolRelation->setLabel($feature);
                         $complementaryToolRelation->setTableNameId($table_name_test_result_id);
                         $complementaryToolRelation->setTableEntryId($test_result_id);
                         $complementaryToolRelation->setCategory($category);
                         $complementaryToolRelation->save($conn);
                     }
                 }
                 $data_tab = array();
                 $test_result_exists_flag = false;
             }
         } elseif (preg_match("#(?=.*Feature)(?=.*Case ?id)(?=.*Check ?points)(?=.*Notes)(?=.*Pass)(?=.*Fail)(?=.*N/A)#i", $first_line)) {
             // Return at the beginning of file
             fseek($csv_report_file, 0);
             // Determine order between different fields on the first line
             $idx = 0;
             $ref_tab = array();
             foreach (fgetcsv($csv_report_file, 0, $delimiter) as $element) {
                 if (preg_match("#^ ?Feature.?\$#i", $element)) {
                     $ref_tab[0] = $idx;
                 } elseif (preg_match("#^ ?Case ?id.?\$#i", $element)) {
                     $ref_tab[1] = $idx;
                 } elseif (preg_match("#^ ?Check ?points.?\$#i", $element)) {
                     $ref_tab[2] = $idx;
                 } elseif (preg_match("#^ ?Notes.?\$#i", $element)) {
                     $ref_tab[3] = $idx;
                 } elseif (preg_match("#^ ?Pass.?\$#i", $element)) {
                     $ref_tab[4] = $idx;
                 } elseif (preg_match("#^ ?Fail.?\$#i", $element)) {
                     $ref_tab[5] = $idx;
                 } elseif (preg_match("#^ ?N/?A.?\$#i", $element)) {
                     $ref_tab[6] = $idx;
                 } elseif (preg_match("#^ ?Defer(red)?.?\$#i", $element)) {
                     $ref_tab[9] = $idx;
                 } elseif (preg_match("#^ ?Not ?run.?\$#i", $element) || preg_match("#^ ?Not_run.?\$#i", $element)) {
                     $ref_tab[10] = $idx;
                 } elseif (preg_match("#^ ?Duration.?\$#i", $element)) {
                     $ref_tab[7] = $idx;
                 } elseif (preg_match("#^ ?Bug.?\$#i", $element)) {
                     $ref_tab[8] = $idx;
                 }
                 $idx++;
             }
             // Go through file and fill datas
             $data_tab = array();
             while ($data_tab = fgetcsv($csv_report_file, 0, $delimiter)) {
                 if (count($data_tab) > 6) {
                     // Check if feature is not empty
                     if (empty($data_tab[$ref_tab[0]])) {
                         return 2301;
                     } else {
                         $feature = $data_tab[$ref_tab[0]];
                     }
                     // Check if case_id is not empty
                     if (empty($data_tab[$ref_tab[1]])) {
                         return 2302;
                     } else {
                         $case_id = $data_tab[$ref_tab[1]];
                     }
                     $test_case = empty($data_tab[$ref_tab[2]]) ? " " : $data_tab[$ref_tab[2]];
                     $comment = empty($data_tab[$ref_tab[3]]) ? " " : $data_tab[$ref_tab[3]];
                     if (!($data_tab[$ref_tab[4]] == "1" or $data_tab[$ref_tab[5]] == "1" or $data_tab[$ref_tab[6]] == "1")) {
                         return 2303;
                     }
                     $pass = empty($data_tab[$ref_tab[4]]) ? "" : $data_tab[$ref_tab[4]];
                     $fail = empty($data_tab[$ref_tab[5]]) ? "" : $data_tab[$ref_tab[5]];
                     $block = empty($data_tab[$ref_tab[6]]) ? "" : $data_tab[$ref_tab[6]];
                     $deferred = empty($data_tab[$ref_tab[9]]) ? "" : $data_tab[$ref_tab[9]];
                     $notrun = empty($data_tab[$ref_tab[10]]) ? "" : $data_tab[$ref_tab[10]];
                     if ($pass == "1") {
                         $decision_criteria_id = -1;
                     } elseif ($fail == "1") {
                         $decision_criteria_id = -2;
                     } elseif ($block == "1") {
                         $decision_criteria_id = -3;
                     } elseif ($deferred == "1") {
                         $decision_criteria_id = -4;
                     } elseif ($notrun == "1") {
                         $decision_criteria_id = -5;
                     }
                     // Check if execution time is not empty
                     if (!empty($data_tab[$ref_tab[7]])) {
                         $executionTime = $data_tab[$ref_tab[7]];
                     } else {
                         $executionTime = 0;
                     }
                     // Check if bug list is not empty
                     if (empty($data_tab[$ref_tab[8]])) {
                         $bugs = "";
                     } else {
                         $bugs = $data_tab[$ref_tab[8]];
                     }
                     // Status hard coded
                     $status = 0;
                     if ($merge_flag) {
                         // Retrieve test result id relying on test name and feature label, if it exists
                         $query = "SELECT tr.id tr_id\n\t\t\t\t\t\t\t\t\tFROM " . $qa_generic . ".test_result tr\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".table_name tn ON tn.name = 'test_result'\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".complementary_tool_relation ctr ON ctr.table_name_id = tn.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.table_entry_id = tr.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.label = '" . addslashes($feature) . "'\n\t\t\t\t\t\t\t\t\tWHERE tr.test_session_id = " . $test_session_id . "\n\t\t\t\t\t\t\t\t\t\tAND tr.name = '" . addslashes($case_id) . "'";
                         $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
                         if (!empty($result)) {
                             $test_result_exists_flag = true;
                             $testResultId = $result['tr_id'];
                         }
                     }
                     // Write into test_result table
                     if ($test_result_exists_flag) {
                         $testResult = Doctrine_Core::getTable("TestResult")->findOneById($testResultId);
                     } else {
                         $testResult = new TestResult();
                         $testResult->setName($case_id);
                         $testResult->setTestSessionId($test_session_id);
                     }
                     $testResult->setDecisionCriteriaId($decision_criteria_id);
                     $testResult->setComplement($test_case);
                     $testResult->setComment($comment);
                     $testResult->setStatus($status);
                     $testResult->setExecutionTime($executionTime);
                     $testResult->setBugs($bugs);
                     $testResult->save($conn);
                     // Retrieve test_result id created
                     $test_result_id = $testResult->getId();
                     // Category = Feature = 1
                     $category = 1;
                     // Write into complementary_tool_relation table
                     if (!$test_result_exists_flag) {
                         $complementaryToolRelation = new ComplementaryToolRelation();
                         $complementaryToolRelation->setLabel($feature);
                         $complementaryToolRelation->setTableNameId($table_name_test_result_id);
                         $complementaryToolRelation->setTableEntryId($test_result_id);
                         $complementaryToolRelation->setCategory($category);
                         $complementaryToolRelation->save($conn);
                     }
                 }
                 $data_tab = array();
                 $test_result_exists_flag = false;
             }
         } elseif (preg_match("#(?=.*Feature)(?=.*Case ?Id)(?=.*Test ?Case)(?=.*Pass)(?=.*Fail)(?=.*N/A)(?=.*Comment)#i", $first_line)) {
             // Return at the beginning of file
             fseek($csv_report_file, 0);
             // Determine order between different fields on the first line
             $idx = 0;
             $ref_tab = array();
             foreach (fgetcsv($csv_report_file, 0, $delimiter) as $element) {
                 if (preg_match("#^ ?Feature.?\$#i", $element)) {
                     $ref_tab[0] = $idx;
                 } elseif (preg_match("#^ ?Case ?Id.?\$#i", $element)) {
                     $ref_tab[1] = $idx;
                 } elseif (preg_match("#^ ?Test ?Case.?\$#i", $element)) {
                     $ref_tab[2] = $idx;
                 } elseif (preg_match("#^ ?Pass.?\$#i", $element)) {
                     $ref_tab[3] = $idx;
                 } elseif (preg_match("#^ ?Fail.?\$#i", $element)) {
                     $ref_tab[4] = $idx;
                 } elseif (preg_match("#^ ?N/?A.?\$#i", $element)) {
                     $ref_tab[5] = $idx;
                 } elseif (preg_match("#^ ?Measured.?\$#i", $element)) {
                     $ref_tab[6] = $idx;
                 } elseif (preg_match("#^ ?Comment.?\$#i", $element)) {
                     $ref_tab[7] = $idx;
                 } elseif (preg_match("#^ ?Measurement ?Name.?\$#i", $element)) {
                     $ref_tab[8] = $idx;
                 } elseif (preg_match("#^ ?Value.?\$#i", $element)) {
                     $ref_tab[9] = $idx;
                 } elseif (preg_match("#^ ?Unit.?\$#i", $element)) {
                     $ref_tab[10] = $idx;
                 } elseif (preg_match("#^ ?Target.?\$#i", $element)) {
                     $ref_tab[11] = $idx;
                 } elseif (preg_match("#^ ?Failure.?\$#i", $element)) {
                     $ref_tab[12] = $idx;
                 } elseif (preg_match("#^ ?Duration.?\$#i", $element)) {
                     $ref_tab[13] = $idx;
                 } elseif (preg_match("#^ ?Bug.?\$#i", $element)) {
                     $ref_tab[14] = $idx;
                 }
                 $idx++;
             }
             // Go through file and fill datas
             $data_tab = array();
             while ($data_tab = fgetcsv($csv_report_file, 0, $delimiter)) {
                 if (count($data_tab) > 6) {
                     // Check if feature is not empty
                     if (empty($data_tab[$ref_tab[0]])) {
                         return 2401;
                     } else {
                         $feature = $data_tab[$ref_tab[0]];
                     }
                     // Check if case_id is not empty
                     if (empty($data_tab[$ref_tab[1]])) {
                         return 2402;
                     } else {
                         $case_id = $data_tab[$ref_tab[1]];
                     }
                     if (!($data_tab[$ref_tab[3]] == "1" or $data_tab[$ref_tab[4]] == "1" or $data_tab[$ref_tab[5]] == "1" or $data_tab[$ref_tab[6]] == "1")) {
                         return 2403;
                     }
                     $test_case = empty($data_tab[$ref_tab[2]]) ? " " : $data_tab[$ref_tab[2]];
                     $pass = empty($data_tab[$ref_tab[3]]) ? "" : $data_tab[$ref_tab[3]];
                     $fail = empty($data_tab[$ref_tab[4]]) ? "" : $data_tab[$ref_tab[4]];
                     $block = empty($data_tab[$ref_tab[5]]) ? "" : $data_tab[$ref_tab[5]];
                     $deferred = empty($data_tab[$ref_tab[15]]) ? "" : $data_tab[$ref_tab[15]];
                     $notrun = empty($data_tab[$ref_tab[16]]) ? "" : $data_tab[$ref_tab[16]];
                     $measured = empty($data_tab[$ref_tab[6]]) ? "" : $data_tab[$ref_tab[6]];
                     $comment = empty($data_tab[$ref_tab[7]]) ? " " : $data_tab[$ref_tab[7]];
                     $measurement_name = empty($data_tab[$ref_tab[8]]) ? "" : $data_tab[$ref_tab[8]];
                     $value = empty($data_tab[$ref_tab[9]]) ? "" : preg_replace('#(,)#', '.', $data_tab[$ref_tab[9]]);
                     $unit = empty($data_tab[$ref_tab[10]]) ? " " : $data_tab[$ref_tab[10]];
                     $target = empty($data_tab[$ref_tab[11]]) ? "" : preg_replace('#(,)#', '.', $data_tab[$ref_tab[11]]);
                     $failure = empty($data_tab[$ref_tab[12]]) ? "" : preg_replace('#(,)#', '.', $data_tab[$ref_tab[12]]);
                     $executionTime = empty($data_tab[$ref_tab[13]]) ? 0 : $data_tab[$ref_tab[13]];
                     $bugs = empty($data_tab[$ref_tab[14]]) ? "" : $data_tab[$ref_tab[14]];
                     preg_replace('#(,)#', '.', $data_tab[$ref_tab[9]]);
                     // Write datas into qa_generic database
                     if ($pass == "1") {
                         $decision_criteria_id = -1;
                     } elseif ($fail == "1") {
                         $decision_criteria_id = -2;
                     } elseif ($block == "1") {
                         $decision_criteria_id = -3;
                     } elseif ($deferred == "1") {
                         $decision_criteria_id = -4;
                     } elseif ($notrun == "1") {
                         $decision_criteria_id = -5;
                     } elseif ($measured == "1") {
                         if (empty($failure)) {
                             if ($value < $target) {
                                 $decision_criteria_id = -2;
                             } else {
                                 $decision_criteria_id = -1;
                             }
                         } else {
                             if ($failure > $target) {
                                 if ($value < $failure) {
                                     $decision_criteria_id = -1;
                                 } else {
                                     $decision_criteria_id = -2;
                                 }
                             } elseif ($failure < $target) {
                                 if ($value > $failure) {
                                     $decision_criteria_id = -1;
                                 } else {
                                     $decision_criteria_id = -2;
                                 }
                             } else {
                                 if ($value < $target) {
                                     $decision_criteria_id = -2;
                                 } else {
                                     $decision_criteria_id = -1;
                                 }
                             }
                         }
                     }
                     // Status hard coded
                     $status = 0;
                     if ($merge_flag) {
                         // Retrieve test result id relying on test name and feature label, if it exists
                         $query = "SELECT tr.id tr_id\n\t\t\t\t\t\t\t\t\tFROM " . $qa_generic . ".test_result tr\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".table_name tn ON tn.name = 'test_result'\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".complementary_tool_relation ctr ON ctr.table_name_id = tn.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.table_entry_id = tr.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.label = '" . addslashes($feature) . "'\n\t\t\t\t\t\t\t\t\tWHERE tr.test_session_id = " . $test_session_id . "\n\t\t\t\t\t\t\t\t\t\tAND tr.name = '" . addslashes($case_id) . "'";
                         $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
                         if (!empty($result)) {
                             $test_result_exists_flag = true;
                             $testResultId = $result['tr_id'];
                         }
                     }
                     // Write into test_result table
                     if ($test_result_exists_flag) {
                         $measures = Doctrine_Query::create()->select('*')->from('Measure')->where('test_result_id = ?', $testResultId)->execute();
                         foreach ($measures as $measure) {
                             $measure->delete($conn);
                         }
                         $testResult = Doctrine_Core::getTable("TestResult")->findOneById($testResultId);
                     } else {
                         $testResult = new TestResult();
                         $testResult->setName($case_id);
                         $testResult->setTestSessionId($test_session_id);
                     }
                     $testResult->setDecisionCriteriaId($decision_criteria_id);
                     $testResult->setComplement($test_case);
                     $testResult->setComment($comment);
                     $testResult->setStatus($status);
                     $testResult->setExecutionTime($executionTime);
                     $testResult->setBugs($bugs);
                     $testResult->save($conn);
                     // Retrieve test_result id created
                     $test_result_id = $testResult->getId();
                     // Category = Feature = 1
                     $category = 1;
                     // Write into complementary_tool_relation table
                     if (!$test_result_exists_flag) {
                         $complementaryToolRelation = new ComplementaryToolRelation();
                         $complementaryToolRelation->setLabel($feature);
                         $complementaryToolRelation->setTableNameId($table_name_test_result_id);
                         $complementaryToolRelation->setTableEntryId($test_result_id);
                         $complementaryToolRelation->setCategory($category);
                         $complementaryToolRelation->save($conn);
                     }
                     // Write into measure table
                     if (!empty($measurement_name) and !empty($value)) {
                         $measureObject = new Measure();
                         $measureObject->setTestResultId($test_result_id);
                         $measureObject->setValue($value);
                         $measureObject->setUnit($unit);
                         $measureObject->setDescription($measurement_name);
                         $measureObject->setCategory(1);
                         $measureObject->setOperator(1);
                         $measureObject->save($conn);
                         if (!empty($target)) {
                             $measureObject = new Measure();
                             $measureObject->setTestResultId($test_result_id);
                             $measureObject->setValue($target);
                             $measureObject->setUnit($unit);
                             $measureObject->setDescription($measurement_name);
                             $measureObject->setCategory(2);
                             $measureObject->setOperator(1);
                             $measureObject->save($conn);
                         }
                         if (!empty($failure)) {
                             $measureObject = new Measure();
                             $measureObject->setTestResultId($test_result_id);
                             $measureObject->setValue($failure);
                             $measureObject->setUnit($unit);
                             $measureObject->setDescription($measurement_name);
                             $measureObject->setCategory(3);
                             $measureObject->setOperator(1);
                             $measureObject->save($conn);
                         }
                     }
                 }
                 $data_tab = array();
                 $test_result_exists_flag = false;
             }
         } elseif (preg_match("#(?=.*Name)(?=.*\\b ?Status ?\\b)#i", $first_line)) {
             // Return at the beginning of file
             fseek($csv_report_file, 0);
             // Determine order between different fields on the first line
             $idx = 0;
             $ref_tab = array();
             $entityTypeFound = false;
             foreach (fgetcsv($csv_report_file, 0, $delimiter) as $element) {
                 if (preg_match("#^ ?Component.?\$#i", $element)) {
                     $ref_tab[0] = $idx;
                 } elseif (preg_match("#^ ?Name.?\$#i", $element)) {
                     $ref_tab[1] = $idx;
                 } elseif (preg_match("#^ ?Status.?\$#i", $element)) {
                     $ref_tab[2] = $idx;
                 } elseif (preg_match("#^ ?Feature.?\$#i", $element)) {
                     $ref_tab[3] = $idx;
                 } elseif (preg_match("#^ ?Description.?\$#i", $element)) {
                     $ref_tab[4] = $idx;
                 } elseif (preg_match("#^ ?Comment.?\$#i", $element)) {
                     $ref_tab[5] = $idx;
                 } elseif (preg_match("#^ ?Bug.?\$#i", $element)) {
                     $ref_tab[6] = $idx;
                 } elseif (preg_match("#^ ?Package.?\$#i", $element)) {
                     $ref_tab[7] = $idx;
                 } elseif (preg_match("#^ ?Measurement ?Name.?\$#i", $element)) {
                     $ref_tab[8] = $idx;
                 } elseif (preg_match("#^ ?Value.?\$#i", $element)) {
                     $ref_tab[9] = $idx;
                 } elseif (preg_match("#^ ?Unit.?\$#i", $element)) {
                     $ref_tab[10] = $idx;
                 } elseif (preg_match("#^ ?Target.?\$#i", $element)) {
                     $ref_tab[11] = $idx;
                 } elseif (preg_match("#^ ?Failure.?\$#i", $element)) {
                     $ref_tab[12] = $idx;
                 } elseif (preg_match("#^ ?StepActualResult.?\$#i", $element)) {
                     $ref_tab[13] = $idx;
                 } elseif (preg_match("# ?EntityType.?#i", $element)) {
                     $ref_tab[14] = $idx;
                     $entityTypeFound = true;
                 } elseif (preg_match("#^ ?Duration.?\$#i", $element)) {
                     $ref_tab[15] = $idx;
                 } elseif (preg_match("#^ ?StepNotes.?\$#i", $element)) {
                     $ref_tab[16] = $idx;
                 }
                 $idx++;
             }
             if (!isset($ref_tab[1])) {
                 return 2501;
             }
             if (!isset($ref_tab[2])) {
                 return 2502;
             }
             if (!isset($ref_tab[0]) && !isset($ref_tab[7])) {
                 return 2509;
             }
             // Go through file and fill datas
             $data_tab = array();
             while ($data_tab = fgetcsv($csv_report_file, 0, $delimiter)) {
                 if (count($data_tab) > 2) {
                     // If 'EntityType' label is found, pass over 'StepRunResult' lines
                     if ($entityTypeFound) {
                         if (empty($data_tab[$ref_tab[14]])) {
                             return 2503;
                         } elseif (!preg_match("#^ ?TestScriptAssignment.?\$#i", $data_tab[$ref_tab[14]])) {
                             continue;
                         }
                     }
                     // Check if feature is not empty
                     if (empty($data_tab[$ref_tab[0]]) and empty($data_tab[$ref_tab[7]])) {
                         return 2504;
                     } else {
                         if (!empty($data_tab[$ref_tab[0]])) {
                             $feature = $data_tab[$ref_tab[0]];
                         } else {
                             $feature = $data_tab[$ref_tab[7]];
                         }
                     }
                     // If 'EntityType' label is found, keep last two string (delimited by '|') in the feature label
                     if ($entityTypeFound) {
                         $feat_delimiter = '|';
                         $feature_tab = explode($feat_delimiter, $feature);
                         $tab_length = count($feature_tab);
                         $feature = $feature_tab[$tab_length - 2] . $feat_delimiter . $feature_tab[$tab_length - 1];
                     }
                     // Check if case_id is not empty
                     if (empty($data_tab[$ref_tab[1]])) {
                         return 2506;
                     } else {
                         $case_id = $data_tab[$ref_tab[1]];
                     }
                     // Check if status is not empty
                     if (empty($data_tab[$ref_tab[2]])) {
                         return 2507;
                     } else {
                         $status = $data_tab[$ref_tab[2]];
                     }
                     $test_case = empty($data_tab[$ref_tab[4]]) ? " " : $data_tab[$ref_tab[4]];
                     $comment = empty($data_tab[$ref_tab[5]]) ? "" : $data_tab[$ref_tab[5]];
                     // $bug = (empty($data_tab[$ref_tab[6]])) ? "" : $data_tab[$ref_tab[6]];
                     $step_actual_result = empty($data_tab[$ref_tab[13]]) ? "" : $data_tab[$ref_tab[13]];
                     $step_notes = empty($data_tab[$ref_tab[16]]) ? "" : $data_tab[$ref_tab[16]];
                     $measurement_name = empty($data_tab[$ref_tab[8]]) ? "" : $data_tab[$ref_tab[8]];
                     $value = empty($data_tab[$ref_tab[9]]) ? "" : preg_replace('#(,)#', '.', $data_tab[$ref_tab[9]]);
                     $unit = empty($data_tab[$ref_tab[10]]) ? " " : $data_tab[$ref_tab[10]];
                     $target = empty($data_tab[$ref_tab[11]]) ? "" : preg_replace('#(,)#', '.', $data_tab[$ref_tab[11]]);
                     $failure = empty($data_tab[$ref_tab[12]]) ? "" : preg_replace('#(,)#', '.', $data_tab[$ref_tab[12]]);
                     $executionTime = empty($data_tab[$ref_tab[15]]) ? 0 : $data_tab[$ref_tab[12]];
                     // Concatenate notes
                     if (empty($comment)) {
                         if (empty($step_notes)) {
                             $notes = "";
                         } else {
                             $notes = $step_notes;
                         }
                     } else {
                         if (empty($step_notes)) {
                             $notes = $comment;
                         } else {
                             $notes = $comment . " " . $step_notes;
                         }
                     }
                     // Check if step_actual_result is not empty
                     if (empty($data_tab[$ref_tab[13]])) {
                         $bugs = "";
                     } else {
                         $bugs = $data_tab[$ref_tab[13]];
                     }
                     // Write datas into qa_generic database
                     if (preg_match("#^ ?pass(ed)? ?\$#i", $status)) {
                         $decision_criteria_id = -1;
                     } elseif (preg_match("#^ ?fail(ed)? ?\$#i", $status)) {
                         $decision_criteria_id = -2;
                     } elseif (preg_match("#^ ?block(ed)? ?\$#i", $status)) {
                         $decision_criteria_id = -3;
                     } elseif (preg_match("#^ ?defer(red)? ?\$#i", $status)) {
                         $decision_criteria_id = -4;
                     } elseif (preg_match("#^ ?not_run ?\$#i", $status) || preg_match("#^ ?not ?run ?\$#i", $status)) {
                         $decision_criteria_id = -5;
                     } elseif (preg_match("#^ ?measured ?\$#i", $status)) {
                         if (empty($failure)) {
                             if ($value < $target) {
                                 $decision_criteria_id = -2;
                             } else {
                                 $decision_criteria_id = -1;
                             }
                         } else {
                             if ($failure > $target) {
                                 if ($value < $failure) {
                                     $decision_criteria_id = -1;
                                 } else {
                                     $decision_criteria_id = -2;
                                 }
                             } elseif ($failure < $target) {
                                 if ($value > $failure) {
                                     $decision_criteria_id = -1;
                                 } else {
                                     $decision_criteria_id = -2;
                                 }
                             } else {
                                 if ($value < $target) {
                                     $decision_criteria_id = -2;
                                 } else {
                                     $decision_criteria_id = -1;
                                 }
                             }
                         }
                     } else {
                         if (preg_match("#^ ?in ?progress ?\$#i", $status)) {
                             $decision_criteria_id = -5;
                         } else {
                             return 2508;
                         }
                     }
                     // Status hard coded
                     $resultStatus = 0;
                     if ($merge_flag) {
                         // Retrieve test result id relying on test name and feature label, if it exists
                         $query = "SELECT tr.id tr_id\n\t\t\t\t\t\t\t\t\tFROM " . $qa_generic . ".test_result tr\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".table_name tn ON tn.name = 'test_result'\n\t\t\t\t\t\t\t\t\t\tJOIN " . $qa_generic . ".complementary_tool_relation ctr ON ctr.table_name_id = tn.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.table_entry_id = tr.id\n\t\t\t\t\t\t\t\t\t\t\tAND ctr.label = '" . addslashes($feature) . "'\n\t\t\t\t\t\t\t\t\tWHERE tr.test_session_id = " . $test_session_id . "\n\t\t\t\t\t\t\t\t\t\tAND tr.name = '" . addslashes($case_id) . "'";
                         $result = Doctrine_Manager::getInstance()->getCurrentConnection()->execute($query)->fetch(PDO::FETCH_ASSOC);
                         if (!empty($result)) {
                             $test_result_exists_flag = true;
                             $testResultId = $result['tr_id'];
                         }
                     }
                     // Write into test_result table
                     if ($test_result_exists_flag) {
                         $measures = Doctrine_Query::create()->select('*')->from('Measure')->where('test_result_id = ?', $testResultId)->execute();
                         foreach ($measures as $measure) {
                             $measure->delete($conn);
                         }
                         $testResult = Doctrine_Core::getTable("TestResult")->findOneById($testResultId);
                     } else {
                         $testResult = new TestResult();
                         $testResult->setName($case_id);
                         $testResult->setTestSessionId($test_session_id);
                     }
                     $testResult->setDecisionCriteriaId($decision_criteria_id);
                     $testResult->setComplement($test_case);
                     $testResult->setStatus($resultStatus);
                     $testResult->setExecutionTime($executionTime);
                     $testResult->setBugs($bugs);
                     $testResult->setComment($notes);
                     $testResult->save($conn);
                     // Retrieve test_result id created
                     $test_result_id = $testResult->getId();
                     // Category = Feature = 1
                     $category = 1;
                     // Write into complementary_tool_relation table
                     if (!$test_result_exists_flag) {
                         $complementaryToolRelation = new ComplementaryToolRelation();
                         $complementaryToolRelation->setLabel($feature);
                         $complementaryToolRelation->setTableNameId($table_name_test_result_id);
                         $complementaryToolRelation->setTableEntryId($test_result_id);
                         $complementaryToolRelation->setCategory($category);
                         $complementaryToolRelation->save($conn);
                     }
                     // Write into measure table
                     if (!empty($measurement_name) and !empty($value)) {
                         $measureObject = new Measure();
                         $measureObject->setTestResultId($test_result_id);
                         $measureObject->setValue($value);
                         $measureObject->setUnit($unit);
                         $measureObject->setDescription($measurement_name);
                         $measureObject->setCategory(1);
                         $measureObject->setOperator(1);
                         $measureObject->save($conn);
                         if (!empty($target)) {
                             $measureObject = new Measure();
                             $measureObject->setTestResultId($test_result_id);
                             $measureObject->setValue($target);
                             $measureObject->setUnit($unit);
                             $measureObject->setDescription($measurement_name);
                             $measureObject->setCategory(2);
                             $measureObject->setOperator(1);
                             $measureObject->save($conn);
                         }
                         if (!empty($failure)) {
                             $measureObject = new Measure();
                             $measureObject->setTestResultId($test_result_id);
                             $measureObject->setValue($failure);
                             $measureObject->setUnit($unit);
                             $measureObject->setDescription($measurement_name);
                             $measureObject->setCategory(3);
                             $measureObject->setOperator(1);
                             $measureObject->save($conn);
                         }
                     }
                 }
                 $data_tab = array();
                 $test_result_exists_flag = false;
             }
         } else {
             // Close the file
             fclose($csv_report_file);
             return 2000;
         }
         // Close the file
         fclose($csv_report_file);
         return 0;
     } else {
         return 10;
     }
 }
 /**
  * Called when a test run finishes.
  *
  * @param   unittest.TestSuite suite
  * @param   unittest.TestResult result
  */
 public function testRunFinished(TestSuite $suite, TestResult $result)
 {
     $this->writeStatus();
     $this->out->writeLine();
     // Summary output
     $this->out->writeLinef("\n%s: %d/%d run (%d skipped), %d succeeded, %d failed", $result->failureCount() > 0 ? 'FAIL' : 'OK', $result->runCount(), $result->count(), $result->skipCount(), $result->successCount(), $result->failureCount());
     $this->out->writeLinef('Memory used: %.2f kB (%.2f kB peak)', Runtime::getInstance()->memoryUsage() / 1024, Runtime::getInstance()->peakMemoryUsage() / 1024);
     $this->out->writeLinef('Time taken: %.3f seconds', $result->elapsed());
 }
Пример #11
0
 public function getTestResult()
 {
     global $db;
     $result = TestResult::getInstance()->calculateResult($this->getAnswers(), $this->getSex());
     $db->update('mbti_student', array('person_formula' => $result['formula']), array('user_id' => $this->id));
     $result['name'] = $this->getName();
     return $result;
 }
Пример #12
0
 /**
  * Saves Test Results
  *
  * @param $testID to save
  * @return view
  */
 public function saveResults($testID)
 {
     $test = Test::find($testID);
     $test->test_status_id = Test::COMPLETED;
     $test->interpretation = Input::get('interpretation');
     $test->tested_by = Auth::user()->id;
     $test->time_completed = date('Y-m-d H:i:s');
     $test->save();
     foreach ($test->testType->measures as $measure) {
         $testResult = TestResult::firstOrCreate(array('test_id' => $testID, 'measure_id' => $measure->id));
         $testResult->result = Input::get('m_' . $measure->id);
         $testResult->save();
     }
     //Fire of entry saved/edited event
     Event::fire('test.saved', array($testID));
     $input = Session::get('TESTS_FILTER_INPUT');
     Session::put('fromRedirect', 'true');
     // Get page
     $url = Session::get('SOURCE_URL');
     $urlParts = explode('&', $url);
     if (isset($urlParts['page'])) {
         $pageParts = explode('=', $urlParts['page']);
         $input['page'] = $pageParts[1];
     }
     // redirect
     return Redirect::action('TestController@index')->with('message', trans('messages.success-saving-results'))->with('activeTest', array($test->id))->withInput($input);
 }
Пример #13
0
    function paintPass($message)
    {
        print "pass " . $message;
    }
    function paintFail($message)
    {
        print "fail " . $message;
    }
}
$reporter = new TestOfTestReporter();
$event = new TestStart("1");
print "<li>Expecting event label [1] got [";
$event->paint($reporter);
print "]</li>\n";
$event = new TestEnd("2");
print "<li>Expecting event label [2] got [";
$event->paint($reporter);
print "]</li>\n";
$event = new TestResult(true, "3");
print "<li>Expecting event label [pass 3] got [";
$event->paint($reporter);
print "]</li>\n";
$event = new TestResult(false, "4");
print "<li>Expecting event label [fail 4] got [";
$event->paint($reporter);
print "]</li>\n";
?>
        </ol>
    </body>
</html>
Пример #14
0
*/
chdir('../..');
include_once 'core/tests/base.php';
class MorgOSInterfaceSuite extends TestSuite
{
    function MorgOSInterfaceSuite()
    {
        $this->setName('MorgOS interface tester');
    }
}
if ($php == "4") {
    include_once 'interface/tests/eventmanager.class.test.php';
    include_once 'interface/tests/actionmanager.class.test.php';
    include_once 'interface/tests/pluginmanager.class.test.php';
    require_once 'PHPUnit/GUI/HTML.php';
    $eventsuite = new TestSuite('eventManagerTest');
    $pluginsuite = new TestSuite('pluginManagerTest');
    $actionsuite = new TestSuite('actionManagerTest');
    $GUI = new PHPUnit_GUI_HTML(array($eventsuite, $pluginsuite, $actionsuite));
    $GUI->show();
} elseif ($php == "5") {
    $suite = new MorgOSInterfaceSuite();
    //$eventTest = new PHPUnit2_Framework_TestSuite('eventManagerTest');
    $suite->addTestFile('interface/tests/eventmanager.class.test.php');
    $suite->addTestFile('interface/tests/actionmanager.class.test.php');
    $suite->addTestFile('interface/tests/pluginmanager.class.test.php');
    $result = new TestResult();
    $result->addListener(new SimpleTestListener());
    $suite->run($result);
    $suite = null;
}
Пример #15
0
 /**
  * Run this test suite
  *
  * @return  unittest.TestResult
  */
 public function run()
 {
     $this->notifyListeners('testRunStarted', array($this));
     $result = new TestResult();
     foreach ($this->order as $classname => $tests) {
         $class = XPClass::forName($classname);
         // Run all tests in this class
         try {
             $this->beforeClass($class);
         } catch (PrerequisitesNotMetError $e) {
             foreach ($tests as $i) {
                 $this->notifyListeners('testSkipped', array($result->setSkipped($this->tests[$i], $e, 0.0)));
             }
             continue;
         }
         foreach ($tests as $i) {
             $this->runInternal($this->tests[$i], $result);
         }
         $this->afterClass($class);
     }
     $this->notifyListeners('testRunFinished', array($this, $result));
     return $result;
 }
 function test_testcase()
 {
     $test_result = new TestResult("test name");
     $test_result->set_testcase('My testcase');
     $this->assert_equals('My testcase', $test_result->get_testcase());
 }
Пример #17
0
 public function testCreateFromRequest()
 {
     $request = new TestRequest(1, 'a', 'b', 'c');
     $result = TestResult::errorFromRequest($request, 'asdf');
     $this->assertEquals(1, $result->getId());
 }
Пример #18
0
    /**
     * MOH 706
     *
     */
    public function moh706()
    {
        //	Variables definition
        $date = date('Y-m-d');
        $from = Input::get('start');
        if (!$from) {
            $from = date('Y-m-01');
        }
        $end = Input::get('end');
        if (!$end) {
            $end = $date;
        }
        $toPlusOne = date_add(new DateTime($end), date_interval_create_from_date_string('1 day'));
        $to = date_add(new DateTime($end), date_interval_create_from_date_string('1 day'))->format('Y-m-d');
        $ageRanges = array('0-5', '5-14', '14-120');
        $sex = array(Patient::MALE, Patient::FEMALE);
        $ranges = array('Low', 'Normal', 'High');
        $specimen_types = array('Urine', 'Pus', 'HVS', 'Throat', 'Stool', 'Blood', 'CSF', 'Water', 'Food', 'Other fluids');
        $isolates = array('Naisseria', 'Klebsiella', 'Staphylococci', 'Streptoccoci' . 'Proteus', 'Shigella', 'Salmonella', 'V. cholera', 'E. coli', 'C. neoformans', 'Cardinella vaginalis', 'Haemophilus', 'Bordotella pertusis', 'Pseudomonas', 'Coliforms', 'Faecal coliforms', 'Enterococcus faecalis', 'Total viable counts-22C', 'Total viable counts-37C', 'Clostridium', 'Others');
        //	Get specimen_types for microbiology
        $labSecId = TestCategory::getTestCatIdByName('microbiology');
        $specTypeIds = DB::select(DB::raw("select distinct(specimen_types.id) as spec_id from testtype_specimentypes" . " join test_types on test_types.id=testtype_specimentypes.test_type_id" . " join specimen_types on testtype_specimentypes.specimen_type_id=specimen_types.id" . "  where test_types.test_category_id=?"), array($labSecId));
        //	Referred out specimen
        $referredSpecimens = DB::select(DB::raw("SELECT specimen_type_id, specimen_types.name as spec, count(specimens.id) as tot," . " facility_id, facilities.name as facility FROM iblis.specimens" . " join referrals on specimens.referral_id=referrals.id" . " join specimen_types on specimen_type_id=specimen_types.id" . " join facilities on referrals.facility_id=facilities.id" . " where referral_id is not null and status=1" . " and time_accepted between ? and ?" . " group by facility_id;"), array($from, $toPlusOne));
        $table = '<!-- URINALYSIS -->
			<div class="col-sm-12">
				<strong>URINE ANALYSIS</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Urine Chemistry</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>&lt;5yrs</th>
							<th>5-14yrs</th>
							<th>&gt;14yrs</th>
						</tr>
					</thead>';
        $urinaId = TestType::getTestTypeIdByTestName('Urinalysis');
        $urinalysis = TestType::find($urinaId);
        $urineChem = TestType::getTestTypeIdByTestName('Urine Chemistry');
        $urineChemistry = TestType::find($urineChem);
        $measures = TestTypeMeasure::where('test_type_id', $urinaId)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tbody>
						<tr>
							<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [$gender], null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, [$gender], null, $from, $toPlusOne)) . '</td>';
        }
        $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, null, null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, null, null, $from, $toPlusOne)) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) + $this->getGroupedTestCounts($urineChemistry, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne)) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            if (in_array($tMeasure->name, ['ph', 'Epithelial cells', 'Pus cells', 'S. haematobium', 'T. vaginalis', 'Yeast cells', 'Red blood cells', 'Bacteria', 'Spermatozoa'])) {
                continue;
            }
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ageRanges as $ageRange) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, null, 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Urine Microscopy</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>&lt;5yrs</th>
							<th>5-14yrs</th>
							<th>&gt;14yrs</th>
						</tr>
					</thead>

					<tbody>
						<tr>
							<td>Totals</td>';
        $urineMic = TestType::getTestTypeIdByTestName('Urine Microscopy');
        $urineMicroscopy = TestType::find($urineMic);
        $measures = TestTypeMeasure::where('test_type_id', $urinaId)->orderBy('measure_id', 'DESC')->get();
        foreach ($sex as $gender) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [$gender], null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, [$gender], null, $from, $toPlusOne)) . '</td>';
        }
        $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, null, null, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, null, null, $from, $toPlusOne)) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . ($this->getGroupedTestCounts($urinalysis, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) + $this->getGroupedTestCounts($urineMicroscopy, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne)) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            if (in_array($tMeasure->name, ['Leucocytes', 'Nitrites', 'Glucose', 'pH', 'Bilirubin', 'Ketones', 'Proteins', 'Blood', 'Urobilinogen Phenlpyruvic acid'])) {
                continue;
            }
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ageRanges as $ageRange) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, null, 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Blood Chemistry</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $bloodChem = TestType::getTestTypeIdByTestName('Blood Sugar');
        $bloodChemistry = TestType::find($bloodChem);
        $measures = TestTypeMeasure::where('test_type_id', $bloodChem)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tr>
							<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($bloodChemistry, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, ['Low', 'Normal', 'High'], null) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>OGTT</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Renal function tests</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $rfts = TestType::getTestTypeIdByTestName('RFTS');
        $rft = TestType::find($rfts);
        $measures = TestTypeMeasure::where('test_type_id', $rfts)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tr>
						<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($rft, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($rft, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($rft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $name = Measure::find($measure->measure_id)->name;
            if ($name == 'Electrolytes') {
                continue;
            }
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Liver Function Tests</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $lfts = TestType::getTestTypeIdByTestName('LFTS');
        $lft = TestType::find($lfts);
        $measures = TestTypeMeasure::where('test_type_id', $lfts)->orderBy('measure_id', 'DESC')->get();
        $table .= '<tr>
						<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($lft, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($lft, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($lft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $name = Measure::find($measure->measure_id)->name;
            if ($name == 'SGOT') {
                $name = 'ASAT (SGOT)';
            }
            if ($name == 'ALAT') {
                $name = 'ASAT (SGPT)';
            }
            if ($name == 'Total Proteins') {
                $name = 'Serum Protein';
            }
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
								<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Gamma GT</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Lipid Profile</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Totals</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr><tr>
							<td>Amylase</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('Serum Amylase'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>Total cholestrol</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('cholestrol'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>Tryglycerides</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('Tryglycerides'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>HDL</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('HDL'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr><tr>
							<td>LDL</td>';
        $tMeasure = Measure::find(Measure::getMeasureIdByName('LDL'));
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
        }
        $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
        foreach ($ranges as $range) {
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range], 1) . '</td>';
        }
        $table .= '</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">CSF Chemistry</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $csf = TestType::getTestTypeIdByTestName('CSF for biochemistry');
        $bioCsf = TestType::find($csf);
        $table .= '<tr>
					<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($bioCsf, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        $measures = TestTypeMeasure::where('test_type_id', $csf)->orderBy('measure_id', 'DESC')->get();
        foreach ($measures as $measure) {
            $name = Measure::find($measure->measure_id)->name;
            $table .= '<tr>
							<td>' . $name . '</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>';
        }
        $table .= '</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Body Fluids</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Totals</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
						</tr>
						<tr>
							<td>Proteins</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Glucose</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Acid phosphatase</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Bence jones protein</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Thyroid Function Tests</th>
							<th colspan="2">No. Exam</th>
							<th colspan="4"> Number positive</th>
						</tr>
						<tr>
							<th>M</th>
							<th>F</th>
							<th>Total</th>
							<th>Low</th>
							<th>Normal</th>
							<th>High</th>
						</tr>
					</thead>
					<tbody>';
        $tfts = TestType::getTestTypeIdByTestName('TFT');
        $tft = TestType::find($tfts);
        $table .= '<tr>
					<td>Totals</td>';
        foreach ($sex as $gender) {
            $table .= '<td>' . $this->getGroupedTestCounts($tft, [$gender], null, $from, $toPlusOne) . '</td>';
        }
        $table .= '<td>' . $this->getGroupedTestCounts($tft, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($tft, [Patient::MALE, Patient::FEMALE], $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        $measures = TestTypeMeasure::where('test_type_id', $tfts)->orderBy('measure_id', 'ASC')->get();
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            $table .= '<tr>
						<td>' . $tMeasure->name . '</td>';
            foreach ($sex as $gender) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, [$gender], null, $from, $toPlusOne, null, null) . '</td>';
            }
            $table .= '<td>' . $this->getTotalTestResults($tMeasure, $sex, null, $from, $toPlusOne, null, 1) . '</td>';
            foreach ($ranges as $range) {
                $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, null, $from, $toPlusOne, [$range]) . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
			</div>
			<!-- URINALYSIS -->
			<!-- PARASITOLOGY -->
			<div class="col-sm-12">
				<strong>PARASITOLOGY</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th colspan="5">Blood Smears</th>
						</tr>
						<tr>
							<th rowspan="2">Malaria</th>
							<th colspan="4">Positive</th>
						</tr>
						<tr>
							<th>Total Done</th>
							<th>&lt;5yrs</th>
							<th>5-14yrs</th>
							<th>&gt;14yrs</th>
						</tr>
					</thead>';
        $bs = TestType::getTestTypeIdByTestName('Bs for mps');
        $bs4mps = TestType::find($bs);
        $table .= '<tbody>
						<tr>
							<td></td>
							<td>' . $this->getGroupedTestCounts($bs4mps, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($bs4mps, null, $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>
						<tr style="text-align:right;">
							<td>Falciparum</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr style="text-align:right;">
							<td>Ovale</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr style="text-align:right;">
							<td>Malariae</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr style="text-align:right;">
							<td>Vivax</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td><strong>Borrelia</strong></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td><strong>Microfilariae</strong></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td><strong>Trypanosomes</strong></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="5"><strong>Genital Smears</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>T. vaginalis</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>S. haematobium</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Yeast cells</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td style="background-color: #CCCCCC;"></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="5"><strong>Spleen/bone marrow</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>L. donovani</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>';
        $stool = TestType::getTestTypeIdByTestName('Stool for O/C');
        $stoolForOc = TestType::find($stool);
        $measures = TestTypeMeasure::where('test_type_id', $stool)->orderBy('measure_id', 'DESC')->get();
        $table .= '<td colspan="5"><strong>Stool</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td>' . $this->getGroupedTestCounts($stoolForOc, null, null, $from, $toPlusOne) . '</td>';
        foreach ($ageRanges as $ageRange) {
            $table .= '<td>' . $this->getGroupedTestCounts($stoolForOc, null, $ageRange, $from, $toPlusOne) . '</td>';
        }
        $table .= '</tr>';
        foreach ($measures as $measure) {
            $tMeasure = Measure::find($measure->measure_id);
            foreach ($tMeasure->measureRanges as $range) {
                if ($range->alphanumeric == 'O#C not seen') {
                    continue;
                }
                $table .= '<tr>
									<td>' . $range->alphanumeric . '</td>';
                $table .= '<td style="background-color: #CCCCCC;"></td>';
                foreach ($ageRanges as $ageRange) {
                    $table .= '<td>' . $this->getTotalTestResults($tMeasure, null, $ageRange, $from, $toPlusOne, [$range->alphanumeric]) . '</td>';
                }
                $table .= '</tr>';
            }
        }
        $table .= '<tr>
							<td colspan="5"><strong>Lavages</strong></td>
						</tr>
						<tr>
							<td>Total</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
			</div>
			<!-- PARASITOLOGY -->
			<!-- BACTERIOLOGY -->
			<div class="col-sm-12">
				<strong>BACTERIOLOGY</strong>
				<div class="row">
					<div class="col-sm-4">
						<table class="table table-condensed report-table-border" style="padding-right:5px;">
							<tbody style="text-align:right;">
								<tr>
									<td>Total examinations done</td>
									<td></td>
								</tr>';
        foreach ($specTypeIds as $key) {
            if (in_array(SpecimenType::find($key->spec_id)->name, ['Aspirate', 'Pleural Tap', 'Synovial Fluid', 'Sputum', 'Ascitic Tap', 'S***n', 'Skin'])) {
                continue;
            }
            $totalCount = DB::select(DB::raw("select count(specimen_id) as per_spec_count from tests" . " join specimens on tests.specimen_id=specimens.id" . " join test_types on tests.test_type_id=test_types.id" . " where specimens.specimen_type_id=?" . " and test_types.test_category_id=?" . " and test_status_id in(?,?)" . " and tests.time_created BETWEEN ? and ?;"), [$key->spec_id, $labSecId, Test::COMPLETED, Test::VERIFIED, $from, $toPlusOne]);
            $table .= '<tr>
									<td>' . SpecimenType::find($key->spec_id)->name . '</td>
									<td>' . $totalCount[0]->per_spec_count . '</td>
								</tr>';
        }
        $table .= '</tr>
									<td>Rectal swab</td>
									<td>0</td>
								</tr>
								</tr>
									<td>Water</td>
									<td>0</td>
								</tr>
								</tr>
									<td>Food</td>
									<td>0</td>
								</tr>
								</tr>
									<td>Other (specify)....</td>
									<td></td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="col-sm-8">
						<table class="table table-condensed report-table-border">
							<tbody>
								<tr>
									<td colspan="3">Drugs</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="3">Sensitivity (Total done)</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="3">Resistance per drug</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="3">KOH Preparations</td>
									<td>Fungi</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td colspan="2">Others (specify)</td>
								</tr>
								<tr>
									<td>Others</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td>...</td>
									<td></td>
								</tr>
								<tr>
									<td>Total</td>
									<td></td>
									<td></td>
									<td></td>
									<td></td>
									<td>...</td>
									<td></td>
								</tr>
							</tbody>
						</table>
						<p>SPUTUM</p>
						<table class="table table-condensed report-table-border">
							<tbody>
								<tr>
									<td></td>
									<td>Total</td>
									<td>Positive</td>
								</tr>
								<tr>
									<td>TB new suspects</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td>Followup</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td>TB smears</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td>MDR</td>
									<td></td>
									<td></td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<table class="table table-condensed report-table-border">
					<tbody>
						<tr><td></td>';
        foreach ($specimen_types as $spec) {
            $table .= '<td>' . $spec . '</td>';
        }
        $table .= '</tr>';
        foreach ($isolates as $isolate) {
            $table .= '<tr>
							<td>' . $isolate . '</td>';
            foreach ($specimen_types as $spec) {
                $table .= '<td>' . TestResult::microCounts($isolate, $spec, $from, $toPlusOne)[0]->total . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '<tr>
							<td colspan="11">Specify species of each isolate</td>
						</tr>
					</tbody>
				</table>
				<div class="row">
					<div class="col-sm-12">
						<strong>HEMATOLOGY REPORT</strong>
						<table class="table table-condensed report-table-border">
							<thead>
								<tr>
									<th colspan="2">Type of examination</th>
									<th>No. of Tests</th>
									<th>Controls</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td colspan="2">Full blood count</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Full haemogram')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Manual WBC counts</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Peripheral blood films</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Erythrocyte Sedimentation rate</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('ESR')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Sickling test</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Sickling test')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">HB electrophoresis</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">G6PD screening</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Bleeding time</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Bleeding time test')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Clotting time</td>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Clotting time test')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Prothrombin test</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Partial prothrombin time</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td colspan="2">Bone Marrow Aspirates</td>
									<td></td>
									<td style="background-color: #CCCCCC;"></td>
								</tr>
								<tr>
									<td colspan="2">Reticulocyte counts</td>
									<td></td>
									<td style="background-color: #CCCCCC;"></td>
								</tr>
								<tr>
									<td colspan="2">Others</td>
									<td></td>
									<td style="background-color: #CCCCCC;"></td>
								</tr>
								<tr>
									<td rowspan="2">Haemoglobin</td>
									<td>No. Tests</td>
									<td>&lt;5</td>
									<td>5&lt;Hb&lt;10</td>
								</tr>
								<tr>
									<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('HB')), null, null, $from, $toPlusOne) . '</td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="2">CD4/CD8</td>
									<td>No. Tests</td>
									<td>&lt;200</td>
									<td>200-350</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="2">CD4%</td>
									<td>No. Tests</td>
									<td>&lt;25%</td>
									<td>&gt;25%</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td></td>
								</tr>
								<tr>
									<td rowspan="2">Peripheral Blood Films</td>
									<td>Parasites</td>
									<td colspan="2">No. smears with inclusions</td>
								</tr>
								<tr>
									<td></td>
									<td></td>
									<td colspan="2"></td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="col-sm-12">
						<strong>BLOOD GROUPING AND CROSSMATCH REPORT</strong>
						<div class="row">
							<div class="col-sm-6">
								<table class="table table-condensed report-table-border">
									<tbody>
										<tr>
											<td>Total groupings done</td>
											<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('GXM')), null, null, $from, $toPlusOne) . '</td>
										</tr>
										<tr>
											<td>Blood units grouped</td>
											<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Blood Grouping')), null, null, $from, $toPlusOne) . '</td>
										</tr>
										<tr>
											<td>Total transfusion reactions</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood cross matches</td>
											<td>' . $this->getGroupedTestCounts(TestType::find(TestType::getTestTypeIdByTestName('Cross Match')), null, null, $from, $toPlusOne) . '</td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="col-sm-6">
								<strong>Blood safety</strong>
								<table class="table table-condensed report-table-border">
									<tbody>
										<tr>
											<td>Measure</td>
											<td>Number</td>
										</tr>
										<tr>
											<td>A. Blood units collected from regional blood transfusion centres</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units collected from other centres and screened at health facility</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units screened at health facility that are HIV positive</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units screened at health facility that are Hepatitis positive</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units positive for other infections</td>
											<td></td>
										</tr>
										<tr>
											<td>Blood units transfered</td>
											<td></td>
										</tr>
										<tr>
											<td rowspan="2">General remarks .............................</td>
											<td rowspan="2"></td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- BACTERIOLOGY -->
			<!-- HISTOLOGY AND CYTOLOGY -->
			<div class="col-sm-12">
				<strong>HISTOLOGY AND CYTOLOGY REPORT</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2"></th>
							<th rowspan="2">Total</th>
							<th rowspan="2">Normal</th>
							<th rowspan="2">Infective</th>
							<th colspan="2">Non-infective</th>
							<th colspan="3">Positive findings</th>
						</tr>
						<tr>
							<th>Benign</th>
							<th>Malignant</th>
							<th>&lt;5 yrs</th>
							<th>5-14 yrs</th>
							<th>&gt;14 yrs</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td colspan="9">SMEARS</td>
						</tr>
						<tr>
							<td>Pap Smear</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Tissue Impressions</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="9">TISSUE ASPIRATES (FNA)</td>
						</tr>
						<tr>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="9">FLUID CYTOLOGY</td>
						</tr>
						<tr>
							<td>Ascitic fluid</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>CSF</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Pleural fluid</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td colspan="9">TISSUE HISTOLOGY</td>
						</tr>
						<tr>
							<td>Cervix</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Prostrate</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Breast</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Ovarian cyst</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Fibroids</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Lymph nodes</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<strong>SEROLOGY REPORT</strong>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th rowspan="2">Serological test</th>
							<th colspan="2">Total</th>
							<th colspan="2">&lt;5 yrs</th>
							<th colspan="2">5-14 yrs</th>
							<th colspan="2">&gt;14 yrs</th>
						</tr>
						<tr>
							<th>Tested</th>
							<th>No. +ve</th>
							<th>Tested</th>
							<th>No. +ve</th>
							<th>Tested</th>
							<th>No. +ve</th>
							<th>Tested</th>
							<th>No. +ve</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Rapid Plasma Region</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'), $ageRange)) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('VDRL'), $ageRange) as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>TPHA</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>ASO Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Asot'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>HIV Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Rapid HIV test'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Widal Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Widal'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Brucella Test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Brucella'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Rheumatoid Factor Tests</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('RF'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Cryptococcal Antigen</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Helicobacter pylori test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('H pylori'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Hepatitis A test</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>
							<td>0</td>';
        $table .= '</tr>
						<tr>
							<td>Hepatitis B test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis B'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Hepatitis C test</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Hepatitis C'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td>0</td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td>' . $count->positive . '</td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Viral Load</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load'))) == 0) {
            $table .= '<td>0</td>
									<td style="background-color: #CCCCCC;"></td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td style="background-color: #CCCCCC;"></td>';
            }
        }
        foreach ($ageRanges as $ageRange) {
            $data = TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('Viral load'), $ageRange);
            if (count($data) == 0) {
                $table .= '<td>0</td>
									<td style="background-color: #CCCCCC;"></td>';
            } else {
                foreach ($data as $count) {
                    $table .= '<td>' . $count->total . '</td>
										<td style="background-color: #CCCCCC;"></td>';
                }
            }
        }
        $table .= '</tr>
						<tr>
							<td>Formal Gel Test</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Other Tests</td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<br />
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th>Dried Blood Spots</th>
							<th>Tested</th>
							<th># +ve</th>
							<th>Discrepant</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Early Infant Diagnosis of HIV</td>';
        if (count(TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('eid of hiv'))) == 0) {
            $table .= '<td>0</td>
									<td>0</td>';
        } else {
            foreach (TestType::getPrevalenceCounts($from, $to, TestType::getTestTypeIdByTestName('eid of hiv')) as $count) {
                if (count($count) == 0) {
                    $count->total = 0;
                    $count->positive = 0;
                }
                $table .= '<td>' . $count->total . '</td>
									<td>' . $count->positive . '</td>';
            }
        }
        $table .= '<td></td>
						</tr>
						<tr>
							<td>Quality Assurance</td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Discordant couples</td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
						<tr>
							<td>Others</td>
							<td></td>
							<td></td>
							<td></td>
						</tr>
					</tbody>
				</table>
				<p><strong>Specimen referral to higher levels</strong></p>
				<table class="table table-condensed report-table-border">
					<thead>
						<tr>
							<th>Specimen</th>
							<th>No</th>
							<th>Sent to</th>
							<th>No. of Reports/results received</th>
						</tr>
					</thead>
					<tbody>';
        if ($referredSpecimens) {
            foreach ($referredSpecimens as $referredSpecimen) {
                $table .= '<tr>
								<td>' . $referredSpecimen->spec . '</td>
								<td>' . $referredSpecimen->tot . '</td>
								<td>' . $referredSpecimen->facility . '</td>
								<td></td>
							</tr>';
            }
        } else {
            $table .= '<tr>
								<td colspan="4">' . trans('messages.no-records-found') . '</td>
							</tr>';
        }
        $table .= '</tbody>
				</table>
			</div>
			<!-- HISTOLOGY AND CYTOLOGY -->';
        if (Input::has('excel')) {
            $date = date("Ymdhi");
            $fileName = "MOH706_" . $date . ".xls";
            $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName);
            $content = $table;
            return Response::make($content, 200, $headers);
        } else {
            //return View::make('reports.moh.706');
            return View::make('reports.moh.index')->with('table', $table)->with('from', $from)->with('end', $end);
        }
    }
Пример #19
0
 public function run()
 {
     /* Users table */
     $usersData = array(array("username" => "administrator", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "kBLIS Administrator", "designation" => "Programmer"), array("username" => "external", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "External System User", "designation" => "Administrator", "image" => "/i/users/user-2.jpg"), array("username" => "lmorena", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "L. Morena", "designation" => "Lab Technologist", "image" => "/i/users/user-3.png"), array("username" => "abumeyang", "password" => Hash::make("password"), "email" => "*****@*****.**", "name" => "A. Abumeyang", "designation" => "Doctor"));
     foreach ($usersData as $user) {
         $users[] = User::create($user);
     }
     $this->command->info('users seeded');
     /* Specimen Types table */
     $specTypesData = array(array("name" => "Ascitic Tap"), array("name" => "Aspirate"), array("name" => "CSF"), array("name" => "Dried Blood Spot"), array("name" => "High Vaginal Swab"), array("name" => "Nasal Swab"), array("name" => "Plasma"), array("name" => "Plasma EDTA"), array("name" => "Pleural Tap"), array("name" => "Pus Swab"), array("name" => "Rectal Swab"), array("name" => "S***n"), array("name" => "Serum"), array("name" => "Skin"), array("name" => "Sputum"), array("name" => "Stool"), array("name" => "Synovial Fluid"), array("name" => "Throat Swab"), array("name" => "Urethral Smear"), array("name" => "Urine"), array("name" => "Vaginal Smear"), array("name" => "Water"), array("name" => "Whole Blood"));
     foreach ($specTypesData as $specimenType) {
         $specTypes[] = SpecimenType::create($specimenType);
     }
     $this->command->info('specimen_types seeded');
     /* Test Categories table - These map on to the lab sections */
     $test_categories = TestCategory::create(array("name" => "PARASITOLOGY", "description" => ""));
     $lab_section_microbiology = TestCategory::create(array("name" => "MICROBIOLOGY", "description" => ""));
     $this->command->info('test_categories seeded');
     /* Measure Types */
     $measureTypes = array(array("id" => "1", "name" => "Numeric Range"), array("id" => "2", "name" => "Alphanumeric Values"), array("id" => "3", "name" => "Autocomplete"), array("id" => "4", "name" => "Free Text"));
     foreach ($measureTypes as $measureType) {
         MeasureType::create($measureType);
     }
     $this->command->info('measure_types seeded');
     /* Measures table */
     $measureBSforMPS = Measure::create(array("measure_type_id" => "2", "name" => "BS for mps", "unit" => ""));
     $measure1 = Measure::create(array("measure_type_id" => "2", "name" => "Grams stain", "unit" => ""));
     $measure2 = Measure::create(array("measure_type_id" => "2", "name" => "SERUM AMYLASE", "unit" => ""));
     $measure3 = Measure::create(array("measure_type_id" => "2", "name" => "calcium", "unit" => ""));
     $measure4 = Measure::create(array("measure_type_id" => "2", "name" => "SGOT", "unit" => ""));
     $measure5 = Measure::create(array("measure_type_id" => "2", "name" => "Indirect COOMBS test", "unit" => ""));
     $measure6 = Measure::create(array("measure_type_id" => "2", "name" => "Direct COOMBS test", "unit" => ""));
     $measure7 = Measure::create(array("measure_type_id" => "2", "name" => "Du test", "unit" => ""));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "No mps seen", "interpretation" => "Negative"));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "+", "interpretation" => "Positive"));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "++", "interpretation" => "Positive"));
     MeasureRange::create(array("measure_id" => $measureBSforMPS->id, "alphanumeric" => "+++", "interpretation" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure1->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure1->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure2->id, "alphanumeric" => "Low"));
     MeasureRange::create(array("measure_id" => $measure2->id, "alphanumeric" => "High"));
     MeasureRange::create(array("measure_id" => $measure2->id, "alphanumeric" => "Normal"));
     MeasureRange::create(array("measure_id" => $measure3->id, "alphanumeric" => "High"));
     MeasureRange::create(array("measure_id" => $measure3->id, "alphanumeric" => "Low"));
     MeasureRange::create(array("measure_id" => $measure3->id, "alphanumeric" => "Normal"));
     MeasureRange::create(array("measure_id" => $measure4->id, "alphanumeric" => "High"));
     MeasureRange::create(array("measure_id" => $measure4->id, "alphanumeric" => "Low"));
     MeasureRange::create(array("measure_id" => $measure4->id, "alphanumeric" => "Normal"));
     MeasureRange::create(array("measure_id" => $measure5->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure5->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure6->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure6->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure7->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure7->id, "alphanumeric" => "Negative"));
     $measures = array(array("measure_type_id" => "1", "name" => "URIC ACID", "unit" => "mg/dl"), array("measure_type_id" => "4", "name" => "CSF for biochemistry", "unit" => ""), array("measure_type_id" => "4", "name" => "PSA", "unit" => ""), array("measure_type_id" => "1", "name" => "Total", "unit" => "mg/dl"), array("measure_type_id" => "1", "name" => "Alkaline Phosphate", "unit" => "u/l"), array("measure_type_id" => "1", "name" => "Direct", "unit" => "mg/dl"), array("measure_type_id" => "1", "name" => "Total Proteins", "unit" => ""), array("measure_type_id" => "4", "name" => "LFTS", "unit" => "NULL"), array("measure_type_id" => "1", "name" => "Chloride", "unit" => "mmol/l"), array("measure_type_id" => "1", "name" => "Potassium", "unit" => "mmol/l"), array("measure_type_id" => "1", "name" => "Sodium", "unit" => "mmol/l"), array("measure_type_id" => "4", "name" => "Electrolytes", "unit" => ""), array("measure_type_id" => "1", "name" => "Creatinine", "unit" => "mg/dl"), array("measure_type_id" => "1", "name" => "Urea", "unit" => "mg/dl"), array("measure_type_id" => "4", "name" => "RFTS", "unit" => ""), array("measure_type_id" => "4", "name" => "TFT", "unit" => ""));
     foreach ($measures as $measure) {
         Measure::create($measure);
     }
     $measureGXM = Measure::create(array("measure_type_id" => "4", "name" => "GXM", "unit" => ""));
     $measureBG = Measure::create(array("measure_type_id" => "2", "name" => "Blood Grouping", "unit" => ""));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "O-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "O+"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "A-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "A+"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "B-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "B+"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "AB-"));
     MeasureRange::create(array("measure_id" => $measureBG->id, "alphanumeric" => "AB+"));
     $measureHB = Measure::create(array("measure_type_id" => Measure::NUMERIC, "name" => "HB", "unit" => "g/dL"));
     $measuresUrinalysisData = array(array("measure_type_id" => "4", "name" => "Urine microscopy", "unit" => ""), array("measure_type_id" => "4", "name" => "Pus cells", "unit" => ""), array("measure_type_id" => "4", "name" => "S. haematobium", "unit" => ""), array("measure_type_id" => "4", "name" => "T. vaginalis", "unit" => ""), array("measure_type_id" => "4", "name" => "Yeast cells", "unit" => ""), array("measure_type_id" => "4", "name" => "Red blood cells", "unit" => ""), array("measure_type_id" => "4", "name" => "Bacteria", "unit" => ""), array("measure_type_id" => "4", "name" => "Spermatozoa", "unit" => ""), array("measure_type_id" => "4", "name" => "Epithelial cells", "unit" => ""), array("measure_type_id" => "4", "name" => "ph", "unit" => ""), array("measure_type_id" => "4", "name" => "Urine chemistry", "unit" => ""), array("measure_type_id" => "4", "name" => "Glucose", "unit" => ""), array("measure_type_id" => "4", "name" => "Ketones", "unit" => ""), array("measure_type_id" => "4", "name" => "Proteins", "unit" => ""), array("measure_type_id" => "4", "name" => "Blood", "unit" => ""), array("measure_type_id" => "4", "name" => "Bilirubin", "unit" => ""), array("measure_type_id" => "4", "name" => "Urobilinogen Phenlpyruvic acid", "unit" => ""), array("measure_type_id" => "4", "name" => "pH", "unit" => ""));
     foreach ($measuresUrinalysisData as $measureU) {
         $measuresUrinalysis[] = Measure::create($measureU);
     }
     $measuresWBCData = array(array("measure_type_id" => Measure::NUMERIC, "name" => "WBC", "unit" => "x10³/µL"), array("measure_type_id" => Measure::NUMERIC, "name" => "Lym", "unit" => "L"), array("measure_type_id" => Measure::NUMERIC, "name" => "Mon", "unit" => "*"), array("measure_type_id" => Measure::NUMERIC, "name" => "Neu", "unit" => "*"), array("measure_type_id" => Measure::NUMERIC, "name" => "Eos", "unit" => ""), array("measure_type_id" => Measure::NUMERIC, "name" => "Baso", "unit" => ""));
     foreach ($measuresWBCData as $value) {
         $measuresWBC[] = Measure::create($value);
     }
     $measureRangesWBC = array(array("measure_id" => $measuresWBC[0]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 4, "range_upper" => 11), array("measure_id" => $measuresWBC[1]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 1.5, "range_upper" => 4), array("measure_id" => $measuresWBC[2]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 0.1, "range_upper" => 9), array("measure_id" => $measuresWBC[3]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 2.5, "range_upper" => 7), array("measure_id" => $measuresWBC[4]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 0, "range_upper" => 6), array("measure_id" => $measuresWBC[5]->id, "age_min" => 0, "age_max" => 100, "gender" => MeasureRange::BOTH, "range_lower" => 0, "range_upper" => 2));
     foreach ($measureRangesWBC as $value) {
         MeasureRange::create($value);
     }
     $this->command->info('measures seeded');
     /* Test Types table */
     $testTypeBS = TestType::create(array("name" => "BS for mps", "test_category_id" => $test_categories->id, "orderable_test" => 1));
     $testTypeStoolCS = TestType::create(array("name" => "Stool for C/S", "test_category_id" => $lab_section_microbiology->id));
     $testTypeGXM = TestType::create(array("name" => "GXM", "test_category_id" => $test_categories->id));
     $testTypeHB = TestType::create(array("name" => "HB", "test_category_id" => $test_categories->id, "orderable_test" => 1));
     $testTypeUrinalysis = TestType::create(array("name" => "Urinalysis", "test_category_id" => $test_categories->id));
     $testTypeWBC = TestType::create(array("name" => "WBC", "test_category_id" => $test_categories->id));
     $this->command->info('test_types seeded');
     /* TestType Measure table */
     TestTypeMeasure::create(array("test_type_id" => $testTypeBS->id, "measure_id" => $measureBSforMPS->id));
     TestTypeMeasure::create(array("test_type_id" => $testTypeGXM->id, "measure_id" => $measureGXM->id));
     TestTypeMeasure::create(array("test_type_id" => $testTypeGXM->id, "measure_id" => $measureBG->id));
     TestTypeMeasure::create(array("test_type_id" => $testTypeHB->id, "measure_id" => $measureHB->id));
     foreach ($measuresUrinalysis as $value) {
         TestTypeMeasure::create(array("test_type_id" => $testTypeUrinalysis->id, "measure_id" => $value->id));
     }
     foreach ($measuresWBC as $value) {
         TestTypeMeasure::create(array("test_type_id" => $testTypeWBC->id, "measure_id" => $value->id));
     }
     $this->command->info('testtype_measures seeded');
     /* testtype_specimentypes table */
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeBS->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeGXM->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[6]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[7]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeHB->id, "specimen_type_id" => $specTypes[12]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeUrinalysis->id, "specimen_type_id" => $specTypes[19]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeUrinalysis->id, "specimen_type_id" => $specTypes[20]->id));
     DB::table('testtype_specimentypes')->insert(array("test_type_id" => $testTypeWBC->id, "specimen_type_id" => $specTypes[count($specTypes) - 1]->id));
     $this->command->info('testtype_specimentypes seeded');
     /* Patients table */
     $patients_array = array(array("name" => "Jam Felicia", "email" => "*****@*****.**", "patient_number" => "1002", "dob" => "2000-01-01", "gender" => "1", "created_by" => "2"), array("name" => "Emma Wallace", "email" => "*****@*****.**", "patient_number" => "1003", "dob" => "1990-03-01", "gender" => "1", "created_by" => "2"), array("name" => "Jack Tee", "email" => "*****@*****.**", "patient_number" => "1004", "dob" => "1999-12-18", "gender" => "0", "created_by" => "1"), array("name" => "Hu Jintao", "email" => "*****@*****.**", "patient_number" => "1005", "dob" => "1956-10-28", "gender" => "0", "created_by" => "2"), array("name" => "Lance Opiyo", "email" => "*****@*****.**", "patient_number" => "2150", "dob" => "2012-01-01", "gender" => "0", "created_by" => "1"));
     foreach ($patients_array as $pat) {
         $patients[] = Patient::create($pat);
     }
     $this->command->info('patients seeded');
     /* Test Phase table */
     $test_phases = array(array("id" => "1", "name" => "Pre-Analytical"), array("id" => "2", "name" => "Analytical"), array("id" => "3", "name" => "Post-Analytical"));
     foreach ($test_phases as $test_phase) {
         TestPhase::create($test_phase);
     }
     $this->command->info('test_phases seeded');
     /* Test Status table */
     $test_statuses = array(array("id" => "1", "name" => "not-received", "test_phase_id" => "1"), array("id" => "2", "name" => "pending", "test_phase_id" => "1"), array("id" => "3", "name" => "started", "test_phase_id" => "2"), array("id" => "4", "name" => "completed", "test_phase_id" => "3"), array("id" => "5", "name" => "verified", "test_phase_id" => "3"));
     foreach ($test_statuses as $test_status) {
         TestStatus::create($test_status);
     }
     $this->command->info('test_statuses seeded');
     /* Specimen Status table */
     $specimen_statuses = array(array("id" => "1", "name" => "specimen-not-collected"), array("id" => "2", "name" => "specimen-accepted"), array("id" => "3", "name" => "specimen-rejected"));
     foreach ($specimen_statuses as $specimen_status) {
         SpecimenStatus::create($specimen_status);
     }
     $this->command->info('specimen_statuses seeded');
     /* Visits table */
     for ($i = 0; $i < 7; $i++) {
         $visits[] = Visit::create(array("patient_id" => $patients[rand(0, count($patients) - 1)]->id));
     }
     $this->command->info('visits seeded');
     /* Rejection Reasons table */
     $rejection_reasons_array = array(array("reason" => "Poorly labelled"), array("reason" => "Over saturation"), array("reason" => "Insufficient Sample"), array("reason" => "Scattered"), array("reason" => "Clotted Blood"), array("reason" => "Two layered spots"), array("reason" => "Serum rings"), array("reason" => "Scratched"), array("reason" => "Haemolysis"), array("reason" => "Spots that cannot elute"), array("reason" => "Leaking"), array("reason" => "Broken Sample Container"), array("reason" => "Mismatched sample and form labelling"), array("reason" => "Missing Labels on container and tracking form"), array("reason" => "Empty Container"), array("reason" => "Samples without tracking forms"), array("reason" => "Poor transport"), array("reason" => "Lipaemic"), array("reason" => "Wrong container/Anticoagulant"), array("reason" => "Request form without samples"), array("reason" => "Missing collection date on specimen / request form."), array("reason" => "Name and signature of requester missing"), array("reason" => "Mismatched information on request form and specimen container."), array("reason" => "Request form contaminated with specimen"), array("reason" => "Duplicate specimen received"), array("reason" => "Delay between specimen collection and arrival in the laboratory"), array("reason" => "Inappropriate specimen packing"), array("reason" => "Inappropriate specimen for the test"), array("reason" => "Inappropriate test for the clinical condition"), array("reason" => "No Label"), array("reason" => "Leaking"), array("reason" => "No Sample in the Container"), array("reason" => "No Request Form"), array("reason" => "Missing Information Required"));
     foreach ($rejection_reasons_array as $rejection_reason) {
         $rejection_reasons[] = RejectionReason::create($rejection_reason);
     }
     $this->command->info('rejection_reasons seeded');
     /* Specimen table */
     $this->command->info('specimens seeded');
     $now = new DateTime();
     /* Test table */
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::NOT_RECEIVED, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::NOT_RECEIVED, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeHB->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeGXM->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "created_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Dr. Abou Meyang"));
     $test_gxm_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeGXM->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Perfect match.", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Dr. Abou Meyang", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT12M8S'))->format('Y-m-d H:i:s')));
     $test_hb_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeHB->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Do nothing!", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Genghiz Khan", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT5M23S'))->format('Y-m-d H:i:s')));
     $tests_accepted_started = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeGXM->id, "specimen_id" => $this->createSpecimen(Test::STARTED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::STARTED, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id, "time_started" => $now->format('Y-m-d H:i:s')));
     $tests_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Positive", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Ariel Smith", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT7M34S'))->format('Y-m-d H:i:s')));
     $tests_accepted_verified = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::VERIFIED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Very high concentration of parasites.", "test_status_id" => Test::VERIFIED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "verified_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Genghiz Khan", "time_started" => $now, "time_completed" => $now->add(new DateInterval('PT5M17S'))->format('Y-m-d H:i:s'), "time_verified" => $now->add(new DateInterval('PT112M33S'))->format('Y-m-d H:i:s')));
     $tests_rejected_pending = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::REJECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id, $users[rand(0, count($users) - 1)]->id, $rejection_reasons[rand(0, count($rejection_reasons) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id, "time_started" => $now->format('Y-m-d H:i:s')));
     //  WBC Started
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeWBC->id, "specimen_id" => $this->createSpecimen(Test::STARTED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Fred Astaire", "created_by" => $users[rand(0, count($users) - 1)]->id));
     $tests_rejected_started = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::STARTED, Specimen::REJECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id, $users[rand(0, count($users) - 1)]->id, $rejection_reasons[rand(0, count($rejection_reasons) - 1)]->id), "test_status_id" => Test::STARTED, "created_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Bony Em", "time_started" => $now->format('Y-m-d H:i:s')));
     $tests_rejected_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeBS->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::REJECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id, $users[rand(0, count($users) - 1)]->id, $rejection_reasons[rand(0, count($rejection_reasons) - 1)]->id), "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Ed Buttler", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT30M4S'))->format('Y-m-d H:i:s')));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeUrinalysis->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeWBC->id, "specimen_id" => $this->createSpecimen(Test::PENDING, Specimen::NOT_COLLECTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "test_status_id" => Test::PENDING, "requested_by" => "Dr. Abou Meyang", "created_by" => $users[rand(0, count($users) - 1)]->id));
     $test_urinalysis_accepted_completed = Test::create(array("visit_id" => $visits[rand(0, count($visits) - 1)]->id, "test_type_id" => $testTypeUrinalysis->id, "specimen_id" => $this->createSpecimen(Test::COMPLETED, Specimen::ACCEPTED, SpecimenType::all()->last()->id, $users[rand(0, count($users) - 1)]->id), "interpretation" => "Whats this !!!! ###%%% ^ *() /", "test_status_id" => Test::COMPLETED, "created_by" => $users[rand(0, count($users) - 1)]->id, "tested_by" => $users[rand(0, count($users) - 1)]->id, "requested_by" => "Dr. Abou Meyang", "time_started" => $now->format('Y-m-d H:i:s'), "time_completed" => $now->add(new DateInterval('PT12M8S'))->format('Y-m-d H:i:s'), "external_id" => 596699));
     $this->command->info('tests seeded');
     /* Test Results table */
     $testResults = array(array("test_id" => $tests_accepted_verified->id, "measure_id" => $measureBSforMPS->id, "result" => "+++"), array("test_id" => $tests_accepted_completed->id, "measure_id" => $measureBSforMPS->id, "result" => "++"), array("test_id" => $test_gxm_accepted_completed->id, "measure_id" => $measureGXM->id, "result" => "COMPATIBLE WITH 061832914 B/G A POS.EXPIRY19/8/14"), array("test_id" => $test_gxm_accepted_completed->id, "measure_id" => $measureBG->id, "result" => "A+"), array("test_id" => $test_hb_accepted_completed->id, "measure_id" => $measureHB->id, "result" => "13.7"), array("test_id" => $tests_rejected_completed->id, "measure_id" => $measureBSforMPS->id, "result" => "No mps seen"));
     foreach ($measuresUrinalysis as $key => $measure) {
         $testResults[] = array("test_id" => $test_urinalysis_accepted_completed->id, "measure_id" => $measure->id, "result" => $key . "50");
     }
     foreach ($testResults as $testResult) {
         TestResult::create($testResult);
     }
     $this->command->info('test results seeded');
     /* Permissions table */
     $permissions = array(array("name" => "view_names", "display_name" => "Can view patient names"), array("name" => "manage_patients", "display_name" => "Can add patients"), array("name" => "receive_external_test", "display_name" => "Can receive test requests"), array("name" => "request_test", "display_name" => "Can request new test"), array("name" => "accept_test_specimen", "display_name" => "Can accept test specimen"), array("name" => "reject_test_specimen", "display_name" => "Can reject test specimen"), array("name" => "change_test_specimen", "display_name" => "Can change test specimen"), array("name" => "start_test", "display_name" => "Can start tests"), array("name" => "enter_test_results", "display_name" => "Can enter tests results"), array("name" => "edit_test_results", "display_name" => "Can edit test results"), array("name" => "verify_test_results", "display_name" => "Can verify test results"), array("name" => "send_results_to_external_system", "display_name" => "Can send test results to external systems"), array("name" => "refer_specimens", "display_name" => "Can refer specimens"), array("name" => "manage_users", "display_name" => "Can manage users"), array("name" => "manage_test_catalog", "display_name" => "Can manage test catalog"), array("name" => "manage_lab_configurations", "display_name" => "Can manage lab configurations"), array("name" => "view_reports", "display_name" => "Can view reports"), array("name" => "manage_inventory", "display_name" => "Can manage inventory"), array("name" => "request_topup", "display_name" => "Can request top-up"), array("name" => "manage_qc", "display_name" => "Can manage Quality Control"));
     foreach ($permissions as $permission) {
         Permission::create($permission);
     }
     $this->command->info('Permissions table seeded');
     /* Roles table */
     $roles = array(array("name" => "Superadmin"), array("name" => "Technologist"), array("name" => "Receptionist"));
     foreach ($roles as $role) {
         Role::create($role);
     }
     $this->command->info('Roles table seeded');
     $user1 = User::find(1);
     $role1 = Role::find(1);
     $permissions = Permission::all();
     //Assign all permissions to role administrator
     foreach ($permissions as $permission) {
         $role1->attachPermission($permission);
     }
     //Assign role Administrator to user 1 administrator
     $user1->attachRole($role1);
     /* Instruments table */
     $instrumentsData = array("name" => "Celltac F Mek 8222", "description" => "Automatic analyzer with 22 parameters and WBC 5 part diff Hematology Analyzer", "driver_name" => "KBLIS\\Plugins\\CelltacFMachine", "ip" => "192.168.1.12", "hostname" => "HEMASERVER");
     $instrument = Instrument::create($instrumentsData);
     $instrument->testTypes()->attach(array($testTypeWBC->id));
     $this->command->info('Instruments table seeded');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596699,"parentLabNo":0,"requestingClinician":"frankenstein Dr",
     "investigation":"Urinalysis","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596700,"parentLabNo":596699,"requestingClinician":"frankenstein Dr",
     "investigation":"Urine microscopy","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596701,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Pus cells","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596702,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"S. haematobium","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596703,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"T. vaginalis","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596704,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Yeast cells","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596705,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Red blood cells","requestDate":"2014-10-14 10:20:35","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596706,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Bacteria","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596707,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Spermatozoa","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596708,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"Epithelial cells","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596709,"parentLabNo":596700,"requestingClinician":"frankenstein Dr",
     "investigation":"ph","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596710,"parentLabNo":596699,"requestingClinician":"frankenstein Dr",
     "investigation":"Urine chemistry","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596711,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Glucose","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596712,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Ketones","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596713,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Proteins","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596714,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Blood","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596715,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Bilirubin","requestDate":"2014-10-14 10:20:36","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596716,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"Urobilinogen Phenlpyruvic acid","requestDate":"2014-10-14 10:20:37","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     $labRequestUrinalysis[] = json_decode('{"cost":null,"receiptNumber":null,"receiptType":null,"labNo":596717,"parentLabNo":596710,"requestingClinician":"frankenstein Dr",
     "investigation":"pH","requestDate":"2014-10-14 10:20:37","orderStage":"ip","patientVisitNumber":643660,"patient":{"id":326983,
     "fullName":"Macau Macau","dateOfBirth":"1996-10-09 00:00:00","gender":"Female"},"address":{"address":null,"postalCode":null,"phoneNumber":"","city":null}}');
     for ($i = 0; $i < count($labRequestUrinalysis); $i++) {
         $dumper = new ExternalDump();
         $dumper->lab_no = $labRequestUrinalysis[$i]->labNo;
         $dumper->parent_lab_no = $labRequestUrinalysis[$i]->parentLabNo;
         $dumper->test_id = $i == 0 ? $test_urinalysis_accepted_completed->id : null;
         $dumper->requesting_clinician = $labRequestUrinalysis[$i]->requestingClinician;
         $dumper->investigation = $labRequestUrinalysis[$i]->investigation;
         $dumper->provisional_diagnosis = '';
         $dumper->request_date = $labRequestUrinalysis[$i]->requestDate;
         $dumper->order_stage = $labRequestUrinalysis[$i]->orderStage;
         $dumper->patient_visit_number = $labRequestUrinalysis[$i]->patientVisitNumber;
         $dumper->patient_id = $labRequestUrinalysis[$i]->patient->id;
         $dumper->full_name = $labRequestUrinalysis[$i]->patient->fullName;
         $dumper->dob = $labRequestUrinalysis[$i]->patient->dateOfBirth;
         $dumper->gender = $labRequestUrinalysis[$i]->patient->gender;
         $dumper->address = $labRequestUrinalysis[$i]->address->address;
         $dumper->postal_code = '';
         $dumper->phone_number = $labRequestUrinalysis[$i]->address->phoneNumber;
         $dumper->city = $labRequestUrinalysis[$i]->address->city;
         $dumper->cost = $labRequestUrinalysis[$i]->cost;
         $dumper->receipt_number = $labRequestUrinalysis[$i]->receiptNumber;
         $dumper->receipt_type = $labRequestUrinalysis[$i]->receiptType;
         $dumper->waiver_no = '';
         $dumper->system_id = "sanitas";
         $dumper->save();
     }
     $this->command->info('ExternalDump table seeded');
     //  Begin seed for prevalence rates report
     /* Test Categories table - These map on to the lab sections */
     $lab_section_hematology = TestCategory::create(array("name" => "HEMATOLOGY", "description" => ""));
     $lab_section_serology = TestCategory::create(array("name" => "SEROLOGY", "description" => ""));
     $lab_section_trans = TestCategory::create(array("name" => "BLOOD TRANSFUSION", "description" => ""));
     $this->command->info('Lab Sections seeded');
     /* Test Types for prevalence */
     $test_types_salmonella = TestType::create(array("name" => "Salmonella Antigen Test", "test_category_id" => $test_categories->id));
     $test_types_direct = TestType::create(array("name" => "Direct COOMBS Test", "test_category_id" => $lab_section_trans->id));
     $test_types_du = TestType::create(array("name" => "DU Test", "test_category_id" => $lab_section_trans->id));
     $test_types_sickling = TestType::create(array("name" => "Sickling Test", "test_category_id" => $lab_section_hematology->id));
     $test_types_borrelia = TestType::create(array("name" => "Borrelia", "test_category_id" => $test_categories->id));
     $test_types_vdrl = TestType::create(array("name" => "VDRL", "test_category_id" => $lab_section_serology->id));
     $test_types_pregnancy = TestType::create(array("name" => "Pregnancy Test", "test_category_id" => $lab_section_serology->id));
     $test_types_brucella = TestType::create(array("name" => "Brucella", "test_category_id" => $lab_section_serology->id));
     $test_types_pylori = TestType::create(array("name" => "H. Pylori", "test_category_id" => $lab_section_serology->id));
     $this->command->info('Test Types seeded');
     /* Test Types and specimen types relationship for prevalence */
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_salmonella->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_direct->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_du->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_sickling->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_borrelia->id, "23"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_vdrl->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_pregnancy->id, "20"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_brucella->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($test_types_pylori->id, "13"));
     DB::insert('INSERT INTO testtype_specimentypes (test_type_id, specimen_type_id) VALUES (?, ?)', array($testTypeStoolCS->id, "16"));
     $this->command->info('TestTypes/SpecimenTypes seeded');
     /*New measures for prevalence*/
     $measure_salmonella = Measure::create(array("measure_type_id" => "2", "name" => "Salmonella Antigen Test", "unit" => ""));
     $measure_direct = Measure::create(array("measure_type_id" => "2", "name" => "Direct COOMBS Test", "unit" => ""));
     $measure_du = Measure::create(array("measure_type_id" => "2", "name" => "Du Test", "unit" => ""));
     $measure_sickling = Measure::create(array("measure_type_id" => "2", "name" => "Sickling Test", "unit" => ""));
     $measure_borrelia = Measure::create(array("measure_type_id" => "2", "name" => "Borrelia", "unit" => ""));
     $measure_vdrl = Measure::create(array("measure_type_id" => "2", "name" => "VDRL", "unit" => ""));
     $measure_pregnancy = Measure::create(array("measure_type_id" => "2", "name" => "Pregnancy Test", "unit" => ""));
     $measure_brucella = Measure::create(array("measure_type_id" => "2", "name" => "Brucella", "unit" => ""));
     $measure_pylori = Measure::create(array("measure_type_id" => "2", "name" => "H. Pylori", "unit" => ""));
     MeasureRange::create(array("measure_id" => $measure_salmonella->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_salmonella->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_direct->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_direct->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_du->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_du->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_sickling->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_sickling->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_borrelia->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_borrelia->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_vdrl->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_vdrl->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_pregnancy->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_pregnancy->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_brucella->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_brucella->id, "alphanumeric" => "Negative"));
     MeasureRange::create(array("measure_id" => $measure_pylori->id, "alphanumeric" => "Positive"));
     MeasureRange::create(array("measure_id" => $measure_pylori->id, "alphanumeric" => "Negative"));
     $this->command->info('Measures seeded again');
     /* TestType Measure for prevalence */
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_salmonella->id, "measure_id" => $measure_salmonella->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_direct->id, "measure_id" => $measure_direct->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_du->id, "measure_id" => $measure_du->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_sickling->id, "measure_id" => $measure_sickling->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_borrelia->id, "measure_id" => $measure_borrelia->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_vdrl->id, "measure_id" => $measure_vdrl->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_pregnancy->id, "measure_id" => $measure_pregnancy->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_brucella->id, "measure_id" => $measure_brucella->id));
     $testtype_measure = TestTypeMeasure::create(array("test_type_id" => $test_types_pylori->id, "measure_id" => $measure_pylori->id));
     $this->command->info('Test Type Measures seeded again');
     /*  Tests for prevalence rates  */
     $tests_completed_one = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_salmonella->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-07-23 15:16:15", "time_started" => "2014-07-23 16:07:15", "time_completed" => "2014-07-23 16:17:19"));
     $tests_completed_two = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_direct->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-07-26 10:16:15", "time_started" => "2014-07-26 13:27:15", "time_completed" => "2014-07-26 13:57:01"));
     $tests_completed_three = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_du->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-08-13 09:16:15", "time_started" => "2014-08-13 10:07:15", "time_completed" => "2014-08-13 10:18:11"));
     $tests_completed_four = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_sickling->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-08-16 09:06:53", "time_started" => "2014-08-16 09:09:15", "time_completed" => "2014-08-16 09:23:37"));
     $tests_completed_five = Test::create(array("visit_id" => "5", "test_type_id" => $test_types_borrelia->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-08-23 10:16:15", "time_started" => "2014-08-23 11:54:39", "time_completed" => "2014-08-23 12:07:18"));
     $tests_completed_six = Test::create(array("visit_id" => "6", "test_type_id" => $test_types_vdrl->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-09-07 07:23:15", "time_started" => "2014-09-07 08:07:20", "time_completed" => "2014-09-07 08:41:13"));
     $tests_completed_seven = Test::create(array("visit_id" => "7", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-03 11:52:15", "time_started" => "2014-10-03 12:31:04", "time_completed" => "2014-10-03 12:45:18"));
     $tests_completed_eight = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_brucella->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-15 17:01:15", "time_started" => "2014-10-15 17:05:24", "time_completed" => "2014-10-15 18:07:15"));
     $tests_completed_nine = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_pylori->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-23 16:06:15", "time_started" => "2014-10-23 16:07:15", "time_completed" => "2014-10-23 16:39:02"));
     $tests_completed_ten = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_salmonella->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::COMPLETED, "created_by" => "2", "tested_by" => "3", "requested_by" => "Ariel Smith", "time_created" => "2014-10-21 19:16:15", "time_started" => "2014-10-21 19:17:15", "time_completed" => "2014-10-21 19:52:40"));
     $tests_verified_one = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_direct->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-07-21 19:16:15", "time_started" => "2014-07-21 19:17:15", "time_completed" => "2014-07-21 19:52:40", "time_verified" => "2014-07-21 19:53:48"));
     $tests_verified_two = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_du->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-08-21 19:16:15", "time_started" => "2014-08-21 19:17:15", "time_completed" => "2014-08-21 19:52:40", "time_verified" => "2014-08-21 19:53:48"));
     $tests_verified_three = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_sickling->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-08-26 19:16:15", "time_started" => "2014-08-26 19:17:15", "time_completed" => "2014-08-26 19:52:40", "time_verified" => "2014-08-26 19:53:48"));
     $tests_verified_four = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_borrelia->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-21 19:16:15", "time_started" => "2014-09-21 19:17:15", "time_completed" => "2014-09-21 19:52:40", "time_verified" => "2014-09-21 19:53:48"));
     $tests_verified_five = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_vdrl->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-22 19:16:15", "time_started" => "2014-09-22 19:17:15", "time_completed" => "2014-09-22 19:52:40", "time_verified" => "2014-09-22 19:53:48"));
     $tests_verified_six = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-23 19:16:15", "time_started" => "2014-09-23 19:17:15", "time_completed" => "2014-09-23 19:52:40", "time_verified" => "2014-09-23 19:53:48"));
     $tests_verified_seven = Test::create(array("visit_id" => "1", "test_type_id" => $test_types_brucella->id, "specimen_id" => "2", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-09-27 19:16:15", "time_started" => "2014-09-27 19:17:15", "time_completed" => "2014-09-27 19:52:40", "time_verified" => "2014-09-27 19:53:48"));
     $tests_verified_eight = Test::create(array("visit_id" => "3", "test_type_id" => $test_types_pylori->id, "specimen_id" => "4", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-10-22 19:16:15", "time_started" => "2014-10-22 19:17:15", "time_completed" => "2014-10-22 19:52:40", "time_verified" => "2014-10-22 19:53:48"));
     $tests_verified_nine = Test::create(array("visit_id" => "4", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "3", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-10-17 19:16:15", "time_started" => "2014-10-17 19:17:15", "time_completed" => "2014-10-17 19:52:40", "time_verified" => "2014-10-17 19:53:48"));
     $tests_verified_ten = Test::create(array("visit_id" => "2", "test_type_id" => $test_types_pregnancy->id, "specimen_id" => "1", "interpretation" => "Budda Boss", "test_status_id" => Test::VERIFIED, "created_by" => "3", "tested_by" => "2", "verified_by" => "3", "requested_by" => "Genghiz Khan", "time_created" => "2014-10-02 19:16:15", "time_started" => "2014-10-02 19:17:15", "time_completed" => "2014-10-02 19:52:40", "time_verified" => "2014-10-02 19:53:48"));
     $this->command->info('Tests seeded again');
     //  Test results for prevalence
     $results = array(array("test_id" => $tests_completed_one->id, "measure_id" => $measure_salmonella->id, "result" => "Positive"), array("test_id" => $tests_completed_two->id, "measure_id" => $measure_direct->id, "result" => "Positive"), array("test_id" => $tests_completed_three->id, "measure_id" => $measure_du->id, "result" => "Positive"), array("test_id" => $tests_completed_four->id, "measure_id" => $measure_sickling->id, "result" => "Positive"), array("test_id" => $tests_completed_five->id, "measure_id" => $measure_borrelia->id, "result" => "Positive"), array("test_id" => $tests_completed_six->id, "measure_id" => $measure_vdrl->id, "result" => "Positive"), array("test_id" => $tests_completed_seven->id, "measure_id" => $measure_pregnancy->id, "result" => "Positive"), array("test_id" => $tests_completed_eight->id, "measure_id" => $measure_brucella->id, "result" => "Positive"), array("test_id" => $tests_completed_nine->id, "measure_id" => $measure_pylori->id, "result" => "Positive"), array("test_id" => $tests_completed_ten->id, "measure_id" => $measure_salmonella->id, "result" => "Positive"), array("test_id" => $tests_verified_one->id, "measure_id" => $measure_direct->id, "result" => "Negative"), array("test_id" => $tests_verified_two->id, "measure_id" => $measure_du->id, "result" => "Positive"), array("test_id" => $tests_verified_three->id, "measure_id" => $measure_sickling->id, "result" => "Positive"), array("test_id" => $tests_verified_four->id, "measure_id" => $measure_borrelia->id, "result" => "Negative"), array("test_id" => $tests_verified_five->id, "measure_id" => $measure_vdrl->id, "result" => "Negative"), array("test_id" => $tests_verified_six->id, "measure_id" => $measure_pregnancy->id, "result" => "Negative"), array("test_id" => $tests_verified_seven->id, "measure_id" => $measure_brucella->id, "result" => "Positive"), array("test_id" => $tests_verified_eight->id, "measure_id" => $measure_pylori->id, "result" => "Positive"), array("test_id" => $tests_verified_nine->id, "measure_id" => $measure_pregnancy->id, "result" => "Negative"), array("test_id" => $tests_verified_ten->id, "measure_id" => $measure_pregnancy->id, "result" => "Positive"));
     foreach ($results as $result) {
         TestResult::create($result);
     }
     $this->command->info('Test results seeded again');
     //  End prevalence rates seed
     //Seed for facilities
     $facilitiesSeed = array(array('name' => "WALTER REED"), array('name' => "AGA KHAN UNIVERSITY HOSPITAL"), array('name' => "TEL AVIV GENERAL HOSPITAL"), array('name' => "GK PRISON DISPENSARY"), array('name' => "KEMRI ALUPE"), array('name' => "AMPATH"));
     foreach ($facilitiesSeed as $facility) {
         Facility::create($facility);
     }
     $this->command->info('Facilities table seeded');
     //Seed for suppliers
     $supplier = Supplier::create(array("name" => "UNICEF", "phone_no" => "0775112233", "email" => "*****@*****.**", "physical_address" => "un-hqtr"));
     $this->command->info('Suppliers table seeded');
     //Seed for metrics
     $metric = Metric::create(array("name" => "mg", "description" => "milligram"));
     $this->command->info('Metrics table seeded');
     //Seed for commodities
     $commodity = Commodity::create(array("name" => "Ampicillin", "description" => "Capsule 250mg", "metric_id" => $metric->id, "unit_price" => "500", "item_code" => "no clue", "storage_req" => "no clue", "min_level" => "100000", "max_level" => "400000"));
     $this->command->info('Commodities table seeded');
     //Seed for receipts
     $receipt = Receipt::create(array("commodity_id" => $commodity->id, "supplier_id" => $supplier->id, "quantity" => "130000", "batch_no" => "002720", "expiry_date" => "2018-10-14", "user_id" => "1"));
     $this->command->info('Receipts table seeded');
     //Seed for Top Up Request
     $topUpRequest = TopupRequest::create(array("commodity_id" => $commodity->id, "test_category_id" => 1, "order_quantity" => "1500", "user_id" => 1, "remarks" => "-"));
     $this->command->info('Top Up Requests table seeded');
     //Seed for Issues
     Issue::create(array("receipt_id" => $receipt->id, "topup_request_id" => $topUpRequest->id, "quantity_issued" => "1700", "issued_to" => 1, "user_id" => 1, "remarks" => "-"));
     $this->command->info('Issues table seeded');
     //Seed for diseases
     $malaria = Disease::create(array('name' => "Malaria"));
     $typhoid = Disease::create(array('name' => "Typhoid"));
     $dysentry = Disease::create(array('name' => "Shigella Dysentry"));
     $this->command->info("Dieases table seeded");
     $reportDiseases = array(array("test_type_id" => $testTypeBS->id, "disease_id" => $malaria->id), array("test_type_id" => $test_types_salmonella->id, "disease_id" => $typhoid->id), array("test_type_id" => $testTypeStoolCS->id, "disease_id" => $dysentry->id));
     foreach ($reportDiseases as $reportDisease) {
         ReportDisease::create($reportDisease);
     }
     $this->command->info("Report Disease table seeded");
     //Seeding for QC
     $lots = array(array('number' => '0001', 'description' => 'First lot', 'expiry' => date('Y-m-d H:i:s', strtotime("+6 months")), 'instrument_id' => 1), array('number' => '0002', 'description' => 'Second lot', 'expiry' => date('Y-m-d H:i:s', strtotime("+7 months")), 'instrument_id' => 1));
     foreach ($lots as $lot) {
         $lot = Lot::create($lot);
     }
     $this->command->info("Lot table seeded");
     //Control seeding
     $controls = array(array('name' => 'Humatrol P', 'description' => 'HUMATROL P control serum has been designed to provide a suitable basis for the quality control (imprecision, inaccuracy) in the clinical chemical laboratory.', 'lot_id' => 1), array('name' => 'Full Blood Count', 'description' => 'Né pas touchér', 'lot_id' => 1));
     foreach ($controls as $control) {
         Control::create($control);
     }
     $this->command->info("Control table seeded");
     //Control measures
     $controlMeasures = array(array('name' => 'ca', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'pi', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'mg', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'na', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'K', 'unit' => 'mmol', 'control_id' => 1, 'control_measure_type_id' => 1), array('name' => 'WBC', 'unit' => 'x 103/uL', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'RBC', 'unit' => 'x 106/uL', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'HGB', 'unit' => 'g/dl', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'HCT', 'unit' => '%', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'MCV', 'unit' => 'fl', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'MCH', 'unit' => 'pg', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'MCHC', 'unit' => 'g/dl', 'control_id' => 2, 'control_measure_type_id' => 1), array('name' => 'PLT', 'unit' => 'x 103/uL', 'control_id' => 2, 'control_measure_type_id' => 1));
     foreach ($controlMeasures as $controlMeasure) {
         ControlMeasure::create($controlMeasure);
     }
     $this->command->info("Control Measure table seeded");
     //Control measure ranges
     $controlMeasureRanges = array(array('upper_range' => '2.63', 'lower_range' => '7.19', 'control_measure_id' => 1), array('upper_range' => '11.65', 'lower_range' => '15.43', 'control_measure_id' => 2), array('upper_range' => '12.13', 'lower_range' => '19.11', 'control_measure_id' => 3), array('upper_range' => '15.73', 'lower_range' => '25.01', 'control_measure_id' => 4), array('upper_range' => '17.63', 'lower_range' => '20.12', 'control_measure_id' => 5), array('upper_range' => '6.5', 'lower_range' => '7.5', 'control_measure_id' => 6), array('upper_range' => '4.36', 'lower_range' => '5.78', 'control_measure_id' => 7), array('upper_range' => '13.8', 'lower_range' => '17.3', 'control_measure_id' => 8), array('upper_range' => '81.0', 'lower_range' => '95.0', 'control_measure_id' => 9), array('upper_range' => '1.99', 'lower_range' => '2.63', 'control_measure_id' => 10), array('upper_range' => '27.6', 'lower_range' => '33.0', 'control_measure_id' => 11), array('upper_range' => '32.8', 'lower_range' => '36.4', 'control_measure_id' => 12), array('upper_range' => '141', 'lower_range' => ' 320.0', 'control_measure_id' => 13));
     foreach ($controlMeasureRanges as $controlMeasureRange) {
         ControlMeasureRange::create($controlMeasureRange);
     }
     $this->command->info("Control Measure ranges table seeded");
     //Control Tests
     $controlTests = array(array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('entered_by' => 3, 'control_id' => 1, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('entered_by' => 1, 'control_id' => 2, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('entered_by' => 1, 'control_id' => 2, 'created_at' => date('Y-m-d', strtotime('-2 days'))));
     foreach ($controlTests as $controltest) {
         ControlTest::create($controltest);
     }
     $this->command->info("Control test table seeded");
     //Control results
     $controlResults = array(array('results' => '2.78', 'control_measure_id' => 1, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '13.56', 'control_measure_id' => 2, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '14.77', 'control_measure_id' => 3, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '25.92', 'control_measure_id' => 4, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '18.87', 'control_measure_id' => 5, 'control_test_id' => 1, 'created_at' => date('Y-m-d', strtotime('-10 days'))), array('results' => '6.78', 'control_measure_id' => 1, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '15.56', 'control_measure_id' => 2, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '18.77', 'control_measure_id' => 3, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '30.92', 'control_measure_id' => 4, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '17.87', 'control_measure_id' => 5, 'control_test_id' => 2, 'created_at' => date('Y-m-d', strtotime('-9 days'))), array('results' => '8.78', 'control_measure_id' => 1, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '17.56', 'control_measure_id' => 2, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '21.77', 'control_measure_id' => 3, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '27.92', 'control_measure_id' => 4, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '22.87', 'control_measure_id' => 5, 'control_test_id' => 3, 'created_at' => date('Y-m-d', strtotime('-8 days'))), array('results' => '6.78', 'control_measure_id' => 1, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '18.56', 'control_measure_id' => 2, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '19.77', 'control_measure_id' => 3, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '12.92', 'control_measure_id' => 4, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '22.87', 'control_measure_id' => 5, 'control_test_id' => 4, 'created_at' => date('Y-m-d', strtotime('-7 days'))), array('results' => '3.78', 'control_measure_id' => 1, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '16.56', 'control_measure_id' => 2, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '17.77', 'control_measure_id' => 3, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '28.92', 'control_measure_id' => 4, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '19.87', 'control_measure_id' => 5, 'control_test_id' => 5, 'created_at' => date('Y-m-d', strtotime('-6 days'))), array('results' => '5.78', 'control_measure_id' => 1, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '15.56', 'control_measure_id' => 2, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '11.77', 'control_measure_id' => 3, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '29.92', 'control_measure_id' => 4, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '14.87', 'control_measure_id' => 5, 'control_test_id' => 6, 'created_at' => date('Y-m-d', strtotime('-5 days'))), array('results' => '9.78', 'control_measure_id' => 1, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '11.56', 'control_measure_id' => 2, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '19.77', 'control_measure_id' => 3, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '32.92', 'control_measure_id' => 4, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '29.87', 'control_measure_id' => 5, 'control_test_id' => 7, 'created_at' => date('Y-m-d', strtotime('-4 days'))), array('results' => '5.45', 'control_measure_id' => 6, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '5.01', 'control_measure_id' => 7, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '12.3', 'control_measure_id' => 8, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '89.7', 'control_measure_id' => 9, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '2.15', 'control_measure_id' => 10, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '34.0', 'control_measure_id' => 11, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '37.2', 'control_measure_id' => 12, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '141.5', 'control_measure_id' => 13, 'control_test_id' => 8, 'created_at' => date('Y-m-d', strtotime('-3 days'))), array('results' => '7.45', 'control_measure_id' => 6, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '9.01', 'control_measure_id' => 7, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '9.3', 'control_measure_id' => 8, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '94.7', 'control_measure_id' => 9, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '12.15', 'control_measure_id' => 10, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '37.0', 'control_measure_id' => 11, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '30.2', 'control_measure_id' => 12, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))), array('results' => '121.5', 'control_measure_id' => 13, 'control_test_id' => 9, 'created_at' => date('Y-m-d', strtotime('-2 days'))));
     foreach ($controlResults as $controlResult) {
         ControlMeasureResult::create($controlResult);
     }
     $this->command->info("Control results table seeded");
 }
Пример #20
0
 /**
  * Called when a test run finishes.
  *
  * @param   unittest.TestSuite suite
  * @param   unittest.TestResult result
  */
 public function testRunFinished(TestSuite $suite, TestResult $result)
 {
     $this->out->writeLine(']');
     // Show failed test details
     $fail = FALSE;
     if ($result->failureCount() > 0) {
         $this->out->writeLine();
         foreach ($result->failed as $failure) {
             $this->out->writeLine('F ', $failure);
         }
         $fail = TRUE;
     }
     $this->out->writeLinef("\n%s%s: %d/%d run (%d skipped), %d succeeded, %d failed%s", $this->colored ? $fail ? "" : "" : '', $fail ? 'FAIL' : 'OK', $result->runCount(), $result->count(), $result->skipCount(), $result->successCount(), $result->failureCount(), $this->colored ? "" : '');
     $this->out->writeLinef('Memory used: %.2f kB (%.2f kB peak)', Runtime::getInstance()->memoryUsage() / 1024, Runtime::getInstance()->peakMemoryUsage() / 1024);
     $this->out->writeLinef('Time taken: %.3f seconds', $result->elapsed());
 }
Пример #21
0
 /**
  * Called when a test run finishes.
  *
  * @param   unittest.TestSuite suite
  * @param   unittest.TestResult result
  */
 public function testRunFinished(TestSuite $suite, TestResult $result)
 {
     // Details
     if ($result->successCount() > 0) {
         $this->out->writeLine("\n---> Succeeeded:");
         foreach (array_keys($result->succeeded) as $key) {
             $this->out->writeLine('* ', $result->succeeded[$key]);
         }
     }
     if ($result->skipCount() > 0) {
         $this->out->writeLine("\n---> Skipped:");
         foreach (array_keys($result->skipped) as $key) {
             $this->out->writeLine('* ', $result->skipped[$key]);
         }
     }
     if ($result->failureCount() > 0) {
         $this->out->writeLine("\n---> Failed:");
         foreach (array_keys($result->failed) as $key) {
             $this->out->writeLine('* ', $result->failed[$key]);
         }
     }
     $this->out->writeLinef("\n===> %s: %d run (%d skipped), %d succeeded, %d failed", $result->failureCount() ? 'FAIL' : 'OK', $result->runCount(), $result->skipCount(), $result->successCount(), $result->failureCount());
     $this->out->writeLinef('===> Memory used: %.2f kB (%.2f kB peak)', Runtime::getInstance()->memoryUsage() / 1024, Runtime::getInstance()->peakMemoryUsage() / 1024);
     $this->out->writeLinef('===> Time taken: %.3f seconds', $result->elapsed());
 }
 /**
  * Called when a test run finishes.
  *
  * @param   unittest.TestSuite suite
  * @param   unittest.TestResult result
  */
 public function testRunFinished(TestSuite $suite, TestResult $result)
 {
     $this->out->writef("]2;%s: %d/%d run (%d skipped), %d succeeded, %d failed", $result->failureCount() > 0 ? 'FAIL' : 'OK', $result->runCount(), $result->count(), $result->skipCount(), $result->successCount(), $result->failureCount());
 }