-
Notifications
You must be signed in to change notification settings - Fork 175
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
[instrument_list/battery] Clean-up battery retrieval function #7167
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,16 +277,9 @@ class NDB_BVL_Battery | |
* Gets an array of instruments which are members of the currently | ||
* selected session's battery | ||
* | ||
* @param string $stage Either 'visit' or 'screening' - determines | ||
* whether to register only screening instruments | ||
* or visit instruments | ||
* @param integer $SubprojectID The SubprojectID of that we want the battery for. | ||
* @param string $visit_label The visit label of the battery that we want to | ||
* retrieve | ||
* | ||
* @return array an array of instrument names | ||
*/ | ||
function getBattery($stage=null, $SubprojectID=null, $visit_label=null) | ||
function getBattery() | ||
{ | ||
$DB = Database::singleton(); | ||
// assert that a battery has already been selected | ||
|
@@ -309,73 +302,55 @@ class NDB_BVL_Battery | |
|
||
// return an array of test names | ||
return $tests; | ||
} // end getBattery() | ||
} | ||
|
||
/** | ||
* Gets an associative array of instruments which are members of the current | ||
* battery | ||
* | ||
* @param string $stage Either 'visit' or 'screening' - determines | ||
* whether to register only screening instruments | ||
* or visit instruments | ||
* @param integer $SubprojectID The SubprojectID of that we want the battery for. | ||
* | ||
* @return array an associative array containing Test_name, | ||
* Full_name, Sub_group, CommentID | ||
*/ | ||
function getBatteryVerbose($stage=null, $SubprojectID=null) | ||
function getBatteryVerbose() | ||
{ | ||
$DB = Database::singleton(); | ||
// assert that a battery has already been selected | ||
$this->_assertBatterySelected(); | ||
|
||
// craft the select query | ||
$query = "SELECT f.Test_name, | ||
t.Full_name, | ||
f.CommentID, | ||
CONCAT('DDE_', f.CommentID) AS DDECommentID, | ||
ts.Subgroup_name as Sub_group, | ||
ts.group_order as Subgroup_order, | ||
t.isDirectEntry"; | ||
if (!is_null($stage)) { | ||
$query .= ", b.instr_order as instrument_order"; | ||
} | ||
$query .= " FROM flag f | ||
JOIN test_names t ON (f.Test_name=t.Test_name) | ||
JOIN test_subgroups ts ON (ts.ID = t.Sub_group) "; | ||
$qparams = ['SID' => $this->sessionID]; | ||
|
||
if (!is_null($stage)) { | ||
$query .= " | ||
LEFT JOIN test_battery b ON (t.Test_name=b.Test_name) "; | ||
} | ||
$query .= " WHERE f.SessionID=:SID | ||
AND f.CommentID NOT LIKE 'DDE%'"; | ||
if (!is_null($stage) && !is_null($SubprojectID)) { | ||
$query .= " AND ( | ||
b.SubprojectID IS NULL | ||
OR b.SubprojectID=:SubprojID | ||
)"; | ||
$qparams['SubprojID'] = $SubprojectID; | ||
} | ||
|
||
if (Utility::columnsHasNull('test_subgroups', 'group_order')) { | ||
$query = "SELECT DISTINCT f.Test_name, | ||
t.Full_name, | ||
f.CommentID, | ||
CONCAT('DDE_', f.CommentID) AS DDECommentID, | ||
ts.Subgroup_name as Sub_group, | ||
ts.group_order as Subgroup_order, | ||
t.isDirectEntry, | ||
b.instr_order as instrument_order | ||
FROM flag f | ||
JOIN test_names t ON (f.Test_name=t.Test_name) | ||
JOIN test_subgroups ts ON (ts.ID = t.Sub_group) | ||
LEFT JOIN session s ON (s.ID=f.SessionID) | ||
LEFT JOIN test_battery b | ||
ON ((t.Test_name=b.Test_name OR b.Test_name IS NULL) | ||
AND (s.SubprojectID=b.SubprojectID OR b.SubprojectID IS NULL) | ||
AND (s.Visit_label=b.Visit_label OR b.Visit_label IS NULL) | ||
Comment on lines
+335
to
+336
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you check for Null subproject IDs or visit labels? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
AND (s.CenterID=b.CenterID OR b.CenterID IS NULL)) | ||
WHERE f.SessionID=:SID | ||
AND LEFT(f.CommentID, 4) != 'DDE_' "; | ||
if (\Utility::columnsHasNull('test_subgroups', 'group_order')) { | ||
$query .= " ORDER BY Subgroup_name"; | ||
} else { | ||
$query .= " ORDER BY Subgroup_order"; | ||
} | ||
if (!is_null($stage)) { | ||
$query .= ", instrument_order"; | ||
} else { | ||
$query .= ", Full_name"; | ||
} | ||
//print_r($query); | ||
$query .= ", instrument_order, Full_name"; | ||
$qparams = ['SID' => $this->sessionID]; | ||
|
||
// get the list of instruments | ||
$rows = $DB->pselect($query, $qparams); | ||
|
||
// return all the data selected | ||
return $rows; | ||
} // end getBatteryVerbose() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There s the same thing line 284 for the getBattery function |
||
} | ||
|
||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be converted to a group BY to avoid start next stage duplication issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this still need to be resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but its unrelated to the survey_accounts bug if thats what you were thinking