Skip to content

Commit

Permalink
23.0 pull to fix travis mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
h-karim committed Jun 5, 2020
1 parent 47f57e2 commit 700fee5
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions modules/imaging_browser/php/imagingbrowserrowprovisioner.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ class ImagingBrowserRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisi
/**
* Create an ImagingBrowserRowProvisioner, which gets rows for
* the imaging browser menu table.
*
* @throws \ConfigurationException
*/
function __construct()
{
$config = \NDB_Config::singleton();
$DB = \NDB_Factory::singleton()->database();

// ===========================================================
// Get the different scan types to be displayed in data table
Expand Down Expand Up @@ -92,7 +95,7 @@ class ImagingBrowserRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisi
}

$NewDataSubquery = "
CASE
CASE
COALESCE(Max(fqc.QCLastChangeTime), 'new')
WHEN 'new' THEN {$acqpif}
WHEN '' THEN {$acqpif}
Expand All @@ -109,9 +112,9 @@ class ImagingBrowserRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisi
$coalesce_desc = array();

foreach ($scan_id_types as $id => $type) {
$pass[$id] = $type . 'pass';
$qc[$id] = $type . 'QC';
$coalesce_desc[$id] = $pass[$id] . '.' . $qc[$id];
$pass[$id] = $DB->quote($type);
$qc[$id] = $DB->quote($type);
$coalesce_desc[$id] = $DB->quote($pass[$id] . '.' . $qc[$id]);
$case_desc[$id] = "
CASE
COALESCE($coalesce_desc[$id], '')
Expand All @@ -126,15 +129,15 @@ class ImagingBrowserRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisi
WHEN 'Fail' THEN
IF(s.MRIQCPending='Y', 'Pending Fail', 'Fail')
WHEN 'Pass' THEN
IF(s.MRIQCPending='Y', 'Pending Pass', 'Pass')
IF(s.MRIQCPending='Y', 'Pending Pass', 'Pass')
ELSE s.MRIQCStatus
END
END
";

$PendingNewquery = "
CASE
CASE
WHEN s.MRIQCPending='Y' THEN 'P'
WHEN MAX(fqc.QCFirstChangeTime) IS NULL $newQueryCase THEN 'N'
WHEN MAX(fqc.QCFirstChangeTime) IS NULL $newQueryCase THEN 'N'
END";

// ====================================================
Expand All @@ -146,14 +149,14 @@ class ImagingBrowserRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisi
foreach ($case_desc as $key => $value) {
$left_joins .= "
LEFT JOIN (
SELECT files.SessionID,
MIN(files_qcstatus.QCStatus+0) as $qc[$key]
FROM files
JOIN files_qcstatus USING (FileID)
WHERE files.AcquisitionProtocolID= $key
AND files_qcstatus.QCStatus IN (1, 2)
GROUP BY files.SessionID) $pass[$key]
ON ($pass[$key].SessionID=f.SessionID
SELECT files.SessionID,
MIN(files_qcstatus.QCStatus+0) as $qc[$key]
FROM files
JOIN files_qcstatus USING (FileID)
WHERE files.AcquisitionProtocolID= $key
AND files_qcstatus.QCStatus IN (1, 2)
GROUP BY files.SessionID) `$pass[$key]`
ON (`$pass[$key]`.SessionID=f.SessionID
) ";
}

Expand All @@ -166,15 +169,16 @@ class ImagingBrowserRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisi
// $scan_types are set in the configuration module
$modalities_subquery = '';
foreach ($case_desc as $key => $value) {
$modalities_subquery = "$value as $scan_id_types[$key]_QC_Status";
$modalities_subquery = $value." as " .
$DB->quote("$scan_id_types[$key]_QC_Status");
}

// =================================================
// Final query
// =================================================

parent::__construct(
"SELECT
"SELECT
p.Name as Site,
c.PSCID as PSCID,
c.CandID as DCCID,
Expand All @@ -189,24 +193,24 @@ class ImagingBrowserRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisi
s.ID as sessionID,
GROUP_CONCAT(DISTINCT modality.Scan_type) as sequenceType,
$PendingNewquery as pending," .
($modalities_subquery==''?'':"$modalities_subquery,") .
"s.CenterID as CenterID,
($modalities_subquery==''?'':"$modalities_subquery,") .
"s.CenterID as CenterID,
c.Entity_type as entityType,
s.ProjectID
FROM psc AS p
JOIN session s ON (s.CenterID=p.CenterID)
JOIN candidate c ON (c.CandID=s.CandID)
FROM psc AS p
JOIN session s ON (s.CenterID=p.CenterID)
JOIN candidate c ON (c.CandID=s.CandID)
LEFT JOIN Project ON (s.ProjectID=Project.ProjectID)
JOIN files f ON (f.SessionID=s.ID)
LEFT JOIN files_qcstatus fqc ON (fqc.FileID=f.FileID)
JOIN files f ON (f.SessionID=s.ID)
LEFT JOIN files_qcstatus fqc ON (fqc.FileID=f.FileID)
JOIN parameter_file pf ON (f.FileID=pf.FileID)
JOIN parameter_type pt USING (ParameterTypeID)
LEFT JOIN mri_scan_type modality ON
LEFT JOIN mri_scan_type modality ON
(f.AcquisitionProtocolID=modality.ID)
$left_joins
WHERE
$left_joins
WHERE
s.Active = 'Y' AND
f.FileType IN ('mnc', 'nii')
f.FileType='mnc'
GROUP BY s.ID
ORDER BY c.PSCID, s.Visit_label
",
Expand Down

0 comments on commit 700fee5

Please sign in to comment.