public function filterBykeyword(Request $request) { $filterKeyword = $request->input('filterKeyword'); $specimens = Specimen::where('genusName', $filterKeyword)->get(); // return response()->json(['name' => 'Abigail', 'state' => 'CA']); return $specimens; }
public static function renderFormInteriorForNewSpecimen($unique_str, $db_connection) { $s = Specimen::createNewSpecimenForNotebookPage(0, $db_connection); $s->specimen_id = $unique_str; $rendered = '<h3><input type="text" name="specimen-name_' . $s->specimen_id . '" id="specimen-name_' . $s->specimen_id . '" value="' . htmlentities($s->name) . '"/></h3>' . "\n" . '<ul class="base-info">' . "\n" . ' <li><div class="field-label">' . util_lang('coordinates') . '</div> : <div class="field-value"><input type="text" name="specimen-gps_longitude_' . $s->specimen_id . '" id="specimen-gps_longitude_' . $s->specimen_id . '" value="' . htmlentities($s->gps_longitude) . '"/>, <input type="text" name="specimen-gps_latitude_' . $s->specimen_id . '" id="specimen-gps_latitude_' . $s->specimen_id . '" value="' . htmlentities($s->gps_latitude) . '"/></div></li>' . "\n" . ' <li><div class="field-label">' . util_lang('notes') . '</div> : <div class="field-value"><textarea name="specimen-notes_' . $s->specimen_id . '" id="specimen-notes_' . $s->specimen_id . '" class="specimen-notes" row="4" cols="120">' . htmlentities($s->notes) . '</textarea></div></li>' . "\n" . ' <li><div class="field-label">' . util_lang('catalog_identifier') . '</div> : <div class="field-value"><input type="text" name="specimen-catalog_identifier_' . $s->specimen_id . '" id="specimen-catalog_identifier_' . $s->specimen_id . '" value="' . htmlentities($s->catalog_identifier) . '"/></div></li>' . "\n" . ' <li><b><i>' . util_lang('msg_save_page_before_image_upload', 'ucfirst') . '</i></b></li>' . "\n" . '</ul>'; return $rendered; }
function get_activity_specimen($lab_config_id, $user_id, $date_from, $date_to) { $query_string = "SELECT * from specimen " . "WHERE user_id={$user_id} " . "AND (date_collected BETWEEN '{$date_from}' AND '{$date_to}') " . "ORDER BY date_collected DESC"; $resultset = query_associative_all($query_string, $row_count); $retval = array(); foreach ($resultset as $record) { $specimen = Specimen::getObject($record); $retval[] = $specimen; } return $retval; }
function testNewPageFieldForm() { $this->doLoginBasic(); global $DB; $DB = $this->DB; $this->get('http://localhost/digitalfieldnotebooks/ajax_actions/specimen.php?action=create&unique=ABC123¬ebook_page_id=1101'); $this->checkBasicAsserts(); $expected = '<div class="specimen embedded">' . "\n" . Specimen::renderFormInteriorForNewSpecimen('ABC123', $this->DB) . "\n</div>"; $results = json_decode($this->getBrowser()->getContent()); $this->assertEqual('success', $results->status); $this->assertEqual($expected, $results->html_output); $this->assertNoPattern('/IMPLEMENTED/'); }
function get_records_to_print($lab_config, $test_type_id, $date_from, $date_to) { $saved_db = DbUtil::switchToLabConfig($lab_config->id); $retval = array(); $query_string = "SELECT * FROM test WHERE test_type_id={$test_type_id} " . "AND specimen_id IN ( " . "SELECT specimen_id FROM specimen " . "WHERE date_collected BETWEEN '{$date_from}' AND '{$date_to}' " . ")"; $resultset = query_associative_all($query_string, $row_count); foreach ($resultset as $record) { $test = Test::getObject($record); $specimen = Specimen::getById($test->specimenId); $patient = Patient::getById($specimen->patientId); $retval[] = array($test, $specimen, $patient); } DbUtil::switchRestore($saved_db); return $retval; }
/** * Returns grouped specimen Counts with optional gender, age range, date range * * @param $gender, $ageRange, $from, $to */ public function groupedSpecimenCount($gender = null, $ageRange = null, $from = null, $to = null) { $specimens = Specimen::where('specimen_type_id', $this->id)->whereIn('specimen_status_id', [Specimen::ACCEPTED]); if ($to && $from) { $specimens = $specimens->whereBetween('time_accepted', [$from, $to]); } if ($gender) { $specimens = $specimens->join('tests', 'specimens.id', '=', 'tests.specimen_id')->join('visits', 'tests.visit_id', '=', 'visits.id')->join('patients', 'visits.patient_id', '=', 'patients.id')->whereIn('gender', $gender); } if ($ageRange) { $ageRange = explode('-', $ageRange); $ageStart = $ageRange[0]; $ageEnd = $ageRange[1]; $now = new DateTime('now'); $finishDate = $now->sub(new DateInterval('P' . $ageStart . 'Y'))->format('Y-m-d'); $startDate = $now->sub(new DateInterval('P' . $ageEnd . 'Y'))->format('Y-m-d'); $specimens = $specimens->whereBetween('dob', [$startDate, $finishDate]); } return $specimens->count(); }
public function getReportResultsForm($form_name, $form_id) { $specimen_list = Specimen::getUnreported(); if($specimen_list == null || count($specimen_list) == 0) return; ?> <table class='tablesorter'> <thead> <tr valign='top'> <?php if($_SESSION['pid'] != 0) { ?> <th><?php echo LangUtil::$generalTerms['PATIENT_ID']; ?></th> <?php } if($_SESSION['dnum'] != 0) { ?> <th><?php echo LangUtil::$generalTerms['PATIENT_DAILYNUM']; ?></th> <?php } if($_SESSION['s_addl'] != 0) { ?> <th><?php echo LangUtil::$generalTerms['SPECIMEN_ID']; ?></th> <?php } ?> <th><?php echo LangUtil::$generalTerms['PATIENT_NAME']; ?></th> <th><?php echo LangUtil::$generalTerms['SPECIMEN_TYPE']; ?></th> <th><?php echo LangUtil::$generalTerms['C_DATE']; ?></th> <th><?php echo LangUtil::$generalTerms['TESTS']; ?></th> <th><?php echo LangUtil::$generalTerms['REPORT_TO']; ?></th> <th> <?php echo LangUtil::$generalTerms['REPORTED']; ?>? <input type='checkbox' name='check_all' id='check_all' onclick='checkoruncheckall();'> </input> </th> </tr> </thead> <tbody> <?php foreach($specimen_list as $specimen) { $test_list = get_tests_by_specimen_id($specimen->specimenId); $patient = Patient::getById($specimen->patientId); ?> <tr valign='top'> <input type='hidden' name='sid[]' value='<?php echo $specimen->specimenId; ?>'></input> <?php if($_SESSION['pid'] != 0) { ?> <td><?php echo $specimen->getSurrogateId(); ?></td> <?php } if($_SESSION['dnum'] != 0) { ?> <td><?php $specimen->getDailyNum(); ?></td> <?php } if($_SESSION['s_addl'] != 0) { ?> <td><?php $specimen->getAuxId(); ?></td> <?php } ?> <td><?php echo $patient->getName(); ?></td> <td><?php echo get_specimen_name_by_id($specimen->specimenTypeId); ?></td> <td><?php echo DateLib::mysqlToString($specimen->dateCollected)." ".$specimen->timeCollected; ?></td> <td> <?php foreach($test_list as $test) { echo get_test_name_by_id($test->testTypeId); echo "<br>"; } ?> </td> <td><?php echo $specimen->getReportTo(); ?></td> <td> <center> <input type='checkbox' class='report_flag' name='mark_<?php echo $specimen->specimenId; ?>'></input> </center> </td> </tr> <?php } ?> </tbody> </table> <?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); }
<?php # # Main page for marking specimen results as reported # Called via Ajax from results_entry.php # include "../includes/db_lib.php"; $sid_list = $_REQUEST['sid']; foreach ($sid_list as $sid) { $marker_key = 'mark_' . $sid; if (isset($_REQUEST[$marker_key])) { # Mark specimen as reported $ts = date("Y-m-d H:i:s"); Specimen::markAsReported($sid, $ts); } }
exit; } # 2. confirm that the user is allowed to take that action // global specimen create // additional permission checks are handled at the save point for notebook pages and authoritative plants respectively $has_permission = $USER->flag_is_system_admin; if (!$has_permission) { $USER->cacheRoleActionTargets(); // check global specimen perms (indiv specimen perms are only for editing, not creating, as indiv perms require a specific object ID as a target for the permission) if (in_array('global_specimen', array_keys($USER->cached_role_action_targets_hash_by_target_type_by_id))) { foreach ($USER->cached_role_action_targets_hash_by_target_type_by_id['global_specimen'] as $glob_rat) { if ($glob_rat->action_id == $ACTIONS['create']->action_id) { $has_permission = true; break; } } } } if (!$has_permission) { $results['note'] = util_lang('no_permission'); echo json_encode($results); exit; } # 3. branch behavior based on the action # create - return an appropriate form field set if ($has_permission && $action == 'create') { $results['html_output'] = '<div class="specimen embedded">' . "\n" . Specimen::renderFormInteriorForNewSpecimen($unique_str, $DB) . "\n</div>"; $results['status'] = 'success'; } echo json_encode($results); exit;
$specimen_list = search_specimens_by_session_exact($session_num); $all_done = true; foreach ($specimen_list as $specimen) { $test_list = get_tests_by_specimen_id($specimen->specimenId); foreach ($test_list as $test) { if (trim($test->result) == "" || $test->result == null) { # This test pending $all_done = false; } } } if ($all_done) { echo "<br><br>"; echo LangUtil::$pageTerms['MSG_RESULTSUBMITTEDALL']; echo "<br>"; $original_specimen = Specimen::getById($_REQUEST['specimen_id']); $today = $original_specimen->dateRecvd; $today_parts = explode("-", $today); $url_string = "reports_testhistory.php?patient_id=" . $patient->patientId . "&location=" . $_SESSION['lab_config_id'] . "&yf=" . $today_parts[0] . "&mf=" . $today_parts[1] . "&df=" . $today_parts[2] . "&yt=" . $today_parts[0] . "&mt=" . $today_parts[1] . "&dt=" . $today_parts[2] . "&ip=0"; ?> <a href='<?php echo $url_string; ?> ' target='_blank'><?php echo $LANG_ARRAY['reports']['MENU_PATIENT']; ?> »</a> <?php } echo "<br><br>"; ?>
public function createSpecimen($testStatus, $specimenStatus, $specimenTypeID, $acceptor = 0, $rejector = 0, $rejectReason = "") { $values["specimen_type_id"] = $specimenTypeID; $values["specimen_status_id"] = $specimenStatus; if ($specimenStatus == Specimen::ACCEPTED) { $values["accepted_by"] = $acceptor; $values["time_accepted"] = date('Y-m-d H:i:s'); } if ($specimenStatus == Specimen::REJECTED) { $values["rejected_by"] = $rejector; $values["rejection_reason_id"] = $rejectReason; $values["time_rejected"] = date('Y-m-d H:i:s'); } $specimen = Specimen::create($values); return $specimen->id; }
public static function getUnreported() { # Returns all test results that have been entered but not reported $query_string = "SELECT sp.* FROM specimen sp " . "WHERE sp.report_to <> '' " . "AND sp.date_reported IS NULL " . "AND ( " . "SELECT DISTINCT t.specimen_id FROM test t " . "WHERE t.specimen_id=sp.specimen_id " . "AND t.result = '' " . ") IS NULL"; $resultset = query_associative_all($query_string, $row_count); $retval = array(); if ($resultset == null) { return $retval; } foreach ($resultset as $record) { $retval[] = Specimen::getObject($record); } return $retval; }
<th> <?php echo LangUtil::$generalTerms['CMD_VERIFY']; ?> ? <input type='checkbox' name='check_all' id='check_all' checked onchange='javascript:checkoruncheckall();'> </input> </th> </tr> </thead> <tbody> <?php $i = 1; foreach ($test_list as $test_entry) { $result_csv = explode(",", $test_entry->result); $specimen = Specimen::getById($test_entry->specimenId); $patient = Patient::getById($specimen->patientId); if ($patient != null) { ?> <tr valign='top'> <input type='hidden' name='specimen_id[]' value='<?php echo $test_entry->specimenId; ?> '></input> <?php if ($_SESSION['pid'] != 0) { ?> <td><?php echo $patient->getSurrogateId(); ?> </td>
function renderAsEdit() { $this->cacheExtras(); $this->cacheNotebookPages(); $this->cacheSpecimens(); $rendered = '<div id="rendered_authoritative_plant_' . $this->authoritative_plant_id . '" class="authoritative-plant edit-authoritative-plant" ' . $this->fieldsAsDataAttribs() . ' data-can-edit="1">' . "\n"; $rendered .= ' <form id="form-edit-authoritative-plant" action="' . APP_ROOT_PATH . '/app_code/authoritative_plant.php">' . "\n"; $rendered .= ' <input type="hidden" name="action" value="update"/>' . "\n"; $rendered .= ' <input type="hidden" id="authoritative_plant_id" name="authoritative_plant_id" value="' . $this->authoritative_plant_id . '"/>' . "\n"; $rendered .= ' <div id="actions"><button id="edit-submit-control" class="btn btn-success" type="submit" name="edit-submit-control" value="update"><i class="icon-ok-sign icon-white"></i> ' . util_lang('update', 'properize') . '</button>' . "\n"; $rendered .= ' <a id="edit-cancel-control" class="btn" href="/digitalfieldnotebooks/app_code/authoritative_plant.php?action=view&authoritative_plant_id=' . $this->authoritative_plant_id . '"><i class="icon-remove"></i> ' . util_lang('cancel', 'properize') . '</a> '; if ($this->authoritative_plant_id != 'NEW') { $rendered .= '<a id="edit-delete-authoritative-plant-control" class="btn btn-danger" href="/digitalfieldnotebooks/app_code/authoritative_plant.php?action=delete&authoritative_plant_id=' . $this->authoritative_plant_id . '"><i class="icon-trash icon-white"></i> ' . util_lang('delete', 'properize') . '</a>'; } $rendered .= '</div>' . "\n"; // basic data fields $rendered .= ' <ul class="base-info">' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('class') . '</div> : <div class="field-value taxonomy taxonomy-class"><input type="text" name="authoritative_plant-class_' . $this->authoritative_plant_id . '" id="authoritative_plant-class_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->class) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('order') . '</div> : <div class="field-value taxonomy taxonomy-order"><input type="text" name="authoritative_plant-order_' . $this->authoritative_plant_id . '" id="authoritative_plant-order_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->order) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('family') . '</div> : <div class="field-value taxonomy taxonomy-family"><input type="text" name="authoritative_plant-family_' . $this->authoritative_plant_id . '" id="authoritative_plant-family_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->family) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('genus') . '</div> : <div class="field-value taxonomy taxonomy-genus"><input type="text" name="authoritative_plant-genus_' . $this->authoritative_plant_id . '" id="authoritative_plant-genus_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->genus) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('species') . '</div> : <div class="field-value taxonomy taxonomy-species"><input type="text" name="authoritative_plant-species_' . $this->authoritative_plant_id . '" id="authoritative_plant-species_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->species) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('variety') . '</div> : <div class="field-value taxonomy taxonomy-variety"><input type="text" name="authoritative_plant-variety_' . $this->authoritative_plant_id . '" id="authoritative_plant-variety_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->variety) . '"/></div></li>' . "\n"; $rendered .= ' <li><div class="field-label">' . util_lang('catalog_identifier') . '</div> : <div class="field-value" taxonomy taxonomy-catalog_identifier><input type="text" name="authoritative_plant-catalog_identifier_' . $this->authoritative_plant_id . '" id="authoritative_plant-catalog_identifier_' . $this->authoritative_plant_id . '" value="' . htmlentities($this->catalog_identifier) . '"/></div></li>' . "\n"; $rendered .= ' </ul>' . "\n"; // flag active control $rendered .= ' <div class="active-state-controls"><input type="checkbox" name="flag_active" value="1"' . ($this->flag_active ? ' checked="checked"' : '') . '/> ' . util_lang('active') . '</div>' . "\n"; // extra info : common names (w/ reordering controls) if ($this->authoritative_plant_id != 'NEW') { $rendered .= ' <h5>' . util_lang('common_names', 'properize') . '</h5>' . "\n"; $rendered .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-common_name">' . "\n"; $rendered .= ' <li><a href="#" id="add_new_authoritative_plant_common_name_button" class="btn">' . util_lang('add_common_name') . '</a></li>' . "\n"; foreach ($this->extras as $ae) { if ($ae->type == 'common name') { $rendered .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $rendered .= ' </ul>' . "\n"; // extra info : images (w/ reordering controls) $rendered .= ' <h5>' . util_lang('images', 'properize') . '</h5>' . "\n"; $rendered .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-image">' . "\n"; $rendered .= ' <li><a href="#" id="add_new_authoritative_plant_image_button" class="btn">' . util_lang('add_image') . '</a></li>' . "\n"; foreach ($this->extras as $ae) { if ($ae->type == 'image') { $rendered .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $rendered .= ' </ul>' . "\n"; // extra info : text (w/ reordering controls) $rendered .= ' <h5>' . util_lang('descriptions', 'properize') . '</h5>' . "\n"; $rendered .= ' <ul class="authoritative-plant-extras authoritative-plant-extra-description">' . "\n"; $rendered .= ' <li><a href="#" id="add_new_authoritative_plant_description_button" class="btn">' . util_lang('add_description') . '</a></li>' . "\n"; foreach ($this->extras as $ae) { if ($ae->type == 'description') { $rendered .= ' ' . $ae->renderAsListItemEdit() . "\n"; } } $rendered .= ' </ul>' . "\n"; $rendered .= ' <input type="hidden" id="created_authoritative_plant_extra_ids" name="created_authoritative_plant_extra_ids" value=""/>' . "\n"; $rendered .= ' <input type="hidden" id="deleted_authoritative_plant_extra_ids" name="deleted_authoritative_plant_extra_ids" value=""/>' . "\n"; $rendered .= ' <input type="hidden" id="deleted_specimen_ids" name="deleted_specimen_ids" value=""/>' . "\n"; $rendered .= ' <input type="hidden" id="created_specimen_ids" name="created_specimen_ids" value=""/>' . "\n"; $rendered .= Specimen::renderSpecimenListBlock($this->specimens); } $rendered .= ' </form>' . "\n"; $rendered .= '</div>' . "\n"; return $rendered; }
public static function createBillForTests($tests, $lab_config_id) { # Create a new bill and associate all of the desired tests with it. // The way we call the bill constructor here is awkward and assumes that the tests are all for the same patient. // While that's true for now, it's not necessarily going to stay that way, so this may need to be revisited. -Robert. $bill = new Bill(Specimen::getById($tests[0]->specimenId)->patientId); $bill->create($lab_config_id); foreach ($tests as $test) { $association = new BillsTestsAssociationObject($bill->id, $test->testId); $association->create($lab_config_id); } return $bill; }
$importPatientId = $_REQUEST['patientId']; $importlabConfigIdEnd = strpos($importPatientId, "0"); $importLabConfigId = substr($importPatientId, 0, $importlabConfigIdEnd); /* $saved_db = DbUtil::switchToCountry($country); $querySelect = "SELECT * FROM patient ". "WHERE patient_id=$importPatientId"; $patientRecord = query_associative_one($querySelect); DbUtil::switchRestore($saved_db); */ $saved_db = DbUtil::switchToLabConfig($importLabConfigId); $querySelect = "SELECT * FROM specimen " . "WHERE patient_id={$importPatientId}"; $resultset = query_associative_all($querySelect, $rowCount); foreach ($resultset as $record) { $specimenRecords[] = Specimen::getObject($record); } foreach ($specimenRecords as $specimenRecord) { $querySelect = "SELECT * FROM test " . "WHERE specimen_id={$specimenRecord->specimenId}"; $resultset = query_associative_all($querySelect, $rowCount); foreach ($resultset as $record) { $testRecords[] = Test::getObject($record); } } DbUtil::switchRestore($saved_db); /* Build a mapping of Specimens from the Global Table & make appropriate substitutions */ $saved_db = DbUtil::switchToGlobal(); $querySelect = "SELECT * FROM specimen_mapping"; $resultset = query_associative_all($querySelect, $rowCount); if ($resultset) { $specimenIds = array();
$del_s->doDelete(); } } } } // altered $ap->cacheSpecimens(); foreach ($ap->specimens as $db_specimen) { $db_specimen->setFromArray($_REQUEST); $db_specimen->updateDb(); } // created $created_specimen_ids = explode(',', $_REQUEST['created_specimen_ids']); foreach ($created_specimen_ids as $created_specimen_id) { if ($created_specimen_id) { $new_s = Specimen::createNewSpecimenForAuthoritativePlant($ap->authoritative_plant_id, $DB); $new_s->specimen_id = $created_specimen_id; $new_s->setFromArray($_REQUEST); if ($new_s->name != util_lang('new_specimen_name')) { $new_s->specimen_id = 'NEW'; $new_s->updateDb(); } } } } $action = 'view'; } if ($action == 'list') { echo '<h2>' . ucfirst(util_lang('authoritative_plants')) . '</h2>' . "\n"; if ($USER->canActOnTarget($ACTIONS['edit'], $ap)) { ?>
$("#"+remarks_input_id).attr("value", msg) } }); */ var result_field_name = 'result_'+test_type_id+"_"+measure_id; var result_field_value = $("#"+result_field_name).val(); var comments_field_name = 'comments_'+test_type_id+"_"+measure_id; $("#"+comments_field_name).val(result_field_value); } </script> <br> <?php $tips_string = LangUtil::$pageTerms['TIPS_ENTRY']; $page_elems->getSideTip(LangUtil::$generalTerms['TIPS'], $tips_string); $specimen_id = $_REQUEST['sid']; $specimen = Specimen::getById($_REQUEST['sid']); ?> <b><?php echo LangUtil::$pageTerms['TITLE_ENTRY']; ?> </b> | <a href='javascript:history.go(-1);'><?php echo LangUtil::$generalTerms['CMD_CANCEL']; ?> </a> <br><br> <?php if ($specimen == null) { ?> <div class='sidetip_nopos'> <?php
echo $patient->getAge(); ?> </td> <?php } ?> <?php if (strpos($_SERVER["HTTP_REFERER"], "search.php") !== false) { # Show status of most recently registered specimens $today = date("Y-m-d"); $query_string = "SELECT * FROM specimen WHERE patient_id={$patient->patientId} and date_collected='{$today}'"; $resultset = query_associative_all($query_string, $row_count); $status = LangUtil::$generalTerms['DONE']; foreach ($resultset as $record) { $specimen = Specimen::getObject($record); if ($specimen->statusCodeId == Specimen::$STATUS_PENDING || $specimen->statusCodeId == Specimen::$STATUS_REFERRED) { $status = LangUtil::$generalTerms['PENDING_RESULTS']; break; } } echo "<td>{$status}</td>"; } ?> <td> <?php if (strpos($_SERVER["HTTP_REFERER"], "find_patient.php") !== false || strpos($_SERVER["HTTP_REFERER"], "doctor_register.php") !== false) { # Called from find_patient.php. Show 'profile' and 'register specimen' link ?> <a href='new_specimen.php?pid=<?php echo $patient->patientId;
} $intitial_specimen_ids = explode(',', $_REQUEST['initial_specimen_ids']); foreach ($intitial_specimen_ids as $specimen_id) { if (!in_array($specimen_id, $deleted_specimen_ids)) { $s = Specimen::getOneFromDb(['specimen_id' => $specimen_id], $DB); if ($s->matchesDb) { $s->setFromArray($_REQUEST); $s->updateDb(); } } } $created_specimen_ids = explode(',', $_REQUEST['created_specimen_ids']); foreach ($created_specimen_ids as $created_specimen_id) { // echo "TO BE IMPLEMENTED: handle creation of specimens"; if ($created_specimen_id) { $new_s = Specimen::createNewSpecimenForNotebookPage($notebook_page->notebook_page_id, $DB); $new_s->specimen_id = $created_specimen_id; $new_s->setFromArray($_REQUEST); if ($new_s->name != util_lang('new_specimen_name')) { $new_s->specimen_id = 'NEW'; $new_s->updateDb(); } } } } $action = 'view'; } echo '<script src="' . APP_ROOT_PATH . '/js/notebook_page_general.js"></script>' . "\n"; if ($action == 'view') { if ($USER->canActOnTarget($ACTIONS['edit'], $notebook_page)) { echo '<div id="actions">' . $notebook_page->renderAsButtonEdit() . '</div>' . "\n";
<form id='payments_form' name='payments_form' action=''> <table class='tablesorter' id='bill_table' style="border-collapse: separate;"> <tr valign='top'> <th style="width: 75px;">Test Date</th> <th>Test Name</th> <th>Specimen Type</th> <th style="width: 80px;">Test Cost</th> <th>Discount Type</th> <th>Discount Amount</th> <th style="width: 80px;"></th> </tr> <?php foreach ($associations as $assoc) { $test = Test::getById($assoc->getTestId()); $testType = TestType::getById($test->testTypeId); $specimen = Specimen::getById($test->specimenId); ?> <tr> <td><?php echo date("Y-m-d", strtotime($test->timestamp)); ?> </td> <td><?php echo $testType->name; ?> </td> <td><?php echo $specimen->getTypeName(); ?> </td> <td id="calculated_cost_for_test_<?php
/** * Display a view of the daily patient records. * */ public function dailyLog() { $from = Input::get('start'); $to = Input::get('end'); $pendingOrAll = Input::get('pending_or_all'); $error = ''; // Check radiobutton for pending/all tests is checked and assign the 'true' value if (Input::get('tests') === '1') { $pending = 'true'; } $date = date('Y-m-d'); if (!$to) { $to = $date; } $toPlusOne = date_add(new DateTime($to), date_interval_create_from_date_string('1 day')); $records = Input::get('records'); $testCategory = Input::get('section_id'); $testType = Input::get('test_type'); $labSections = TestCategory::lists('name', 'id'); if ($testCategory) { $testTypes = TestCategory::find($testCategory)->testTypes->lists('name', 'id'); } else { $testTypes = array("" => ""); } if ($records == 'patients') { if ($from || $to) { if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($date) || strtotime($to) > strtotime($date)) { $error = trans('messages.check-date-range'); } else { $visits = Visit::whereBetween('created_at', array($from, $toPlusOne))->get(); } if (count($visits) == 0) { Session::flash('message', trans('messages.no-match')); } } else { $visits = Visit::where('created_at', 'LIKE', $date . '%')->orderBy('patient_id')->get(); } if (Input::has('word')) { $date = date("Ymdhi"); $fileName = "daily_visits_log_" . $date . ".doc"; $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName); $content = View::make('reports.daily.exportPatientLog')->with('visits', $visits)->withInput(Input::all()); return Response::make($content, 200, $headers); } else { return View::make('reports.daily.patient')->with('visits', $visits)->with('error', $error)->withInput(Input::all()); } } else { if ($records == 'rejections') { $specimens = Specimen::where('specimen_status_id', '=', Specimen::REJECTED); /*Filter by test category*/ if ($testCategory && !$testType) { $specimens = $specimens->join('tests', 'specimens.id', '=', 'tests.specimen_id')->join('test_types', 'tests.test_type_id', '=', 'test_types.id')->where('test_types.test_category_id', '=', $testCategory); } /*Filter by test type*/ if ($testCategory && $testType) { $specimens = $specimens->join('tests', 'specimens.id', '=', 'tests.specimen_id')->where('tests.test_type_id', '=', $testType); } /*Filter by date*/ if ($from || $to) { if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($date) || strtotime($to) > strtotime($date)) { $error = trans('messages.check-date-range'); } else { $specimens = $specimens->whereBetween('time_rejected', array($from, $toPlusOne))->get(array('specimens.*')); } } else { $specimens = $specimens->where('time_rejected', 'LIKE', $date . '%')->orderBy('id')->get(array('specimens.*')); } if (Input::has('word')) { $date = date("Ymdhi"); $fileName = "daily_rejected_specimen_" . $date . ".doc"; $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName); $content = View::make('reports.daily.exportSpecimenLog')->with('specimens', $specimens)->with('testCategory', $testCategory)->with('testType', $testType)->withInput(Input::all()); return Response::make($content, 200, $headers); } else { return View::make('reports.daily.specimen')->with('labSections', $labSections)->with('testTypes', $testTypes)->with('specimens', $specimens)->with('testCategory', $testCategory)->with('testType', $testType)->with('error', $error)->withInput(Input::all()); } } else { $tests = Test::whereNotIn('test_status_id', [Test::NOT_RECEIVED]); /*Filter by test category*/ if ($testCategory && !$testType) { $tests = $tests->join('test_types', 'tests.test_type_id', '=', 'test_types.id')->where('test_types.test_category_id', '=', $testCategory); } /*Filter by test type*/ if ($testType) { $tests = $tests->where('test_type_id', '=', $testType); } /*Filter by all tests*/ if ($pendingOrAll == 'pending') { $tests = $tests->whereIn('test_status_id', [Test::PENDING, Test::STARTED]); } else { if ($pendingOrAll == 'all') { $tests = $tests->whereIn('test_status_id', [Test::PENDING, Test::STARTED, Test::COMPLETED, Test::VERIFIED]); } else { $tests = $tests->whereIn('test_status_id', [Test::COMPLETED, Test::VERIFIED]); } } /*Get collection of tests*/ /*Filter by date*/ if ($from || $to) { if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($date) || strtotime($to) > strtotime($date)) { $error = trans('messages.check-date-range'); } else { $tests = $tests->whereBetween('time_created', array($from, $toPlusOne))->get(array('tests.*')); } } else { $tests = $tests->where('time_created', 'LIKE', $date . '%')->get(array('tests.*')); } if (Input::has('word')) { $date = date("Ymdhi"); $fileName = "daily_test_records_" . $date . ".doc"; $headers = array("Content-type" => "text/html", "Content-Disposition" => "attachment;Filename=" . $fileName); $content = View::make('reports.daily.exportTestLog')->with('tests', $tests)->with('testCategory', $testCategory)->with('testType', $testType)->with('pendingOrAll', $pendingOrAll)->withInput(Input::all()); return Response::make($content, 200, $headers); } else { return View::make('reports.daily.test')->with('labSections', $labSections)->with('testTypes', $testTypes)->with('tests', $tests)->with('counts', $tests->count())->with('testCategory', $testCategory)->with('testType', $testType)->with('pendingOrAll', $pendingOrAll)->with('error', $error)->withInput(Input::all()); } } } }
?> </th> <th><?php echo LangUtil::$generalTerms['CMD_SKIP']; ?> ?</th> <th><!-- Related Tests Column --></th> </tr> </thead> <tbody> <?php for ($i = 1; $i <= count($pending_tests); $i++) { ?> <tr valign='top'> <?php $specimen = Specimen::getById($pending_tests[$i - 1]->specimenId); $patient = Patient::getById($specimen->patientId); if ($worksheet_config->usePatientId != 0) { ?> <td><?php echo $patient->getSurrogateId(); ?> </td> <?php } if ($worksheet_config->useDailyNum != 0) { ?> <td><?php echo $specimen->getDailyNumFull(); ?> </td>
</tbody> @elseif($selectedReport == 2) <!-- Specimens Registry Report--> <thead> <tr> <th>{{Lang::choice('messages.specimen-number',1)}}</th> <th>{{Lang::choice('messages.specimen-type',1)}}</th> <th>{{Lang::choice('messages.patient-number',1)}}</th> <th>{{Lang::choice('messages.patient',1)}}</th> <th>{{Lang::choice('messages.registration-date',1)}}</th> </tr> </thead> <tbody> @forelse($reportData as $row) <?php $specimen = Specimen::find($row->id); ?> <tr> <td>{{$specimen->id}}</td> <td>{{$specimen->specimenType->name}}</td> <td>{{$specimen->test->visit->patient->patient_number}}</td> <td>{{$specimen->test->visit->patient->name}}</td> <td>{{$specimen->time_accepted}}</td> </tr> @empty <tr> <td colspan='6'>{{Lang::choice('messages.no-data-found',1)}}</td> </tr> @endforelse </tbody>
?> </th> <th><?php echo LangUtil::$generalTerms['SP_STATUS']; ?> </th> <th></th> </tr> </thead> <tbody> <?php for ($i = 0; $i < count($specimen_done_list); $i++) { $specimen_id = $specimen_done_list[$i]; $status = $status_list[$i]; $test_entry = $test_list[$i]; $specimen = Specimen::getById($specimen_id); $patient = Patient::getById($specimen->patientId); ?> <tr> <?php if ($_SESSION['pid'] != 0) { ?> <td><?php echo $patient->getSurrogateId(); ?> </td> <?php } if ($_SESSION['dnum'] != 0) { ?> <td><?php
public function getSpecimen() { return Specimen::getOneFromDb(['specimen_id' => $this->specimen_id, 'flag_delete' => FALSE], $this->dbConnection); }
public function process($labRequest) { //First: Check if patient exists, if true dont save again $patient = Patient::where('external_patient_number', '=', $labRequest->PatientNumber)->get(); if (!$patient->first()) { $patient = new Patient(); $patient->external_patient_number = $labRequest->PatientNumber; $patient->patient_number = $labRequest->PatientNumber; $patient->name = $labRequest->FullNames; $gender = array('M' => Patient::MALE, 'F' => Patient::FEMALE, 'U' => Patient::UNKNOWN); $patient->gender = $gender[$labRequest->Sex]; $patient->dob = $this->getDobFromAge($labRequest->Age); $patient->address = $labRequest->PoBox; $patient->phone_number = $labRequest->PatientsContact; $patient->created_by = User::EXTERNAL_SYSTEM_USER; } else { $patient = $patient->first(); } //We check if the test exists in our system if not we just save the request in stagingTable $testTypeId = TestType::getTestTypeIdByTestName($labRequest->investigation); if (is_null($testTypeId) && $labRequest->parentLabNo == '0') { $this->saveToExternalDump($labRequest, ExternalDump::TEST_NOT_FOUND); return; } //Check if visit exists, if true dont save again $visit = Visit::where('visit_number', '=', $labRequest->RevisitNumber)->get(); if (!$visit->first()) { $visit = new Visit(); $visit->visit_type = 'Out-patient'; // We'll save Visit in a transaction a little bit below } else { $visit = $visit->first(); } $test = null; //Check via the labno, if this is a duplicate request and we already saved the test $test = Test::where('external_id', '=', $labRequest->RequestID)->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->DoctorRequesting; $test->external_id = $labRequest->RequestID; DB::transaction(function () use($visit, $specimen, $test, $patient) { $patient->save(); $visit->patient_id = $patient->id; $visit->visit_number = Visit::orderBy('id', 'desc')->first()->id + 1; //$labRequest->RevisitNumber; $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); mssql_close($connection); }
public function testWaitTime() { $specIDs = Specimen::where('specimen_status_id', '!=', Specimen::NOT_COLLECTED)->lists('id'); if (count($specIDs) == 0) { $this->assertTrue(false); } foreach ($specIDs as $id) { $test = Specimen::find($id)->test()->first(); $this->assertTrue($test->getWaitTime() >= 0); } }
$results['html_output'] = $newSpecimenImage->renderAsListItemEdit(); $results['status'] = 'success'; } elseif ($has_permission && $action == 'delete') { $specimenImage->doDelete(); $specimenImageDel = Specimen_Image::getOneFromDb(['specimen_image_id' => $specimenImageId], $DB); if (!$specimenImageDel->matchesDb) { $results['status'] = 'success'; } else { $results['note'] = util_lang('msg_delete_failed'); echo json_encode($results); exit; } } elseif ($has_permission && $action == 'reorder') { // get the specimen if (!$specimen) { $specimen = Specimen::getOneFromDb(['specimen_id' => $specimenId], $DB); } // get the image for it $specimen->loadImages(); foreach ($specimen->images as $si) { $req_key = 'ordering_' . $si->specimen_image_id; if (array_key_exists($req_key, $_REQUEST) && is_numeric($_REQUEST[$req_key])) { $si->ordering = $_REQUEST[$req_key]; $si->updateDb(); if (!$si->matchesDb) { $results['note'] = util_lang('msg_database_update_failed'); echo json_encode($results); exit; } } }