diff --git a/SQL/0000-00-00-schema.sql b/SQL/0000-00-00-schema.sql index 8d3e93ad7df..164ebf4b3a8 100644 --- a/SQL/0000-00-00-schema.sql +++ b/SQL/0000-00-00-schema.sql @@ -36,8 +36,6 @@ CREATE TABLE `candidate` ( `Sibling3` int(6) default NULL, `Active` enum('Y','N') NOT NULL default 'Y', `Date_active` date default NULL, - `Cancelled` enum('N','Y') NOT NULL default 'N', - `Date_cancelled` date default NULL, `RegisteredBy` varchar(255) default NULL, `UserID` varchar(255) NOT NULL default '', `Date_registered` date default NULL, @@ -1121,8 +1119,6 @@ CREATE TABLE `session` ( `Date_approval` date default NULL, `Active` enum('Y','N') NOT NULL default 'Y', `Date_active` date default NULL, - `Cancelled` enum('N','Y') NOT NULL default 'N', - `Date_cancelled` date default NULL, `RegisteredBy` varchar(255) default NULL, `UserID` varchar(255) NOT NULL default '', `Date_registered` date default NULL, diff --git a/SQL/2012-01-31-RemoveCancelled.sql b/SQL/2012-01-31-RemoveCancelled.sql new file mode 100644 index 00000000000..5299a55d5e4 --- /dev/null +++ b/SQL/2012-01-31-RemoveCancelled.sql @@ -0,0 +1,8 @@ +alter table candidate drop column Cancelled; +Alter table session drop column Cancelled; + +Alter table candidate drop column Date_cancelled; +Alter table session drop column Date_cancelled; + +alter table session drop column pscid; + diff --git a/htdocs/ScatterPlot-SVG.php b/htdocs/ScatterPlot-SVG.php index a0a99ba8705..146aaeebd46 100644 --- a/htdocs/ScatterPlot-SVG.php +++ b/htdocs/ScatterPlot-SVG.php @@ -21,7 +21,7 @@ } else { $Field = "Candidate_Age"; } -$QueryCondition = "$Field IS NOT NULL AND c.Active='Y' and c.Cancelled='N' and s.Active='Y' and s.Cancelled='N'"; +$QueryCondition = "$Field IS NOT NULL AND c.Active='Y' and s.Active='Y'"; if(isset($_REQUEST['site']) && !empty($_REQUEST['site'])) { $QueryCondition .= " AND c.CenterID=$_REQUEST[site]"; diff --git a/htdocs/feedback_mri_popup.php b/htdocs/feedback_mri_popup.php index c394cd60518..2a4b0073983 100644 --- a/htdocs/feedback_mri_popup.php +++ b/htdocs/feedback_mri_popup.php @@ -65,11 +65,11 @@ // show identifier of subject/volume if($comments->objectType == 'volume') { - $query = "SELECT c.CandID AS DCCID, c.PSCID, s.Visit_label, s.SubprojectID, f.File AS File_name, st.Scan_type FROM files AS f, session AS s, candidate AS c, mri_scan_type AS st WHERE f.FileID='$comments->fileID' AND f.SessionID=s.ID AND s.CandID=c.CandID and f.AcquisitionProtocolID=st.ID AND s.Active='Y' AND s.Cancelled='N'"; + $query = "SELECT c.CandID AS DCCID, c.PSCID, s.Visit_label, s.SubprojectID, f.File AS File_name, st.Scan_type FROM files AS f, session AS s, candidate AS c, mri_scan_type AS st WHERE f.FileID='$comments->fileID' AND f.SessionID=s.ID AND s.CandID=c.CandID and f.AcquisitionProtocolID=st.ID AND s.Active='Y'"; } elseif ($comments->objectType == 'visit') { - $query = "SELECT c.CandID, c.PSCID, s.Visit_label, s.SubprojectID FROM session AS s, candidate AS c WHERE s.ID='$comments->sessionID' AND s.CandID=c.CandID AND s.Active='Y' AND s.Cancelled='N'"; //AND VisitNo='$comments->visitNo' + $query = "SELECT c.CandID, c.PSCID, s.Visit_label, s.SubprojectID FROM session AS s, candidate AS c WHERE s.ID='$comments->sessionID' AND s.CandID=c.CandID AND s.Active='Y'"; //AND VisitNo='$comments->visitNo' } else { - $query = "SELECT c.CandID FROM session AS s, candidate AS c WHERE s.ID='$comments->sessionID' AND s.CandID=c.CandID AND s.Active='Y' AND s.Cancelled='N'"; + $query = "SELECT c.CandID FROM session AS s, candidate AS c WHERE s.ID='$comments->sessionID' AND s.CandID=c.CandID AND s.Active='Y'"; } $DB->select($query, $result); diff --git a/htdocs/mri_efax.php b/htdocs/mri_efax.php index c944933ad78..e2fd8a1e55f 100644 --- a/htdocs/mri_efax.php +++ b/htdocs/mri_efax.php @@ -239,9 +239,9 @@ // get the list of candidates for the form if ($_REQUEST['scanType'] == 'subject') { - $query = "SELECT CandID, CONCAT(CandID,'/',PSCID) AS Label FROM candidate as c WHERE Active = 'Y' AND Cancelled = 'N' AND CenterID = '".$_REQUEST['centerID']."' AND Entity_type = 'Human' ORDER BY CandID"; + $query = "SELECT CandID, CONCAT(CandID,'/',PSCID) AS Label FROM candidate as c WHERE Active = 'Y' AND CenterID = '".$_REQUEST['centerID']."' AND Entity_type = 'Human' ORDER BY CandID"; } else { - $query = "SELECT c.CandID, CONCAT('Scanner(',c.CandID,'): ',m.Model,'-',m.Software) AS Label FROM candidate as c, mri_scanner as m, session as s WHERE c.CandID=s.CandID AND c.CandID=m.CandID AND c.Active = 'Y' AND c.Cancelled = 'N' AND c.Entity_type = 'Scanner' AND s.CenterID = '".$_REQUEST['centerID']."' GROUP BY c.CandID ORDER BY c.CandID"; + $query = "SELECT c.CandID, CONCAT('Scanner(',c.CandID,'): ',m.Model,'-',m.Software) AS Label FROM candidate as c, mri_scanner as m, session as s WHERE c.CandID=s.CandID AND c.CandID=m.CandID AND c.Active = 'Y' AND c.Entity_type = 'Scanner' AND s.CenterID = '".$_REQUEST['centerID']."' GROUP BY c.CandID ORDER BY c.CandID"; } @@ -315,7 +315,7 @@ $query = "SELECT DATE_FORMAT(t.Value, '%Y-%m-%d') as Study_date FROM session as s, files as f, parameter_file as t WHERE f.FileID = t.FileID AND t.ParameterTypeID=27 AND s.ID = f.SessionID AND s.Active = 'Y' - AND s.Cancelled = 'N' AND t.Value <> '0000-00-00' AND s.ID = '".$_REQUEST['sessionID']."' GROUP BY Study_date"; + AND t.Value <> '0000-00-00' AND s.ID = '".$_REQUEST['sessionID']."' GROUP BY Study_date"; $DB->select($query, $result); if (PEAR::isError($result)) { $tpl_data['error_message'][] = "Error, failed to select date of MRI studies for the timepoint (".$_REQUEST['sessionID']."):\n" . $timePoint->getMessage(); diff --git a/php/libraries/Candidate.class.inc b/php/libraries/Candidate.class.inc index 3dedd7d7d59..32da5d71671 100644 --- a/php/libraries/Candidate.class.inc +++ b/php/libraries/Candidate.class.inc @@ -51,7 +51,7 @@ class Candidate } // get candidate data from database - $query = "SELECT c.CenterID, c.CandID, c.PSCID, c.DoB, c.EDC, c.Gender, p.Name AS PSC, c.Ethnicity, c.ZIP, c.Sibling1, c.Sibling2, c.Sibling3, c.Active, c.Cancelled, u1.Real_name as RegisteredBy, c.UserID FROM candidate as c left join psc as p using (CenterID) left join users as u1 on (u1.UserID = c.RegisteredBy) WHERE c.CandID='$candID' AND c.Active = 'Y' AND c.Cancelled = 'N'"; + $query = "SELECT c.CenterID, c.CandID, c.PSCID, c.DoB, c.EDC, c.Gender, p.Name AS PSC, c.Ethnicity, c.ZIP, c.Sibling1, c.Sibling2, c.Sibling3, c.Active, u1.Real_name as RegisteredBy, c.UserID FROM candidate as c left join psc as p using (CenterID) left join users as u1 on (u1.UserID = c.RegisteredBy) WHERE c.CandID='$candID' AND c.Active = 'Y'"; $row = array(); $db->selectRow($query, $row); @@ -77,7 +77,7 @@ class Candidate // get Time Point SessionIDs for the $candID // select ALL of them - later you can filter out cancelled and inactive ones - $query = "SELECT s.ID FROM session as s WHERE s.CandID='$candID' AND s.Active='Y' AND s.Cancelled='N' ORDER BY ID"; + $query = "SELECT s.ID FROM session as s WHERE s.CandID='$candID' AND s.Active='Y' ORDER BY ID"; $db->select($query, $row); if(PEAR::isError($row)) { @@ -268,11 +268,6 @@ class Candidate return $this->candidateInfo["Active"]; } - function isCancelled() - { - return $this->candidateInfo["Cancelled"]; - } - function registeredBy() { return $this->candidateInfo["RegisteredBy"]; @@ -300,7 +295,7 @@ class Candidate return PEAR::raiseError("Could not connect to database: ".$db->getMessage()); } - $query = "SELECT ID, Visit_label FROM session WHERE CandID='$candID' AND Active='Y' AND Cancelled='N' ORDER BY ID"; + $query = "SELECT ID, Visit_label FROM session WHERE CandID='$candID' AND Active='Y' ORDER BY ID"; $db->select($query, $result); if(PEAR::isError($result)) { return PEAR::raiseError("Could not retrieve existing data for session"); @@ -328,7 +323,7 @@ class Candidate return PEAR::raiseError("Could not connect to database: ".$db->getMessage()); } - $query = "SELECT IFNULL(max(VisitNo)+1, 1) AS nextVisitNo FROM session WHERE CandID='$candID' AND (Active='Y' OR Active is null) AND (Cancelled='N' OR Cancelled IS NULL) GROUP BY CandID"; + $query = "SELECT IFNULL(max(VisitNo)+1, 1) AS nextVisitNo FROM session WHERE CandID='$candID' AND (Active='Y' OR Active is null) GROUP BY CandID"; $db->selectRow($query, $result); if(PEAR::isError($result)) { return PEAR::raiseError("Could not retrieve existing data for session"); @@ -358,7 +353,7 @@ class Candidate if($visitLabelSettings['generation'] == 'user' && !empty($visitLabelSettings['suggest'])) { $existingVisitLabels = $this->getListOfVisitLabels(); - $query = "SELECT IFNULL(max(VisitNo)+1, 1) AS nextVisitLabel FROM session WHERE CandID='$candID' AND (Active='Y' OR Active is null) AND (Cancelled='N' OR Cancelled IS NULL) GROUP BY CandID"; + $query = "SELECT IFNULL(max(VisitNo)+1, 1) AS nextVisitLabel FROM session WHERE CandID='$candID' AND (Active='Y' OR Active is null) GROUP BY CandID"; $db->selectRow($query, $result); if(PEAR::isError($result)) { return PEAR::raiseError("Could not retrieve existing data for session"); diff --git a/php/libraries/NDB_Menu_Filter_candidate_list.class.inc b/php/libraries/NDB_Menu_Filter_candidate_list.class.inc index cee8c1bf38d..655264b450c 100644 --- a/php/libraries/NDB_Menu_Filter_candidate_list.class.inc +++ b/php/libraries/NDB_Menu_Filter_candidate_list.class.inc @@ -44,9 +44,9 @@ class NDB_Menu_Filter_candidate_list extends NDB_Menu_Filter $this->columns=array_merge($this->columns,array('max(session.VisitNo) as Visit_count', 'max(session.Current_stage) as Latest_visit_status', 'min(feedback_bvl_thread.Status+0) as Feedback')); - $this->query = " FROM psc, candidate LEFT JOIN session ON candidate.CandID = session.CandID AND session.Cancelled = 'N' AND session.Active = 'Y' + $this->query = " FROM psc, candidate LEFT JOIN session ON candidate.CandID = session.CandID AND session.Active = 'Y' LEFT JOIN feedback_bvl_thread ON (candidate.CandID=feedback_bvl_thread.CandID) - WHERE candidate.CenterID = psc.CenterID AND candidate.Entity_type = 'Human' AND candidate.Cancelled = 'N' AND candidate.Active = 'Y' "; + WHERE candidate.CenterID = psc.CenterID AND candidate.Entity_type = 'Human' AND candidate.Active = 'Y' "; $user =& User::singleton(); if (!$user->hasPermission('access_all_profiles')) { $this->query .= " AND candidate.CenterID=" . $user->getCenterID(); diff --git a/php/libraries/NDB_Menu_Filter_mri_safety.class.inc b/php/libraries/NDB_Menu_Filter_mri_safety.class.inc index b5e4fe91369..2de98aa4844 100644 --- a/php/libraries/NDB_Menu_Filter_mri_safety.class.inc +++ b/php/libraries/NDB_Menu_Filter_mri_safety.class.inc @@ -121,7 +121,7 @@ class NDB_Menu_Filter_mri_safety extends NDB_Menu_Filter LEFT JOIN parameter_type USING (ParameterTypeID) LEFT JOIN mri_safety ON (session.ID = mri_safety.SessionID AND DATE_FORMAT(parameter_file.Value, '%Y-%m-%d')=mri_safety.Acquisition_date) WHERE - psc.CenterID = session.CenterID AND candidate.Active='Y' AND session.Active='Y' AND session.Cancelled='N' AND candidate.Entity_type='Human' + psc.CenterID = session.CenterID AND candidate.Active='Y' AND session.Active='Y' AND candidate.Entity_type='Human' AND parameter_file.ParameterTypeID = 29 AND DATE_FORMAT(parameter_file.Value, '%Y-%m-%d')<> '0000-00-00' AND parameter_file.Value IS NOT NULL AND candidate.CandID = '".$_REQUEST['candID']."' "; @@ -146,7 +146,7 @@ class NDB_Menu_Filter_mri_safety extends NDB_Menu_Filter LEFT JOIN mri_safety ON (session.ID = mri_safety.SessionID) WHERE psc.CenterID = session.CenterID - AND candidate.Active='Y' AND session.Active='Y' AND session.Cancelled='N' AND candidate.Entity_type='Human' + AND candidate.Active='Y' AND session.Active='Y' AND candidate.Entity_type='Human' AND mri_safety.ID IS NOT NULL "; } diff --git a/php/libraries/NDB_Menu_Filter_timepoint_flag.class.inc b/php/libraries/NDB_Menu_Filter_timepoint_flag.class.inc index 30bdca1ac1c..4b113087fe5 100644 --- a/php/libraries/NDB_Menu_Filter_timepoint_flag.class.inc +++ b/php/libraries/NDB_Menu_Filter_timepoint_flag.class.inc @@ -118,7 +118,7 @@ class NDB_Menu_Filter_timepoint_flag extends NDB_Menu_Filter // set the class variables $this->columns = array_merge($columns, array('session.SubprojectID', 'parameter_timepoint_flag_session.Flag_status AS status', 'parameter_timepoint_flag_session.Comment AS comment_text', "IF(parameter_timepoint_flag_session.Last_change IS NULL, '', CONCAT(parameter_timepoint_flag_session.Last_change, ' by ', IF(users.Real_name IS NULL, '', users.Real_name))) AS last_change", 'parameter_timepoint_flag_session.Pending_issue as pending_issue', 'parameter_timepoint_flag_session.Comment_pending as comment_pending_text')); - $this->query = " FROM session, psc, candidate, parameter_timepoint_flag_type as ft, parameter_timepoint_flag_category as fc, parameter_timepoint_flag, parameter_timepoint_flag_session LEFT JOIN users USING(UserID) WHERE session.CandID = candidate.CandID AND candidate.Entity_type = 'Human' AND candidate.Cancelled = 'N' AND candidate.Active = 'Y' AND session.CenterID = psc.CenterID AND session.ID = parameter_timepoint_flag_session.SessionID AND parameter_timepoint_flag_session.Flag_name = parameter_timepoint_flag.Flag_name AND parameter_timepoint_flag_session.TypeID = ft.TypeID AND parameter_timepoint_flag.CategoryID = fc.CategoryID"; + $this->query = " FROM session, psc, candidate, parameter_timepoint_flag_type as ft, parameter_timepoint_flag_category as fc, parameter_timepoint_flag, parameter_timepoint_flag_session LEFT JOIN users USING(UserID) WHERE session.CandID = candidate.CandID AND candidate.Entity_type = 'Human' AND candidate.Active = 'Y' AND session.CenterID = psc.CenterID AND session.ID = parameter_timepoint_flag_session.SessionID AND parameter_timepoint_flag_session.Flag_name = parameter_timepoint_flag.Flag_name AND parameter_timepoint_flag_session.TypeID = ft.TypeID AND parameter_timepoint_flag.CategoryID = fc.CategoryID"; $this->formToFilter = array( 'centerID' => 'session.CenterID', @@ -168,7 +168,7 @@ class NDB_Menu_Filter_timepoint_flag extends NDB_Menu_Filter // this query includes only the subject w/ existing flags $query = "SELECT c.CandID, s.Visit_label, s.ID FROM candidate AS c, session AS s, parameter_timepoint_flag_session as p - WHERE c.CandID = s.CandID AND p.SessionID = s.ID AND c.Entity_type = 'Human' AND c.Cancelled = 'N' AND c.Active = 'Y'"; + WHERE c.CandID = s.CandID AND p.SessionID = s.ID AND c.Entity_type = 'Human' AND c.Active = 'Y'"; if (!empty($_REQUEST['centerID'])) $query .= " AND s.CenterID = '".$this->filter['session.CenterID']."'"; if (!empty($_REQUEST['subprojectID'])) $query .= " AND s.SubprojectID like '".$_REQUEST['subprojectID']."'"; if ($_REQUEST['last_change'] == 'evaluated') { diff --git a/php/libraries/TimePoint.class.inc b/php/libraries/TimePoint.class.inc index 61230e7ed6a..1e4b760ec21 100644 --- a/php/libraries/TimePoint.class.inc +++ b/php/libraries/TimePoint.class.inc @@ -55,7 +55,7 @@ Class TimePoint } // get user data from database - $query = "SELECT s.ID AS SessionID, s.CandID, p.Name AS PSC, s.CenterID, s.VisitNo,s.Visit_label,s.SubprojectID,s.Submitted,s.Current_stage,s.Screening,s.Date_screening,s.Visit,s.Date_visit,s.Approval,s.Date_approval,s.Active,s.Cancelled, s.registeredBy, s.UserID, u.Real_name, s.Hardcopy_request, s.BVLQCStatus, s.BVLQCType, s.BVLQCExclusion, s.Scan_done FROM session as s left join psc as p using (CenterID) left join users as u on (s.registeredBy=u.UserID) WHERE s.ID ='$sessionID' AND s.Active = 'Y' AND s.Cancelled = 'N'"; + $query = "SELECT s.ID AS SessionID, s.CandID, p.Name AS PSC, s.CenterID, s.VisitNo,s.Visit_label,s.SubprojectID,s.Submitted,s.Current_stage,s.Screening,s.Date_screening,s.Visit,s.Date_visit,s.Approval,s.Date_approval,s.Active, s.registeredBy, s.UserID, u.Real_name, s.Hardcopy_request, s.BVLQCStatus, s.BVLQCType, s.BVLQCExclusion, s.Scan_done FROM session as s left join psc as p using (CenterID) left join users as u on (s.registeredBy=u.UserID) WHERE s.ID ='$sessionID' AND s.Active = 'Y'"; $db->selectRow($query, $row); if(PEAR::isError($row)) { @@ -75,7 +75,7 @@ Class TimePoint // so require a config option to be set if($config->getSetting("SupplementalSessionStatus") == true) { - $query = "SELECT ss.Name, ss.Value FROM session_status ss JOIN session s ON (s.ID=ss.SessionID) WHERE s.ID=:sessionID AND s.Active='Y' AND s.Cancelled='N'"; + $query = "SELECT ss.Name, ss.Value FROM session_status ss JOIN session s ON (s.ID=ss.SessionID) WHERE s.ID=:sessionID AND s.Active='Y'"; $statuses = $db->pselect($query, array(":sessionID" => $sessionID)); foreach ($statuses as $row) { @@ -105,7 +105,7 @@ Class TimePoint $db =& Database::singleton(); // select the candidate data - $query = "SELECT c.PSCID, c.CenterID, IFNULL(max(s.VisitNo)+1, 1) AS nextVisitNo FROM candidate AS c LEFT OUTER JOIN session AS s USING (CandID) WHERE c.CandID=$candID AND (s.Active='Y' OR s.Active is null) AND (s.Cancelled='N' OR s.Cancelled IS NULL) GROUP BY c.CandID"; + $query = "SELECT c.PSCID, c.CenterID, IFNULL(max(s.VisitNo)+1, 1) AS nextVisitNo FROM candidate AS c LEFT OUTER JOIN session AS s USING (CandID) WHERE c.CandID=$candID AND (s.Active='Y' OR s.Active is null) GROUP BY c.CandID"; $db->selectRow($query, $row); if(PEAR::isError($row)) { return PEAR::raiseError("Could not retrieve existing data for candidate".$row->getMessage()); @@ -245,10 +245,7 @@ Class TimePoint return $this->_timePointInfo["Active"] == 'Y'; } - function isCancelled() - { - return $this->_timePointInfo["Cancelled"] == 'Y'; - } + function getScanDone() { diff --git a/tools/derive_timepoint_flags.php b/tools/derive_timepoint_flags.php index 711e4d1ecdc..a596dfa6619 100644 --- a/tools/derive_timepoint_flags.php +++ b/tools/derive_timepoint_flags.php @@ -46,7 +46,7 @@ } // get the list of timepoints - submitted to DCC, Pass or In Progress -$query = "SELECT * FROM session as s WHERE s.Active = 'Y' AND s.Cancelled = 'N' AND s.Submitted = 'Y' AND s.Current_stage='Approval' AND s.Approval IN('In progress', 'Pass')"; +$query = "SELECT * FROM session as s WHERE s.Active = 'Y' AND s.Submitted = 'Y' AND s.Current_stage='Approval' AND s.Approval IN('In progress', 'Pass')"; // subproject if (!empty($subProjectID)) $query .= " AND s.SubprojectID = '$subProjectID'"; // sessionid diff --git a/tools/evaluate_instrument_validity.php b/tools/evaluate_instrument_validity.php index 6e1fb52b684..fb344da4b4f 100644 --- a/tools/evaluate_instrument_validity.php +++ b/tools/evaluate_instrument_validity.php @@ -28,7 +28,7 @@ // get a list of instrument instances $instances = array(); - $query = "SELECT flag.CommentID, flag.SessionID, session.Visit_label, session.CandID, t.Examiner, t.Date_taken FROM $test_name AS t, flag, session WHERE flag.CommentID=t.CommentID AND flag.Test_name='$test_name' AND flag.SessionID=session.ID AND session.Submitted = 'Y' AND session.Cancelled='N' AND session.Active='Y' AND flag.Data_entry='Complete' AND flag.Administration IN ('All', 'Partial')"; + $query = "SELECT flag.CommentID, flag.SessionID, session.Visit_label, session.CandID, t.Examiner, t.Date_taken FROM $test_name AS t, flag, session WHERE flag.CommentID=t.CommentID AND flag.Test_name='$test_name' AND flag.SessionID=session.ID AND session.Submitted = 'Y' AND session.Active='Y' AND flag.Data_entry='Complete' AND flag.Administration IN ('All', 'Partial')"; $db->select($query, $instances); diff --git a/tools/excelDump.php b/tools/excelDump.php index 3b823f4d897..f068fa49bb4 100644 --- a/tools/excelDump.php +++ b/tools/excelDump.php @@ -66,19 +66,19 @@ function MapSubprojectID(&$results) { //Query to pull the data from the DB $Test_name = $instrument['Test_name']; if($Test_name == 'prefrontal_task') { - $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, 'See validity_of_data field' as Validity, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND c.Cancelled='N' AND s.Active='Y' AND s.Cancelled='N' order by s.Visit_label, c.PSCID"; + $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, 'See validity_of_data field' as Validity, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID"; } else if ($Test_name == 'radiology_review') { - $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, 'Site review:', i.*, 'Final Review:', COALESCE(fr.Review_Done, 0) as Review_Done, fr.Final_Review_Results, fr.Final_Exclusionary, fr.SAS, fr.PVS, fr.Final_Incidental_Findings, fre.full_name as Final_Examiner_Name, fr.Final_Review_Results2, fre2.full_name as Final_Examiner2_Name, fr.Final_Exclusionary2, COALESCE(fr.Review_Done2, 0) as Review_Done2, fr.SAS2, fr.PVS2, fr.Final_Incidental_Findings2, fr.Finalized from candidate c, session s, flag f, $Test_name i left join final_radiological_review fr ON (fr.CommentID=i.CommentID) left outer join examiners e on (i.Examiner = e.examinerID) left join examiners fre ON (fr.Final_Examiner=fre.examinerID) left join examiners fre2 ON (fre2.examinerID=fr.Final_Examiner2) where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND c.Cancelled='N' AND s.Active='Y' AND s.Cancelled='N' order by s.Visit_label, c.PSCID"; + $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, 'Site review:', i.*, 'Final Review:', COALESCE(fr.Review_Done, 0) as Review_Done, fr.Final_Review_Results, fr.Final_Exclusionary, fr.SAS, fr.PVS, fr.Final_Incidental_Findings, fre.full_name as Final_Examiner_Name, fr.Final_Review_Results2, fre2.full_name as Final_Examiner2_Name, fr.Final_Exclusionary2, COALESCE(fr.Review_Done2, 0) as Review_Done2, fr.SAS2, fr.PVS2, fr.Final_Incidental_Findings2, fr.Finalized from candidate c, session s, flag f, $Test_name i left join final_radiological_review fr ON (fr.CommentID=i.CommentID) left outer join examiners e on (i.Examiner = e.examinerID) left join examiners fre ON (fr.Final_Examiner=fre.examinerID) left join examiners fre2 ON (fre2.examinerID=fr.Final_Examiner2) where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID"; } else { if (is_file("../project/instruments/NDB_BVL_Instrument_$Test_name.class.inc")) { $instrument =& NDB_BVL_Instrument::factory($Test_name, '', false); if($instrument->ValidityEnabled == true) { - $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND c.Cancelled='N' AND s.Active='Y' AND s.Cancelled='N' order by s.Visit_label, c.PSCID"; + $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID"; } else { - $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND c.Cancelled='N' AND s.Active='Y' AND s.Cancelled='N' order by s.Visit_label, c.PSCID"; + $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID"; } } else { - $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND c.Cancelled='N' AND s.Active='Y' AND s.Cancelled='N' order by s.Visit_label, c.PSCID"; + $query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, s.Submitted, s.Current_stage, s.Screening, s.Visit, f.Administration, e.full_name as Examiner_name, f.Data_entry, f.Validity, i.* from candidate c, session s, flag f, $Test_name i left outer join examiners e on i.Examiner = e.examinerID where c.PSCID not like 'dcc%' and c.PSCID not like '0%' and c.PSCID not like '1%' and c.PSCID not like '2%' and c.PSCID != 'scanner' and i.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = i.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID"; } } $DB->select($query, $instrument_table); @@ -95,7 +95,7 @@ function MapSubprojectID(&$results) { * Special figs_year3_relatives query */ $Test_name = "figs_year3_relatives"; -$query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, fyr.* from candidate c, session s, flag f, figs_year3_relatives fyr where c.PSCID not like 'dcc%' and fyr.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = fyr.CommentID AND c.Active='Y' and c.Cancelled='N' AND s.Active='Y' AND s.Cancelled='N' order by s.Visit_label, c.PSCID"; +$query = "select c.PSCID, c.CandID, s.SubprojectID, s.Visit_label, fyr.* from candidate c, session s, flag f, figs_year3_relatives fyr where c.PSCID not like 'dcc%' and fyr.CommentID not like 'DDE%' and c.CandID = s.CandID and s.ID = f.sessionID and f.CommentID = fyr.CommentID AND c.Active='Y' AND s.Active='Y' order by s.Visit_label, c.PSCID"; $DB->select($query, $instrument_table); if(PEAR::isError($instrument_table)) { print "Cannot figs_year3_relatives data ".$instrument_table->getMessage()."
\n"; @@ -109,7 +109,7 @@ function MapSubprojectID(&$results) { */ $Test_name = "candidate_info"; //this query is a but clunky, but it gets rid of all the crap that would otherwise appear. -$query = "select distinct c.PSCID, c.CandID, c.Gender, c.DoB, s.SubprojectID from candidate c, session s where c.CandID = s.CandID and substring(c.PSCID, 1, 3) in ('PHI', 'STL', 'SEA', 'UNC') and c.Active='Y' and c.Cancelled='N' order by c.PSCID"; +$query = "select distinct c.PSCID, c.CandID, c.Gender, c.DoB, s.SubprojectID from candidate c, session s where c.CandID = s.CandID and substring(c.PSCID, 1, 3) in ('PHI', 'STL', 'SEA', 'UNC') and c.Active='Y' order by c.PSCID"; $DB->select($query, $results); if (PEAR::isError($results)) { PEAR::raiseError("Couldn't get candidate info. " . $results->getMessage()); diff --git a/tools/fix_session_records.php b/tools/fix_session_records.php index b2e696108d1..a927a2fe8db 100644 --- a/tools/fix_session_records.php +++ b/tools/fix_session_records.php @@ -45,7 +45,7 @@ // get list of sessionIDs w/ problems // apply the fix only where candidate.Entity_type = 'Human' -$query = "Select s.ID FROM candidate as c, session as s WHERE c.CandID = s.CandID AND c.Entity_type = 'Human' AND c.Active = 'Y' AND c.Cancelled = 'N' AND s.Active = 'Y' AND s.Cancelled = 'N' AND (s.Current_stage is NULL OR s.PSCID = '' OR s.Objective = 0) ORDER BY s.ID"; +$query = "Select s.ID FROM candidate as c, session as s WHERE c.CandID = s.CandID AND c.Entity_type = 'Human' AND c.Active = 'Y' AND s.Active = 'Y' AND (s.Current_stage is NULL OR s.Objective = 0) ORDER BY s.ID"; $db->select($query,$result); if (PEAR::isError($db)) { diff --git a/tools/generate_exclusion_report.php b/tools/generate_exclusion_report.php index 2b92ba56bd3..5fe74b9984d 100644 --- a/tools/generate_exclusion_report.php +++ b/tools/generate_exclusion_report.php @@ -67,7 +67,7 @@ function dumpLine: /** * get list of sessionIDs */ -$query = "Select Submitted, MRIQCStatus, MRIQCPending, Scan_done, Approval, BVLQCStatus, BVLQCType, ID as SessionID FROM session WHERE Active = 'Y' AND Cancelled = 'N' AND Screening = 'Pass' AND VisitNo=1"; +$query = "Select Submitted, MRIQCStatus, MRIQCPending, Scan_done, Approval, BVLQCStatus, BVLQCType, ID as SessionID FROM session WHERE Active = 'Y' AND Screening = 'Pass' AND VisitNo=1"; // temporary constraint $query .= " AND Objective = 1"; // order by diff --git a/tools/score_instrument.php b/tools/score_instrument.php index 0b9cfbf1c95..47ea4dce161 100644 --- a/tools/score_instrument.php +++ b/tools/score_instrument.php @@ -116,7 +116,7 @@ function log_msg($message) { $query = "SELECT s.CandID, s.Visit_label, s.ID as SessionID, t.CommentID FROM candidate as c, session as s, flag as f, $test_name as t WHERE c.CandID=s.CandID AND s.ID=f.SessionID AND f.CommentID=t.CommentID - AND s.Active = 'Y' AND s.Cancelled = 'N' AND c.Active='Y' AND c.Cancelled='N' + AND s.Active = 'Y' AND c.Active='Y' AND f.Test_name = '$test_name' AND f.Administration <> 'None' AND f.Administration IS NOT NULL"; if ($action=='one') { $query .= " AND s.ID = '$sessionID' AND s.CandID='$candID'";