From 49da3bff0f6a5565a6bcfbbf4e01bacc230651d7 Mon Sep 17 00:00:00 2001 From: Cecile Madjar Date: Wed, 17 Jul 2019 10:33:10 -0400 Subject: [PATCH 1/3] removed mri_acquisition_dates table from the database and the LORIS code --- SQL/0000-00-00-schema.sql | 7 --- SQL/9999-99-99-drop_tables.sql | 1 - ...-17_remove_mri_acquisition_dates_table.sql | 1 + modules/dashboard/ajax/get_scan_line_data.php | 18 ++++-- .../php/imaging_browser.class.inc | 8 ++- .../test/imaging_browserTest.php | 18 ------ .../RB_files/RB_mri_acquisition_dates.sql | 59 ------------------- test/RBdata.sql | 9 --- tools/delete_timepoint.php | 14 ----- 9 files changed, 19 insertions(+), 116 deletions(-) create mode 100644 SQL/New_patches/2019-07-17_remove_mri_acquisition_dates_table.sql delete mode 100644 raisinbread/RB_files/RB_mri_acquisition_dates.sql diff --git a/SQL/0000-00-00-schema.sql b/SQL/0000-00-00-schema.sql index 25097e3ef8b..8ab5c120a56 100644 --- a/SQL/0000-00-00-schema.sql +++ b/SQL/0000-00-00-schema.sql @@ -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 '', diff --git a/SQL/9999-99-99-drop_tables.sql b/SQL/9999-99-99-drop_tables.sql index d679bd033fd..eef8d474cb4 100644 --- a/SQL/9999-99-99-drop_tables.sql +++ b/SQL/9999-99-99-drop_tables.sql @@ -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`; diff --git a/SQL/New_patches/2019-07-17_remove_mri_acquisition_dates_table.sql b/SQL/New_patches/2019-07-17_remove_mri_acquisition_dates_table.sql new file mode 100644 index 00000000000..ed5cc487bcc --- /dev/null +++ b/SQL/New_patches/2019-07-17_remove_mri_acquisition_dates_table.sql @@ -0,0 +1 @@ +DROP TABLE mri_acquisition_dates; \ No newline at end of file diff --git a/modules/dashboard/ajax/get_scan_line_data.php b/modules/dashboard/ajax/get_scan_line_data.php index bc3641280bb..4cabae22f16 100644 --- a/modules/dashboard/ajax/get_scan_line_data.php +++ b/modules/dashboard/ajax/get_scan_line_data.php @@ -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'] @@ -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, diff --git a/modules/imaging_browser/php/imaging_browser.class.inc b/modules/imaging_browser/php/imaging_browser.class.inc index 4b738fb933a..acba783537f 100644 --- a/modules/imaging_browser/php/imaging_browser.class.inc +++ b/modules/imaging_browser/php/imaging_browser.class.inc @@ -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)"; @@ -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; @@ -231,7 +233,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', + 'DATE_FORMAT(MIN(pf.Value), "%Y-%m-%d") as First_Acquisition', 'FROM_UNIXTIME(MIN(f.InsertTime)) as First_Insertion', 'FROM_UNIXTIME(MAX(fqc.QCLastChangeTime)) as Last_QC', "$NewDataSubquery as New_Data", diff --git a/modules/imaging_browser/test/imaging_browserTest.php b/modules/imaging_browser/test/imaging_browserTest.php index c9d529c0d51..f6da83d8a88 100644 --- a/modules/imaging_browser/test/imaging_browserTest.php +++ b/modules/imaging_browser/test/imaging_browserTest.php @@ -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( @@ -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')); diff --git a/raisinbread/RB_files/RB_mri_acquisition_dates.sql b/raisinbread/RB_files/RB_mri_acquisition_dates.sql deleted file mode 100644 index fe06a3f51d6..00000000000 --- a/raisinbread/RB_files/RB_mri_acquisition_dates.sql +++ /dev/null @@ -1,59 +0,0 @@ -SET FOREIGN_KEY_CHECKS=0; -TRUNCATE TABLE `mri_acquisition_dates`; -LOCK TABLES `mri_acquisition_dates` WRITE; -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (22,'2009-06-09'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (38,'2009-06-10'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (40,'2009-05-29'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (47,'2009-05-27'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (59,'2010-01-12'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (96,'2009-06-10'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (100,'2010-01-12'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (103,'2010-08-18'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (117,'2010-07-21'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (125,'2011-10-19'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (135,'2011-08-15'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (144,'2011-10-20'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (170,'2010-08-17'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (192,'2010-08-18'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (324,'2009-05-27'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (542,'2016-08-15'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (545,'2011-09-17'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (557,'2009-05-27'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (561,'2016-08-15'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (564,'2009-05-29'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (597,'2009-05-27'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (601,'2016-08-15'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (617,'2010-08-18'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (628,'2016-08-15'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (632,'2009-06-10'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (641,'2016-08-15'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (680,'2009-05-29'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1053,'2018-04-20'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1135,'2009-05-28'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1189,'2009-06-09'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1190,'2010-07-21'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1216,'2010-07-21'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1318,'2009-05-29'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1411,'2009-06-09'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1430,'2011-10-20'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1440,'2009-06-10'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (1932,'2009-05-29'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2138,'2009-05-27'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2139,'2009-05-27'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2140,'2009-05-27'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2141,'2018-04-20'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2142,'2018-01-01'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2143,'2018-02-02'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2144,'2018-03-03'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2145,'2018-01-01'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2148,'2018-03-03'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2149,'2018-04-06'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2150,'2018-04-06'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2151,'2018-04-06'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2152,'2016-08-19'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2153,'2018-01-06'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2154,'2018-01-06'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2157,'2018-04-20'); -INSERT INTO `mri_acquisition_dates` (`SessionID`, `AcquisitionDate`) VALUES (2160,'2018-04-20'); -UNLOCK TABLES; -SET FOREIGN_KEY_CHECKS=1; diff --git a/test/RBdata.sql b/test/RBdata.sql index cd773339bb1..561f96139d6 100644 --- a/test/RBdata.sql +++ b/test/RBdata.sql @@ -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`; diff --git a/tools/delete_timepoint.php b/tools/delete_timepoint.php index 5ce75396a85..ad4b5e8befb 100755 --- a/tools/delete_timepoint.php +++ b/tools/delete_timepoint.php @@ -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"; @@ -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)); @@ -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); From 854acdc6448e58fa6631e149011eaff8b5dd284b Mon Sep 17 00:00:00 2001 From: Cecile Madjar Date: Thu, 18 Jul 2019 12:38:01 -0400 Subject: [PATCH 2/3] making Travis happy --- modules/imaging_browser/php/imaging_browser.class.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/imaging_browser/php/imaging_browser.class.inc b/modules/imaging_browser/php/imaging_browser.class.inc index acba783537f..faabc02a1b6 100644 --- a/modules/imaging_browser/php/imaging_browser.class.inc +++ b/modules/imaging_browser/php/imaging_browser.class.inc @@ -224,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', @@ -233,7 +234,7 @@ END"; WHERE ProjectID=c.ProjectID) as project', 's.visit_label as Visit_Label', "$PendingFailSubquery as Visit_QC_Status", - 'DATE_FORMAT(MIN(pf.Value), "%Y-%m-%d") 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", From 187653d21667607f05e636d7591dd30603735132 Mon Sep 17 00:00:00 2001 From: Cecile Madjar Date: Tue, 23 Jul 2019 11:57:28 -0400 Subject: [PATCH 3/3] fix the diplay of the graph in the dashboard and fixed PHPCS --- modules/dashboard/ajax/get_scan_line_data.php | 4 +-- .../php/imaging_browser.class.inc | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/modules/dashboard/ajax/get_scan_line_data.php b/modules/dashboard/ajax/get_scan_line_data.php index 4cabae22f16..506ea0a5e2b 100644 --- a/modules/dashboard/ajax/get_scan_line_data.php +++ b/modules/dashboard/ajax/get_scan_line_data.php @@ -66,8 +66,8 @@ function createLineChartLabels($startDate, $endDate) { $startDateYear = substr($startDate, 0, 4); $endDateYear = substr($endDate, 0, 4); - $startDateMonth = substr($startDate, 5, 2); - $endDateMonth = substr($endDate, 5, 2); + $startDateMonth = substr($startDate, 4, 2); + $endDateMonth = substr($endDate, 4, 2); $labels = array(); for ($year = (int)$startDateYear; $year <= (int)$endDateYear; $year++) { $startMonth = ($year == (int)$startDateYear) ? (int)$startDateMonth : 1; diff --git a/modules/imaging_browser/php/imaging_browser.class.inc b/modules/imaging_browser/php/imaging_browser.class.inc index faabc02a1b6..69204c5056d 100644 --- a/modules/imaging_browser/php/imaging_browser.class.inc +++ b/modules/imaging_browser/php/imaging_browser.class.inc @@ -6,24 +6,24 @@ * * PHP Version 5 * - * @category Behavioural - * @package Main - * @subpackage Imaging - * @author Dave MacFarlane - * @license Loris License - * @link https://www.github.com/aces/Loris-Trunk/ + * @category Behavioural + * @package Main + * @subpackage Imaging + * @author Dave MacFarlane + * @license Loris License + * @link https://www.github.com/aces/Loris-Trunk/ */ namespace LORIS\imaging_browser; /** * Provides the PHP code for the menu filter for the imaging browser * - * @category Behavioural - * @package Main - * @subpackage Imaging - * @author Dave MacFarlane - * @license Loris License - * @link https://www.github.com/aces/Loris-Trunk/ + * @category Behavioural + * @package Main + * @subpackage Imaging + * @author Dave MacFarlane + * @license Loris License + * @link https://www.github.com/aces/Loris-Trunk/ */ class Imaging_Browser extends \NDB_Menu_Filter { @@ -225,6 +225,7 @@ END"; } $firstAcquisitionSubquery = 'DATE_FORMAT(MIN(pf.Value), "%Y-%m-%d")'; + $this->columns = array( 'p.Name as Site', 'c.PSCID as PSCID',