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

[candidate_parameters] Allow configuration of which status means comment required #9494

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 9 additions & 8 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1254,19 +1254,20 @@ CREATE TABLE `participant_status_options` (
`Description` varchar(255) DEFAULT NULL,
`Required` tinyint(1) DEFAULT NULL,
`parentID` int(10) DEFAULT NULL,
`commentRequired` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT INTO `participant_status_options` (Description, Required) VALUES
('Active',0),
('Refused/Not Enrolled',0),
('Ineligible',0),
('Excluded',0),
('Inactive',1),
('Incomplete',1),
('Complete',0);
INSERT INTO `participant_status_options` (Description, Required, commentRequired) VALUES
('Active',0,0),
('Refused/Not Enrolled',0,1),
('Ineligible',0,1),
('Excluded',0,1),
('Inactive',1,1),
('Incomplete',1,1),
('Complete',0,0);

INSERT INTO `participant_status_options` (Description, Required, parentID) VALUES
('Unsure',NULL,@tmp_val),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE participant_status_options
ADD COLUMN commentRequired tinyint(1) DEFAULT NULL;

UPDATE participant_status_options
SET commentRequired = 1
WHERE Description NOT IN ('Active', 'Complete') AND parentID IS NULL;
17 changes: 11 additions & 6 deletions modules/candidate_parameters/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,22 @@ function getParticipantStatusFields()
['candid' => $candID]
);

$statusOptions = \Candidate::getParticipantStatusOptions();
$reasonOptions = [];

$req = $db->pselect(
'SELECT ID from participant_status_options where Required=1',
'SELECT ID, Required, commentRequired from participant_status_options
WHERE Required=1 OR commentRequired=1',
[]
);
$required = [];
foreach ($req as $k=>$row) {
$required[$k] = $row['ID'];
$commentRequired = [];
foreach ($req as $_=>$row) {
if ($row['Required'] == 1) {
$required[] = $row['ID'];
}
if ($row['commentRequired'] == 1) {
$commentRequired[] = $row['ID'];
}
}
$parentIDs = $db->pselect(
'SELECT distinct(parentID) from participant_status_options',
Expand All @@ -357,7 +363,6 @@ function getParticipantStatusFields()
}
}
}

$query = "SELECT participant_status, participant_suboptions,
reason_specify FROM participant_status WHERE CandID=:candid";
$row = $db->pselectRow($query, ['candid' => $candID]);
Expand All @@ -373,8 +378,8 @@ function getParticipantStatusFields()
$result = [
'pscid' => $pscid,
'candID' => $candID->__toString(),
'statusOptions' => $statusOptions,
'required' => $required,
'commentRequired' => $commentRequired,
'reasonOptions' => $reasonOptions,
'parentIDs' => $parentIDMap,
'participantStatus' => $status,
Expand Down
8 changes: 3 additions & 5 deletions modules/candidate_parameters/jsx/ParticipantStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ParticipantStatus extends Component {
}

let required = this.state.Data.required;
let commentRequired = this.state.Data.commentRequired;
let subOptions = {};
let suboptionsRequired = false;
let participantStatus = (
Expand All @@ -155,11 +156,8 @@ class ParticipantStatus extends Component {
}

let commentsRequired = false;
let statusOpts = this.state.Data.statusOptions;
if (
statusOpts &&
statusOpts[participantStatus] !== 'Active' &&
statusOpts[participantStatus] !== 'Complete'
if (participantStatus &&
commentRequired.indexOf(parseInt(participantStatus)) > -1
) {
commentsRequired = true;
}
Expand Down
24 changes: 12 additions & 12 deletions raisinbread/RB_files/RB_participant_status_options.sql
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE `participant_status_options`;
LOCK TABLES `participant_status_options` WRITE;
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (1,'Active',0,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (2,'Refused/Not Enrolled',0,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (3,'Ineligible',0,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (4,'Excluded',0,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (5,'Inactive',1,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (6,'Incomplete',1,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (7,'Complete',0,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (8,'Unsure',NULL,5);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (9,'Requiring Further Investigation',NULL,5);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (10,'Not Responding',NULL,5);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (11,'Death',NULL,6);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`) VALUES (12,'Lost to Followup',NULL,6);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (1,'Active',0,NULL,0);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (2,'Refused/Not Enrolled',0,NULL,1);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (3,'Ineligible',0,NULL,1);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (4,'Excluded',0,NULL,1);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (5,'Inactive',1,NULL,1);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (6,'Incomplete',1,NULL,1);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (7,'Complete',0,NULL,0);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (8,'Unsure',NULL,5,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (9,'Requiring Further Investigation',NULL,5,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (10,'Not Responding',NULL,5,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (11,'Death',NULL,6,NULL);
INSERT INTO `participant_status_options` (`ID`, `Description`, `Required`, `parentID`, `commentRequired`) VALUES (12,'Lost to Followup',NULL,6,NULL);
UNLOCK TABLES;
SET FOREIGN_KEY_CHECKS=1;
Loading