示例#1
0
/**
 * Populates the DDE ignore fields for each instrument and runs
 * the ignoreColumn function on the instrument for the given fields
 * @param $instruments
 * @throws Exception
 */
function detectIgnoreColumns($instruments)
{
    $instrumentFields = array();
    foreach ($instruments as $instrument) {
        echo "Checking DDE ignore fields for " . $instrument . "\n";
        $file = "../project/instruments/NDB_BVL_Instrument_{$instrument}.class.inc";
        if (file_exists($file)) {
            include $file;
            $instance =& NDB_BVL_Instrument::factory($instrument, null, null);
            $DDEIgnoreFields = $instance->_doubleDataEntryDiffIgnoreColumns;
            if ($DDEIgnoreFields != null) {
                foreach ($DDEIgnoreFields as $key => $DDEField) {
                    if (!in_array($DDEField, $this->defaultFields)) {
                        $instrumentFields = array_merge($instrumentFields, array($DDEField => $instrument));
                    }
                }
            } else {
                echo "No DDE ignore fields found for " . $instrument . "\n";
            }
            if (!$this->instrumentSpecified) {
                defaultIgnoreColumns();
            }
            ignoreColumn($instrument, $instrumentFields);
        }
    }
}
示例#2
0
 /**
  * Construct the object to handle requests. This will instantiate
  * the NDB_BVL_Instrument object and call toJSON to return the
  * JSON to the client.
  *
  * @param string $method     The HTTP method used for the request
  * @param string $Instrument The instrument to be serialized
  */
 function __construct($method, $Instrument)
 {
     $this->AutoHandleRequestDelegation = false;
     parent::__construct($method);
     try {
         $this->Instrument = \NDB_BVL_Instrument::factory($Instrument, null, null, true);
     } catch (\Exception $e) {
         $this->header("HTTP/1.1 404 Not Found");
         $this->error("Invalid Instrument");
         $this->safeExit(0);
     }
     // JSON is used by both calculateETag and handleGET, so do it
     // before either is called.
     $this->JSONString = $this->Instrument->toJSON();
     $this->handleRequest();
 }
示例#3
0
 /**
  * Handle a GET request
  *
  * @return none, but populate $this->JSON
  */
 function handleGET()
 {
     $this->JSON = ["Meta" => ["Instrument" => $this->Instrument->testName, "Visit" => $this->VisitLabel, "Candidate" => $this->CandID, "DDE" => $this->bDDE]];
     if (!$this->bFlags) {
         $Values = \NDB_BVL_Instrument::loadInstanceData($this->Instrument);
         unset($Values['CommentID']);
         unset($Values['UserID']);
         unset($Values['Testdate']);
         unset($Values['Data_entry_completion_status']);
         $this->JSON[$this->Instrument->testName] = $Values;
     } else {
         $flags = $this->DB->pselectRow("SELECT Data_entry, Administration, Validity\n                 FROM flag WHERE CommentID=:CID", ['CID' => $this->Instrument->getCommentID()]);
         if (!$this->Instrument->ValidityEnabled) {
             unset($flags['Validity']);
         }
         $this->JSON['Flags'] = $flags;
     }
 }
示例#4
0
                AND s.Active='Y' and s.Cancelled='N' 
                AND c.Active='Y' and c.Cancelled='N'", $Missings);
print $t . ":" . count($Missings) . "\n";
foreach($Missings as $row) {
    $date = explode('-', $row['Date_taken']);
    $dateArray = array ('Y' => $date[0], 'M' => $date[1], 'd' => $date[2]);
    $instrument =& NDB_BVL_Instrument::factory('mullen', $row['CommentID'], null);
    $instrument->_saveValues(array('Date_taken' => $dateArray));
}
*/
//}
$instruments = Utility::getAllInstruments();
foreach ($instruments as $inst) {
    // Now works with vineland
    //if($inst == 'vineland' || $inst=="vineland_proband" || $inst=="vineland_subject") continue;
    $DB->select("SELECT i.CommentID, i.Date_taken FROM {$inst} i JOIN flag f USING(CommentID) JOIN session s ON (s.ID=f.SessionID) JOIN candidate c USING(CandID) WHERE c.Active='Y' and s.Active='Y' AND i.Candidate_Age IS NULL AND i.Date_taken IS NOT NULL", $CommentIDs);
    print "{$inst} (" . count($CommentIDs) . ")\n";
    $db->select("SELECT TABLE_NAME FROM information_schema.columns WHERE TABLE_SCHEMA='{$database['database']}' AND COLUMN_NAME='Date_taken' AND TABLE_NAME='{$inst}'", $tables);
    if (count($tables) > 0) {
        foreach ($CommentIDs as $row) {
            $date = explode('-', $row['Date_taken']);
            $dateArray = array('Y' => $date[0], 'M' => $date[1], 'd' => $date[2]);
            $instrument =& NDB_BVL_Instrument::factory($inst, $row['CommentID'], null, false);
            if ($instrument && !empty($row['Date_taken'])) {
                //print_r($dateArray);
                $instrument->_saveValues(array('Date_taken' => $dateArray));
            }
        }
    }
}
print_r($instruments);
/**
* *Detect those conflicts which are currently in the conflicts_unresolved table
* But should be excluded based on the _doubleDataEntryDiffIgnoreColumns array
*
* @param String $instrument        The instrument used for conflict detection
* @param Array  $commentids        Used for creation of instrument-instantiation
* @param Array  $current_conflicts An array of current conflicts detected
* 
* @return Array $conflicts_to_excluded Array of confllicts to be execluded
*/
function detectConflictsTobeExcluded($instrument, $commentids, $current_conflicts)
{
    $conflicts_to_excluded = array();
    $instance1 =& NDB_BVL_Instrument::factory($instrument, $commentids[0]['CommentID'], null);
    $ignore_columns = $instance1->_doubleDataEntryDiffIgnoreColumns;
    foreach ($current_conflicts as $conflict) {
        /**
         * if the field is part of the ignore_columns, 
         * and it doesn exist in the conflict array
         * then track it
         */
        if (in_array($conflict['FieldName'], $ignore_columns)) {
            $conflicts_to_excluded[] = $conflict;
        }
    }
    return $conflicts_to_excluded;
}
示例#6
0
<?php

/**
 * This returns the instrument passed in by the Instrument GET parameter
 * and serializes it as JSON for the REST API.
 *
 * PHP Version 5
 *
 * @category Loris
 * @package  API
 * @author   Dave MacFarlane <*****@*****.**>
 * @license  Loris license
 * @link     https://github.com/aces/Loris
 */
//Load config file and ensure paths are correct
set_include_path(get_include_path() . ":" . __DIR__ . "../../../php/libraries");
// Ensures the user is logged in, and parses the config file.
require_once "NDB_Client.class.inc";
$client = new NDB_Client();
$client->initialize("../../../project/config.xml");
require_once 'NDB_BVL_Instrument.class.inc';
$Instrument = $_REQUEST['Instrument'];
$a = NDB_BVL_Instrument::factory($Instrument, null, null);
print $a->toJSON();
示例#7
0
 log_msg("------------------------------");
 $query = "SELECT s.CandID, s.Visit_label, s.ID as SessionID, t.CommentID, c.PSCID\n        FROM candidate as c, session as s, flag as f, {$test_name} as t\n        WHERE c.CandID=s.CandID AND s.ID=f.SessionID AND f.CommentID=t.CommentID\n        AND s.Active = 'Y' AND c.Active='Y' \n        AND f.Test_name = '{$test_name}' AND f.Administration <> 'None' AND f.Administration IS NOT NULL";
 if ($action == 'one') {
     $query .= " AND s.ID = '{$sessionID}' AND s.CandID='{$candID}'";
 }
 $db->select($query, $result);
 // return error if no candidates/timepoint matched the args
 if (!is_array($result) || count($result) == 0) {
     fwrite(STDERR, "No records match the criteria returned for candidate ({$candID}), timepoint ({$sessionID})!\n");
     return false;
 }
 fwrite(STDERR, "Start \n");
 // loop the list and derive scores for each record
 foreach ($result as $record) {
     // make an instance of the instrument's object
     $instrument =& NDB_BVL_Instrument::factory($test_name, $record['CommentID'], null);
     // check if the instrument has a scoring method
     if (!method_exists($instrument, "score")) {
         fwrite(STDERR, "Error, the instrument ({$test_name}) does not have a scoring feature \n");
         return false;
     }
     // print out candidate/session info
     fwrite(STDERR, "Candidate: " . $record['CandID'] . "/" . $record['Visit_label'] . "/" . $record['SessionID'] . ":: ({$record['PSCID']})\n");
     //fwrite(STDERR, "Candidate: ".$instrument->_dob."/"."Test_name:".$test_name."/". $instrument->_pls3Age."/".$instrument->getDateOfAdministration().":: \n");
     // call the score function
     $db->selectRow("SELECT * FROM {$test_name} WHERE CommentID='{$record['CommentID']}'", $oldRecord);
     $success = $instrument->score();
     $db->selectRow("SELECT * FROM {$test_name} WHERE CommentID='{$record['CommentID']}'", $newRecord);
     unset($oldRecord['Testdate']);
     unset($newRecord['Testdate']);
     $diff = array_diff_assoc($oldRecord, $newRecord);
    if (PEAR::isError($timePoint)) {
        $tpl_data['error_message'][] = $timePoint->getMessage();
    } else {
        $tpl_data['visitLabel'] = $timePoint->getVisitLabel();
    }
    $tpl_data['sessionID'] = $_REQUEST['sessionID'];
}
if (!empty($_REQUEST['commentID'])) {
    $tpl_data['commentID'] = $_REQUEST["commentID"];
    $subtest = isset($_REQUEST['subtest']) ? $subtest : null;
    if (!empty($_REQUEST['test_name'])) {
        $InstrumentPath = $paths['base'] . "project/instruments/NDB_BVL_Instrument_" . $_REQUEST['test_name'] . ".class.inc";
        if (file_exists($InstrumentPath)) {
            // otherwise create an instrument_<test_name> object
            include_once $InstrumentPath;
            $instrument =& NDB_BVL_Instrument::factory($_REQUEST['test_name'], $_REQUEST['commentID'], $subtest);
            if (PEAR::isError($instrument)) {
                $tpl_data['error_message'][] = $instrument->getMessage();
            }
            $tpl_data['instrument_name'] = $instrument->getFullName();
        } else {
            $tpl_data['instrument_name'] = $_REQUEST['test_name'];
        }
        ///get the fields names....
        // "Add Feedback" Form" - option array for select boxes - 2 arrays;
        // one is for labels
        $field_names = Utility::getSourcefields($_REQUEST['test_name']);
        $Fields['Across All Fields'] = 'Across All Fields';
        foreach ($field_names as $field_name) {
            $Fields[$field_name['SourceField']] = $field_name['SourceField'];
        }
示例#9
0
//$query = "select * from test_names where Test_name like 'a%' order by Test_name";  //for rapid testing
$DB->select($query, $instruments);
if (PEAR::isError($instruments)) {
    PEAR::raiseError("Couldn't get instruments. " . $instruments->getMessage());
}
foreach ($instruments as $instrument) {
    //Query to pull the data from the DB
    $Test_name = $instrument['Test_name'];
    if ($Test_name == 'prefrontal_task') {
        $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, 'See validity_of_data field' as Validity, i.* from candidate c, session s, flag f, {$Test_name} i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
    } else {
        if ($Test_name == 'radiology_review') {
            $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, 'Site review:', i.*, 'Final Review:', COALESCE(fr.Review_Done, 0) as Review_Done, fr.Final_Review_Results, fr.Final_Exclusionary, fr.Final_Incidental_Findings, fre.full_name as Final_Examiner_Name, fr.Final_Review_Results2, fre2.full_name as Final_Examiner2_Name, fr.Final_Exclusionary2, COALESCE(fr.Review_Done2, 0) as Review_Done2, fr.Final_Incidental_Findings2, fr.Finalized from candidate c, session s, flag f, {$Test_name} i left join final_radiological_review fr ON (fr.CommentID=i.CommentID) left outer join examiners e on (i.Examiner = e.examinerID) left join examiners fre ON (fr.Final_Examiner=fre.examinerID) left join examiners fre2 ON (fre2.examinerID=fr.Final_Examiner2) where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
        } else {
            if (is_file("../project/instruments/NDB_BVL_Instrument_{$Test_name}.class.inc")) {
                $instrument =& NDB_BVL_Instrument::factory($Test_name, '', false);
                if ($instrument->ValidityEnabled == true) {
                    $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, i.* from candidate c, session s, flag f, {$Test_name} i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
                } else {
                    $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, i.* from candidate c, session s, flag f, {$Test_name} i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
                }
            } else {
                $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, i.* from candidate c, session s, flag f, {$Test_name} i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID";
            }
        }
    }
    $DB->select($query, $instrument_table);
    if (PEAR::isError($instrument_table)) {
        print "Cannot pull instrument table data " . $instrument_table->getMessage() . "<br>\n";
        die;
    }