function get_records_to_print($lab_config, $patient_id) { global $date_from, $date_to; $retval = array(); if (isset($_REQUEST['ip']) && $_REQUEST['ip'] == 0) { # Do not include pending tests $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.result <> '' " . "AND t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } else { # Include pending tests $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } $resultset = query_associative_all($query_string, $row_count); if (count($resultset) == 0 || $resultset == null) { return $retval; } foreach ($resultset as $record) { $test = Test::getObject($record); $hide_patient_name = TestType::toHidePatientName($test->testTypeId); if ($hide_patient_name == 1) { $hidePatientName = 1; } $specimen = get_specimen_by_id($test->specimenId); $retval[] = array($test, $specimen, $hide_patient_name); } return $retval; }
/** * @see http://lists.shadanakar.org/onphp-dev-ru/0811/0774.html **/ public function testRecursiveContainers() { $this->markTestSkipped('wontfix'); foreach (DBTestPool::me()->getPool() as $db) { DBPool::me()->setDefault($db); TestObject::dao()->import(TestObject::create()->setId(1)->setName('test object')); TestType::dao()->import(TestType::create()->setId(1)->setName('test type')); $type = TestType::dao()->getById(1); $type->getObjects()->fetch()->setList(array(TestObject::dao()->getById(1)))->save(); $object = TestObject::dao()->getById(1); TestObject::dao()->save($object->setName('test object modified')); $list = $type->getObjects()->getList(); $modifiedObject = TestObject::dao()->getById(1); $this->assertEquals($list[0], $modifiedObject); } }
function get_records_to_print($lab_config, $patient_id, $specimen_id) { $retval = array(); $query_string = "SELECT * FROM test,specimen " . "WHERE specimen.specimen_id={$specimen_id} and test.specimen_id=specimen.specimen_id and specimen.patient_id={$patient_id}"; $resultset = query_associative_one($query_string); if ($resultset == null) { echo "hiral"; } $test = Test::getObject($resultset); $hide_patient_name = TestType::toHidePatientName($test->testTypeId); if ($hide_patient_name == 1) { $hidePatientName = 1; } $specimen = get_specimen_by_id($test->specimenId); $retval[] = array($test, $specimen, $hide_patient_name); return $retval; }
function generate_worksheet_config($lab_config_id) { $lab_config = LabConfig::getById($lab_config_id); $test_ids = $lab_config->getTestTypeIds(); $saved_db = DbUtil::switchToLabConfig($lab_config_id); foreach ($test_ids as $test_id) { $test_entry = TestType::getById($test_id); $query_string = "SELECT * FROM report_config WHERE test_type_id={$test_id} LIMIT 1"; $record = query_associative_one($query_string); if ($record == null) { # Add new entry $query_string_add = "INSERT INTO report_config (" . "test_type_id, header, footer, margins, " . "p_fields, s_fields, t_fields, p_custom_fields, s_custom_fields " . ") VALUES (" . "'{$test_id}', 'Worksheet - " . $test_entry->name . "', '', '5,0,5,0', " . "'0,1,0,1,1,0,0', '0,0,1,1,0,0', '1,0,1,0,0,0,0,1', '', '' " . ")"; query_insert_one($query_string_add); } } DbUtil::switchRestore($saved_db); }
/** * Set compatible specimen types * * @return void */ public function setTestTypes($testTypes) { $testTypesAdded = array(); if (is_array($testTypes)) { foreach ($testTypes as $name) { try { $testTypesAdded[] = TestType::where('name', '=', $name)->first()->id; } catch (\Exception $e) { Log::error($e); } } } if (count($testTypesAdded) > 0) { // Delete existing instrument test_type mappings $this->testTypes()->detach(); // Add the new mapping $this->testTypes()->attach($testTypesAdded); } }
public function decodeResultWithoutMeasures($show_range = false) { # Converts stored result value(s) for showing on front-end $test_type = TestType::getById($this->testTypeId); $measure_list = $test_type->getMeasures(); $result_csv = $this->getResultWithoutHash(); $result_list = explode(",", $result_csv); $retval = ""; for ($i = 0; $i < count($measure_list); $i++) { # Pretty print $curr_measure = $measure_list[$i]; if (isset($result_list[$i])) { # If matching result value exists (e.g. after a new measure was added to this test type) if (count($measure_list) == 1) { # Only one measure: Do not print measure name //$retval .= $curr_measure->name." "; if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) { $result_string = ""; $value_list = explode("_", $result_list[$i]); foreach ($value_list as $value) { if (trim($value) == "") { continue; } $result_string .= $value . "<br>"; } $result_string = substr($result_string, 0, -4); $retval .= "<br>" . $result_string . " "; } else { if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) { if ($result_list[$i] != $curr_measure->unit) { $retval .= "<br><b>" . $result_list[$i] . "</b> "; } else { $retval .= "<br>" . $result_list[$i] . " "; } } else { $retval .= "<br>" . $result_list[$i] . " "; } } } else { # Print measure name with each result value // $retval .= $curr_measure->name." "; if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) { $result_string = ""; $value_list = str_replace("_", ",", $result_list[$i]); //$retval .= ":<br>".$value_list."<br>"; $retval .= "<br>" . $value_list . "<br>"; } else { if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) { if ($result_list[$i] != $curr_measure->unit) { //$retval .= "<b>".$result_list[$i]."</b> "; $retval .= "<br><b>" . $result_list[$i] . "</b> <br>"; } else { //$retval .= $result_list[$i]." "; $retval .= "<br>" . $result_list[$i] . " <br>"; } } else { //$retval .= $result_list[$i]." "; $retval .= "<br>" . $result_list[$i] . " <br>"; } } } if ($show_range === true) { $retval .= $curr_measure->getRangeString(); } if ($i != count($measure_list) - 1) { //$retval .= "<br>"; } } else { # Matching result value not found: Show "-" if (count($measure_list) == 1) { $retval .= $curr_measure->name . " "; } $retval .= " - <br>"; } } $retval = str_replace("_", ",", $retval); # Replace all underscores with a comma return $retval; }
public function decodeResultWithoutMeasures($show_range = false) { # Converts stored result value(s) for showing on front-end # Get measure, unit pairs for this test $test_type = TestType::getById($this->testTypeId); $measure_list = $test_type->getMeasures(); //print_r($measure_list); $submeasure_list = array(); $comb_measure_list = array(); // print_r($measure_list); foreach ($measure_list as $measure) { $submeasure_list = $measure->getSubmeasuresAsObj(); //echo "<br>".count($submeasure_list); //print_r($submeasure_list); $submeasure_count = count($submeasure_list); if ($measure->checkIfSubmeasure() == 1) { continue; } if ($submeasure_count == 0) { array_push($comb_measure_list, $measure); } else { array_push($comb_measure_list, $measure); foreach ($submeasure_list as $submeasure) { array_push($comb_measure_list, $submeasure); } } } $measure_list = $comb_measure_list; $result_csv = $this->getResultWithoutHash(); //$result_csv = $this->getResultWithoutHash(); //echo "<br>"; //echo $result_csv; //echo "<br>"; if (strpos($result_csv, "[\$]") === false) { $result_list = explode(",", $result_csv); } else { //$testt = "one,[$]two[/$],[$]twotwo[/$],three"; $testt = $result_csv; //$test2 = strstr($testt, $); $start_tag = "[\$]"; $end_tag = "[/\$]"; //$testtt = str_replace("[$]two[/$],", "", $testt); $freetext_results = array(); $ft_count = substr_count($testt, $start_tag); //echo $ft_count; $k = 0; while ($k < $ft_count) { $ft_beg = strpos($testt, $start_tag); $ft_end = strpos($testt, $end_tag); $ft_sub = substr($testt, $ft_beg + 3, $ft_end - $ft_beg - 3); $ft_left = substr($testt, 0, $ft_beg); $ft_right = substr($testt, $ft_end + 5); //echo "<br>".$ft_left."--".$ft_right."<br>"; $testt = $ft_left . $ft_right; array_push($freetext_results, $ft_sub); $k++; } //echo $freetext_results."<br>".$testt; //$testtt = str_replace($subb, "", $testt, 1); //echo "$testto<br>$subb<br>"; $result_csv = $testt; if (strpos($testt, ",") == 0) { $result_csv = substr($testt, 1, strlen($testt)); } $result_list = explode(",", $result_csv); //echo "<br>"; //print_r($result_list); //echo "<br>"; } $retval = ""; //NC3065 //echo print_r($measure_list); //echo "<br>"; //echo $result_csv; //echo "<br>"; //echo print_r($result_list,true); //echo "Num->".count($measure_list); //-NC3065 $j = 0; $i = 0; $c = 0; //for($i = 0; $i < count($measure_list); $i++) { while ($c < count($measure_list)) { # Pretty print $curr_measure = $measure_list[$c]; if ($curr_measure->getRangeType() != Measure::$RANGE_FREETEXT) { if (isset($result_list[$i])) { //echo "Num->".$i; # If matching result value exists (e.g. after a new measure was added to this test type) if (count($measure_list) == 1) { # Only one measure: Do not print measure name if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) { $result_string = ""; $value_list = explode("_", $result_list[$i]); foreach ($value_list as $value) { if (trim($value) == "") { continue; } $result_string .= $value . "<br>"; } $result_string = substr($result_string, 0, -4); $retval .= "<br>" . $result_string . " "; } else { if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) { if ($result_list[$i] != $curr_measure->unit) { $retval .= "<br><b>" . $result_list[$i] . "</b> "; } else { $retval .= "<br>" . $result_list[$i] . " "; } } else { $retval .= "<br>" . $result_list[$i] . " "; } } } else { # Print measure name with each result value if ($curr_measure->getRangeType() == Measure::$RANGE_AUTOCOMPLETE) { $result_string = ""; $value_list = str_replace("_", ",", $result_list[$i]); $retval .= "<br><b>" . $value_list . "</b>"; } else { if ($curr_measure->getRangeType() == Measure::$RANGE_OPTIONS) { if ($result_list[$i] != $curr_measure->unit) { $retval .= "<br><b>" . $result_list[$i] . "</b>" . " "; } else { $retval .= $result_list[$i] . " "; } } else { $retval .= "<br><b>" . $result_list[$i] . "</b>" . " "; } } } if ($show_range === true) { $retval .= $curr_measure->getRangeString(); } if ($i != count($measure_list) - 1) { $retval .= "<br>"; } } else { # Matching result value not found: Show "-" if (count($measure_list) == 1) { } $retval .= " - <br>"; } $i++; } else { $ft_result = $freetext_results[$j]; if (count($measure_list) == 1) { $retval .= "<br>" . $ft_result . " "; } else { $retval .= "<br>" . $ft_result . " "; } if ($show_range === true) { $retval .= $curr_measure->getRangeString(); } if ($i != count($measure_list) - 1) { $retval .= "<br>"; } $j++; } $c++; } //end //$retval = str_replace("_",",",$retval); # Replace all underscores with a comma return $retval; }
<?php # # Deletes a test type from DB # Sets disabled flag to true instead of deleting the record # This maintains info for samples that were linked to this test type previously # include "../includes/db_lib.php"; $saved_session = SessionUtil::save(); $saved_db = DbUtil::switchToGlobal(); $test_type_id = $_REQUEST['id']; TestType::deleteById($test_type_id); DbUtil::switchRestore($saved_db); SessionUtil::restore($saved_session); header("Location: catalog.php?tdel");
} # For each measure: foreach ($measure_list as $measure) { $measure_id = $measure->measureId; # Remove entries from test_type_measure $query_string = "DELETE FROM test_type_measure WHERE measure_id={$measure_id}"; query_delete($query_string); # Remove entry from measure $query_string = "DELETE FROM measure WHERE measure_id={$measure_id}"; query_delete($query_string); } $query_string = "SELECT * FROM specimen_type"; $resultset = query_associative_all($query_string, $row_count); $specimen_list = array(); foreach ($resultset as $record) { $specimen_list[] = TestType::getObject($record); } # For each specimen type: foreach ($specimen_list as $specimen) { $specimen_type_id = $specimen->specimenTypeId; # Remove entries from lab_config_specimen_type $query_string = "DELETE FROM lab_config_specimen_type WHERE specimen_type_id={$specimen_type_id}"; query_delete($query_string); # Remove entries from specimen_test $query_string = "DELETE FROM specimen_test WHERE specimen_type_id={$specimen_type_id}"; query_delete($query_string); # Remove entry from specimen_type $query_string = "DELETE FROM specimen_type WHERE specimen_type_id={$specimen_type_id}"; query_delete($query_string); } DbUtil::switchRestore($saved_db);
<?php # # Adds result for a single test # Called via ajax from results_entry.php # include "../includes/db_lib.php"; include "../includes/user_lib.php"; LangUtil::setPageId("results_entry"); $test_id = $_REQUEST['test_id']; $test_name = get_test_name_by_id($test_id); $test = Test::getById($test_id); $test_type = TestType::getById($test->testTypeId); $specimen_id = $_REQUEST['specimen_id']; $specimen = Specimen::getById($specimen_id); $patient = Patient::getById($specimen->patientId); $comment = $_REQUEST['comments']; $comment_1 = $_REQUEST['comments_1']; $dd_to = $_REQUEST['dd_to']; $mm_to = $_REQUEST['mm_to']; $yyyy_to = $_REQUEST['yyyy_to']; if ($comment !== "" && $comment_1 != "") { $comments = $comment . " , " . $comment_1; } else { if ($comment == "" && $comment_1 != "") { $comments = $comment_1; } else { if ($comment != "" && $comment_1 == "") { $comments = $comment; } }
echo "</td>"; } } if ($report_config->useComments == 1) { echo "<td>"; echo $specimen->getComments(); echo "</td>"; } if ($report_config->useReferredTo == 1) { echo "<td>" . $specimen->getReferredToName() . "</td>"; } if ($report_config->useDoctor == 1) { echo "<td>" . $specimen->getDoctor() . "</td>"; } if ($report_config->useTestName == 1 || $report_config->useResults == 1) { $test_entry = TestType::getById($test_type_id); $measure_list = $test_entry->getMeasures(); foreach ($measure_list as $measure) { # Show range/options here $range = $measure->range; if (strpos($range, ":") !== false) { echo "<td>"; echo "</td>"; } else { if (strpos($range, "/") !== false) { $range_parts = explode("/", $range); echo "<td>"; echo "</td>"; /* foreach($range_parts as $option_value) {
$subtitle = trans("messages.for") . ' ' . date('Y'); } if ($interval == 'M') { $subtitle .= ' (' . trans("messages.monthly") . ') '; } else { if ($interval == 'D') { $subtitle .= ' (' . trans("messages.daily") . ') '; } else { $subtitle .= ' (' . trans("messages.weekly") . ') '; } } if ($testCategory) { $subtitle .= ' - ' . TestCategory::find($testCategory)->name; } if ($testType) { $subtitle .= '(' . TestType::find($testType)->name . ')'; } echo '"' . $subtitle . '"'; ?> }, credits: { enabled: 'false' }, xAxis: { type: 'datetime', dateTimeLabelFormats: { month: '%e. %b', year: '%b' }, }, yAxis: {
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"); }
public function testCountPerStatus() { Input::replace($this->testTypeData); $testType = new TestTypeController(); $testType->store(); $testTypestored = TestType::orderBy('id', 'desc')->take(1)->get()->toArray(); $testTypeSaved = TestType::find($testTypestored[0]['id']); $count = $testTypeSaved->countPerStatus([Test::NOT_RECEIVED, Test::STARTED, Test::PENDING, Test::COMPLETED, Test::VERIFIED]); $this->assertEquals($testTypeSaved->tests->count(), $count); }
public function get_test_type($test_type_id) { global $con; if ($_SESSION['level'] < 2 || $_SESSION['level'] > 4) { $user = get_user_by_id($_SESSION['user_id']); $lab_config_id = $user->labConfigId; } if ($lab_config_id == null) { $lab_config_id = get_lab_config_id_admin($_SESSION['user_id']); } $test_type_id = mysql_real_escape_string($test_type_id, $con); $saved_db = DbUtil::switchToLabConfig($lab_config_id); $query_string = "SELECT * FROM test_type WHERE test_type_id={$test_type_id} LIMIT 1"; $record = query_associative_one($query_string); $test_type = TestType::getObject($record); //print_r($test_type); $ret = array(); if ($test_type != null) { $ret['info'] = $test_type; } else { return 0; } $measure_list = array(); $measure_list_objs = $test_type->getMeasures(); //print_r($measure_list); $submeasure_list_objs = array(); $comb_measure_list = array(); // print_r($measure_list); foreach ($measure_list_objs as $measure) { $submeasure_list_objs = $measure->getSubmeasuresAsObj(); //echo "<br>".count($submeasure_list); //print_r($submeasure_list); $submeasure_count = count($submeasure_list_objs); if ($measure->checkIfSubmeasure() == 1) { continue; } if ($submeasure_count == 0) { array_push($comb_measure_list, $measure); } else { array_push($comb_measure_list, $measure); foreach ($submeasure_list_objs as $submeasure) { array_push($comb_measure_list, $submeasure); } } } $measure_list_ids = array(); //echo "<pre>"; //print_r($comb_measure_list); //echo "</pre>"; foreach ($comb_measure_list as $measure) { array_push($measure_list_ids, $measure->measureId); } /* echo "<pre>"; print_r($measure_list); print_r($measure_list_ids); echo "</pre>"; */ $measure_list = $measure_list_ids; //print_r($measure_list_objs); $ret['measures'] = $measure_list_objs; DbUtil::switchRestore($saved_db); return $ret; }
/** * Pull test results from an instrument as JSON. * * @return Response */ public function getTestResult() { //Get Instrument Interface Class file $testTypeID = Input::get("test_type_id"); $testType = TestType::find($testTypeID); $instrument = $testType->instruments->first(); // Fetch the results return $instrument->fetchResult($testType); }
public function run() { DB::table('testtypes')->delete(); TestType::create(array('description' => 'Ansiedad')); TestType::create(array('description' => '')); TestType::create(array('description' => 'Evaluación Mental')); }
$report_config->landscape = true; } else { $report_config->landscape = false; } if ($_REQUEST['Clinical_Data'] == 'Y') { $ClinicalData = 1; } else { $ClinicalData = 0; } $name = "../../logo_" . $lab_config_id . ".jpg"; # Header text $align_header = array(); $align_header[0] = db_escape($_REQUEST['header']); $align_header[1] = $_REQUEST['align']; $report_config->headerText = db_escape(implode("??", $align_header)); $testType = TestType::getById($_REQUEST['t_type']); $testName = $testType->name; $title_text = ""; $count = 0; foreach ($_REQUEST['title'] as $title_line) { $count++; $title_text .= $title_line; if ($count < count($_REQUEST['title'])) { $title_text .= "<br>"; } } move_uploaded_file($_FILES["file"]["tmp_name"], $name); $report_config->titleText = db_escape($title_text); # Footer text $report_config->footerText = db_escape($_REQUEST['footer']); $report_config->designation = db_escape($_REQUEST['designation']);
/** * Display a test((un)grouped) and specimen((un)grouped) counts. * */ public function countReports() { $date = date('Y-m-d'); $from = Input::get('start'); if (!$from) { $from = date('Y-m-01'); } $to = Input::get('end'); if (!$to) { $to = $date; } $toPlusOne = date_add(new DateTime($to), date_interval_create_from_date_string('1 day')); $counts = Input::get('counts'); // Begin grouped test counts if ($counts == trans('messages.grouped-test-counts')) { $testCategories = TestCategory::all(); $testTypes = TestType::all(); $ageRanges = array('0-5', '5-15', '15-120'); // Age ranges - will definitely change in configurations $gender = array(Patient::MALE, Patient::FEMALE); // Array for gender - male/female $perAgeRange = array(); // array for counts data for each test type and age range $perTestType = array(); // array for counts data per testype if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($date) || strtotime($to) > strtotime($date)) { Session::flash('message', trans('messages.check-date-range')); } foreach ($testTypes as $testType) { $countAll = $testType->groupedTestCount(null, null, $from, $toPlusOne->format('Y-m-d H:i:s')); $countMale = $testType->groupedTestCount([Patient::MALE], null, $from, $toPlusOne->format('Y-m-d H:i:s')); $countFemale = $testType->groupedTestCount([Patient::FEMALE], null, $from, $toPlusOne->format('Y-m-d H:i:s')); $perTestType[$testType->id] = ['countAll' => $countAll, 'countMale' => $countMale, 'countFemale' => $countFemale]; foreach ($ageRanges as $ageRange) { $maleCount = $testType->groupedTestCount([Patient::MALE], $ageRange, $from, $toPlusOne->format('Y-m-d H:i:s')); $femaleCount = $testType->groupedTestCount([Patient::FEMALE], $ageRange, $from, $toPlusOne->format('Y-m-d H:i:s')); $perAgeRange[$testType->id][$ageRange] = ['male' => $maleCount, 'female' => $femaleCount]; } } return View::make('reports.counts.groupedTestCount')->with('testCategories', $testCategories)->with('ageRanges', $ageRanges)->with('gender', $gender)->with('perTestType', $perTestType)->with('perAgeRange', $perAgeRange)->withInput(Input::all()); } else { if ($counts == trans('messages.ungrouped-specimen-counts')) { if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($date) || strtotime($to) > strtotime($date)) { Session::flash('message', trans('messages.check-date-range')); } $ungroupedSpecimen = array(); foreach (SpecimenType::all() as $specimenType) { $rejected = $specimenType->countPerStatus([Specimen::REJECTED], $from, $toPlusOne->format('Y-m-d H:i:s')); $accepted = $specimenType->countPerStatus([Specimen::ACCEPTED], $from, $toPlusOne->format('Y-m-d H:i:s')); $total = $rejected + $accepted; $ungroupedSpecimen[$specimenType->id] = ["total" => $total, "rejected" => $rejected, "accepted" => $accepted]; } // $data = $data->groupBy('test_type_id')->paginate(Config::get('kblis.page-items')); return View::make('reports.counts.ungroupedSpecimenCount')->with('ungroupedSpecimen', $ungroupedSpecimen)->withInput(Input::all()); } else { if ($counts == trans('messages.grouped-specimen-counts')) { $ageRanges = array('0-5', '5-15', '15-120'); // Age ranges - will definitely change in configurations $gender = array(Patient::MALE, Patient::FEMALE); // Array for gender - male/female $perAgeRange = array(); // array for counts data for each test type and age range $perSpecimenType = array(); // array for counts data per testype if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($date) || strtotime($to) > strtotime($date)) { Session::flash('message', trans('messages.check-date-range')); } $specimenTypes = SpecimenType::all(); foreach ($specimenTypes as $specimenType) { $countAll = $specimenType->groupedSpecimenCount([Patient::MALE, Patient::FEMALE], null, $from, $toPlusOne->format('Y-m-d H:i:s')); $countMale = $specimenType->groupedSpecimenCount([Patient::MALE], null, $from, $toPlusOne->format('Y-m-d H:i:s')); $countFemale = $specimenType->groupedSpecimenCount([Patient::FEMALE], null, $from, $toPlusOne->format('Y-m-d H:i:s')); $perSpecimenType[$specimenType->id] = ['countAll' => $countAll, 'countMale' => $countMale, 'countFemale' => $countFemale]; foreach ($ageRanges as $ageRange) { $maleCount = $specimenType->groupedSpecimenCount([Patient::MALE], $ageRange, $from, $toPlusOne->format('Y-m-d H:i:s')); $femaleCount = $specimenType->groupedSpecimenCount([Patient::FEMALE], $ageRange, $from, $toPlusOne->format('Y-m-d H:i:s')); $perAgeRange[$specimenType->id][$ageRange] = ['male' => $maleCount, 'female' => $femaleCount]; } } return View::make('reports.counts.groupedSpecimenCount')->with('specimenTypes', $specimenTypes)->with('ageRanges', $ageRanges)->with('gender', $gender)->with('perSpecimenType', $perSpecimenType)->with('perAgeRange', $perAgeRange)->withInput(Input::all()); } else { if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($date) || strtotime($to) > strtotime($date)) { Session::flash('message', trans('messages.check-date-range')); } $ungroupedTests = array(); foreach (TestType::all() as $testType) { $pending = $testType->countPerStatus([Test::PENDING, Test::STARTED], $from, $toPlusOne->format('Y-m-d H:i:s')); $complete = $testType->countPerStatus([Test::COMPLETED, Test::VERIFIED], $from, $toPlusOne->format('Y-m-d H:i:s')); $ungroupedTests[$testType->id] = ["complete" => $complete, "pending" => $pending]; } // $data = $data->groupBy('test_type_id')->paginate(Config::get('kblis.page-items')); return View::make('reports.counts.ungroupedTestCount')->with('ungroupedTests', $ungroupedTests)->withInput(Input::all()); } } } }
$female_total = array(); $cross_gender_total = array(); $age_total = array(); $age_total1 = array(); $age_total2 = array(); $curr_male_total = 0; $curr_female_total = 0; $curr_cross_gender_total = 0; $age_total; $age_total1; $age_total2; foreach ($site_list as $labConfigId) { $lab_config = get_lab_config_by_id($labConfigId); $testTypeId = $testIds[$labConfigId]; $saved_db = DbUtil::switchToLabConfig($labConfigId); $testType = TestType::getById($testTypeId); StatsLib::setDiseaseSetList($lab_config, $testType, $date_from, $date_to); DbUtil::switchRestore($saved_db); $is_range_options = true; if (strpos($measure->range, "/") === false) { $is_range_options = false; } $range_values = array(); if ($is_range_options) { # Alphanumeric options $range_values1 = explode("/", $measure->range); $range_values = str_replace("#", "/", $range_values1); } else { # Numeric ranges: Fetch ranges configured for this test-type/measure from DB $range_values = $disease_report->getMeasureGroupAsList(); }
function clean_range($test, $report_config, $patient) { $test_type = TestType::getById($test->testTypeId); $measure_list = $test_type->getMeasures(); $range_output = ''; $loop_count = 0; foreach ($measure_list as $measure) { $type = $measure->getRangeType(); if ($type == Measure::$RANGE_NUMERIC) { $range_list_array = $measure->getRangeString($patient); $lower = $range_list_array[0]; $upper = $range_list_array[1]; $unit = $measure->unit; if (stripos($unit, ",") != false) { $units = explode(",", $unit); $lower_parts = explode(".", $lower); $upper_parts = explode(".", $upper); if ($lower_parts[0] != 0) { $range_output .= $lower_parts[0]; $range_output .= $units[0]; } if ($lower_parts[1] != 0) { $range_output .= $lower_parts[1]; $range_output .= $units[1]; } $range_output .= "-"; if ($upper_parts[0] != 0) { $range_output .= $upper_parts[0]; $range_output .= $units[0]; } if ($upper_parts[1] != 0) { $range_output .= $upper_parts[1]; $range_output .= $units[1]; } } else { if (stripos($unit, ":") != false) { $units = explode(":", $unit); $range_output .= $lower; $range_output .= $units[0] . "-"; $range_output .= $upper; $range_output .= $units[0]; $range_output .= " " . $units[1]; } else { $range_output .= $lower . "-" . $upper; $range_output .= " " . $measure->unit; } } } else { if ($measure->unit == "") { $range_output .= ""; } } if ($loop_count < count($measure_list) - 1) { $range_output .= ", "; } $loop_count++; } // put ranges into an array $range_output_array = explode(", ", $range_output); return $range_output_array; }
/** * Given the test name we return the test type ID * * @param $testname the name of the test */ public static function getTestTypeIdByTestName($testName) { try { $testName = trim($testName); $testTypeId = TestType::where('name', 'like', $testName)->orderBy('name')->firstOrFail(); return $testTypeId->id; } catch (ModelNotFoundException $e) { Log::error("The test type ` {$testName} ` does not exist: " . $e->getMessage()); //TODO: send email? return null; } }
$i++; } DbUtil::switchRestore($saved_db); return $retval; } public static function getRangeInfectionStats($lab_config, $date_from, $date_to) { $test_type_list = get_range_value_test_types($lab_config); # For each test type, fetch all measures # For each measure, create distribution based on range foreach ($test_type_list as $test_type_id) { # Collect measure(s) information $measure_list = get_test_type_measures($test_type_id); $measure_meta_list = array(); foreach ($measure_list as $measure_id) { $measure = get_measure_by_id($measure_id); $measure_meta = new MeasureMeta(); $measure_meta->name = $measure->getName(); $measure_meta->countParts = array(); $range = $measure->range; if (strpos($range, ":") === false) { # Discrete value range $range_options = explode("#", $range); $measure_meta->rangeType = MeasureMeta::$DISCRETE; $measure_meta->rangeValues = $range_options; } else { # Continuous value range $range_bounds = explode(":", $range); $measure_meta->rangeType = MeasureMeta::$CONTINUOUS; $measure_meta->rangeValues = $range_bounds; } $measure_meta_list[] = $measure_meta; } # Calculate stats $query_string = "SELECT COUNT(*) AS count_val FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''"; $record = query_associative_one($query_string); $count_all = $record['count_val']; # Fetch result values $query_string = "SELECT t.result FROM test t, specimen s " . "WHERE t.test_type_id={$test_type_id} " . "AND t.specimen_id=s.specimen_id " . "AND ( s.date_collected BETWEEN '{$date_from}' AND '{$date_to}' ) " . "AND t.result <> ''"; $resultset = query_associative_all($query_string, $row_count); foreach ($resultset as $record) { $result_string = substr($record['result'], 0, -1); $result_list = explode(",", $result_string); for ($i = 0; $i < count($result_list); $i++) { $measure_meta = $measure_meta_list[$i]; if ($measure_meta->rangeType == MeasureMeta::$CONTINUOUS) { $range_bounds = $measure_meta->rangeValues; $interval = $range_bounds[1] - $range_bounds[0]; $base = $interval / 10; $offset = $result_list[$i] - $range_bounds[0]; $bucket = $offset / $base; echo $bucket; break;
/** * Save a new Test. * * @return Response */ public function saveNewTest() { //Create New Test $rules = array('visit_type' => 'required', 'physician' => 'required', 'testtypes' => 'required'); $validator = Validator::make(Input::all(), $rules); // process the login if ($validator->fails()) { return Redirect::route('test.create', array(Input::get('patient_id')))->withInput()->withErrors($validator); } else { $visitType = ['Out-patient', 'In-patient']; $activeTest = array(); /* * - Create a visit * - Fields required: visit_type, patient_id */ $visit = new Visit(); $visit->patient_id = Input::get('patient_id'); $visit->visit_type = $visitType[Input::get('visit_type')]; $visit->save(); /* * - Create tests requested * - Fields required: visit_id, test_type_id, specimen_id, test_status_id, created_by, requested_by */ $testTypes = Input::get('testtypes'); if (is_array($testTypes)) { foreach ($testTypes as $value) { $testTypeID = (int) $value; // Create Specimen - specimen_type_id, accepted_by, referred_from, referred_to $specimen = new Specimen(); $specimen->specimen_type_id = TestType::find($testTypeID)->specimenTypes->lists('id')[0]; $specimen->accepted_by = Auth::user()->id; $specimen->save(); $test = new Test(); $test->visit_id = $visit->id; $test->test_type_id = $testTypeID; $test->specimen_id = $specimen->id; $test->test_status_id = Test::PENDING; $test->created_by = Auth::user()->id; $test->requested_by = Input::get('physician'); $test->save(); $activeTest[] = $test->id; } } $url = Session::get('SOURCE_URL'); return Redirect::to($url)->with('message', 'messages.success-creating-test')->with('activeTest', $activeTest); } }
<?php # # Returns batch results entry form for a given test type # Called via ajax from results_entry.php # include "../includes/db_lib.php"; include "../includes/page_elems.php"; LangUtil::setPageId("results_entry"); $page_elems = new PageElems(); $test_type_id = $_REQUEST['t_type']; $date_to = $_REQUEST['date_to']; $date_from = $_REQUEST['date_from']; $date_from_array = explode("-", $date_from); $date_to_array = explode("-", $date_to); $test_type = TestType::getById($test_type_id); $lab_config = LabConfig::getById($_SESSION['lab_config_id']); $worksheet_config = $lab_config->getWorkSheetConfig($test_type_id); # Fetch all measures for this test type $measure_list = $test_type->getMeasures(); # Create a table with specimen ID field and these measures # Fetch currently pending tests for this test type $pending_tests = get_pending_tests_by_type_date($test_type_id, $date_from, $date_to); if (count($pending_tests) == 0 || $pending_tests == null) { ?> <div class='sidetip_nopos'> <?php echo get_test_name_by_id($test_type_id) . " " . LangUtil::$pageTerms['MSG_PENDINGNOTFOUND']; ?> . </div>
function get_records_to_print($lab_config, $patient_id) { global $date_from, $date_to, $LIS_DOCTOR; $retval = array(); if (isset($_REQUEST['ip']) && $_REQUEST['ip'] == 0) { # Do not include pending tests $labsection = 0; if (isset($_REQUEST['labsection'])) { $labsection = $_REQUEST['labsection']; } if ($labsection == 0) { $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.result <> '' " . "AND t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; } else { $query_string = "SELECT distinct t.* FROM test t, specimen sp, test_type tt, test_category tc " . "WHERE t.specimen_id=sp.specimen_id " . "AND t.result <> '' " . "AND sp.patient_id={$patient_id} " . "AND t.test_type_id = tt.test_type_id " . "AND tt.test_type_id in (select test_type_id from test_type where test_category_id = {$labsection})"; } #Taking care of removal tests cases $query_string .= " AND t.test_id not in (select distinct r_id from removal_record where `status` = 1) "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } else { # Include pending tests $labsection = 0; if (isset($_REQUEST['labsection'])) { $labsection = $_REQUEST['labsection']; } if ($labsection == 0) { $query_string = "SELECT t.* FROM test t, specimen sp " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} "; } else { $query_string = "SELECT distinct t.* FROM test t, specimen sp, test_type tt, test_category tc " . "WHERE t.specimen_id=sp.specimen_id " . "AND sp.patient_id={$patient_id} " . "AND t.test_type_id = tt.test_type_id " . "AND tt.test_type_id in (select test_type_id from test_type where test_category_id = {$labsection})"; } #Taking care of removal tests cases $query_string .= " AND t.test_id not in (select distinct r_id from removal_record where `status` = 1) "; if (isset($_REQUEST['yf'])) { $query_string .= "AND (sp.date_collected BETWEEN '{$date_from}' AND '{$date_to}') "; } $query_string .= "ORDER BY sp.date_collected DESC"; } $resultset = query_associative_all($query_string, $row_count); if (count($resultset) == 0 || $resultset == null) { return $retval; } foreach ($resultset as $record) { $test = Test::getObject($record); if ($_SESSION['user_level'] == $LIS_DOCTOR) { if ($test->verifiedBy == 0) { continue; } } $hide_patient_name = TestType::toHidePatientName($test->testTypeId); if ($hide_patient_name == 1) { $hidePatientName = 1; } $specimen = get_specimen_by_id($test->specimenId); $retval[] = array($test, $specimen, $hide_patient_name); } return $retval; }
/** * Display data after applying the filters on the report uses patient ID * * @return Response */ public function cd4() { // check if accredited $accredited = array(); $from = Input::get('start'); $to = Input::get('end'); $pending = Input::get('pending'); $date = date('Y-m-d'); $error = ''; // Check dates if (!$from) { $from = date('Y-m-01'); } if (!$to) { $to = $date; } // Get columns $columns = array(Lang::choice('messages.cd4-less', 1), Lang::choice('messages.cd4-greater', 1)); $rows = array(Lang::choice('messages.baseline', 1), Lang::choice('messages.follow-up', 1)); // Get test $test = TestType::find(TestType::getTestTypeIdByTestName('cd4')); $counts = array(); foreach ($columns as $column) { foreach ($rows as $row) { if ($test != null) { $counts[$column][$row] = $test->cd4($from, $to, $column, $row); } else { $counts[$column][$row] = 0; } } } if (Input::has('word')) { $date = date("Ymdhi"); $fileName = "cd4_report_" . $date . ".doc"; $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName); $content = View::make('reports.cd4.export')->with('columns', $columns)->with('rows', $rows)->with('accredited', $accredited)->with('test', $test)->with('counts', $counts)->withInput(Input::all()); return Response::make($content, 200, $headers); } else { if (Input::has('excel')) { $date = date("Ymdhi"); $fileName = "cd4_report_" . $date . ".xls"; $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName); $content = View::make('reports.cd4.export')->with('columns', $columns)->with('rows', $rows)->with('accredited', $accredited)->with('test', $test)->with('counts', $counts)->withInput(Input::all()); return Response::make($content, 200, $headers); } else { return View::make('reports.cd4.index')->with('columns', $columns)->with('rows', $rows)->with('accredited', $accredited)->with('test', $test)->with('counts', $counts)->withInput(Input::all()); } } }
public function getCustomWorksheetSummary($worksheet) { ?> <table class='hor-minimalist-b' style='width:auto;'> <tbody> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['NAME']; ?></td> <td><?php echo $worksheet->name; ?></td> </tr> <tr valign='top'> <td>Header</td> <td><?php echo $worksheet->headerText; ?></td> </tr> <tr valign='top'> <td>Title</td> <td><?php echo $worksheet->titleText; ?></td> </tr> <tr valign='top'> <td>Footer</td> <td><?php echo $worksheet->footerText; ?></td> </tr> <tr valign='top'> <td><?php echo LangUtil::$pageTerms['MARGINS']; ?> (%)</td> <td> <?php echo LangUtil::$pageTerms['TOP'];?> <?php echo $worksheet->margins[ReportConfig::$TOP]; ?> <?php echo LangUtil::$pageTerms['BOTTOM'];?> <?php echo $worksheet->margins[ReportConfig::$BOTTOM]; ?> <?php echo LangUtil::$pageTerms['LEFT'];?> <?php echo $worksheet->margins[ReportConfig::$LEFT]; ?> <?php echo LangUtil::$pageTerms['RIGHT'];?> <?php echo $worksheet->margins[ReportConfig::$RIGHT]; ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['PATIENT_ID']; ?></td> <td> <?php if($worksheet->idFields[CustomWorksheet::$OFFSET_PID] == 1) { echo LangUtil::$generalTerms['YES']; } else { echo LangUtil::$generalTerms['NO']; } ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></td> <td> <?php if($worksheet->idFields[CustomWorksheet::$OFFSET_DNUM] == 1) { echo LangUtil::$generalTerms['YES']; } else { echo LangUtil::$generalTerms['NO']; } ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$generalTerms['ADDL_ID']; ?></td> <td> <?php if($worksheet->idFields[CustomWorksheet::$OFFSET_ADDLID] == 1) { echo LangUtil::$generalTerms['YES']; } else { echo LangUtil::$generalTerms['NO']; } ?> </td> </tr> <tr valign='top'> <td><?php echo LangUtil::$pageTerms['CUSTOMFIELDS']; ?></td> <td> <span id='uf_list_box'> <?php foreach($worksheet->userFields as $field_entry) { $field_id = $field_entry[0]; $field_name = $field_entry[1]; $field_width = $field_entry[2]; echo $field_name; echo " ("; echo LangUtil::$pageTerms['COLUMN_WIDTH'].": "; echo $field_width; echo ")"; echo "<br>"; } ?> </span> </td> </tr> </table> <br> <div class='smaller_font' style='width:auto;'> <?php $test_type_list = $worksheet->testTypes; foreach($test_type_list as $test_type_id) { $test_type = TestType::getById($test_type_id); $measure_list = $test_type->getMeasures(); ?> <div> <b><?php echo $test_type->getName(); ?></b> <br> <div id='ttype_<?php echo $test_type->testTypeId; ?>_mlist' style='position:relative; margin-left:15px;'> <table class='hor-minimalist-b'> <thead> <tr> <th style='width:200px;'><?php echo LangUtil::$generalTerms['MEASURES']; ?></th> <th><?php echo LangUtil::$pageTerms['COLUMN_WIDTH']; ?> (%)</th> </tr> <?php foreach($measure_list as $measure) { $measure_id = $measure->measureId; ?> <tr> <td> <?php echo $measure->getName(); ?> </td> <td> <?php echo $worksheet->columnWidths[$test_type_id][$measure_id]; ?> </td> </tr> <?php } ?> </thead> <tbody> </tbody> </table> </div> </div> <br> <?php } ?> </div> </div> <?php }
/** * Function for processing the requests we receive from the external system * and putting the data into our system. * * @var array lab_requests */ public function process($labRequest) { //First: Check if patient exists, if true dont save again $patient = Patient::where('external_patient_number', '=', $labRequest->patient->id)->get(); if (!$patient->first()) { $patient = new Patient(); $patient->external_patient_number = $labRequest->patient->id; $patient->patient_number = $labRequest->patient->id; $patient->name = $labRequest->patient->fullName; $gender = array('Male' => Patient::MALE, 'Female' => Patient::FEMALE); $patient->gender = $gender[$labRequest->patient->gender]; $patient->dob = $labRequest->patient->dateOfBirth; $patient->address = $labRequest->address->address; $patient->phone_number = $labRequest->address->phoneNumber; $patient->created_by = User::EXTERNAL_SYSTEM_USER; $patient->save(); } else { $patient = $patient->first(); } //We check if the test exists in our system if not we just save the request in stagingTable if ($labRequest->parentLabNo == '0') { $testTypeId = TestType::getTestTypeIdByTestName($labRequest->investigation); } else { $testTypeId = null; } if (is_null($testTypeId) && $labRequest->parentLabNo == '0') { $this->saveToExternalDump($labRequest, ExternalDump::TEST_NOT_FOUND); return; } //Check if visit exists, if true dont save again $visitType = array('ip' => 'In-patient', 'op' => 'Out-patient'); //Should be a constant $visit = Visit::where('visit_number', '=', $labRequest->patientVisitNumber)->where('visit_type', '=', $visitType[$labRequest->orderStage])->get(); if (!$visit->first()) { $visit = new Visit(); $visit->patient_id = $patient->id; $visit->visit_type = $visitType[$labRequest->orderStage]; $visit->visit_number = $labRequest->patientVisitNumber; // We'll save Visit in a transaction a little bit below } else { $visit = $visit->first(); if (strcmp($visitType[$labRequest->orderStage], $visit->visit_type) != 0) { $visit = new Visit(); $visit->patient_id = $patient->id; $visit->visit_type = $visitType[$labRequest->orderStage]; $visit->visit_number = $labRequest->patientVisitNumber; } } $test = null; //Check if parentLabNO is 0 thus its the main test and not a measure if ($labRequest->parentLabNo == '0') { //Check via the labno, if this is a duplicate request and we already saved the test $test = Test::where('external_id', '=', $labRequest->labNo)->get(); if (!$test->first()) { //Specimen $specimen = new Specimen(); $specimen->specimen_type_id = TestType::find($testTypeId)->specimenTypes->lists('id')[0]; // We'll save the Specimen in a transaction a little bit below $test = new Test(); $test->test_type_id = $testTypeId; $test->test_status_id = Test::NOT_RECEIVED; $test->created_by = User::EXTERNAL_SYSTEM_USER; //Created by external system 0 $test->requested_by = $labRequest->requestingClinician; $test->external_id = $labRequest->labNo; DB::transaction(function () use($visit, $specimen, $test) { $visit->save(); $specimen->save(); $test->visit_id = $visit->id; $test->specimen_id = $specimen->id; $test->save(); }); $this->saveToExternalDump($labRequest, $test->id); return; } } $this->saveToExternalDump($labRequest, null); }
function get_cumul_stats($lab_config_id, $test_type_id, $date_from, $date_to) { $lab_config = LabConfig::getById($lab_config_id); $test_type = TestType::getById($test_type_id); $measure_list = $test_type->getMeasures(); $site_settings = DiseaseReport::getByKeys($lab_config->id, 0, 0); $age_group_list = $site_settings->getAgeGroupAsList(); ?> <table class='pretty_print' style='border-collapse: collapse;'> <thead> <tr valign='top'> <th><?php echo LangUtil::$generalTerms['TEST']; ?> </th> <th ><?php echo LangUtil::$generalTerms['RESULTS']; ?> </th> <?php if ($site_settings->groupByGender == 1) { echo "<th >" . LangUtil::$generalTerms['GENDER'] . "</th>"; } if ($site_settings->groupByAge == 1) { echo "<th >" . LangUtil::$pageTerms['RANGE_AGE'] . "</th>"; for ($i = 1; $i < count($age_group_list); $i++) { echo "<th >" . LangUtil::$pageTerms['RANGE_AGE'] . "</th>"; } } if ($site_settings->groupByGender == 1) { echo "<th ></th>"; } ?> <th ><?php echo LangUtil::$pageTerms['TOTAL']; ?> </th> <th ><?php echo LangUtil::$pageTerms['TOTAL_TESTS']; ?> </th> </tr> <tr> <th ></th> <th ></th> <?php if ($site_settings->groupByGender == 1) { echo "<th ></th>"; } if ($site_settings->groupByAge == 1) { foreach ($age_group_list as $age_slot) { echo "<th>{$age_slot['0']}"; if (trim($age_slot[1]) == "+") { echo "+"; } else { echo " - {$age_slot['1']}"; } echo "</th>"; } } if ($site_settings->groupByGender == 1) { echo "<th >" . LangUtil::$pageTerms['TOTAL_MF'] . "</th>"; } echo "<th ></th>"; echo "<th ></th>"; ?> <tr> </thead> <tbody> <?php StatsLib::setDiseaseSetList($lab_config, $test_type, $date_from, $date_to); $measures = $test_type->getMeasures(); foreach ($measures as $measure) { $male_total = array(); $female_total = array(); $cross_gender_total = array(); $curr_male_total = 0; $curr_female_total = 0; $curr_cross_gender_total = 0; $disease_report = DiseaseReport::getByKeys($lab_config->id, $test_type->testTypeId, $measure->measureId); if ($disease_report == null) { # TODO: Check for error control # Alphanumeric values. Hence entry not found. //continue; } $is_range_options = true; if (strpos($measure->range, "/") === false) { $is_range_options = false; } $range_values = array(); if ($is_range_options) { # Alphanumeric options $range_values = explode("/", $measure->range); } else { # Numeric ranges: Fetch ranges configured for this test-type/measure from DB $range_values = $disease_report->getMeasureGroupAsList(); } ?> <tr valign='top'> <td><?php echo $measure->getName(); ?> </td> <td> <?php foreach ($range_values as $range_value) { if ($is_range_options) { echo "{$range_value}<br>"; } else { echo "{$range_value['0']}-{$range_value['1']}<br>"; } if ($site_settings->groupByGender == 1) { echo "<br>"; } } ?> </td> <?php if ($site_settings->groupByGender == 1) { # Group by gender set to true echo "<td>"; for ($i = 1; $i <= count($range_values); $i++) { echo "M<br>F<br>"; } } if ($site_settings->groupByAge == 1) { # Group by age set to true: Fetch age slots from DB $age_slot_list = $site_settings->getAgeGroupAsList(); foreach ($age_slot_list as $age_slot) { echo "<td>"; $range_value_count = 0; foreach ($range_values as $range_value) { $range_value_count++; if (!isset($male_total[$range_value_count])) { $male_total[$range_value_count] = 0; $female_total[$range_value_count] = 0; $cross_gender_total[$range_value_count] = 0; } $curr_male_total = 0; $curr_female_total = 0; $curr_cross_gender_total = 0; $range_type = DiseaseSetFilter::$CONTINUOUS; if ($is_range_options == true) { $range_type = DiseaseSetFilter::$DISCRETE; } if ($site_settings->groupByGender == 0) { # No genderwise count required. # Create filter $disease_filter = new DiseaseSetFilter(); $disease_filter->patientAgeRange = $age_slot; $disease_filter->patientGender = null; $disease_filter->measureId = $measure->measureId; $disease_filter->rangeType = $range_type; $disease_filter->rangeValues = $range_value; $curr_total = StatsLib::getDiseaseFilterCount($disease_filter); $curr_cross_gender_total += $curr_total; echo "{$curr_total}<br>"; } else { # Genderwise count required. # Create filter $disease_filter = new DiseaseSetFilter(); $disease_filter->patientAgeRange = $age_slot; $disease_filter->measureId = $measure->measureId; $disease_filter->rangeType = $range_type; $disease_filter->rangeValues = $range_value; ## Count for males. $disease_filter->patientGender = 'M'; $curr_total1 = StatsLib::getDiseaseFilterCount($disease_filter); $curr_male_total += $curr_total1; ## Count for females. $disease_filter->patientGender = 'F'; $curr_total2 = StatsLib::getDiseaseFilterCount($disease_filter); $curr_female_total += $curr_total2; echo "{$curr_total1}<br>{$curr_total2}<br>"; } # Build assoc list to track genderwise totals $male_total[$range_value_count] += $curr_male_total; $female_total[$range_value_count] += $curr_female_total; $cross_gender_total[$range_value_count] += $curr_cross_gender_total; } echo "</td>"; } } else { # Age slots not configured: Show cumulative count for all age values $range_value_count = 0; foreach ($range_values as $range_value) { $range_value_count++; if (!isset($male_total[$range_value_count])) { $male_total[$range_value_count] = 0; $female_total[$range_value_count] = 0; $cross_gender_total[$range_value_count] = 0; } $curr_male_total = 0; $curr_female_total = 0; $curr_cross_gender_total = 0; $range_type = DiseaseSetFilter::$CONTINUOUS; if ($is_range_options == true) { $range_type = DiseaseSetFilter::$DISCRETE; } if ($site_settings->groupByGender == 0) { # No genderwise count required. # Create filter $disease_filter = new DiseaseSetFilter(); $disease_filter->patientAgeRange = array(0, 200); $disease_filter->patientGender = null; $disease_filter->measureId = $measure->measureId; $disease_filter->rangeType = $range_type; $disease_filter->rangeValues = $range_value; $curr_total = StatsLib::getDiseaseFilterCount($disease_filter); $curr_cross_gender_total += $curr_total; } else { # Genderwise count required. # Create filter $disease_filter = new DiseaseSetFilter(); $disease_filter->patientAgeRange = array(0, 200); $disease_filter->measureId = $measure->measureId; $disease_filter->rangeType = $range_type; $disease_filter->rangeValues = $range_value; ## Count for males. $disease_filter->patientGender = 'M'; $curr_total1 = StatsLib::getDiseaseFilterCount($disease_filter); $curr_male_total += $curr_total1; ## Count for females. $disease_filter->patientGender = 'F'; $curr_total2 = StatsLib::getDiseaseFilterCount($disease_filter); $curr_female_total += $curr_total2; } # Build assoc list to track genderwise totals $male_total[$range_value_count] += $curr_male_total; $female_total[$range_value_count] += $curr_female_total; $cross_gender_total[$range_value_count] += $curr_cross_gender_total; } } if ($site_settings->groupByGender == 1) { echo "<td>"; for ($i = 1; $i <= count($range_values); $i++) { $this_male_total = $male_total[$i]; $this_female_total = $female_total[$i]; echo "{$this_male_total}<br>{$this_female_total}<br>"; $this_cross_gender_total = $this_male_total + $this_female_total; } echo "</td>"; } echo "<td>"; for ($i = 1; $i <= count($range_values); $i++) { if ($site_settings->groupByGender == 1) { echo $male_total[$i] + $female_total[$i]; echo "<br><br>"; } else { echo $cross_gender_total[$i]; echo "<br>"; } } echo "</td>"; # Grand total: # TODO: Check the following function for off-by-one error //$disease_total = StatsLib::getDiseaseTotal($lab_config, $test, $date_from, $date_to); //echo "<td >$disease_total</td>"; echo "<td>"; if ($site_settings->groupByGender == 1) { echo array_sum($male_total) + array_sum($female_total); } else { echo array_sum($cross_gender_total); } echo "</td>"; ?> </tr> <?php } ?> </tbody> </table> <?php }