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

[New Feature] Tracking and Configuration of Candidate's Diagnosis Evolution #7560

Merged
merged 15 commits into from
Jan 11, 2024
Merged
26 changes: 26 additions & 0 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,32 @@ CREATE TABLE `visit_project_cohort_rel` (
REFERENCES `project_cohort_rel`(`ProjectCohortRelID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Diagnosis Evolution
CREATE TABLE `diagnosis_evolution` (
`DxEvolutionID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Name` varchar(255) DEFAULT NULL,
`ProjectID` int(10) unsigned NOT NULL,
`visitLabel` varchar(255) DEFAULT NULL,
`instrumentName` varchar(255) DEFAULT NULL,
`sourceField` varchar(255) DEFAULT NULL,
`orderNumber` int(10) unsigned DEFAULT NULL,
CONSTRAINT `PK_diagnosis_evolution` PRIMARY KEY (`DxEvolutionID`),
CONSTRAINT `UK_diagnosis_evolution_Name` UNIQUE KEY `Name` (`Name`),
CONSTRAINT `FK_diagnosis_evolution_ProjectID` FOREIGN KEY (`ProjectID`) REFERENCES `Project` (`ProjectID`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `FK_diagnosis_evolution_instrumentName` FOREIGN KEY (`instrumentName`) REFERENCES `test_names` (`Test_name`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `candidate_diagnosis_evolution_rel` (
`CandID` int(6) NOT NULL,
`DxEvolutionID` int(10) unsigned NOT NULL,
`Diagnosis` text DEFAULT NULL,
`Confirmed` enum('Y', 'N') DEFAULT NULL,
`LastUpdate` datetime NOT NULL DEFAULT NOW() ON UPDATE NOW(),
CONSTRAINT `PK_candidate_diagnosis_evolution_rel` PRIMARY KEY (`CandID`, `DxEvolutionID`),
CONSTRAINT `FK_candidate_diagnosis_evolution_rel_CandID` FOREIGN KEY (`CandID`) REFERENCES `candidate` (`CandID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `FK_candidate_diagnosis_evolution_rel_DxEvolutionID` FOREIGN KEY (`DxEvolutionID`) REFERENCES `diagnosis_evolution` (`DxEvolutionID`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Publication Status
CREATE TABLE `publication_status` (
`PublicationStatusID` int(2) unsigned NOT NULL AUTO_INCREMENT,
Expand Down
24 changes: 24 additions & 0 deletions SQL/New_patches/2021-07-28_diagnosis_evolution.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE TABLE `diagnosis_evolution` (
`DxEvolutionID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Name` varchar(255) DEFAULT NULL,
`ProjectID` int(10) unsigned NOT NULL,
`visitLabel` varchar(255) DEFAULT NULL,
`instrumentName` varchar(255) DEFAULT NULL,
`sourceField` varchar(255) DEFAULT NULL,
`orderNumber` int(10) unsigned DEFAULT NULL,
CONSTRAINT `PK_diagnosis_evolution` PRIMARY KEY (`DxEvolutionID`),
CONSTRAINT `UK_diagnosis_evolution_Name` UNIQUE KEY `Name` (`Name`),
CONSTRAINT `FK_diagnosis_evolution_ProjectID` FOREIGN KEY (`ProjectID`) REFERENCES `Project` (`ProjectID`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `FK_diagnosis_evolution_instrumentName` FOREIGN KEY (`instrumentName`) REFERENCES `test_names` (`Test_name`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `candidate_diagnosis_evolution_rel` (
`CandID` int(6) NOT NULL,
zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
`DxEvolutionID` int(10) unsigned NOT NULL,
`Diagnosis` text DEFAULT NULL,
`Confirmed` enum('Y', 'N') DEFAULT NULL,
`LastUpdate` datetime NOT NULL DEFAULT NOW() ON UPDATE NOW(),
CONSTRAINT `PK_candidate_diagnosis_evolution_rel` PRIMARY KEY (`CandID`, `DxEvolutionID`),
CONSTRAINT `FK_candidate_diagnosis_evolution_rel_CandID` FOREIGN KEY (`CandID`) REFERENCES `candidate` (`CandID`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `FK_candidate_diagnosis_evolution_rel_DxEvolutionID` FOREIGN KEY (`DxEvolutionID`) REFERENCES `diagnosis_evolution` (`DxEvolutionID`) ON DELETE RESTRICT ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
5 changes: 4 additions & 1 deletion jsx/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ export class FieldsetElement extends Component {
FieldsetElement.propTypes = {
columns: PropTypes.number,
name: PropTypes.string,
legend: PropTypes.string,
legend: PropTypes.oneOfType([
PropTypes.string,
PropTypes.node,
]),
children: PropTypes.node,
};

Expand Down
80 changes: 80 additions & 0 deletions modules/candidate_parameters/ajax/getData.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
case 'candidateDOD':
echo json_encode(getDODFields());
exit;
case 'diagnosisEvolution':
zaliqarosli marked this conversation as resolved.
Show resolved Hide resolved
echo json_encode(getDiagnosisEvolutionFields());
exit;
default:
header("HTTP/1.1 404 Not Found");
exit;
Expand Down Expand Up @@ -555,3 +558,80 @@ function getDODFields(): array
return $result;
}

/**
* Handles the fetching of candidate's diagnosis evolution.
*
* @return array
*/
function getDiagnosisEvolutionFields(): array
{
$candID = new CandID($_GET['candID']);
$db = \NDB_Factory::singleton()->database();

$pscid = $db->pselectOne(
"SELECT PSCID FROM candidate
WHERE CandID=:candID",
['candID' => $candID]
);

$candidateDiagnosisEvolution = $db->pselect(
"SELECT
de.Name AS TrajectoryName,
p.Name AS Project,
visitLabel,
instrumentName,
sourceField,
Diagnosis,
Confirmed,
LastUpdate,
OrderNumber
FROM candidate_diagnosis_evolution_rel
JOIN diagnosis_evolution de USING (DxEvolutionID)
JOIN Project p USING (ProjectID)
WHERE CandID=:candID",
['candID' => $candID]
);

$projectList = \Utility::getProjectList();

// Get all candidate's project affiliations
$candProjIDs = $db->pselectCol(
"SELECT DISTINCT ProjectID
FROM session
WHERE CandID=:candID",
['candID' => $candID]
);

$candProjects = [];
$candidate = \Candidate::singleton($candID);
$latestDiagnosis = [];
$latestConfirmedDiagnosis = [];
foreach ($candProjIDs as $projectID) {
$candProjects[$projectID] = $projectList[$projectID];
$latestDiagnosis[] = $candidate->getLatestDiagnosis(
new \ProjectID($projectID),
false
);
$latestConfirmedDiagnosis[] = $candidate->getLatestDiagnosis(
new \ProjectID($projectID),
true
);
}

// remove null results and re-index
$latestDiagnosis = array_values(array_filter($latestDiagnosis));
$latestConfirmedDiagnosis = array_values(
array_filter($latestConfirmedDiagnosis)
);

$result = [
'pscid' => $pscid,
'candID' => $candID,
'diagnosisEvolution' => $candidateDiagnosisEvolution,
'latestProjectDiagnosis' => $latestDiagnosis,
'latestConfirmedProjectDiagnosis' => $latestConfirmedDiagnosis,
'projects' => $candProjects
];
return $result;
}

6 changes: 6 additions & 0 deletions modules/candidate_parameters/jsx/CandidateParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ParticipantStatus from './ParticipantStatus';
import ConsentStatus from './ConsentStatus';
import CandidateDOB from './CandidateDOB';
import CandidateDOD from './CandidateDOD';
import DiagnosisEvolution from './DiagnosisEvolution';
import {Tabs, TabPane} from 'Tabs';

/**
Expand Down Expand Up @@ -78,6 +79,11 @@ class CandidateParameters extends Component {
label: 'Date of Death',
component: CandidateDOD,
},
{
id: 'diagnosisEvolution',
label: 'Diagnosis Evolution',
component: DiagnosisEvolution,
},
];

if (loris.config('useProband') === 'true') {
Expand Down
Loading
Loading