Skip to content
Open
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions tools/CouchDB_Import_Demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function _generateQuery()
$latestProjDx.Diagnosis AS $latestProjDx";
$tablesToJoin .= "
LEFT JOIN (
SELECT c.CandID, Diagnosis
SELECT c.ID as CandidateID, c.CandID, Diagnosis
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to select the CandidateID?

Copy link
Contributor Author

@kongtiaowang kongtiaowang May 26, 2025

Choose a reason for hiding this comment

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

Because the following query requires candidateID (line 307,311), candidateID is an alias.

FROM candidate_diagnosis_evolution_rel cde
JOIN diagnosis_evolution de USING (DxEvolutionID)
JOIN candidate c ON c.ID=cde.CandidateID
Expand All @@ -304,7 +304,7 @@ function _generateQuery()
WHERE de2.ProjectID=$projectID
GROUP BY CandID
) AS maxOrderNumber ON (
maxOrderNumber.CandidateID=cde.CandidateID
maxOrderNumber.CandID=cde.CandidateID
AND maxOrderNumber.OrderNumber=de.OrderNumber
)
WHERE ProjectID=$projectID
Expand Down Expand Up @@ -432,7 +432,7 @@ function run()
if ($config_setting->getSetting("useFamilyID") === "true") {
$familyID = $this->SQLDB->pselectOne(
"SELECT FamilyID FROM family
WHERE CandID=:cid",
WHERE CandidateID=:cid",
['cid' => $demographics['CandID']]
);
if (!empty($familyID)) {
Expand Down
Loading