Exemplo n.º 1
0
function verify_and_update($test_type_id, $verified_entry, $hash_value)
{
    $specimen_id = $verified_entry->specimenId;
    $query_string = "SELECT * FROM test " . "WHERE specimen_id={$specimen_id} " . "AND test_type_id={$test_type_id} LIMIT 1";
    $record = query_associative_one($query_string);
    $existing_entry = Test::getObject($record);
    $test_id = $existing_entry->testId;
    $verified_result_value = $verified_entry->result . $hash_value;
    $query_verify = "";
    if ($existing_entry->result == $verified_result_value && $existing_entry->comments == $verified_entry->comments) {
        # No changes or corrections after verification
        $query_verify = "UPDATE test " . "SET verified_by={$verified_entry->verifiedBy}, " . "date_verified='{$verified_entry->dateVerified}' " . "WHERE test_id={$test_id}";
    } else {
        # Update with corrections and mark as verified
        $query_verify = "UPDATE test " . "SET result='{$verified_result_value}', " . "comments='{$verified_entry->comments}', " . "verified_by={$verified_entry->verifiedBy}, " . "date_verified='{$verified_entry->dateVerified}' " . "WHERE test_id={$test_id}";
    }
    query_blind($query_verify);
}
Exemplo n.º 2
0
function mergedata()
{
    if (!isset($_SESSION['lab_config_id'])) {
        return false;
    }
    $workedID = "";
    $lab_config = $_SESSION['lab_config_id'];
    $saved_db = DbUtil::switchToLabConfig($importLabConfigId);
    $querySelect = "SELECT patient_id,name,surr_id,addl_id FROM patient order by surr_id asc";
    $resultset = query_associative_all($querySelect, $rowCount);
    $rowCount = 0;
    foreach ($resultset as $record) {
        if (strstr($workedID, $record['surr_id'])) {
            continue;
        } else {
            $workedID .= "," . $record['surr_id'];
        }
        $querySelect = "SELECT patient_id,name,surr_id,addl_id FROM patient where \n\t\tsurr_id='" . $record['surr_id'] . "' and \n\t\tpatient_id <> " . $record['patient_id'];
        $Dupresult = query_associative_all($querySelect, $rowCount);
        foreach ($Dupresult as $Duprecord) {
            $rowCount += 1;
            echo '<br> Working... ' . $record['surr_id'];
            //update spacimen
            $updateQuery = "update specimen set patient_id=" . $record['patient_id'] . "where patient_id=" . $Duprecord['patient_id'];
            query_blind($updateQuery);
            //update bills
            $updateQuery = "update bills set patient_id=" . $record['patient_id'] . "where patient_id=" . $Duprecord['patient_id'];
            query_blind($updateQuery);
            //now delete from custom_data and patients table
            $deleteQuery = "delete from patient_custom_data where patient_id=" . $Duprecord['patient_id'];
            query_blind($deleteQuery);
            $deleteQuery = "delete from patient where patient_id=" . $Duprecord['patient_id'];
            query_blind($deleteQuery);
        }
    }
    //var_dump ( $resultset);
    if ($rowCount > 0) {
        echo '<br>' . $rowCount . " Duplicate Records corrected.";
    } else {
        echo '<br>' . "No Duplicate Records found.";
    }
    return true;
}
Exemplo n.º 3
0
function query_empty_table($table_name)
{
    # Empty all data in the given table
    global $con;
    $query_string = "DELETE FROM {$table_name}";
    query_blind($query_string);
    //if($LOG_QUERIES == true)
    DebugLib::logQuery($query_string, db_get_current(), $_SESSION['username']);
    DebugLib::logDBUpdates($query, db_get_current());
}
Exemplo n.º 4
0
 }
 fclose($fileWriteHandle);
 fclose($fileHandle);
 $blisLabBackupTempFilePath = "\"" . $mainBlisDir . "\\htdocsxport\\blis_" . $lab_config_id . "_temp_backup.sql\"";
 $mysqlExePath = "\"" . $mainBlisDir . "server\\mysql\\bin\\mysql.exe\"";
 $dbTempName = "blis_" . $lab_config_id . "_temp";
 $command = $mysqlExePath . " -h {$DB_HOST} -P 7188 -u {$DB_USER} -p{$DB_PASS} {$dbTempName} < {$blisLabBackupTempFilePath}";
 $command = "C: &" . $command;
 //the C: is a useless command to prevent the original command from failing because of having more than 2 double quotes
 system($command, $return);
 unlink($backupLabDbTempFileName);
 $saved_db = db_get_current();
 $switchDatabaseName = "blis_" . $lab_config_id . "_temp";
 db_change($switchDatabaseName);
 $queryUpdate = "UPDATE patient " . "SET name = hash_value";
 query_blind($queryUpdate);
 $backupLabDbTempFileName = "blis_" . $lab_config_id . "_temp_backup.sql";
 $count = 0;
 $command = $mysqldumpPath . " -B -h {$DB_HOST} -P 7188 -u {$DB_USER} -p{$DB_PASS} {$dbTempName} > {$backupLabDbTempFileName}";
 system($command);
 DbUtil::switchRestore($saved_db);
 $query = "DROP DATABASE " . $dbname . "_temp";
 mysql_query($query, $con);
 $fileHandle = fopen($backupLabDbTempFileName, "r");
 $backupLabDbFileName = "blis_" . $lab_config_id . "_backup.sql";
 unlink($backupLabDbFileName);
 $fileWriteHandle = fopen($backupLabDbFileName, "w");
 while (!feof($fileHandle)) {
     $line = fgets($fileHandle);
     if (strstr($line, "CREATE DATABASE ")) {
         $line = str_replace($dbname . "_temp", $dbname, $line);
Exemplo n.º 5
0
 public function addToDb()
 {
     $infectionReportSettings = $this;
     $saved_db = DbUtil::switchToGlobal();
     # Remove existing entry
     $query_string = "DELETE FROM infection_report_settings " . "WHERE user_id={$this->userId} " . "AND test_id={$this->testId} " . "AND measure_id={$this->measureId}";
     query_blind($query_string);
     # Add updated entry
     $query_string = "INSERT INTO infection_report_settings( " . "id, " . "user_id, " . "test_id, " . "measure_id, " . "group_by_gender, " . "group_by_age, " . "age_groups, " . "measure_groups " . ") " . "VALUES ( " . "{$infectionReportSettings->id}, " . "{$infectionReportSettings->userId}, " . "{$infectionReportSettings->testId}, " . "{$infectionReportSettings->measureId}, " . "{$infectionReportSettings->groupByGender}, " . "{$infectionReportSettings->groupByAge}, " . "'{$infectionReportSettings->ageGroups}', " . "'{$infectionReportSettings->measureGroups}' " . ")";
     query_insert_one($query_string);
     DbUtil::switchRestore($saved_db);
 }
Exemplo n.º 6
0
<?php

#
# Adds user rating to DB.
#
include "../includes/db_lib.php";
global $con;
$user_id = $_REQUEST['user_id'];
$rating = $_REQUEST['rating'];
$skipped = $_REQUEST['skipped'];
$comments = $_REQUEST['comments'];
//$comments= mysql_real_escape_string($_REQUEST['comments'],$con);
if ($skipped == -1) {
    $rating = 6;
}
$query_string = "INSERT INTO user_rating (user_id, rating, comments) " . "VALUES ({$user_id}, {$rating}, '{$comments}')";
echo $query_string;
query_blind($query_string);
Exemplo n.º 7
0
 public function deleteItems($lab_config_id, $items)
 {
     $sql = "delete from dhims2_api_config where id in ({$items})";
     query_blind($sql, $db);
     return 1;
 }
Exemplo n.º 8
0
function clear_random_data($lab_config)
{
    # TODO:
    if ($lab_config == null) {
        return;
    }
    # Remove entries from 'test' table and 'specimen' table
    global $MAX_NUM_PATIENTS, $MAX_NUM_SPECIMENS, $PATIENT_ID_START, $SPECIMEN_ID_START;
    $saved_db = DbUtil::switchToLabConfig($lab_config->id);
    for ($i = $SPECIMEN_ID_START; $i <= $SPECIMEN_ID_START + $MAX_NUM_SPECIMENS; $i++) {
        $query_string = "DELETE FROM test WHERE specimen_id={$i}";
        query_blind($query_string);
        $query_string = "DELETE FROM specimen WHERE specimen_id={$i}";
        query_blind($query_string);
    }
    # Remove entries from 'patient' table
    for ($i = $PATIENT_ID_START; $i <= $PATIENT_ID_START + $MAX_NUM_PATIENTS; $i++) {
        $query_string = "DELETE FROM patient WHERE patient_id={$i}";
        query_blind($query_string);
    }
    DbUtil::switchRestore($saved_db);
}