Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions SQL/2012-01-31-RemoveCancelled.sql
Original file line number Diff line number Diff line change
@@ -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;

2 changes: 1 addition & 1 deletion htdocs/ScatterPlot-SVG.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]";

Expand Down
6 changes: 3 additions & 3 deletions htdocs/feedback_mri_popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions htdocs/mri_efax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}


Expand Down Expand Up @@ -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();
Expand Down
15 changes: 5 additions & 10 deletions php/libraries/Candidate.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)) {
Expand Down Expand Up @@ -268,11 +268,6 @@ class Candidate
return $this->candidateInfo["Active"];
}

function isCancelled()
{
return $this->candidateInfo["Cancelled"];
}

function registeredBy()
{
return $this->candidateInfo["RegisteredBy"];
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions php/libraries/NDB_Menu_Filter_candidate_list.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions php/libraries/NDB_Menu_Filter_mri_safety.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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']."' ";

Expand All @@ -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
";
}
Expand Down
4 changes: 2 additions & 2 deletions php/libraries/NDB_Menu_Filter_timepoint_flag.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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') {
Expand Down
11 changes: 4 additions & 7 deletions php/libraries/TimePoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -245,10 +245,7 @@ Class TimePoint
return $this->_timePointInfo["Active"] == 'Y';
}

function isCancelled()
{
return $this->_timePointInfo["Cancelled"] == 'Y';
}


function getScanDone()
{
Expand Down
2 changes: 1 addition & 1 deletion tools/derive_timepoint_flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/evaluate_instrument_validity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
Loading