예제 #1
0
            } else {
                $query_string = "SELECT count(s.specimen_id) as val 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(SELECT test_type_id FROM test_type WHERE test_category_id={$lab_section}) AND s.specimen_id NOT IN (select r_id from removal_record where category='specimen' AND status=1) ";
            }
        } else {
            if ($attrib_type == 9) {
                $decoded = decodeSpecimenBarcode($attrib_value);
                # Search by patient specimen id
                if ($lab_section == 0) {
                    $query_string = "SELECT count(specimen_id) as val FROM specimen " . "WHERE specimen_id = {$decoded['1']} " . "AND ( status_code_id=" . Specimen::$STATUS_PENDING . " " . "OR status_code_id=" . Specimen::$STATUS_REFERRED . " ) AND specimen_id NOT IN (select r_id from removal_record where category='specimen' AND status=1) " . "ORDER BY date_collected DESC LIMIT 0,{$rcap}";
                } else {
                    $query_string = "SELECT count(s.specimen_id) as val FROM specimen s, test t " . "WHERE s.specimen_id = {$decoded['1']} AND s.specimen_id = t.specimen_id " . "AND ( s.status_code_id=" . Specimen::$STATUS_PENDING . " " . "OR s.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})  " . "AND specimen_id NOT IN (select r_id from removal_record where category='specimen' AND status=1) " . "ORDER BY date_collected DESC LIMIT 0,{$rcap}";
                }
            } else {
                if ($attrib_type == 10) {
                    # Search by patient specimen id
                    $decoded = decodePatientBarcode($attrib_value);
                    if ($lab_section == 0) {
                        $query_string = "SELECT count(s.specimen_id) as val FROM specimen s, test t, patient p " . "WHERE p.patient_id=s.patient_id " . "AND p.surr_id='{$decoded['1']}'" . "AND s.specimen_id=t.specimen_id " . "AND s.specimen_id NOT IN (select r_id from removal_record where category='specimen') ";
                    } else {
                        $query_string = "SELECT count(s.specimen_id) as val FROM specimen s, test t, patient p " . "WHERE p.patient_id=s.patient_id " . "AND p.surr_id='{$attrib_value}'" . "AND s.specimen_id=t.specimen_id " . "AND test_type_id IN\r\n    \t\t\t\t\t\t\t(SELECT test_type_id FROM test_type WHERE test_category_id={$lab_section}) AND s.specimen_id NOT IN (select r_id from removal_record where category='specimen' AND status=1) LIMIT 0,{$rcap} ";
                    }
                }
            }
        }
    }
}
//echo $query_string;
$resultset = query_associative_one($query_string);
$count = $resultset['val'];
//echo $query_string;
echo $count;
예제 #2
0
파일: db_lib.php 프로젝트: caseyi/BLIS
function getPatientFromBarcode($patient_code)
{
    $pieces = decodePatientBarcode($patient_code);
    $patient_id = $pieces[1];
    $patientClass = new Patient();
    $patient = $patientClass->getById($patient_id);
    return $patient;
}