Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion php/libraries/MRIFile.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class MRIFile
{
var $fileData = array();
var $parameters = array();
var $QCData = array();

function MRIFile($fileID)
{
Expand All @@ -17,6 +18,13 @@ class MRIFile
$this->fileData[$key] = $value;
}

$query = "SELECT * FROM files_qcstatus WHERE FileID=$fileID";
$db->selectRow($query, $qcData);
if(!empty($qcData)) {
foreach($qcData AS $key=>$value) {
$this->QCData[$key] = $value;
}
}
$query = "SELECT Name, Value FROM parameter_file as p, parameter_type as f WHERE f.ParameterTypeID=p.ParameterTypeID AND FileID=$fileID";
$db->select($query, $parameterRaw);
foreach($parameterRaw AS $row) {
Expand All @@ -26,6 +34,7 @@ class MRIFile

function getParameter($parameterName)
{
if(isset($this->QCData[$parameterName])) return $this->QCData[$parameterName];
if(isset($this->fileData[$parameterName])) return $this->fileData[$parameterName];
elseif(isset($this->parameters[$parameterName])) return $this->parameters[$parameterName];
else return null;
Expand All @@ -41,4 +50,4 @@ class MRIFile
$acquisitionProtocol = $db->selectOne($query);
return $acquisitionProtocol;
}
}
}
10 changes: 5 additions & 5 deletions php/libraries/MRIMenuPage.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MRIMenuPage {
'visitLabel' => 's.Visit_label',
'qcStatus' => 's.MRIQCStatus',
'SubprojectID' => 's.SubprojectID',
'pending' => "(s.MRIQCPending='Y' OR s.MRIQCStatus='' OR ifnull(f.QCFirstChangeTime,0)=0)"
'pending' => "(s.MRIQCPending='Y' OR s.MRIQCStatus='' OR ifnull(fqc.QCFirstChangeTime,0)=0)"
);
$this->headers = array(
'No.' => '',
Expand Down Expand Up @@ -94,7 +94,7 @@ class MRIMenuPage {
UNIX_TIMESTAMP(md.AcquisitionDate) AS firstAcqDate,
UNIX_TIMESTAMP(s.MRIQCFirstChangeTime) AS firstQCDate,
UNIX_TIMESTAMP(s.MRIQCLastChangeTime) AS lastQCDate
FROM psc AS p, candidate AS c, session AS s, files AS f, mri_acquisition_dates AS md
FROM psc AS p JOIN session s ON (s.CenterID=p.CenterID) JOIN candidate c ON (c.CandID=s.CandID) JOIN files f ON (f.SessionID=s.ID) LEFT JOIN files_qcstatus fqc ON (fqc.FileID=f.FileID) JOIN mri_acquisition_dates md ON (md.SessionID=s.ID)
WHERE s.CenterID=p.CenterID AND s.CandID=c.CandID AND f.SessionID=s.ID AND md.SessionID=s.ID
$extra_where_string
AND f.PendingStaging=0 AND f.FileType='mnc' AND f.OutputType='native' AND f.AcquisitionProtocolID not in (1, 2, 3, 52)
Expand Down Expand Up @@ -124,11 +124,11 @@ class MRIMenuPage {


function _PopulateQCBreakdown($ProtocolID, $SessionID) {
$Passes = $this->DB->selectOne("SELECT count(File) FROM files where SessionID=".$SessionID." AND AcquisitionProtocolID=$ProtocolID AND QCStatus='Pass'");
$Passes = $this->DB->selectOne("SELECT count(File) FROM files join files_qcstatus qc USING (FileID) where SessionID=".$SessionID." AND AcquisitionProtocolID=$ProtocolID AND qc.QCStatus='Pass'");
if($Passes > 0) {
return 'Pass';
}
$Fails = $this->DB->selectOne("SELECT count(File) FROM files where SessionID=".$SessionID." AND AcquisitionProtocolID=$ProtocolID AND QCStatus='Fail'");
$Fails = $this->DB->selectOne("SELECT count(File) FROM files JOIN files_qcstatus qc USING (FileID) where SessionID=".$SessionID." AND AcquisitionProtocolID=$ProtocolID AND qc.QCStatus='Fail'");
if($Fails > 0) {
return 'Fail';
}
Expand All @@ -143,7 +143,7 @@ class MRIMenuPage {

// Go through each
for($i=0; $i<$visit_tpl_data['numTimepoints']; $i++) {
$minQCDate = $this->DB->selectOne("select min(QCLastChangeTime) from files where SessionID=".$visit_tpl_data['timepoints'][$i]['sessionID']." AND OutputType='native' AND AcquisitionProtocolID not in (1, 2, 3, 52) group by QCLastChangeTime order by QCLastChangeTime limit 1");
$minQCDate = $this->DB->selectOne("select min(QCLastChangeTime) from files left join files_qcstatus USING(FileID) where SessionID=".$visit_tpl_data['timepoints'][$i]['sessionID']." AND OutputType='native' AND AcquisitionProtocolID not in (1, 2, 3, 52) group by QCLastChangeTime order by QCLastChangeTime limit 1");
// New data if not QCed
$visit_tpl_data['timepoints'][$i]['newData'] = empty($minQCDate);
$visit_tpl_data['timepoints'][$i]['rownum'] = ($i+1);
Expand Down
33 changes: 21 additions & 12 deletions php/libraries/MRIViewScansPage.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ class MRIViewScansPage {
$updateSet = array('QCStatus'=>$curStatus, 'QCLastChangeTime'=>time());

// set first change time, if it's null only
$firstChangeTime = $this->DB->selectOne("SELECT QCFirstChangeTime FROM files WHERE FileID=$curFileID");
$firstChangeTime = $this->DB->selectOne("SELECT QCFirstChangeTime FROM files_qcstatus WHERE FileID=$curFileID");
if(empty($firstChangeTime)) $updateSet['QCFirstChangeTime'] = time();

$updateWhere['FileID'] = $curFileID;
$success = $this->DB->update('files', $updateSet, $updateWhere);
if(PEAR::isError($success)) {
die("DB Error: ".$success->getMessage());
$QCExists = $this->DB->selectOne("SELECT 'x' FROM files_qcstatus WHERE FileID=$curFileID");
if(!empty($QCExists)) {
$updateWhere['FileID'] = $curFileID;
$success = $this->DB->update('files_qcstatus', $updateSet, $updateWhere);
if(PEAR::isError($success)) {
die("DB Error: ".$success->getMessage());
}
} else {
$file = new MRIFile($curFileID);
$updateSet['SeriesUID'] = $file->getParameter('series_instance_uid');
$updateSet['FileID'] = $curFileID;
$this->DB->insert("files_qcstatus", $updateSet);
}
}
}
Expand Down Expand Up @@ -99,11 +107,12 @@ class MRIViewScansPage {
}

function GetSubjectData() {
// Cache the data, since it's called twice. Once in display,
// and once for the header
//if(isset($this->_subjectData)) {
// return $this->_subjectData;
//}
// subjectData['Scanner'] may already be set, so if
// $this->_subjectData is set, use that as the starting
// point
if(isset($this->_subjectData)) {
$subjectData = $this->_subjectData;
}
$timePoint =& TimePoint::singleton($_REQUEST['sessionID']);
if(PEAR::isError($timePoint)) {
print $timePoint->getMessage()."<br>";
Expand Down Expand Up @@ -145,7 +154,7 @@ class MRIViewScansPage {

// Cache the data
$this->_subjectData = $subjectData;
return $subjectData;
return $this->_subjectData;
}

function _getOutputType() {
Expand Down Expand Up @@ -189,7 +198,7 @@ class MRIViewScansPage {
$scannerID = $file->getParameter('ScannerID');
if(!empty($scannerID)) {
$query = "SELECT CONCAT_WS(' ', Manufacturer, Model, Serial_number) FROM mri_scanner WHERE ID=$scannerID";
$subjectData['scanner'] = $this->DB->selectOne($query);
$this->_subjectData['scanner'] = $this->DB->selectOne($query);
}
}
$fileData[$fIdx]['fileID'] = $fileID['FileID'];
Expand Down