Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SQL] Removed mri_acquisition_dates table from the database and the LORIS code #4962

Merged
merged 3 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 0 additions & 7 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,6 @@ CREATE TABLE `files_qcstatus` (
FOREIGN KEY (`FileID`) REFERENCES `files` (`FileID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `mri_acquisition_dates` (
`SessionID` int(10) unsigned NOT NULL default '0',
`AcquisitionDate` date default NULL,
PRIMARY KEY (`SessionID`),
CONSTRAINT `FK_mri_acquisition_dates_1` FOREIGN KEY (`SessionID`) REFERENCES `session` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `mri_protocol` (
`ID` int(11) unsigned NOT NULL auto_increment,
`Center_name` varchar(4) NOT NULL default '',
Expand Down
1 change: 0 additions & 1 deletion SQL/9999-99-99-drop_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ DROP TABLE IF EXISTS `mri_upload`;
DROP TABLE IF EXISTS `MRICandidateErrors`;
DROP TABLE IF EXISTS `mri_protocol_violated_scans`;
DROP TABLE IF EXISTS `mri_protocol`;
DROP TABLE IF EXISTS `mri_acquisition_dates`;
DROP TABLE IF EXISTS `files_qcstatus`;
DROP TABLE IF EXISTS `files_intermediary`;
DROP TABLE IF EXISTS `files`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE mri_acquisition_dates;
18 changes: 13 additions & 5 deletions modules/dashboard/ajax/get_scan_line_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@

$scanData = array();
$scanStartDate = $DB->pselectOne(
"SELECT MIN(AcquisitionDate) FROM mri_acquisition_dates",
"SELECT MIN(pf.Value)
FROM parameter_file pf
JOIN parameter_type pt USING (ParameterTypeID)
WHERE pt.Name='acquisition_date'",
array()
);
$scanEndDate = $DB->pselectOne(
"SELECT MAX(AcquisitionDate) FROM mri_acquisition_dates",
"SELECT MAX(pf.Value)
FROM parameter_file pf
JOIN parameter_type pt USING (ParameterTypeID)
WHERE pt.Name='acquisition_date'",
array()
);
$scanData['labels']
Expand Down Expand Up @@ -92,11 +98,13 @@ function getScanData($siteID, $labels)
$data[] = $DB->pselectOne(
"SELECT COUNT(distinct s.ID)
FROM files f
LEFT JOIN mri_acquisition_dates mad ON (mad.SessionID=f.SessionID)
LEFT JOIN parameter_file pf USING (FileID)
LEFT JOIN session s ON (s.ID=f.SessionID)
JOIN parameter_type pt USING (ParameterTypeID)
WHERE s.CenterID=:Site
AND MONTH(mad.AcquisitionDate)=:Month
AND YEAR(mad.AcquisitionDate)=:Year",
AND pt.Name='acquisition_date'
AND MONTH(pf.Value)=:Month
AND YEAR(pf.Value)=:Year",
array(
'Site' => $siteID,
'Month' => $month,
Expand Down
9 changes: 6 additions & 3 deletions modules/imaging_browser/php/imaging_browser.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ END";
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)
JOIN parameter_file pf ON (f.FileID=pf.FileID)
JOIN parameter_type pt USING (ParameterTypeID)
LEFT JOIN mri_scan_type modality ON
(f.AcquisitionProtocolID=modality.ID)";

Expand All @@ -176,7 +177,8 @@ END";
$where = "
WHERE
s.Active = 'Y' AND
f.FileType='mnc'";
pt.Name = 'acquisition_date' AND
f.FileType ='mnc'";

$this->query .= $left_joins;
$this->query .= $where;
Expand Down Expand Up @@ -222,6 +224,7 @@ END";
$as[$key];
}

$firstAcquisitionSubquery = 'DATE_FORMAT(MIN(pf.Value), "%Y-%m-%d")';
$this->columns = array(
'p.Name as Site',
'c.PSCID as PSCID',
Expand All @@ -231,7 +234,7 @@ END";
WHERE ProjectID=c.ProjectID) as project',
's.visit_label as Visit_Label',
"$PendingFailSubquery as Visit_QC_Status",
'MIN(md.AcquisitionDate) as First_Acquisition',
"$firstAcquisitionSubquery as First_Acquisition",
'FROM_UNIXTIME(MIN(f.InsertTime)) as First_Insertion',
'FROM_UNIXTIME(MAX(fqc.QCLastChangeTime)) as Last_QC',
"$NewDataSubquery as New_Data",
Expand Down
18 changes: 0 additions & 18 deletions modules/imaging_browser/test/imaging_browserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,6 @@ public function setUp()
);
// @codingStandardsIgnoreStart

$this->DB->insert(
'mri_acquisition_dates',
array(
'SessionID' => 999998,
'AcquisitionDate' => '2014-02-17',
)
);

$this->DB->insert(
'mri_acquisition_dates',
array(
'SessionID' => 999999,
'AcquisitionDate' => '2014-02-17',
)
);

$this->DB->insert(
'files_qcstatus',
array(
Expand Down Expand Up @@ -335,8 +319,6 @@ public function tearDown()
"mri_processing_protocol",
array('ProcessProtocolID' => '2222')
);
$this->DB->delete("mri_acquisition_dates", array('SessionID' => '999998'));
$this->DB->delete("mri_acquisition_dates", array('SessionID' => '999999'));
$this->DB->delete("files_qcstatus", array('FileID' => '1111'));
$this->DB->delete("files_qcstatus", array('FileID' => '2222'));
$this->DB->delete("tarchive", array('TarchiveID' => '263'));
Expand Down
59 changes: 0 additions & 59 deletions raisinbread/RB_files/RB_mri_acquisition_dates.sql

This file was deleted.

9 changes: 0 additions & 9 deletions test/RBdata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1585,15 +1585,6 @@ UNLOCK TABLES;



LOCK TABLES `mri_acquisition_dates` WRITE;
DELETE FROM `mri_acquisition_dates`;
/*!40000 ALTER TABLE `mri_acquisition_dates` DISABLE KEYS */;
INSERT INTO `mri_acquisition_dates` (SessionID,AcquisitionDate) VALUES (22,'2009-06-09'),(38,'2009-06-10'),(40,'2009-05-29'),(47,'2009-05-27'),(59,'2010-01-12'),(96,'2009-06-10'),(100,'2010-01-12'),(103,'2010-08-18'),(117,'2010-07-21'),(125,'2011-10-19'),(135,'2011-08-15'),(144,'2011-10-20'),(170,'2010-08-17'),(192,'2010-08-18'),(324,'2009-05-27'),(545,'2011-09-17'),(557,'2009-05-27'),(564,'2009-05-29'),(597,'2009-05-27'),(617,'2010-08-18'),(632,'2009-06-10'),(680,'2009-05-29'),(1135,'2009-05-28'),(1189,'2009-06-09'),(1190,'2010-07-21'),(1216,'2010-07-21'),(1318,'2009-05-29'),(1411,'2009-06-09'),(1430,'2011-10-20'),(1440,'2009-06-10'),(1932,'2009-05-29'),(2138,'2009-05-27'),(2139,'2009-05-27'),(2140,'2009-05-27');
/*!40000 ALTER TABLE `mri_acquisition_dates` ENABLE KEYS */;
UNLOCK TABLES;



LOCK TABLES `mri_protocol` WRITE;
/*!40000 ALTER TABLE `mri_protocol` DISABLE KEYS */;
DELETE FROM `mri_protocol`;
Expand Down
14 changes: 0 additions & 14 deletions tools/delete_timepoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,6 @@ function deleteTimepoint($CandID, $sessionID, $confirm, $printToSQL, $DB, $outpu
$result = $DB->pselect('SELECT * FROM issues WHERE sessionID=:sid', array('sid' => $sessionID));
print_r($result);

// Print from mri_acquisition_dates
echo "\nMRI Acquisition Dates\n";
echo "-------\n";
$result = $DB->pselect('SELECT * FROM mri_acquisition_dates WHERE SessionID=:sid', array('sid' => $sessionID));
print_r($result);

// Print from mri_upload
echo "\nMRI Upload\n";
echo "-------\n";
Expand Down Expand Up @@ -275,10 +269,6 @@ function deleteTimepoint($CandID, $sessionID, $confirm, $printToSQL, $DB, $outpu
echo "\n-- Deleting from issues.\n";
$DB->delete('issues', array('sessionID' => $sessionID));

// Delete from mri_acquisition_dates
echo "\n-- Deleting from mri acquisition dates.\n";
$DB->delete('mri_acquisition_dates', array('SessionID' => $sessionID));

// Delete from mri_upload
echo "\n-- Deleting from mri upload.\n";
$DB->delete('mri_upload', array('SessionID' => $sessionID));
Expand Down Expand Up @@ -318,10 +308,6 @@ function deleteTimepoint($CandID, $sessionID, $confirm, $printToSQL, $DB, $outpu
$output .= "\n-- Deleting from issues.\n";
_printResultsSQL('issues', array('sessionID' => $sessionID), $output, $DB);

// Delete from mri_acquisition_dates
$output .= "\n-- Deleting from MRI acquisition dates.\n";
_printResultsSQL('mri_acquisition_dates', array('SessionID' => $sessionID), $output, $DB);

// Delete from mri_upload
$output .= "\n-- Deleting from MRI upload.\n";
_printResultsSQL('mri_upload', array('SessionID' => $sessionID), $output, $DB);
Expand Down