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

Rename candidate center id to registration center #4078

Merged
6 changes: 3 additions & 3 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ CREATE TABLE `candidate` (
`DoB` date DEFAULT NULL,
`EDC` date DEFAULT NULL,
`Sex` enum('Male','Female') DEFAULT NULL,
`CenterID` integer unsigned NOT NULL DEFAULT '0',
`RegistrationCenterID` integer unsigned NOT NULL DEFAULT '0',
`ProjectID` int(11) DEFAULT NULL,
`Ethnicity` varchar(255) DEFAULT NULL,
`Active` enum('Y','N') NOT NULL DEFAULT 'Y',
Expand All @@ -291,11 +291,11 @@ CREATE TABLE `candidate` (
PRIMARY KEY (`CandID`),
UNIQUE KEY `ID` (`ID`),
UNIQUE KEY `ExternalID` (`ExternalID`),
KEY `FK_candidate_1` (`CenterID`),
KEY `FK_candidate_1` (`RegistrationCenterID`),
KEY `CandidateActive` (`Active`),
KEY `FK_candidate_2_idx` (`flagged_reason`),
KEY `PSCID` (`PSCID`),
CONSTRAINT `FK_candidate_1` FOREIGN KEY (`CenterID`) REFERENCES `psc` (`CenterID`),
CONSTRAINT `FK_candidate_1` FOREIGN KEY (`RegistrationCenterID`) REFERENCES `psc` (`CenterID`),
CONSTRAINT `FK_candidate_2` FOREIGN KEY (`flagged_reason`) REFERENCES `caveat_options` (`ID`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE `candidate` DROP FOREIGN KEY `FK_candidate_1`;
ALTER TABLE `candidate`
CHANGE COLUMN `CenterID` `RegistrationCenterID` integer unsigned NOT NULL DEFAULT '0';
ALTER TABLE `candidate`
ADD CONSTRAINT `FK_candidate_1` FOREIGN KEY (`RegistrationCenterID`) REFERENCES `psc` (`CenterID`);

2 changes: 1 addition & 1 deletion htdocs/api/v0.0.2/Candidates.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function handleGET()
$candidates = $this->DB->pselect(
"SELECT CandID, ProjectID, PSCID, s.Alias as Site,
EDC, DoB, Sex as Gender
FROM candidate c JOIN psc s on (s.CenterID=c.CenterID)
FROM candidate c JOIN psc s on (s.CenterID=c.RegistrationCenterID)
WHERE Active='Y'
",
[]
Expand Down
2 changes: 1 addition & 1 deletion htdocs/api/v0.0.3-dev/Candidates.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function handleGET()
$candidates = $this->DB->pselect(
"SELECT CandID, ProjectID, PSCID, s.Alias as Site,
EDC, DoB, Sex
FROM candidate c JOIN psc s on (s.CenterID=c.CenterID)
FROM candidate c JOIN psc s on (s.CenterID=c.RegistrationCenterID)
WHERE Active='Y'
",
[]
Expand Down
14 changes: 7 additions & 7 deletions modules/candidate_list/php/candidate_list.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Candidate_List extends \NDB_Menu_Filter

// set the class variables
$this->columns = array(
'psc.Name AS Site',
'psc.Name AS RegistrationSite',
'c.CandID AS DCCID',
'c.PSCID',
'c.Sex',
Expand All @@ -87,7 +87,7 @@ class Candidate_List extends \NDB_Menu_Filter
);

$this->formToFilter = array(
'centerID' => 'c.CenterID',
'centerID' => 'c.RegistrationCenterID',
'DCCID' => 'c.CandID',
'PSCID' => 'c.PSCID',
'Sex' => 'c.Sex',
Expand All @@ -96,7 +96,7 @@ class Candidate_List extends \NDB_Menu_Filter

$this->validFilters = array(
'pso.ID',
'c.CenterID',
'c.RegistrationCenterID',
'c.CandID',
'c.PSCID',
'c.Sex',
Expand All @@ -121,7 +121,7 @@ class Candidate_List extends \NDB_Menu_Filter
);

$this->query = " FROM candidate c
LEFT JOIN psc ON (c.CenterID=psc.CenterID)
LEFT JOIN psc ON (c.RegistrationCenterID=psc.CenterID)
LEFT JOIN session s ON (c.CandID = s.CandID AND s.Active = 'Y')
LEFT JOIN feedback_bvl_thread
ON (c.CandID=feedback_bvl_thread.CandID)
Expand All @@ -135,7 +135,7 @@ class Candidate_List extends \NDB_Menu_Filter
if (!$user->hasPermission('access_all_profiles')) {

$site_arr = implode(",", $user->getCenterIDs());
$this->query .= " AND c.CenterID IN (" . $site_arr . ")";
$this->query .= " AND c.RegistrationCenterID IN (" . $site_arr . ")";
}

//'COALESCE(pso.ID,1) AS Participant_Status',
Expand Down Expand Up @@ -167,7 +167,7 @@ class Candidate_List extends \NDB_Menu_Filter
);
$this->EqualityFilters = array(
's.SubprojectID',
'c.CenterID',
'c.RegistrationCenterID',
'c.ProjectID',
's.Scan_done',
's.Visit_label',
Expand Down Expand Up @@ -259,7 +259,7 @@ class Candidate_List extends \NDB_Menu_Filter
$visits = array_merge(array('' => 'All'), $visits);

// add form elements
$this->addSelect('centerID', 'Site', $list_of_sites);
$this->addSelect('centerID', 'Registration Site', $list_of_sites);
$this->addBasicText('PSCID', 'PSCID');
$this->addBasicText('DCCID', 'DCCID');
$this->addBasicText('candID', 'DCCID');
Expand Down
2 changes: 1 addition & 1 deletion modules/conflict_resolver/php/conflict_resolver.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class Conflict_Resolver extends \NDB_Menu_Filter_Form
if (!$user->hasPermission('access_all_profiles')) {
// restrict data to own site
$site_arr = implode(",", $user->getCenterIDs());
$this->query .= " AND candidate.CenterID IN (" . $site_arr . ")";
$this->query .= " AND session.CenterID IN (" . $site_arr . ")";
}

$this->group_by = '';
Expand Down
2 changes: 1 addition & 1 deletion modules/conflict_resolver/php/resolved_conflicts.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Resolved_Conflicts extends \NDB_Menu_Filter
if (!$user->hasPermission('access_all_profiles')) {
// restrict data to own site
$site_arr = implode(",", $user->getCenterIDs());
$this->query .= " AND candidate.CenterID IN (" . $site_arr . ")";
$this->query .= " AND session.CenterID IN (" . $site_arr . ")";
}

$this->group_by = '';
Expand Down
6 changes: 5 additions & 1 deletion modules/create_timepoint/php/create_timepoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class Create_Timepoint extends \NDB_Form
// check user permissions
return (
$user->hasPermission('data_entry') &&
(in_array($candidate->getData('CenterID'), $user->getData('CenterIDs')))
(in_array(
$candidate->getData('RegistrationCenterID'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine for now but should be bettered in phase 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the link of that comment to issue #4058 so that it does not get lost when I do the second part of the implementation :).

$user->getData('CenterIDs')
)
)
);
}

Expand Down
4 changes: 2 additions & 2 deletions modules/dashboard/ajax/get_recruitment_bar_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
$sexData['datasets']['female'][] = $DB->pselectOne(
"SELECT COUNT(c.CandID)
FROM candidate c
WHERE c.CenterID=:Site AND c.Sex='female' AND c.Active='Y'
WHERE c.RegistrationCenterID=:Site AND c.Sex='female' AND c.Active='Y'
AND c.Entity_type='Human'",
array('Site' => $siteID)
);
$sexData['datasets']['male'][] = $DB->pselectOne(
"SELECT COUNT(c.CandID)
FROM candidate c
WHERE c.CenterID=:Site AND c.Sex='male' AND c.Active='Y'
WHERE c.RegistrationCenterID=:Site AND c.Sex='male' AND c.Active='Y'
AND c.Entity_type='Human'",
array('Site' => $siteID)
);
Expand Down
2 changes: 1 addition & 1 deletion modules/dashboard/ajax/get_recruitment_line_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function getRecruitmentData($siteID, $labels)
$data[] = $DB->pselectOne(
"SELECT COUNT(c.CandID)
FROM candidate c
WHERE c.CenterID=:Site
WHERE c.RegistrationCenterID=:Site
AND MONTH(c.Date_registered)=:Month
AND YEAR(c.Date_registered)=:Year
AND c.Entity_type='Human'",
Expand Down
5 changes: 4 additions & 1 deletion modules/dashboard/ajax/get_recruitment_pie_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
$totalRecruitment = $DB->pselectOne(
"SELECT COUNT(c.CandID)
FROM candidate c
WHERE c.CenterID=:Site AND c.Active='Y' AND c.Entity_type='Human'",
WHERE
c.RegistrationCenterID=:Site AND
c.Active='Y' AND
c.Entity_type='Human'",
array('Site' => $siteID)
);

Expand Down
13 changes: 7 additions & 6 deletions modules/dashboard/php/dashboard.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Dashboard extends \NDB_Form
LEFT JOIN session s ON (flag.SessionID=s.ID)
LEFT JOIN candidate c ON (c.CandID=s.CandID)
LEFT JOIN Project p ON (c.ProjectID=p.ProjectID )
WHERE FIND_IN_SET(c.CenterID, :siteID)
WHERE FIND_IN_SET(s.CenterID, :siteID)
cmadjar marked this conversation as resolved.
Show resolved Hide resolved
AND s.Active='Y' AND c.Active='Y'",
array('siteID' => implode(',', $siteID))
);
Expand Down Expand Up @@ -207,7 +207,7 @@ class Dashboard extends \NDB_Form
$this->tpl_data['violated_scans'] = $DB->pselectOne(
"SELECT COUNT(*) FROM mri_protocol_violated_scans
LEFT JOIN candidate c USING (CandID)
WHERE COALESCE(c.CenterID, 0) <> 1",
WHERE COALESCE(c.RegistrationCenterID, 0) <> 1",
/* include null CenterIDs so we don't accidentally
filter things out */
array()
Expand Down Expand Up @@ -307,7 +307,8 @@ class Dashboard extends \NDB_Form
$DB = \Database::singleton();
$totalRecruitment = $DB->pselectOne(
"SELECT COUNT(*) FROM candidate c
WHERE c.Active='Y' AND c.Entity_type='Human' AND c.CenterID <> 1",
WHERE c.Active='Y' AND c.Entity_type='Human'
AND c.RegistrationCenterID <> 1",
array()
);
return $totalRecruitment;
Expand All @@ -327,7 +328,7 @@ class Dashboard extends \NDB_Form
"SELECT COUNT(*)
FROM candidate c
WHERE c.Active='Y' AND c.ProjectID=:PID AND c.Entity_type='Human'
AND c.CenterID <> 1",
AND c.RegistrationCenterID <> 1",
array('PID' => $projectID)
);
return $totalRecruitment;
Expand All @@ -347,7 +348,7 @@ class Dashboard extends \NDB_Form
"SELECT COUNT(c.CandID)
FROM candidate c
WHERE c.Sex=:sex AND c.Active='Y' AND c.Entity_type='Human'
AND c.CenterID <> 1",
AND c.RegistrationCenterID <> 1",
array('sex' => $sex)
);
return $total;
Expand All @@ -369,7 +370,7 @@ class Dashboard extends \NDB_Form
"SELECT COUNT(c.CandID)
FROM candidate c
WHERE c.Sex=:sex AND c.Active='Y' AND c.ProjectID=:PID
AND c.Entity_type='Human' AND c.CenterID <> 1",
AND c.Entity_type='Human' AND c.RegistrationCenterID <> 1",
array(
'sex' => $sex,
'PID' => $projectID,
Expand Down
Loading