Skip to content

Commit

Permalink
Add database->quote for easy merge with aces#6668
Browse files Browse the repository at this point in the history
  • Loading branch information
h-karim committed Jun 5, 2020
1 parent f0c18bb commit cefffde
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 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 Down Expand Up @@ -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,13 +149,13 @@ 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]
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 Down

0 comments on commit cefffde

Please sign in to comment.