Example #1
0
                $query_string = "SELECT s.specimen_id FROM specimen s, test t, patient p " . "WHERE s.specimen_id=t.specimen_id " . "AND t.result = '' " . "AND s.patient_id=p.patient_id " . "AND p.name LIKE '{$attrib_value}' LIMIT {$offset},{$result_cap}";
            } else {
                $query_string = "SELECT s.specimen_id FROM specimen s, test t, patient p " . "WHERE s.specimen_id=t.specimen_id " . "AND t.result = '' " . "AND s.patient_id=p.patient_id " . "AND p.name LIKE '{$attrib_value}' AND test_type_id IN\r\n\t\t\t\t\t(SELECT test_type_id FROM test_type WHERE test_category_id={$lab_section}) LIMIT {$offset},{$result_cap}";
            }
        } else {
            if ($attrib_type == 3) {
                # Search by patient daily number
                if ($lab_section == 0) {
                    $query_string = "SELECT specimen_id FROM specimen " . "WHERE daily_num LIKE '%-{$attrib_value}' " . "AND ( status_code_id=" . Specimen::$STATUS_PENDING . " " . "OR status_code_id=" . Specimen::$STATUS_REFERRED . " ) " . "ORDER BY date_collected DESC LIMIT {$offset},{$result_cap}";
                } else {
                    $query_string = "SELECT s.specimen_id FROM specimen s, test t WHERE s.specimen_id = t.specimen_id AND " . "daily_num LIKE '%-{$attrib_value}'" . "AND ( status_code_id=" . Specimen::$STATUS_PENDING . " " . "OR status_code_id=" . Specimen::$STATUS_REFERRED . " ) AND t.test_type_id IN\r\n\t\t\t\t\t(SELECT test_type_id FROM test_type WHERE test_category_id={$lab_section})" . "ORDER BY date_collected DESC LIMIT {$offset},{$result_cap}";
                }
            } else {
                if ($attrib_type == 9) {
                    # Search by patient specimen id
                    $decoded = decodeSpecimenBarcode($attrib_value);
                    if ($lab_section == 0) {
                        $query_string = "SELECT specimen_id FROM specimen " . "WHERE specimen_id = {$decoded['1']} " . "AND ( status_code_id=" . Specimen::$STATUS_PENDING . " " . "OR status_code_id=" . Specimen::$STATUS_REFERRED . " ) " . "ORDER BY date_collected DESC LIMIT {$offset},{$result_cap}";
                    } else {
                        $query_string = "SELECT specimen_id FROM specimen " . "WHERE specimen_id = {$decoded['1']} " . "AND ( status_code_id=" . Specimen::$STATUS_PENDING . " " . "OR status_code_id=" . Specimen::$STATUS_REFERRED . " ) " . "ORDER BY date_collected DESC LIMIT {$offset},{$result_cap}";
                    }
                }
            }
        }
    }
}
$resultset = query_associative_all($query_string, $row_count);
if (count($resultset) == 0 || $resultset == null) {
    ?>
	<div class='sidetip_nopos'>
	<?php 
Example #2
0
function getSpecimenFromBarcode($specimen_code)
{
    $pieces = decodeSpecimenBarcode($specimen_code);
    $specimen_id = $pieces[1];
    $patientClass = new Patient();
    $patient = $patientClass->getById($patient_id);
    return $patient;
}